Added custom QWidget descendant class. Handle it when required to set parameters to a window's custom widget child.

git-svn-id: http://yate.null.ro/svn/yate/trunk@2347 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
marian 2008-11-18 12:12:54 +00:00
parent 56ce66f169
commit 936f602932
2 changed files with 29 additions and 0 deletions

View File

@ -73,6 +73,7 @@ public:
Unknown = 14, // Unknown type
Action, // QAction descendant
CustomTable, // QtTable descendant
CustomWidget, // QtCustomWidget descendant
Missing // Invalid pointer
};
// Set widget from object
@ -148,6 +149,8 @@ public:
{ return static_cast<QSpinBox*>(m_widget); }
inline QtTable* customTable()
{ return qobject_cast<QtTable*>(m_widget); }
inline QtCustomWidget* customWidget()
{ return qobject_cast<QtCustomWidget*>(m_widget); }
inline QAction* action()
{ return m_action; }
@ -159,6 +162,8 @@ public:
return i;
if (customTable())
return CustomTable;
if (customWidget())
return CustomWidget;
return Unknown;
}
if (m_action && m_action->inherits("QAction"))
@ -749,6 +754,8 @@ bool QtWindow::setParams(const NamedList& params)
QtWidget w(this,ns->name());
if (w.type() == QtWidget::CustomTable)
ok = w.customTable()->setParams(*nl) && ok;
else if (w.type() == QtWidget::CustomWidget)
ok = w.customWidget()->setParams(*nl) && ok;
else
ok = false;
}

View File

@ -475,6 +475,28 @@ protected:
QPoint m_movePos; // Old position used when moving the window
};
/**
* This class encapsulates a custom QT table
* @short A custom QT table widget
*/
class YQT4_API QtCustomWidget : public QWidget, public UIWidget
{
YCLASS(QtCustomWidget,UIWidget)
Q_CLASSINFO("QtCustomWidget","Yate")
Q_OBJECT
public:
/**
* Constructor
* @param name Widget's name
* @param parent Optional parent widget
*/
inline QtCustomWidget(const char* name, QWidget* parent = 0)
: QWidget(parent), UIWidget(name)
{ setObjectName(name); }
private:
QtCustomWidget() {} // No default constructor
};
/**
* This class encapsulates a custom QT table