1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, 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 = pId == -1 ? this : findItem( pId, true );
78 QtxPreferenceItem* item = parent->findItem( title, true );
80 if ( item && item->depth() < 5 )
86 myRoot = new QtxPagePrefListItem( QString( "root" ), this );
93 switch ( parent->depth() )
96 item = new QtxPagePrefTabsItem( title, parent, sect, param );
99 item = new QtxPagePrefFrameItem( title, parent, sect, param, true );
102 item = new QtxPagePrefGroupItem( title, parent, sect, param );
107 item = new QtxPagePrefSpaceItem( parent );
110 item = new QtxPagePrefCheckItem( title, parent, sect, param );
113 item = new QtxPagePrefColorItem( title, parent, sect, param );
116 item = new QtxPagePrefEditItem( QtxPagePrefEditItem::String, title, parent, sect, param );
119 item = new QtxPagePrefSelectItem( title, parent, sect, param );
122 item = new QtxPagePrefSpinItem( QtxPagePrefSpinItem::Double, title, parent, sect, param );
125 item = new QtxPagePrefSpinItem( QtxPagePrefSpinItem::Integer, title, parent, sect, param );
128 item = new QtxPagePrefEditItem( QtxPagePrefEditItem::Double, title, parent, sect, param );
131 item = new QtxPagePrefEditItem( QtxPagePrefEditItem::Integer, title, parent, sect, param );
134 item = new QtxPagePrefSliderItem( title, parent, sect, param );
137 item = new QtxPagePrefGroupItem( title, parent, sect, param );
140 item = new QtxPagePrefTabsItem( title, parent, sect, param );
143 item = new QtxPagePrefFrameItem( title, parent, sect, param );
146 item = new QtxPagePrefFontItem( title, parent, sect, param );
149 item = new QtxPagePrefPathItem( Qtx::PT_OpenFile, title, parent, sect, param );
152 item = new QtxPagePrefPathListItem( Qtx::PT_Directory, title, parent, sect, param );
155 item = new QtxPagePrefShortcutBtnsItem( title, parent, sect, param );
158 item = new QtxPagePrefShortcutTreeItem( title, parent, sect, param );
161 item = new QtxPagePrefBiColorItem( title, parent, sect, param );
164 item = new QtxPagePrefBackgroundItem( title, parent, sect, param );
167 item = new QtxUserDefinedItem(parent);
171 return item ? item->id() : -1;
174 QVariant SUIT_PreferenceMgr::optionValue( const QString& name ) const
176 QVariant val = QtxPagePrefMgr::optionValue( name );
177 if ( !val.isValid() && myRoot )
178 val = myRoot->option( name );
182 void SUIT_PreferenceMgr::setOptionValue( const QString& name, const QVariant& val )
184 QtxPagePrefMgr::setOptionValue( name, val );
186 myRoot->setOption( name, val );