1 // File: QtxResourceEdit.h
2 // Author: Sergey TELKOV
4 #ifndef QTXRESOURCEEDIT_H
5 #define QTXRESOURCEEDIT_H
8 #pragma warning( disable:4251 )
19 class QTX_EXPORT QtxResourceEdit
25 QtxResourceEdit( QtxResourceMgr* );
26 virtual ~QtxResourceEdit();
28 QtxResourceMgr* resourceMgr() const;
30 int addItem( const QString& label, const int pId = -1, const int = -1,
31 const QString& section = QString::null,
32 const QString& param = QString::null );
34 QVariant property( const int, const QString& ) const;
35 void setProperty( const int, const QString&, const QVariant& );
38 virtual void retrieve();
40 virtual void update();
42 virtual void toBackup();
43 virtual void fromBackup();
46 Item* item( const int ) const;
47 Item* item( const QString& ) const;
48 Item* item( const QString&, const int ) const;
50 virtual Item* createItem( const QString&, const int ) = 0;
52 void resourceValues( QMap<int, QString>& ) const;
53 void resourceValues( QMap<Item*, QString>& ) const;
55 void setResourceValues( QMap<int, QString>& ) const;
56 void setResourceValues( QMap<Item*, QString>& ) const;
58 void differentValues( const QMap<int, QString>&, const QMap<int, QString>&,
59 QMap<int, QString>&, const bool fromFirst = false ) const;
60 void differentValues( const QMap<Item*, QString>&, const QMap<Item*, QString>&,
61 QMap<Item*, QString>&, const bool fromFirst = false ) const;
63 virtual void changedResources( const QMap<Item*, QString>& );
66 void removeItem( Item* );
67 Item* createItem( const QString&, const int, const int );
70 typedef QMap<int, Item*> ItemMap;
74 QtxResourceMgr* myResMgr;
75 QMap<Item*, QString> myBackup;
77 friend class QtxResourceEdit::Item;
81 Class: QtxResourceEditor::Item
82 Descr: Class for incapsulation of one preference item
85 class QtxResourceEdit::Item
88 Item( QtxResourceEdit*, Item* = 0 );
92 virtual int type() const = 0;
94 Item* parentItem() const;
95 void childItems( QPtrList<Item>& ) const;
97 QString title() const;
98 void resource( QString&, QString& ) const;
100 virtual void setTitle( const QString& );
101 virtual void setResource( const QString&, const QString& );
103 virtual void update();
105 QVariant property( const QString& ) const;
106 virtual void setProperty( const QString&, const QVariant& );
108 virtual void store() = 0;
109 virtual void retrieve() = 0;
111 virtual Item* createItem( const QString&, const int ) = 0;
113 QString resourceValue() const;
114 void setResourceValue( const QString& );
117 QtxResourceMgr* resourceMgr() const;
118 QtxResourceEdit* resourceEdit() const;
120 int getInteger( const int = 0 ) const;
121 double getDouble( const double = 0.0 ) const;
122 bool getBoolean( const bool = false ) const;
123 QColor getColor( const QColor& = QColor() ) const;
124 QString getString( const QString& = QString::null ) const;
126 void setInteger( const int );
127 void setDouble( const double );
128 void setBoolean( const bool );
129 void setColor( const QColor& );
130 void setString( const QString& );
132 Item* item( const int ) const;
133 Item* item( const QString& ) const;
134 Item* item( const QString&, const int ) const;
137 typedef QPtrList<Item> ItemList;
138 typedef QPtrListIterator<Item> ItemListIterator;
141 static int generateId();
149 QString myResSection;
150 QString myResParameter;
152 QtxResourceEdit* myEdit;
156 #pragma warning( default:4251 )