lib

property.h
1/* This file is part of the KDE project
2 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
3 Copyright (C) 2004 Alexander Dymo <cloudtemple@mskat.net>
4 Copyright (C) 2004-2006 Jaroslaw Staniek <js@iidea.pl>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20*/
21
22#ifndef KPROPERTY_PROPERTY_H
23#define KPROPERTY_PROPERTY_H
24
25#include <tqvariant.h>
26#include "koproperty_global.h"
27
28template<class U> class TQAsciiDict;
29template<class U> class TQAsciiDictIterator;
30
52namespace KoProperty {
53
54class PropertyPrivate;
55class CustomProperty;
56class Set;
57
59//KOPROPERTY_EXPORT TQStringVariantMap createValueListFromStringLists(
60// const TQStringList &keys, const TQStringList &values);
61
66 //standard supported TQVariant types
67 Auto = TQVariant::Invalid - 1,
68 Invalid = TQVariant::Invalid ,
69 Map = TQVariant::Map ,
70 List = TQVariant::List ,
71 String = TQVariant::String ,
72 StringList = TQVariant::StringList ,
73 Font = TQVariant::Font ,
74 Pixmap = TQVariant::Pixmap ,
76 Rect = TQVariant::Rect ,
77 Size = TQVariant::Size ,
78 Color = TQVariant::Color ,
82 Point = TQVariant::Point ,
84 Integer = TQVariant::Int ,
86 Boolean = TQVariant::Bool ,
87 Double = TQVariant::Double ,
88 CString = TQVariant::CString ,
92 Cursor = TQVariant::Cursor ,
93 SizePolicy = TQVariant::SizePolicy ,
94 Date = TQVariant::Date ,
95 Time = TQVariant::Time ,
96 DateTime = TQVariant::DateTime ,
104
105 //predefined custom types
107 Symbol = 2001 ,
113
114 // Child property types
115 Size_Height = 3001,
116 Size_Width,
117 Point_X,
118 Point_Y,
119 Rect_X,
120 Rect_Y,
121 Rect_Width,
122 Rect_Height,
123 SizePolicy_HorData,
124 SizePolicy_VerData,
125 SizePolicy_HorStretch,
126 SizePolicy_VerStretch,
127
129};
130
176class KOPROPERTY_EXPORT Property
177{
178 public:
180 static const Property null;
181
182 typedef TQAsciiDict<Property> Dict;
183 typedef TQAsciiDictIterator<Property> DictIterator;
184
186 class KOPROPERTY_EXPORT ListData
187 {
188 public:
191 ListData(const TQStringList& keys_, const TQStringList& names_);
192 ListData(const TQValueList<TQVariant> keys_, const TQStringList& names_);
193 ListData();
194 ~ListData();
195
196 void setKeysAsStringList(const TQStringList& list);
197 TQStringList keysAsStringList() const;
198
203 TQValueList<TQVariant> keys;
204// TQStringList keys;
205
207
209 TQStringList names;
210
211//unused for now /*! True (the default), if the list has fixed number of possible
212//unused for now items (keys). If this is false, user can add or enter own values. */
213//unused for now bool fixed : 1;
214 };
215
217 Property();
218
223 Property(const TQCString &name, const TQVariant &value = TQVariant(),
224 const TQString &caption = TQString(), const TQString &description = TQString(),
225 int type = Auto, Property* parent = 0);
226
228 Property(const TQCString &name, const TQStringList &keys, const TQStringList &strings,
229 const TQVariant &value = TQVariant(),
230 const TQString &caption = TQString(), const TQString &description = TQString(),
231 int type = ValueFromList, Property* parent = 0);
232
235 Property(const TQCString &name, ListData* listData,
236 const TQVariant &value = TQVariant(),
237 const TQString &caption = TQString(), const TQString &description = TQString(),
238 int type = ValueFromList, Property* parent = 0);
239
241 Property(const Property &prop);
242
243 ~Property();
244
246 TQCString name() const;
247
249 void setName(const TQCString &name);
250
252 TQString caption() const;
253
257 TQString captionForDisplaying() const;
258
262 void setCaption(const TQString &caption);
263
265 TQString description() const;
266
268 void setDescription(const TQString &description);
269
271 int type() const;
272
274 void setType(int type);
275
277 TQVariant value() const;
278
280 TQVariant oldValue() const;
281
283 void setValue(const TQVariant &value, bool rememberOldValue = true, bool useCustomProperty=true);
284
287 void resetValue();
288
291 ListData* listData() const;
292
295 void setListData(ListData* list);
296
300 void setListData(const TQStringList &keys, const TQStringList &names);
301
304 void setIcon(const TQString &icon);
305
307 TQString icon() const;
308
311 const TQValueList<Property*>* children() const;
312
314 Property* child(const TQCString &name);
315
317 Property* parent() const;
318
321 CustomProperty* customProperty() const;
322
325 void setCustomProperty(CustomProperty *prop);
326
328 bool isNull() const;
329
331 operator bool () const;
332
334 bool isModified() const;
335
337 void clearModifiedFlag();
338
344 bool isReadOnly() const;
345
348 void setReadOnly(bool readOnly);
349
351 bool isVisible() const;
352
354 void setVisible(bool visible);
355
359 bool isStorable() const;
360
362 void setStorable(bool storable);
363
370 int autoSync() const;
371
378 void setAutoSync(int sync);
379
385 void setOption(const char* name, const TQVariant& val);
386
388 TQVariant option(const char* name) const;
389
391 bool hasOptions() const;
392
394 const Property& operator= (const TQVariant& val);
395
397 const Property& operator= (const Property &property);
398
400 bool operator ==(const Property &prop) const;
401
406 int sortingKey() const;
407
408 protected:
411 void addChild(Property *prop);
412
414 void addSet(Set *set);
415
417 void setSortingKey(int key);
418
420 const TQValueList<Property*>* related() const;
421
423 void addRelatedProperty(Property *property);
424
428 void emitPropertyChanged();
429
431 void debug();
432
434 PropertyPrivate *d;
435
436 friend class Set;
437 friend class Buffer;
438 friend class CustomProperty;
439};
440
441}
442
443#endif
Base class for custom properties.
ListData(const TQStringList &keys_, const TQStringList &names_)
Definition property.cpp:114
TQValueList< TQVariant > keys
Definition property.h:203
void setSortingKey(int key)
Definition property.cpp:737
void addSet(Set *set)
Definition property.cpp:677
void setAutoSync(int sync)
Definition property.cpp:506
void setType(int type)
Definition property.cpp:296
TQCString name() const
Definition property.cpp:248
TQString icon() const
Definition property.cpp:302
CustomProperty * customProperty() const
Definition property.cpp:721
bool isReadOnly() const
Definition property.cpp:476
void setStorable(bool storable)
Definition property.cpp:518
bool isModified() const
Definition property.cpp:464
Property * child(const TQCString &name)
Definition property.cpp:640
bool isNull() const
Definition property.cpp:458
const TQValueList< Property * > * children() const
Definition property.cpp:634
ListData * listData() const
Definition property.cpp:428
TQVariant option(const char *name) const
Definition property.cpp:530
Property * parent() const
Definition property.cpp:651
static const Property null
A contant for null property.
Definition property.h:180
void addRelatedProperty(Property *property)
Definition property.cpp:710
void clearModifiedFlag()
Clears "modified" flag, so isModified() will return false.
Definition property.cpp:470
TQVariant value() const
Definition property.cpp:314
void setReadOnly(bool readOnly)
Definition property.cpp:482
void setCaption(const TQString &caption)
Definition property.cpp:272
void addChild(Property *prop)
Definition property.cpp:657
TQString description() const
Definition property.cpp:278
void setName(const TQCString &name)
Definition property.cpp:254
void setVisible(bool visible)
Definition property.cpp:494
bool isStorable() const
Definition property.cpp:512
void setValue(const TQVariant &value, bool rememberOldValue=true, bool useCustomProperty=true)
Definition property.cpp:331
const TQValueList< Property * > * related() const
Definition property.cpp:704
bool hasOptions() const
Definition property.cpp:538
int autoSync() const
Definition property.cpp:500
TQString caption() const
Definition property.cpp:260
int sortingKey() const
Definition property.cpp:732
TQString captionForDisplaying() const
Definition property.cpp:266
void setListData(ListData *list)
Definition property.cpp:434
TQVariant oldValue() const
Definition property.cpp:322
void setCustomProperty(CustomProperty *prop)
Definition property.cpp:727
void setOption(const char *name, const TQVariant &val)
Definition property.cpp:524
void setDescription(const TQString &description)
Definition property.cpp:284
void setIcon(const TQString &icon)
Definition property.cpp:308
bool isVisible() const
Definition property.cpp:488
Lists holding properties in groups.
Definition set.h:41
Namespace for a set of classes implementing generic properties framework.
@ DateTime
date and time
Definition property.h:96
@ Point
point (x,y)
Definition property.h:82
@ String
string
Definition property.h:71
@ Boolean
boolean
Definition property.h:86
@ Time
time
Definition property.h:95
@ List
TQValueList<TQVariant>.
Definition property.h:70
@ LineStyle
line style
Definition property.h:112
@ Pixmap
pixmap
Definition property.h:74
@ Symbol
unicode symbol code
Definition property.h:107
@ Rect
rectangle (x,y, width, height)
Definition property.h:76
@ DirectoryURL
url of a directory
Definition property.h:111
@ Size
size (width, height)
Definition property.h:77
@ Font
font
Definition property.h:73
@ FileURL
url of a file
Definition property.h:109
@ UserDefined
plugin defined properties should start here
Definition property.h:128
@ Color
color
Definition property.h:78
@ PictureFileURL
url of a pixmap
Definition property.h:110
@ Integer
integer
Definition property.h:84
@ Invalid
invalid property type
Definition property.h:68
@ FontName
font name, e.g.
Definition property.h:108
@ StringList
string list
Definition property.h:72
@ Date
date
Definition property.h:94
@ SizePolicy
size policy (horizontal, vertical)
Definition property.h:93
@ Cursor
cursor
Definition property.h:92
@ Map
TQStringVariantMap.
Definition property.h:69
@ ValueFromList
string value from a list
Definition property.h:106
@ Double
double
Definition property.h:87