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
24 enum { Space, Bool, Color, String, List, RealSpin, IntegerSpin, RealEdit, IntegerEdit };
27 QtxResourceEdit( QtxResourceMgr* );
28 virtual ~QtxResourceEdit();
30 QtxResourceMgr* resourceMgr() const;
32 int addItem( const QString& label, const int pId = -1, const int = -1,
33 const QString& section = QString::null,
34 const QString& param = QString::null );
36 QVariant property( const int, const QString& ) const;
37 void setProperty( const int, const QString&, const QVariant& );
40 virtual void retrieve();
42 virtual void update();
44 virtual void toBackup();
45 virtual void fromBackup();
48 Item* item( const int ) const;
49 Item* item( const QString& ) const;
50 Item* item( const QString&, const int ) const;
52 virtual Item* createItem( const QString&, const int ) = 0;
54 void resourceValues( QMap<int, QString>& ) const;
55 void resourceValues( QMap<Item*, QString>& ) const;
57 void setResourceValues( QMap<int, QString>& ) const;
58 void setResourceValues( QMap<Item*, QString>& ) const;
60 void differentValues( const QMap<int, QString>&, const QMap<int, QString>&,
61 QMap<int, QString>&, const bool fromFirst = false ) const;
62 void differentValues( const QMap<Item*, QString>&, const QMap<Item*, QString>&,
63 QMap<Item*, QString>&, const bool fromFirst = false ) const;
65 virtual void changedResources( const QMap<Item*, QString>& );
68 void removeItem( Item* );
69 Item* createItem( const QString&, const int, const int );
72 typedef QMap<int, Item*> ItemMap;
76 QtxResourceMgr* myResMgr;
77 QMap<Item*, QString> myBackup;
79 friend class QtxResourceEdit::Item;
83 Class: QtxResourceEditor::Item
84 Descr: Class for incapsulation of one preference item
87 class QtxResourceEdit::Item
90 Item( QtxResourceEdit*, Item* = 0 );
94 virtual int type() const = 0;
96 Item* parentItem() const;
97 void childItems( QPtrList<Item>& ) const;
99 QString title() const;
100 void resource( QString&, QString& ) const;
102 virtual void setTitle( const QString& );
103 virtual void setResource( const QString&, const QString& );
105 virtual void update();
107 QVariant property( const QString& ) const;
108 virtual void setProperty( const QString&, const QVariant& );
110 virtual void store() = 0;
111 virtual void retrieve() = 0;
113 virtual Item* createItem( const QString&, const int ) = 0;
115 QString resourceValue() const;
116 void setResourceValue( const QString& );
119 QtxResourceMgr* resourceMgr() const;
120 QtxResourceEdit* resourceEdit() const;
122 int getInteger( const int = 0 ) const;
123 double getDouble( const double = 0.0 ) const;
124 bool getBoolean( const bool = false ) const;
125 QColor getColor( const QColor& = QColor() ) const;
126 QString getString( const QString& = QString::null ) const;
128 void setInteger( const int );
129 void setDouble( const double );
130 void setBoolean( const bool );
131 void setColor( const QColor& );
132 void setString( const QString& );
134 Item* item( const int ) const;
135 Item* item( const QString& ) const;
136 Item* item( const QString&, const int ) const;
139 typedef QPtrList<Item> ItemList;
140 typedef QPtrListIterator<Item> ItemListIterator;
143 static int generateId();
151 QString myResSection;
152 QString myResParameter;
154 QtxResourceEdit* myEdit;
158 #pragma warning( default:4251 )