Salome HOME
IPAL54545: Problem with Preferences dialog if HOMARD module is before YACS in the...
[modules/gui.git] / src / SUIT / SUIT_PreferenceMgr.cxx
index d1bf51b9d874c6be36494179b71ab036e9333b08..91d0175c790856bcfc6f03c8ed6b8093e65499be 100644 (file)
@@ -70,23 +70,26 @@ int SUIT_PreferenceMgr::addItem( const QString& title, const int pId,
                                  const SUIT_PreferenceMgr::PrefItemType type,
                                  const QString& sect, const QString& param )
 {
-  QtxPreferenceItem* parent = pId == -1 ? this : findItem( pId, true );
+  QtxPreferenceItem* parent = 0;
+  if ( pId == -1 )
+  {
+    if ( !myRoot )
+      myRoot = new QtxPagePrefListItem( QString( "root" ), this );
+    parent = myRoot;
+  }
+  else
+  {
+    parent = findItem( pId, true );
+  }
 
   if ( !parent )
     return -1;
 
-  QtxPreferenceItem* item = parent->findItem( title, true );
+  QtxPreferenceItem* item = parent->findItem( title, false );
 
   if ( item && item->depth() < 5 )
     return item->id();
 
-  if ( pId == -1 )
-  {
-    if ( !myRoot )
-      myRoot = new QtxPagePrefListItem( QString( "root" ), this );
-    parent = myRoot;
-  }
-
   switch( type )
   {
   case Auto:
@@ -185,3 +188,8 @@ void SUIT_PreferenceMgr::setOptionValue( const QString& name, const QVariant& va
   if ( myRoot )
     myRoot->setOption( name, val );
 }
+
+QtxPreferenceItem* SUIT_PreferenceMgr::root() const
+{
+  return myRoot;
+}