1 // Copyright (C) 2007-2014 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: QtxPreferenceMgr.h
21 // Author: Sergey TELKOV
23 #ifndef QTXPREFERENCEMGR_H
24 #define QTXPREFERENCEMGR_H
27 #pragma warning( disable:4251 )
38 class QtxPreferenceMgr;
40 class QTX_EXPORT QtxPreferenceItem
45 QtxPreferenceItem( QtxPreferenceItem* = 0 );
46 QtxPreferenceItem( const QString&, QtxPreferenceItem* );
47 QtxPreferenceItem( const QString&, const QString&, const QString&, QtxPreferenceItem* );
48 virtual ~QtxPreferenceItem();
51 virtual int rtti() const;
53 QtxPreferenceItem* rootItem() const;
54 QtxPreferenceItem* parentItem() const;
55 QList<QtxPreferenceItem*> childItems( const bool = false ) const;
59 virtual bool isEmpty() const;
61 void appendItem( QtxPreferenceItem* );
62 void removeItem( QtxPreferenceItem* );
63 void insertItem( QtxPreferenceItem*, QtxPreferenceItem* = 0 );
66 QString title() const;
67 void resource( QString&, QString& ) const;
69 virtual void setIcon( const QIcon& );
70 virtual void setTitle( const QString& );
71 virtual void setResource( const QString&, const QString& );
73 virtual void updateContents();
75 QVariant option( const QString& ) const;
76 void setOption( const QString&, const QVariant& );
78 bool isEvaluateValues() const;
79 void setEvaluateValues( const bool );
81 virtual void store() = 0;
82 virtual void retrieve() = 0;
84 QString resourceValue() const;
85 void setResourceValue( const QString& );
87 QtxPreferenceItem* findItem( const int, const bool = false ) const;
88 QtxPreferenceItem* findItem( const QString&, const bool = false ) const;
89 QtxPreferenceItem* findItem( const QString&, const int, const bool = false ) const;
91 virtual QtxResourceMgr* resourceMgr() const;
92 virtual QtxPreferenceMgr* preferenceMgr() const;
94 virtual void activate();
100 int getInteger( const int = 0 ) const;
101 double getDouble( const double = 0.0 ) const;
102 bool getBoolean( const bool = false ) const;
103 QColor getColor( const QColor& = QColor() ) const;
104 QFont getFont( const QFont& = QFont() ) const;
105 QString getString( const QString& = QString() ) const;
107 void setInteger( const int );
108 void setDouble( const double );
109 void setBoolean( const bool );
110 void setColor( const QColor& );
111 void setFont( const QFont& );
112 void setString( const QString& );
114 virtual void itemAdded( QtxPreferenceItem* );
115 virtual void itemRemoved( QtxPreferenceItem* );
116 virtual void itemChanged( QtxPreferenceItem* );
118 virtual void ensureVisible( QtxPreferenceItem* );
120 void sendItemChanges();
122 virtual void triggerUpdate();
124 virtual QVariant optionValue( const QString& ) const;
125 virtual void setOptionValue( const QString&, const QVariant& );
128 typedef QList<QtxPreferenceItem*> ItemList;
131 static int generateId();
135 QtxPreferenceItem* myParent;
145 class QTX_EXPORT QtxPreferenceMgr : public QtxPreferenceItem
148 QtxPreferenceMgr( QtxResourceMgr* );
149 virtual ~QtxPreferenceMgr();
151 virtual QtxResourceMgr* resourceMgr() const;
152 virtual QtxPreferenceMgr* preferenceMgr() const;
154 QVariant option( const int, const QString& ) const;
155 void setOption( const int, const QString&, const QVariant& );
157 virtual void store();
158 virtual void retrieve();
160 virtual void update();
162 virtual void toBackup();
163 virtual void fromBackup();
166 typedef QMap<QtxPreferenceItem*, QString> ResourceMap;
168 void resourceValues( QMap<int, QString>& ) const;
169 void resourceValues( ResourceMap& ) const;
171 void setResourceValues( QMap<int, QString>& ) const;
172 void setResourceValues( ResourceMap& ) const;
174 void differentValues( const QMap<int, QString>&, const QMap<int, QString>&,
175 QMap<int, QString>&, const bool fromFirst = false ) const;
176 void differentValues( const ResourceMap&, const ResourceMap&,
177 ResourceMap&, const bool fromFirst = false ) const;
179 virtual void changedResources( const ResourceMap& );
182 QtxResourceMgr* myResMgr;
183 ResourceMap myBackup;
187 #pragma warning( default:4251 )