From a61d8b3559a75cf73edd6797601f19c5b74f3fe8 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 13 May 2010 08:11:18 +0000 Subject: [PATCH] *** empty log message *** --- src/Qtx/QtxPagePrefMgr.cxx | 78 +++++++++++++++++++++++++++++++++ src/Qtx/QtxPagePrefMgr.h | 29 ++++++++++++ src/SUIT/SUIT_PreferenceMgr.cxx | 3 ++ src/SUIT/SUIT_PreferenceMgr.h | 3 +- 4 files changed, 112 insertions(+), 1 deletion(-) diff --git a/src/Qtx/QtxPagePrefMgr.cxx b/src/Qtx/QtxPagePrefMgr.cxx index 6fb5b4359..df939b8bd 100644 --- a/src/Qtx/QtxPagePrefMgr.cxx +++ b/src/Qtx/QtxPagePrefMgr.cxx @@ -3909,3 +3909,81 @@ void QtxPagePrefDateTimeItem::updateDateTime() 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); +} diff --git a/src/Qtx/QtxPagePrefMgr.h b/src/Qtx/QtxPagePrefMgr.h index bbc634240..f0c532458 100644 --- a/src/Qtx/QtxPagePrefMgr.h +++ b/src/Qtx/QtxPagePrefMgr.h @@ -664,4 +664,33 @@ private: 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 diff --git a/src/SUIT/SUIT_PreferenceMgr.cxx b/src/SUIT/SUIT_PreferenceMgr.cxx index 512fdafa0..ac1c801b2 100644 --- a/src/SUIT/SUIT_PreferenceMgr.cxx +++ b/src/SUIT/SUIT_PreferenceMgr.cxx @@ -150,6 +150,9 @@ int SUIT_PreferenceMgr::addItem( const QString& title, const int pId, case DirList: item = new QtxPagePrefPathListItem( Qtx::PT_Directory, title, parent, sect, param ); break; + case UserDefined: + item = new QtxUserDefinedItem(parent); + break; } return item ? item->id() : -1; diff --git a/src/SUIT/SUIT_PreferenceMgr.h b/src/SUIT/SUIT_PreferenceMgr.h index f6987252f..bf4c61fe1 100644 --- a/src/SUIT/SUIT_PreferenceMgr.h +++ b/src/SUIT/SUIT_PreferenceMgr.h @@ -39,7 +39,8 @@ class SUIT_EXPORT SUIT_PreferenceMgr : public QtxPagePrefMgr 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 ); -- 2.39.2