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
00052 namespace KoProperty {
00053
00054 class PropertyPrivate;
00055 class CustomProperty;
00056 class Set;
00057
00059
00060
00061
00065 enum PropertyType {
00066
00067 Auto = QVariant::Invalid - 1,
00068 Invalid = QVariant::Invalid ,
00069 Map = QVariant::Map ,
00070 List = QVariant::List ,
00071 String = QVariant::String ,
00072 StringList = QVariant::StringList ,
00073 Font = QVariant::Font ,
00074 Pixmap = QVariant::Pixmap ,
00076 Rect = QVariant::Rect ,
00077 Size = QVariant::Size ,
00078 Color = QVariant::Color ,
00082 Point = QVariant::Point ,
00084 Integer = QVariant::Int ,
00086 Boolean = QVariant::Bool ,
00087 Double = QVariant::Double ,
00088 CString = QVariant::CString ,
00092 Cursor = QVariant::Cursor ,
00093 SizePolicy = QVariant::SizePolicy ,
00094 Date = QVariant::Date ,
00095 Time = QVariant::Time ,
00096 DateTime = QVariant::DateTime ,
00104
00105
00106 ValueFromList = 2000 ,
00107 Symbol = 2001 ,
00108 FontName ,
00109 FileURL ,
00110 PictureFileURL ,
00111 DirectoryURL ,
00112 LineStyle ,
00113
00114
00115 Size_Height = 3001,
00116 Size_Width,
00117 Point_X,
00118 Point_Y,
00119 Rect_X,
00120 Rect_Y,
00121 Rect_Width,
00122 Rect_Height,
00123 SizePolicy_HorData,
00124 SizePolicy_VerData,
00125 SizePolicy_HorStretch,
00126 SizePolicy_VerStretch,
00127
00128 UserDefined = 4000
00129 };
00130
00176 class KOPROPERTY_EXPORT Property
00177 {
00178 public:
00180 QT_STATIC_CONST Property null;
00181
00182 typedef QAsciiDict<Property> Dict;
00183 typedef QAsciiDictIterator<Property> DictIterator;
00184
00186 class KOPROPERTY_EXPORT ListData
00187 {
00188 public:
00191 ListData(const QStringList& keys_, const QStringList& names_);
00192 ListData(const QValueList<QVariant> keys_, const QStringList& names_);
00193 ListData();
00194 ~ListData();
00195
00196 void setKeysAsStringList(const QStringList& list);
00197 QStringList keysAsStringList() const;
00198
00203 QValueList<QVariant> keys;
00204
00205
00207
00209 QStringList names;
00210
00211
00212
00213
00214 };
00215
00217 Property();
00218
00223 Property(const QCString &name, const QVariant &value = QVariant(),
00224 const QString &caption = QString::null, const QString &description = QString::null,
00225 int type = Auto, Property* parent = 0);
00226
00228 Property(const QCString &name, const QStringList &keys, const QStringList &strings,
00229 const QVariant &value = QVariant(),
00230 const QString &caption = QString::null, const QString &description = QString::null,
00231 int type = ValueFromList, Property* parent = 0);
00232
00235 Property(const QCString &name, ListData* listData,
00236 const QVariant &value = QVariant(),
00237 const QString &caption = QString::null, const QString &description = QString::null,
00238 int type = ValueFromList, Property* parent = 0);
00239
00241 Property(const Property &prop);
00242
00243 ~Property();
00244
00246 QCString name() const;
00247
00249 void setName(const QCString &name);
00250
00252 QString caption() const;
00253
00257 QString captionForDisplaying() const;
00258
00262 void setCaption(const QString &caption);
00263
00265 QString description() const;
00266
00268 void setDescription(const QString &description);
00269
00271 int type() const;
00272
00274 void setType(int type);
00275
00277 QVariant value() const;
00278
00280 QVariant oldValue() const;
00281
00283 void setValue(const QVariant &value, bool rememberOldValue = true, bool useCustomProperty=true);
00284
00287 void resetValue();
00288
00291 ListData* listData() const;
00292
00295 void setListData(ListData* list);
00296
00300 void setListData(const QStringList &keys, const QStringList &names);
00301
00304 void setIcon(const QString &icon);
00305
00307 QString icon() const;
00308
00311 const QValueList<Property*>* children() const;
00312
00314 Property* child(const QCString &name);
00315
00317 Property* parent() const;
00318
00321 CustomProperty* customProperty() const;
00322
00325 void setCustomProperty(CustomProperty *prop);
00326
00328 bool isNull() const;
00329
00331 operator bool () const;
00332
00334 bool isModified() const;
00335
00337 void clearModifiedFlag();
00338
00344 bool isReadOnly() const;
00345
00348 void setReadOnly(bool readOnly);
00349
00351 bool isVisible() const;
00352
00354 void setVisible(bool visible);
00355
00359 bool isStorable() const;
00360
00362 void setStorable(bool storable);
00363
00370 int autoSync() const;
00371
00378 void setAutoSync(int sync);
00379
00385 void setOption(const char* name, const QVariant& val);
00386
00388 QVariant option(const char* name) const;
00389
00391 bool hasOptions() const;
00392
00394 const Property& operator= (const QVariant& val);
00395
00397 const Property& operator= (const Property &property);
00398
00400 bool operator ==(const Property &prop) const;
00401
00406 int sortingKey() const;
00407
00408 protected:
00411 void addChild(Property *prop);
00412
00414 void addSet(Set *set);
00415
00417 void setSortingKey(int key);
00418
00420 const QValueList<Property*>* related() const;
00421
00423 void addRelatedProperty(Property *property);
00424
00428 void emitPropertyChanged();
00429
00431 void debug();
00432
00434 PropertyPrivate *d;
00435
00436 friend class Set;
00437 friend class Buffer;
00438 friend class CustomProperty;
00439 };
00440
00441 }
00442
00443 #endif