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 )
38 class QTX_EXPORT QtxResourceEdit
44 QtxResourceEdit( QtxResourceMgr* );
45 virtual ~QtxResourceEdit();
47 QtxResourceMgr* resourceMgr() const;
49 virtual int addItem( const QString& label, const int pId = -1, const int = -1,
50 const QString& section = QString::null,
51 const QString& param = QString::null );
53 QVariant itemProperty( const int, const QString& ) const;
54 virtual void setItemProperty( const int, const QString&, const QVariant& );
56 void resource( const int, QString&, QString& ) const;
59 virtual void retrieve();
61 virtual void update();
63 virtual void toBackup();
64 virtual void fromBackup();
67 Item* item( const int ) const;
68 Item* item( const QString& ) const;
69 Item* item( const QString&, const int ) const;
71 virtual Item* createItem( const QString&, const int ) = 0;
73 void resourceValues( QMap<int, QString>& ) const;
74 void resourceValues( QMap<Item*, QString>& ) const;
76 void setResourceValues( QMap<int, QString>& ) const;
77 void setResourceValues( QMap<Item*, QString>& ) const;
79 void differentValues( const QMap<int, QString>&, const QMap<int, QString>&,
80 QMap<int, QString>&, const bool fromFirst = false ) const;
81 void differentValues( const QMap<Item*, QString>&, const QMap<Item*, QString>&,
82 QMap<Item*, QString>&, const bool fromFirst = false ) const;
84 virtual void changedResources( const QMap<Item*, QString>& );
86 virtual void itemAdded( Item* );
87 virtual void itemRemoved( Item* );
89 void childItems( QPtrList<Item>& ) const;
92 void removeItem( Item* );
93 Item* createItem( const QString&, const int, const int );
96 typedef QMap<int, Item*> ItemMap;
100 QtxResourceMgr* myResMgr;
101 QMap<Item*, QString> myBackup;
102 QPtrList<Item> myChildren;
104 friend class QtxResourceEdit::Item;
108 Class: QtxResourceEditor::Item
109 Descr: Class for incapsulation of one preference item
112 class QTX_EXPORT QtxResourceEdit::Item
115 Item( QtxResourceEdit*, Item* = 0 );
119 virtual int type() const = 0;
121 Item* parentItem() const;
122 void childItems( QPtrList<Item>& ) const;
124 virtual bool isEmpty() const;
126 QString title() const;
127 void resource( QString&, QString& ) const;
129 virtual void setTitle( const QString& );
130 virtual void setResource( const QString&, const QString& );
132 virtual void update();
134 QVariant property( const QString& ) const;
135 virtual void setProperty( const QString&, const QVariant& );
137 virtual void store() = 0;
138 virtual void retrieve() = 0;
140 virtual Item* createItem( const QString&, const int ) = 0;
142 QString resourceValue() const;
143 void setResourceValue( const QString& );
145 virtual void insertChild( Item* );
146 virtual void removeChild( Item* );
149 QtxResourceMgr* resourceMgr() const;
150 QtxResourceEdit* resourceEdit() const;
152 int getInteger( const int = 0 ) const;
153 double getDouble( const double = 0.0 ) const;
154 bool getBoolean( const bool = false ) const;
155 QColor getColor( const QColor& = QColor() ) const;
156 QFont getFont( const QFont& = QFont() ) const;
157 QString getString( const QString& = QString::null ) const;
159 void setInteger( const int );
160 void setDouble( const double );
161 void setBoolean( const bool );
162 void setColor( const QColor& );
163 void setFont( const QFont& );
164 void setString( const QString& );
166 Item* item( const int ) const;
167 Item* item( const QString& ) const;
168 Item* item( const QString&, const int ) const;
171 typedef QPtrList<Item> ItemList;
172 typedef QPtrListIterator<Item> ItemListIterator;
175 static int generateId();
183 QString myResSection;
184 QString myResParameter;
186 QtxResourceEdit* myEdit;
190 #pragma warning( default:4251 )