1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: SUIT_PreferenceMgr.cxx
23 // Author: Sergey TELKOV
25 #include "SUIT_PreferenceMgr.h"
27 SUIT_PreferenceMgr::SUIT_PreferenceMgr( QtxResourceMgr* resMgr, QWidget* parent )
28 : QtxPagePrefMgr( resMgr, parent ),
33 SUIT_PreferenceMgr::~SUIT_PreferenceMgr()
37 QIcon SUIT_PreferenceMgr::itemIcon( const int id ) const
39 const QtxPreferenceItem* item = 0;
43 item = findItem( id, true );
44 return item ? item->icon() : QIcon();
47 void SUIT_PreferenceMgr::setItemIcon( const int id, const QIcon& ico )
49 QtxPreferenceItem* item = id == -1 ? this : findItem( id, true );
54 QVariant SUIT_PreferenceMgr::itemProperty( const QString& prop, const int id ) const
56 const QtxPreferenceItem* item = 0;
60 item = findItem( id, true );
61 return item ? item->option( prop ) : QVariant();
64 void SUIT_PreferenceMgr::setItemProperty( const QString& prop, const QVariant& val, const int id )
66 QtxPreferenceItem* item = id == -1 ? this : findItem( id, true );
68 item->setOption( prop, val );
71 int SUIT_PreferenceMgr::addItem( const QString& title, const int pId,
72 const SUIT_PreferenceMgr::PrefItemType type,
73 const QString& sect, const QString& param )
75 QtxPreferenceItem* parent = pId == -1 ? this : findItem( pId, true );
80 QtxPreferenceItem* item = parent->findItem( title, true );
82 if ( item && item->depth() < 5 )
88 myRoot = new QtxPagePrefListItem( QString( "root" ), this );
95 switch ( parent->depth() )
98 item = new QtxPagePrefTabsItem( title, parent, sect, param );
101 item = new QtxPagePrefFrameItem( title, parent, sect, param );
104 item = new QtxPagePrefGroupItem( title, parent, sect, param );
109 item = new QtxPagePrefSpaceItem( parent );
112 item = new QtxPagePrefCheckItem( title, parent, sect, param );
115 item = new QtxPagePrefColorItem( title, parent, sect, param );
118 item = new QtxPagePrefEditItem( QtxPagePrefEditItem::String, title, parent, sect, param );
121 item = new QtxPagePrefSelectItem( title, parent, sect, param );
124 item = new QtxPagePrefSpinItem( QtxPagePrefSpinItem::Double, title, parent, sect, param );
127 item = new QtxPagePrefSpinItem( QtxPagePrefSpinItem::Integer, title, parent, sect, param );
130 item = new QtxPagePrefEditItem( QtxPagePrefEditItem::Double, title, parent, sect, param );
133 item = new QtxPagePrefEditItem( QtxPagePrefEditItem::Integer, title, parent, sect, param );
136 item = new QtxPagePrefGroupItem( title, parent, sect, param );
139 item = new QtxPagePrefTabsItem( title, parent, sect, param );
142 item = new QtxPagePrefFrameItem( title, parent, sect, param );
145 item = new QtxPagePrefFontItem( title, parent, sect, param );
148 item = new QtxPagePrefPathItem( Qtx::PT_OpenFile, title, parent, sect, param );
151 item = new QtxPagePrefPathListItem( Qtx::PT_Directory, title, parent, sect, param );
155 return item ? item->id() : -1;
158 QVariant SUIT_PreferenceMgr::optionValue( const QString& name ) const
160 QVariant val = QtxPagePrefMgr::optionValue( name );
161 if ( !val.isValid() && myRoot )
162 val = myRoot->option( name );
166 void SUIT_PreferenceMgr::setOptionValue( const QString& name, const QVariant& val )
168 QtxPagePrefMgr::setOptionValue( name, val );
170 myRoot->setOption( name, val );