00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KPROPERTY_PROPERTY_H
00023 #define KPROPERTY_PROPERTY_H
00024
00025 #include <qvariant.h>
00026 #include "koproperty_global.h"
00027
00028 template<class U> class QAsciiDict;
00029 template<class U> class QAsciiDictIterator;
00030
00047 namespace KoProperty {
00048
00049 class PropertyPrivate;
00050 class CustomProperty;
00051 class Set;
00052
00054
00055
00056
00059 enum PropertyType {
00060
00061 Auto = QVariant::Invalid - 1,
00062 Invalid = QVariant::Invalid ,
00063 Map = QVariant::Map ,
00064 List = QVariant::List ,
00065 String = QVariant::String ,
00066 StringList = QVariant::StringList ,
00067 Font = QVariant::Font ,
00068 Pixmap = QVariant::Pixmap ,
00070 Rect = QVariant::Rect ,
00071 Size = QVariant::Size ,
00072 Color = QVariant::Color ,
00076 Point = QVariant::Point ,
00078 Integer = QVariant::Int ,
00080 Boolean = QVariant::Bool ,
00081 Double = QVariant::Double ,
00082 CString = QVariant::CString ,
00086 Cursor = QVariant::Cursor ,
00087 SizePolicy = QVariant::SizePolicy ,
00088 Date = QVariant::Date ,
00089 Time = QVariant::Time ,
00090 DateTime = QVariant::DateTime ,
00098
00099
00100 ValueFromList = 2000 ,
00101 Symbol = 2001 ,
00102 FontName ,
00103 FileURL ,
00104 PictureFileURL ,
00105 DirectoryURL ,
00106 LineStyle ,
00107
00108
00109 Size_Height = 3001,
00110 Size_Width,
00111 Point_X,
00112 Point_Y,
00113 Rect_X,
00114 Rect_Y,
00115 Rect_Width,
00116 Rect_Height,
00117 SizePolicy_HorData,
00118 SizePolicy_VerData,
00119 SizePolicy_HorStretch,
00120 SizePolicy_VerStretch,
00121
00122 UserDefined = 4000
00123 };
00124
00161 class KOPROPERTY_EXPORT Property
00162 {
00163 public:
00165 QT_STATIC_CONST Property null;
00166
00167 typedef QAsciiDict<Property> Dict;
00168 typedef QAsciiDictIterator<Property> DictIterator;
00169
00171 class KOPROPERTY_EXPORT ListData
00172 {
00173 public:
00176 ListData(const QStringList& keys_, const QStringList& names_);
00177 ListData(const QValueList<QVariant> keys_, const QStringList& names_);
00178 ListData();
00179 ~ListData();
00180
00181 void setKeysAsStringList(const QStringList& list);
00182 QStringList keysAsStringList() const;
00183
00188 QValueList<QVariant> keys;
00189
00190
00192
00194 QStringList names;
00195
00196
00197
00198
00199 };
00200
00202 Property();
00203
00208 Property(const QCString &name, const QVariant &value = QVariant(),
00209 const QString &caption = QString::null, const QString &description = QString::null,
00210 int type = Auto, Property* parent = 0);
00211
00213 Property(const QCString &name, const QStringList &keys, const QStringList &strings,
00214 const QVariant &value = QVariant(),
00215 const QString &caption = QString::null, const QString &description = QString::null,
00216 int type = ValueFromList, Property* parent = 0);
00217
00220 Property(const QCString &name, ListData* listData,
00221 const QVariant &value = QVariant(),
00222 const QString &caption = QString::null, const QString &description = QString::null,
00223 int type = ValueFromList, Property* parent = 0);
00224
00226 Property(const Property &prop);
00227
00228 ~Property();
00229
00231 QCString name() const;
00232
00234 void setName(const QCString &name);
00235
00237 QString caption() const;
00238
00242 QString captionForDisplaying() const;
00243
00247 void setCaption(const QString &caption);
00248
00250 QString description() const;
00251
00253 void setDescription(const QString &description);
00254
00256 int type() const;
00257
00259 void setType(int type);
00260
00262 QVariant value() const;
00263
00265 QVariant oldValue() const;
00266
00268 void setValue(const QVariant &value, bool rememberOldValue = true, bool useCustomProperty=true);
00269
00272 void resetValue();
00273
00276 ListData* listData() const;
00277
00280 void setListData(ListData* list);
00281
00285 void setListData(const QStringList &keys, const QStringList &names);
00286
00289 void setIcon(const QString &icon);
00290
00292 QString icon() const;
00293
00296 const QValueList<Property*>* children() const;
00297
00299 Property* child(const QCString &name);
00300
00302 Property* parent() const;
00303
00306 void setCustomProperty(CustomProperty *prop);
00307
00309 bool isNull() const;
00310
00312 operator bool () const;
00313
00315 bool isModified() const;
00316
00322 bool isReadOnly() const;
00323
00326 void setReadOnly(bool readOnly);
00327
00329 bool isVisible() const;
00330
00332 void setVisible(bool visible);
00333
00337 bool isStorable() const;
00338
00340 void setStorable(bool storable);
00341
00348 int autoSync() const;
00349
00356 void setAutoSync(int sync);
00357
00363 void setOption(const char* name, const QVariant& val);
00364
00366 QVariant option(const char* name) const;
00367
00369 bool hasOptions() const;
00370
00372 const Property& operator= (const QVariant& val);
00373
00375 const Property& operator= (const Property &property);
00376
00378 bool operator ==(const Property &prop) const;
00379
00384 int sortingKey() const;
00385
00386 protected:
00389 void addChild(Property *prop);
00390
00392 void addSet(Set *set);
00393
00395 void setSortingKey(int key);
00396
00398 const QValueList<Property*>* related() const;
00399
00401 void addRelatedProperty(Property *property);
00402
00404 void debug();
00405
00407 PropertyPrivate *d;
00408
00409 friend class Set;
00410 friend class Buffer;
00411 friend class CustomProperty;
00412 };
00413
00414 }
00415
00416 #endif