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
Property::Property | ( | ) |
Constructs a null property.
Definition at line 232 of file property.cpp.
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 | |||
) |
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 175 of file property.cpp.
Property::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 | |||
) |
Constructs property of ValueFromList type.
Definition at line 196 of file property.cpp.
Property::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 | |||
) |
Constructs property of ValueFromList type. This is overload of the above ctor added for convenience.
Definition at line 214 of file property.cpp.
Property::Property | ( | const Property & | prop | ) |
Constructs a deep copy of prop property.
Definition at line 237 of file property.cpp.
Member Function Documentation
void Property::addChild | ( | Property * | prop | ) | [protected] |
Adds prop as a child of this property. The children will be owned by this property.
Definition at line 658 of file property.cpp.
void Property::addRelatedProperty | ( | Property * | property | ) | [protected] |
Adds related property for this property.
Definition at line 711 of file property.cpp.
void Property::addSet | ( | Set * | set | ) | [protected] |
Adds set to this property.
Definition at line 678 of file property.cpp.
int Property::autoSync | ( | ) | const |
- Returns:
- 1 if the property should be synced automatically in Property Editor as soon as editor contents change (e.g. when the user types text). If autoSync() == 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 autoSync() !=0 and !=1 (the default).
Definition at line 501 of file property.cpp.
QString Property::caption | ( | ) | const |
QString Property::captionForDisplaying | ( | ) | const |
- Returns:
- the caption text of the property for displaying. It is similar to caption() but if the property caption contains newline characters, these are not substituted with spaces.
Definition at line 268 of file property.cpp.
Property * Property::child | ( | const QCString & | name | ) |
- Returns:
- a child property for name, or NULL if there is no property with that name.
Definition at line 641 of file property.cpp.
const QValueList< Property * > * Property::children | ( | ) | const |
- Returns:
- a list of all children for this property, or NULL of there is no children for this property
Definition at line 635 of file property.cpp.
void Property::debug | ( | ) | [protected] |
Outputs debug string for this property.
Definition at line 740 of file property.cpp.
QString Property::description | ( | ) | const |
bool Property::hasOptions | ( | ) | const |
- Returns:
- true if at least one option is defined for this property.
Definition at line 539 of file property.cpp.
QString Property::icon | ( | ) | const |
bool Property::isModified | ( | ) | const |
bool Property::isNull | ( | ) | const |
- Returns:
- true if this property is null. Null properties have empty names.
Definition at line 465 of file property.cpp.
bool Property::isReadOnly | ( | ) | const |
- Returns:
- true if the property is read-only. The property can be read-write but still not editable because the property set containing it may be set to read-only. By default the property is read-write. See Set::isReadOnly() for more details.
Definition at line 477 of file property.cpp.
bool Property::isStorable | ( | ) | const |
- Returns:
- true if the property can be saved to a stream, xml, etc. There is a possibility to use "GUI" properties that aren't stored but used only in a GUI.
Definition at line 513 of file property.cpp.
bool Property::isVisible | ( | ) | const |
Property::ListData * Property::listData | ( | ) | const |
- Returns:
- the qstring-to-value correspondence list of the property. used to create comboboxes-like property editors.
Definition at line 435 of file property.cpp.
QCString Property::name | ( | ) | const |
- Returns:
- the internal name of the property (that's used in List).
Definition at line 250 of file property.cpp.
QVariant Property::oldValue | ( | ) | const |
Gets the previous property value.
Definition at line 324 of file property.cpp.
Property::operator bool | ( | ) | const |
Equivalent to !isNull()
Definition at line 546 of file property.cpp.
Assigns a deep copy of all attributes of property to this property.
Definition at line 559 of file property.cpp.
const Property & Property::operator= | ( | const QVariant & | val | ) |
Equivalent to setValue(const QVariant &)
Definition at line 552 of file property.cpp.
bool Property::operator== | ( | const Property & | prop | ) | const |
Compares two properties.
Definition at line 627 of file property.cpp.
QVariant Property::option | ( | const char * | name | ) | const |
- Returns:
- a value for option name or null value if there is no such option set.
Definition at line 531 of file property.cpp.
Property * Property::parent | ( | ) | const |
- Returns:
- parent property for this property, or NULL if there is no parent property.
Definition at line 652 of file property.cpp.
const QValueList< Property * > * Property::related | ( | ) | const [protected] |
- Returns:
- a list of related properties for this property.
Definition at line 705 of file property.cpp.
void Property::resetValue | ( | ) |
Resets the value of the property to the old value.
- See also:
- oldValue()
Definition at line 414 of file property.cpp.
void Property::setAutoSync | ( | int | sync | ) |
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 507 of file property.cpp.
void Property::setCaption | ( | const QString & | caption | ) |
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 274 of file property.cpp.
void Property::setCustomProperty | ( | CustomProperty * | prop | ) |
Sets custom property prop for this property.
- See also:
- CustomPropertyFactory
Definition at line 722 of file property.cpp.
void Property::setDescription | ( | const QString & | description | ) |
Sets the description of the property.
Definition at line 286 of file property.cpp.
void Property::setIcon | ( | const QString & | icon | ) |
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 310 of file property.cpp.
void Property::setListData | ( | const QStringList & | keys, | |
const QStringList & | names | |||
) |
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 452 of file property.cpp.
void Property::setListData | ( | ListData * | list | ) |
Sets the qstring-to-value correspondence list of the property. This is used to create comboboxes-like property editors.
Definition at line 441 of file property.cpp.
void Property::setName | ( | const QCString & | name | ) |
Sets the internal name of the property.
Definition at line 256 of file property.cpp.
void Property::setOption | ( | const char * | name, | |
const QVariant & | val | |||
) |
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 525 of file property.cpp.
void Property::setReadOnly | ( | bool | readOnly | ) |
Sets this property to be read-only.
- See also:
- isReadOnly()
Definition at line 483 of file property.cpp.
void Property::setSortingKey | ( | int | key | ) | [protected] |
Sets a key used for sorting.
Definition at line 732 of file property.cpp.
void Property::setStorable | ( | bool | storable | ) |
Sets "storable" flag for this property.
- See also:
- isStorable()
Definition at line 519 of file property.cpp.
void Property::setType | ( | int | type | ) |
Sets the type of the property.
Definition at line 298 of file property.cpp.
void Property::setValue | ( | const QVariant & | value, | |
bool | rememberOldValue = true , |
|||
bool | useCustomProperty = true | |||
) |
Sets the value of the property.
Definition at line 333 of file property.cpp.
void Property::setVisible | ( | bool | visible | ) |
Set the visibility.
Definition at line 495 of file property.cpp.
int Property::sortingKey | ( | ) | const |
- Returns:
- a key used for sorting. Usually it's set by Set::addProperty() and Property::addChild() t oa unique value, so that this property can be sorted in a property editor in original order.
- See also:
- EditorItem::compare()
Definition at line 727 of file property.cpp.
int Property::type | ( | ) | const |
QVariant Property::value | ( | ) | const |
Member Data Documentation
QT_STATIC_CONST_IMPL Property KoProperty::Property::null |
The documentation for this class was generated from the following files: