Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QtxPreferenceMgr.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 // File: QtxPreferenceMgr.h
21 // Author: Sergey TELKOV
22 //
23 #ifndef QTXPREFERENCEMGR_H
24 #define QTXPREFERENCEMGR_H
25 
26 #ifdef WIN32
27 #pragma warning( disable:4251 )
28 #endif
29 
30 #include "Qtx.h"
31 
32 #include <QFont>
33 #include <QIcon>
34 #include <QColor>
35 #include <QVariant>
36 
37 class QtxResourceMgr;
38 class QtxPreferenceMgr;
39 
41 {
42  class Updater;
43 
44 public:
46  QtxPreferenceItem( const QString&, QtxPreferenceItem* );
47  QtxPreferenceItem( const QString&, const QString&, const QString&, QtxPreferenceItem* );
48  virtual ~QtxPreferenceItem();
49 
50  int id() const;
51  virtual int rtti() const;
52 
53  QtxPreferenceItem* rootItem() const;
54  QtxPreferenceItem* parentItem() const;
55  QList<QtxPreferenceItem*> childItems( const bool = false ) const;
56 
57  int depth() const;
58  int count() const;
59  virtual bool isEmpty() const;
60 
61  void appendItem( QtxPreferenceItem* );
62  void removeItem( QtxPreferenceItem* );
63  void insertItem( QtxPreferenceItem*, QtxPreferenceItem* = 0 );
64 
65  QIcon icon() const;
66  QString title() const;
67  void resource( QString&, QString& ) const;
68 
69  virtual void setIcon( const QIcon& );
70  virtual void setTitle( const QString& );
71  virtual void setResource( const QString&, const QString& );
72 
73  virtual void updateContents();
74 
75  QVariant option( const QString& ) const;
76  void setOption( const QString&, const QVariant& );
77 
78  bool isEvaluateValues() const;
79  void setEvaluateValues( const bool );
80 
81  bool isRestartRequired() const;
82  void setRestartRequired( const bool );
83 
84  virtual void store() = 0;
85  virtual void retrieve() = 0;
86 
87  QString resourceValue() const;
88  void setResourceValue( const QString& );
89 
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;
93 
94  virtual QtxResourceMgr* resourceMgr() const;
95  virtual QtxPreferenceMgr* preferenceMgr() const;
96 
97  virtual void activate();
98  void ensureVisible();
99 
100  static int RTTI();
101 
102 protected:
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;
109 
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& );
116 
117  virtual void itemAdded( QtxPreferenceItem* );
118  virtual void itemRemoved( QtxPreferenceItem* );
119  virtual void itemChanged( QtxPreferenceItem* );
120 
121  virtual void ensureVisible( QtxPreferenceItem* );
122 
123  void sendItemChanges();
124 
125  virtual void triggerUpdate();
126 
127  virtual QVariant optionValue( const QString& ) const;
128  virtual void setOptionValue( const QString&, const QVariant& );
129 
130 protected:
132 
133 private:
134  static int generateId();
135 
136 private:
137  int myId;
140 
141  bool myEval;
143  QIcon myIcon;
144  QString myTitle;
145  QString mySection;
146  QString myParameter;
147 };
148 
150 {
151 public:
153  virtual ~QtxPreferenceMgr();
154 
155  virtual QtxResourceMgr* resourceMgr() const;
156  virtual QtxPreferenceMgr* preferenceMgr() const;
157 
158  QVariant option( const int, const QString& ) const;
159  void setOption( const int, const QString&, const QVariant& );
160 
161  virtual void store();
162  virtual void retrieve();
163 
164  virtual void update();
165 
166  virtual void toBackup();
167  virtual void fromBackup();
168 
169 protected:
170  typedef QMap<QtxPreferenceItem*, QString> ResourceMap;
171 
172  void resourceValues( QMap<int, QString>& ) const;
173  void resourceValues( ResourceMap& ) const;
174 
175  void setResourceValues( QMap<int, QString>& ) const;
176  void setResourceValues( ResourceMap& ) const;
177 
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;
182 
183  virtual void changedResources( const ResourceMap& );
184 
185 private:
188 };
189 
190 #ifdef WIN32
191 #pragma warning( default:4251 )
192 #endif
193 
194 #endif