Salome HOME
Copyright update 2022
[modules/gui.git] / src / SUIT / SUIT_PreferenceMgr.cxx
index 1d08111800e8cfd8d54f494c214145788a4d140c..b19b0797d409a75329ce0095ec88ae5ed374261b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -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;
+}