-// Copyright (C) 2007-2012 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
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
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:
return item ? item->id() : -1;
}
+void SUIT_PreferenceMgr::removeItem( const QString& title )
+{
+ if ( myRoot )
+ {
+ QtxPreferenceItem* item = myRoot->findItem( title, false );
+ if ( item ) {
+ QtxPagePrefMgr::removeItem( item );
+ delete item;
+ }
+ }
+}
+
QVariant SUIT_PreferenceMgr::optionValue( const QString& name ) const
{
QVariant val = QtxPagePrefMgr::optionValue( name );
if ( myRoot )
myRoot->setOption( name, val );
}
+
+QtxPreferenceItem* SUIT_PreferenceMgr::root() const
+{
+ return myRoot;
+}