1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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/
19 // File: QtxResourceEdit.h
20 // Author: Sergey TELKOV
22 #ifndef QTXRESOURCEEDIT_H
23 #define QTXRESOURCEEDIT_H
26 #pragma warning( disable:4251 )
39 \class QtxResourceEdit
40 Class for managing preferences items
42 class QTX_EXPORT QtxResourceEdit
48 QtxResourceEdit( QtxResourceMgr* );
49 virtual ~QtxResourceEdit();
51 QtxResourceMgr* resourceMgr() const;
53 virtual int addItem( const QString& label, const int pId = -1, const int = -1,
54 const QString& section = QString::null,
55 const QString& param = QString::null );
57 QVariant itemProperty( const int, const QString& ) const;
58 virtual void setItemProperty( const int, const QString&, const QVariant& );
60 void resource( const int, QString&, QString& ) const;
63 virtual void retrieve();
65 virtual void update();
67 virtual void toBackup();
68 virtual void fromBackup();
71 Item* item( const int ) const;
72 Item* item( const QString& ) const;
73 Item* item( const QString&, const int ) const;
75 virtual Item* createItem( const QString&, const int ) = 0;
77 void resourceValues( QMap<int, QString>& ) const;
78 void resourceValues( QMap<Item*, QString>& ) const;
80 void setResourceValues( QMap<int, QString>& ) const;
81 void setResourceValues( QMap<Item*, QString>& ) const;
83 void differentValues( const QMap<int, QString>&, const QMap<int, QString>&,
84 QMap<int, QString>&, const bool fromFirst = false ) const;
85 void differentValues( const QMap<Item*, QString>&, const QMap<Item*, QString>&,
86 QMap<Item*, QString>&, const bool fromFirst = false ) const;
88 virtual void changedResources( const QMap<Item*, QString>& );
90 virtual void itemAdded( Item* );
91 virtual void itemRemoved( Item* );
93 void childItems( QPtrList<Item>& ) const;
96 void removeItem( Item* );
97 Item* createItem( const QString&, const int, const int );
100 typedef QMap<int, Item*> ItemMap;
104 QtxResourceMgr* myResMgr;
105 QMap<Item*, QString> myBackup;
106 QPtrList<Item> myChildren;
108 friend class QtxResourceEdit::Item;
112 \class QtxResourceEditor::Item
113 Class for incapsulation of one preference item
116 class QTX_EXPORT QtxResourceEdit::Item
119 Item( QtxResourceEdit*, Item* = 0 );
123 virtual int type() const = 0;
125 Item* parentItem() const;
126 void childItems( QPtrList<Item>& ) const;
128 virtual bool isEmpty() const;
130 QString title() const;
131 void resource( QString&, QString& ) const;
133 virtual void setTitle( const QString& );
134 virtual void setResource( const QString&, const QString& );
136 virtual void update();
138 QVariant property( const QString& ) const;
139 virtual void setProperty( const QString&, const QVariant& );
141 virtual void store() = 0;
142 virtual void retrieve() = 0;
144 virtual Item* createItem( const QString&, const int ) = 0;
146 QString resourceValue() const;
147 void setResourceValue( const QString& );
149 virtual void insertChild( Item* );
150 virtual void removeChild( Item* );
153 QtxResourceMgr* resourceMgr() const;
154 QtxResourceEdit* resourceEdit() const;
156 int getInteger( const int = 0 ) const;
157 double getDouble( const double = 0.0 ) const;
158 bool getBoolean( const bool = false ) const;
159 QColor getColor( const QColor& = QColor() ) const;
160 QFont getFont( const QFont& = QFont() ) const;
161 QString getString( const QString& = QString::null ) const;
163 void setInteger( const int );
164 void setDouble( const double );
165 void setBoolean( const bool );
166 void setColor( const QColor& );
167 void setFont( const QFont& );
168 void setString( const QString& );
170 Item* item( const int ) const;
171 Item* item( const QString& ) const;
172 Item* item( const QString&, const int ) const;
175 typedef QPtrList<Item> ItemList;
176 typedef QPtrListIterator<Item> ItemListIterator;
179 static int generateId();
187 QString myResSection;
188 QString myResParameter;
190 QtxResourceEdit* myEdit;
194 #pragma warning( default:4251 )