1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: SUIT_PreferenceMgr.cxx
21 // Author: Sergey TELKOV
23 #include "SUIT_PreferenceMgr.h"
25 SUIT_PreferenceMgr::SUIT_PreferenceMgr( QtxResourceMgr* resMgr, QWidget* parent )
26 : QtxPagePrefMgr( resMgr, parent ),
31 SUIT_PreferenceMgr::~SUIT_PreferenceMgr()
35 QIcon SUIT_PreferenceMgr::itemIcon( const int id ) const
37 const QtxPreferenceItem* item = 0;
41 item = findItem( id, true );
42 return item ? item->icon() : QIcon();
45 void SUIT_PreferenceMgr::setItemIcon( const int id, const QIcon& ico )
47 QtxPreferenceItem* item = id == -1 ? this : findItem( id, true );
52 QVariant SUIT_PreferenceMgr::itemProperty( const QString& prop, const int id ) const
54 const QtxPreferenceItem* item = 0;
58 item = findItem( id, true );
59 return item ? item->option( prop ) : QVariant();
62 void SUIT_PreferenceMgr::setItemProperty( const QString& prop, const QVariant& val, const int id )
64 QtxPreferenceItem* item = id == -1 ? this : findItem( id, true );
66 item->setOption( prop, val );
69 int SUIT_PreferenceMgr::addItem( const QString& title, const int pId,
70 const SUIT_PreferenceMgr::PrefItemType type,
71 const QString& sect, const QString& param )
73 QtxPreferenceItem* parent = 0;
77 myRoot = new QtxPagePrefListItem( QString( "root" ), this );
82 parent = findItem( pId, true );
88 QtxPreferenceItem* item = parent->findItem( title, false );
90 if ( item && item->depth() < 5 )
96 switch ( parent->depth() )
99 item = new QtxPagePrefTabsItem( title, parent, sect, param );
102 item = new QtxPagePrefFrameItem( title, parent, sect, param, true );
105 item = new QtxPagePrefGroupItem( title, parent, sect, param );
110 item = new QtxPagePrefSpaceItem( parent );
113 item = new QtxPagePrefCheckItem( title, parent, sect, param );
116 item = new QtxPagePrefColorItem( title, parent, sect, param );
119 item = new QtxPagePrefEditItem( QtxPagePrefEditItem::String, title, parent, sect, param );
122 item = new QtxPagePrefSelectItem( title, parent, sect, param );
125 item = new QtxPagePrefSpinItem( QtxPagePrefSpinItem::Double, title, parent, sect, param );
128 item = new QtxPagePrefSpinItem( QtxPagePrefSpinItem::Integer, title, parent, sect, param );
131 item = new QtxPagePrefEditItem( QtxPagePrefEditItem::Double, title, parent, sect, param );
134 item = new QtxPagePrefEditItem( QtxPagePrefEditItem::Integer, title, parent, sect, param );
137 item = new QtxPagePrefSliderItem( title, parent, sect, param );
140 item = new QtxPagePrefGroupItem( title, parent, sect, param );
143 item = new QtxPagePrefTabsItem( title, parent, sect, param );
146 item = new QtxPagePrefFrameItem( title, parent, sect, param );
149 item = new QtxPagePrefFontItem( title, parent, sect, param );
152 item = new QtxPagePrefPathItem( Qtx::PT_OpenFile, title, parent, sect, param );
155 item = new QtxPagePrefPathItem( Qtx::PT_Directory, title, parent, sect, param );
158 item = new QtxPagePrefPathListItem( Qtx::PT_Directory, title, parent, sect, param );
161 item = new QtxPagePrefShortcutBtnsItem( title, parent, sect, param );
164 item = new QtxPagePrefShortcutTreeItem( title, parent, sect, param );
167 item = new QtxPagePrefBiColorItem( title, parent, sect, param );
170 item = new QtxPagePrefBackgroundItem( title, parent, sect, param );
173 item = new QtxUserDefinedItem(parent);
177 return item ? item->id() : -1;
180 void SUIT_PreferenceMgr::removeItem( const QString& title )
184 QtxPreferenceItem* item = myRoot->findItem( title, false );
186 QtxPagePrefMgr::removeItem( item );
192 QVariant SUIT_PreferenceMgr::optionValue( const QString& name ) const
194 QVariant val = QtxPagePrefMgr::optionValue( name );
195 if ( !val.isValid() && myRoot )
196 val = myRoot->option( name );
200 void SUIT_PreferenceMgr::setOptionValue( const QString& name, const QVariant& val )
202 QtxPagePrefMgr::setOptionValue( name, val );
204 myRoot->setOption( name, val );
207 QtxPreferenceItem* SUIT_PreferenceMgr::root() const