From 2a274a78d8cd2f4f833a81d7c30596eb44c46a03 Mon Sep 17 00:00:00 2001 From: stv Date: Thu, 5 Jul 2007 11:20:22 +0000 Subject: [PATCH] no message --- src/Qtx/QtxPreferenceMgr.cxx | 6 ++--- src/SUIT/SUIT_PreferenceMgr.cxx | 40 ++++++++++++++++++++++++--------- src/SUIT/SUIT_PreferenceMgr.h | 15 +++++++++---- 3 files changed, 44 insertions(+), 17 deletions(-) diff --git a/src/Qtx/QtxPreferenceMgr.cxx b/src/Qtx/QtxPreferenceMgr.cxx index 7a73095f3..b355a6d0c 100644 --- a/src/Qtx/QtxPreferenceMgr.cxx +++ b/src/Qtx/QtxPreferenceMgr.cxx @@ -380,7 +380,7 @@ QtxPreferenceMgr* QtxPreferenceItem::preferenceMgr() const 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 ) @@ -398,7 +398,7 @@ QtxPreferenceItem* QtxPreferenceItem::findItem( const int id, const bool rec ) c 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 ) @@ -417,7 +417,7 @@ QtxPreferenceItem* QtxPreferenceItem::findItem( const QString& title, const bool 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 ) diff --git a/src/SUIT/SUIT_PreferenceMgr.cxx b/src/SUIT/SUIT_PreferenceMgr.cxx index 04dbffda2..5f64e9544 100644 --- a/src/SUIT/SUIT_PreferenceMgr.cxx +++ b/src/SUIT/SUIT_PreferenceMgr.cxx @@ -22,7 +22,8 @@ #include "SUIT_PreferenceMgr.h" SUIT_PreferenceMgr::SUIT_PreferenceMgr( QtxResourceMgr* resMgr, QWidget* parent ) -: QtxPagePrefMgr( resMgr, parent ) +: QtxPagePrefMgr( resMgr, parent ), +myRoot( 0 ) { } @@ -30,15 +31,19 @@ SUIT_PreferenceMgr::~SUIT_PreferenceMgr() { } -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 ); } @@ -54,15 +59,15 @@ int SUIT_PreferenceMgr::addItem( const QString& title, const int pId, QtxPreferenceItem* parent = 0; if ( pId == -1 ) { - QList lst = childItems(); - for ( QList::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 ) { @@ -123,3 +128,18 @@ int SUIT_PreferenceMgr::addItem( const QString& title, const int pId, 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 ); +} diff --git a/src/SUIT/SUIT_PreferenceMgr.h b/src/SUIT/SUIT_PreferenceMgr.h index 6a95da776..e852bef5c 100644 --- a/src/SUIT/SUIT_PreferenceMgr.h +++ b/src/SUIT/SUIT_PreferenceMgr.h @@ -42,11 +42,18 @@ public: 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 -- 2.39.2