lib
KoProperty::Property Class Reference
#include <property.h>
Detailed Description
The base class representing a single property.
It can hold a property of any type supported by QVariant. You can also create you own property types (see Using Custom Properties in Factory doc). As a consequence, do not subclass Property, use CustomProperty instead.
Each property stores old value to allow undo. It has a name (a QCString), a caption (i18n'ed name shown in Editor) and a description (also i18n'ed).
It also supports setting arbitrary number of options (of type option=value). See Editor for a list of options, and their meaning.
// To create a property property = Property(name, value, caption, description); // name is a QCString, // value is whatever type QVariant supports // To create a list property QStringList keys, strings; keys << "one" << "two" << "three"; strings << i18n("One") << i18n("Two") << i18n("Three"); property = Property(name, keys, strings, "two", caption);
Note that you need to use QVariant(bool, int) to create a boolean property value. See QVariant docs for more details.
Sometimes, for longer property captions or these with more words, e.g. "Allow Zero Size", it's usable to provide newline characters, e.g. "Allow Zero\nSize". If caption argument of the constructors contains newline characters, caption() will return this text with substituted these characters with spaces. In such cases, captionForDisplaying() is used to get the original caption text usable (with newline, if any) for displaying within a property editor.
- Author:
- Cedric Pasteur <cedric.pasteur@free.fr>
Alexander Dymo <cloudtemple@mskat.net>
Jaroslaw Staniek <js@iidea.pl>
Definition at line 161 of file property.h.
Public Types | |
typedef QAsciiDict< Property > | Dict |
typedef QAsciiDictIterator< Property > | DictIterator |
Public Member Functions | |
Property () | |
Property (const QCString &name, const QVariant &value=QVariant(), const QString &caption=QString::null, const QString &description=QString::null, int type=Auto, Property *parent=0) | |
Property (const QCString &name, const QStringList &keys, const QStringList &strings, const QVariant &value=QVariant(), const QString &caption=QString::null, const QString &description=QString::null, int type=ValueFromList, Property *parent=0) | |
Property (const QCString &name, ListData *listData, const QVariant &value=QVariant(), const QString &caption=QString::null, const QString &description=QString::null, int type=ValueFromList, Property *parent=0) | |
Property (const Property &prop) | |
~Property () | |
QCString | name () const |
void | setName (const QCString &name) |
QString | caption () const |
QString | captionForDisplaying () const |
void | setCaption (const QString &caption) |
QString | description () const |
void | setDescription (const QString &description) |
int | type () const |
void | setType (int type) |
QVariant | value () const |
QVariant | oldValue () const |
void | setValue (const QVariant &value, bool rememberOldValue=true, bool useCustomProperty=true) |
void | resetValue () |
ListData * | listData () const |
void | setListData (ListData *list) |
void | setListData (const QStringList &keys, const QStringList &names) |
void | setIcon (const QString &icon) |
QString | icon () const |
const QValueList< Property * > * | children () const |
Property * | child (const QCString &name) |
Property * | parent () const |
void | setCustomProperty (CustomProperty *prop) |
bool | isNull () const |
operator bool () const | |
bool | isModified () const |
bool | isReadOnly () const |
void | setReadOnly (bool readOnly) |
bool | isVisible () const |
void | setVisible (bool visible) |
bool | isStorable () const |
void | setStorable (bool storable) |
int | autoSync () const |
void | setAutoSync (int sync) |
void | setOption (const char *name, const QVariant &val) |
QVariant | option (const char *name) const |
bool | hasOptions () const |
const Property & | operator= (const QVariant &val) |
const Property & | operator= (const Property &property) |
bool | operator== (const Property &prop) const |
int | sortingKey () const |
Public Attributes | |
QT_STATIC_CONST Property | null |
Protected Member Functions | |
void | addChild (Property *prop) |
void | addSet (Set *set) |
void | setSortingKey (int key) |
const QValueList< Property * > * | related () const |
void | addRelatedProperty (Property *property) |
void | debug () |
Protected Attributes | |
PropertyPrivate * | d |
Friends | |
class | Set |
class | Buffer |
class | CustomProperty |
Classes | |
class | ListData |
Constructor & Destructor Documentation
|
Constructs a null property. Definition at line 231 of file property.cpp. |
|
Constructs property of simple type. If caption contains newline characters, caption() will return caption with substituted these with spaces. captionForDisplaying() is used to get original caption text usable (with newline, if any) for displaying within a property editor. Definition at line 174 of file property.cpp. |
|
Constructs property of ValueFromList type. Definition at line 195 of file property.cpp. |
|
Constructs property of ValueFromList type. This is overload of the above ctor added for convenience. Definition at line 213 of file property.cpp. |
|
Constructs a deep copy of prop property. Definition at line 236 of file property.cpp. |
Member Function Documentation
|
Adds prop as a child of this property. The children will be owned by this property. Definition at line 653 of file property.cpp. |
|
Adds related property for this property. Definition at line 706 of file property.cpp. |
|
Adds set to this property. Definition at line 673 of file property.cpp. |
|
Definition at line 498 of file property.cpp. |
|
Definition at line 261 of file property.cpp. |
|
Definition at line 267 of file property.cpp. |
|
Definition at line 636 of file property.cpp. |
|
Definition at line 630 of file property.cpp. |
|
Outputs debug string for this property. Definition at line 735 of file property.cpp. |
|
Definition at line 279 of file property.cpp. |
|
Definition at line 536 of file property.cpp. |
|
Definition at line 303 of file property.cpp. |
|
Definition at line 468 of file property.cpp. |
|
Definition at line 462 of file property.cpp. |
|
Definition at line 474 of file property.cpp. |
|
Definition at line 510 of file property.cpp. |
|
Definition at line 486 of file property.cpp. |
|
Definition at line 432 of file property.cpp. |
|
Definition at line 249 of file property.cpp. |
|
Gets the previous property value. Definition at line 323 of file property.cpp. |
|
Equivalent to !isNull() Definition at line 543 of file property.cpp. |
|
Assigns a deep copy of all attributes of property to this property. Definition at line 556 of file property.cpp. |
|
Equivalent to setValue(const QVariant &) Definition at line 549 of file property.cpp. |
|
Compares two properties. Definition at line 622 of file property.cpp. |
|
Definition at line 528 of file property.cpp. |
|
Definition at line 647 of file property.cpp. |
|
Definition at line 700 of file property.cpp. |
|
Resets the value of the property to the old value.
Definition at line 411 of file property.cpp. |
|
if sync is 1, the property will be synced automatically in the Property Editor as soon as editor's contents change (e.g. when the user types text). If sync is 0, property value will be updated when the user presses Enter or when another editor gets the focus. Property follows Property Editor's global rule if sync !=0 and !=1 (the default). Definition at line 504 of file property.cpp. |
|
Sets the name of the property. If the caption contains newline characters, these are replaced by spaces. You can use captionForDisplaying() to access the original caption text you passed here. Definition at line 273 of file property.cpp. |
|
Sets custom property prop for this property.
Definition at line 717 of file property.cpp. |
|
Sets the description of the property. Definition at line 285 of file property.cpp. |
|
Sets icon by name for this property. Icons are optional and are used e.g. in property editor - displayed at the left hand. Definition at line 309 of file property.cpp. |
|
Sets the string-to-value correspondence list of the property. This is used to create comboboxes-like property editors. This is overload of the above ctor added for convenience. Definition at line 449 of file property.cpp. |
|
Sets the qstring-to-value correspondence list of the property. This is used to create comboboxes-like property editors. Definition at line 438 of file property.cpp. |
|
Sets the internal name of the property. Definition at line 255 of file property.cpp. |
|
Sets value val for option name. Options are used to describe additional details for property behaviour, e.g. within Editor. See Editor ctor documentation for the list of supported options. Definition at line 522 of file property.cpp. |
|
Sets this property to be read-only.
Definition at line 480 of file property.cpp. |
|
Sets a key used for sorting. Definition at line 727 of file property.cpp. |
|
Sets "storable" flag for this property.
Definition at line 516 of file property.cpp. |
|
Sets the type of the property. Definition at line 297 of file property.cpp. |
|
Sets the value of the property. Definition at line 332 of file property.cpp. |
|
Set the visibility. Definition at line 492 of file property.cpp. |
|
Definition at line 722 of file property.cpp. |
|
Definition at line 291 of file property.cpp. |
|
Definition at line 315 of file property.cpp. |
Member Data Documentation
|
A contant for null property.
Definition at line 165 of file property.h. |
The documentation for this class was generated from the following files: