QtxPreferenceItem* QtxPreferenceItem::findItem( const int id, const bool rec ) const
{
QtxPreferenceItem* item = 0;
- for ( ItemList::const_iterator it = myChildren.begin(); it != myChildren.end() && item; ++it )
+ for ( ItemList::const_iterator it = myChildren.begin(); it != myChildren.end() && !item; ++it )
{
QtxPreferenceItem* i = *it;
if ( i->id() == id )
QtxPreferenceItem* QtxPreferenceItem::findItem( const QString& title, const bool rec ) const
{
QtxPreferenceItem* item = 0;
- for ( ItemList::const_iterator it = myChildren.begin(); it != myChildren.end() && item; ++it )
+ for ( ItemList::const_iterator it = myChildren.begin(); it != myChildren.end() && !item; ++it )
{
QtxPreferenceItem* i = *it;
if ( i->title() == title )
QtxPreferenceItem* QtxPreferenceItem::findItem( const QString& title, const int id, const bool rec ) const
{
QtxPreferenceItem* item = 0;
- for ( ItemList::const_iterator it = myChildren.begin(); it != myChildren.end() && item; ++it )
+ for ( ItemList::const_iterator it = myChildren.begin(); it != myChildren.end() && !item; ++it )
{
QtxPreferenceItem* i = *it;
if ( i->title() == title && i->id() == id )
#include "SUIT_PreferenceMgr.h"
SUIT_PreferenceMgr::SUIT_PreferenceMgr( QtxResourceMgr* resMgr, QWidget* parent )
-: QtxPagePrefMgr( resMgr, parent )
+: QtxPagePrefMgr( resMgr, parent ),
+myRoot( 0 )
{
}
{
}
-QVariant SUIT_PreferenceMgr::itemProperty( const int id, const QString& prop ) const
+QVariant SUIT_PreferenceMgr::itemProperty( const QString& prop, const int id ) const
{
- QtxPreferenceItem* item = findItem( id, true );
+ const QtxPreferenceItem* item = 0;
+ if ( id == -1 )
+ item = this;
+ else
+ item = findItem( id, true );
return item ? item->option( prop ) : QVariant();
}
-void SUIT_PreferenceMgr::setItemProperty( const int id, const QString& prop, const QVariant& val )
+void SUIT_PreferenceMgr::setItemProperty( const QString& prop, const QVariant& val, const int id )
{
- QtxPreferenceItem* item = findItem( id, true );
+ QtxPreferenceItem* item = id == -1 ? this : findItem( id, true );
if ( item )
item->setOption( prop, val );
}
QtxPreferenceItem* parent = 0;
if ( pId == -1 )
{
- QList<QtxPreferenceItem*> lst = childItems();
- for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end() && !parent; ++it )
- parent = *it;
+ if ( !myRoot )
+ myRoot = new QtxPagePrefListItem( QString( "root" ), this );
+ parent = myRoot;
}
else
- parent = findItem( pId );
+ parent = findItem( pId, true );
if ( !parent )
- parent = new QtxPagePrefListItem( QString( "Root" ), this );
+ return -1;
switch( type )
{
return item ? item->id() : -1;
}
+
+QVariant SUIT_PreferenceMgr::optionValue( const QString& name ) const
+{
+ QVariant val = QtxPagePrefMgr::optionValue( name );
+ if ( !val.isValid() && myRoot )
+ val = myRoot->option( name );
+ return val;
+}
+
+void SUIT_PreferenceMgr::setOptionValue( const QString& name, const QVariant& val )
+{
+ QtxPagePrefMgr::setOptionValue( name, val );
+ if ( myRoot )
+ myRoot->setOption( name, val );
+}
SUIT_PreferenceMgr( QtxResourceMgr*, QWidget* = 0 );
virtual ~SUIT_PreferenceMgr();
- QVariant itemProperty( const int, const QString& ) const;
- void setItemProperty( const int, const QString&, const QVariant& );
+ QVariant itemProperty( const QString&, const int = -1 ) const;
+ void setItemProperty( const QString&, const QVariant&, const int = -1 );
- int addItem( const QString&, const int pId = -1, const PrefItemType = Auto,
- const QString& = QString(), const QString& = QString() );
+ int addItem( const QString&, const int pId = -1, const PrefItemType = Auto,
+ const QString& = QString(), const QString& = QString() );
+
+protected:
+ virtual QVariant optionValue( const QString& ) const;
+ virtual void setOptionValue( const QString&, const QVariant& );
+
+private:
+ QtxPreferenceItem* myRoot;
};
#endif