myDateTime->setDisplayFormat( dispFmt );
}
+
+
+
+/*!
+ \brief Constructor.
+
+ Creates preference item of user defined widget. The item widget has to be inherited from
+ QtxUserDefinedContent class. An instance of this class has to be installed into the item
+ with help of setContent method. Methods optionValue and setOptionValue use pointer on the
+ content widget an qint64 value.
+
+ \param parent parent preference item
+*/
+QtxUserDefinedItem::QtxUserDefinedItem( QtxPreferenceItem* parent )
+ : QtxPageNamedPrefItem(QString(), parent), myContent(0)
+{
+}
+
+/*!
+ \brief Lets to Store preferences for content instance
+ \sa retrieve()
+*/
+void QtxUserDefinedItem::store()
+{
+ if (myContent) {
+ myContent->store( resourceMgr(), preferenceMgr());
+ }
+}
+
+/*!
+ \brief Lets to Retrieve preferences for content instance
+ \sa store()
+*/
+void QtxUserDefinedItem::retrieve()
+{
+ if (myContent) {
+ myContent->retrieve( resourceMgr(), preferenceMgr());
+ }
+}
+
+/*!
+ * \brief Returns option value
+ * \param theName is a string "content"
+ * \return pointer on QtxUserDefinedContent class instance as a qint64 value
+ */
+QVariant QtxUserDefinedItem::optionValue( const QString& theName ) const
+{
+ if ( theName == "content" )
+ return (qint64) myContent;
+ else
+ return QtxPreferenceItem::optionValue( theName );
+}
+
+/*!
+ * \brief Sets option value
+ * \param theName is a string "content"
+ * \param theVal is a pointer on QtxUserDefinedContent class instance represented as qint64 value
+ */
+void QtxUserDefinedItem::setOptionValue( const QString& theName, const QVariant& theVal)
+{
+ if ( theName == "content" ) {
+ if ( theVal.canConvert( QVariant::ULongLong ) ) {
+ setContent( (QtxUserDefinedContent*)theVal.toULongLong() );
+ }
+ } else
+ QtxPreferenceItem::setOptionValue( theName, theVal );
+}
+
+/*!
+ * \brief Defines content of the property item as a Widget which has to be inherited from
+ * QtxUserDefinedContent class.
+ * \param theContent is an QtxUserDefinedContent class instance.
+ */
+void QtxUserDefinedItem::setContent( QtxUserDefinedContent* theContent )
+{
+ myContent = theContent;
+ setControl(myContent);
+}
QDateTimeEdit* myDateTime;
};
+
+class QtxUserDefinedContent: public QWidget
+{
+ public:
+ QtxUserDefinedContent(QWidget* parent = 0, Qt::WindowFlags f = 0 ):QWidget(parent, f) {};
+ virtual void store(QtxResourceMgr* theRes, QtxPreferenceMgr* thePref) = 0;
+ virtual void retrieve(QtxResourceMgr* theRes, QtxPreferenceMgr* thePref) = 0;
+};
+
+
+class QTX_EXPORT QtxUserDefinedItem : public QtxPageNamedPrefItem
+{
+public:
+ QtxUserDefinedItem( QtxPreferenceItem* parent );
+
+ void setContent( QtxUserDefinedContent* theContent );
+
+ virtual void store();
+ virtual void retrieve();
+
+protected:
+ virtual QVariant optionValue( const QString& theName ) const;
+ virtual void setOptionValue( const QString& theName, const QVariant& theVal );
+
+private:
+ QtxUserDefinedContent* myContent;
+};
+
+
#endif
public:
typedef enum { Auto, Space, Bool, Color, String, Selector,
DblSpin, IntSpin, Double, Integer,
- GroupBox, Tab, Frame, Font, DirList, File } PrefItemType;
+ GroupBox, Tab, Frame, Font, DirList, File,
+ UserDefined = 1000 } PrefItemType;
public:
SUIT_PreferenceMgr( QtxResourceMgr*, QWidget* = 0 );