1 // Copyright (C) 2007-2020 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 bool isRestartRequired() const;
82 void setRestartRequired( const bool );
84 virtual void store() = 0;
85 virtual void retrieve() = 0;
87 QString resourceValue() const;
88 void setResourceValue( const QString& );
90 QtxPreferenceItem* findItem( const int, const bool = false ) const;
91 QtxPreferenceItem* findItem( const QString&, const bool = false ) const;
92 QtxPreferenceItem* findItem( const QString&, const int, const bool = false ) const;
94 virtual QtxResourceMgr* resourceMgr() const;
95 virtual QtxPreferenceMgr* preferenceMgr() const;
97 virtual void activate();
103 int getInteger( const int = 0 ) const;
104 double getDouble( const double = 0.0 ) const;
105 bool getBoolean( const bool = false ) const;
106 QColor getColor( const QColor& = QColor() ) const;
107 QFont getFont( const QFont& = QFont() ) const;
108 QString getString( const QString& = QString() ) const;
110 void setInteger( const int );
111 void setDouble( const double );
112 void setBoolean( const bool );
113 void setColor( const QColor& );
114 void setFont( const QFont& );
115 void setString( const QString& );
117 virtual void itemAdded( QtxPreferenceItem* );
118 virtual void itemRemoved( QtxPreferenceItem* );
119 virtual void itemChanged( QtxPreferenceItem* );
121 virtual void ensureVisible( QtxPreferenceItem* );
123 void sendItemChanges();
125 virtual void triggerUpdate();
127 virtual QVariant optionValue( const QString& ) const;
128 virtual void setOptionValue( const QString&, const QVariant& );
131 typedef QList<QtxPreferenceItem*> ItemList;
134 static int generateId();
138 QtxPreferenceItem* myParent;
142 bool myRestartNeeded;
149 class QTX_EXPORT QtxPreferenceMgr : public QtxPreferenceItem
152 QtxPreferenceMgr( QtxResourceMgr* );
153 virtual ~QtxPreferenceMgr();
155 virtual QtxResourceMgr* resourceMgr() const;
156 virtual QtxPreferenceMgr* preferenceMgr() const;
158 QVariant option( const int, const QString& ) const;
159 void setOption( const int, const QString&, const QVariant& );
161 virtual void store();
162 virtual void retrieve();
164 virtual void update();
166 virtual void toBackup();
167 virtual void fromBackup();
170 typedef QMap<QtxPreferenceItem*, QString> ResourceMap;
172 void resourceValues( QMap<int, QString>& ) const;
173 void resourceValues( ResourceMap& ) const;
175 void setResourceValues( QMap<int, QString>& ) const;
176 void setResourceValues( ResourceMap& ) const;
178 void differentValues( const QMap<int, QString>&, const QMap<int, QString>&,
179 QMap<int, QString>&, const bool fromFirst = false ) const;
180 void differentValues( const ResourceMap&, const ResourceMap&,
181 ResourceMap&, const bool fromFirst = false ) const;
183 virtual void changedResources( const ResourceMap& );
186 QtxResourceMgr* myResMgr;
187 ResourceMap myBackup;
191 #pragma warning( default:4251 )