A MultiContextProperty provides a property which has different values in different contexts. More...
#include <QtilitiesProperty.h>
Public Member Functions | |
void | addContext (QVariant new_value, int context_id) |
Adds an context ID from the property. | |
QMap< quint32, QVariant > | contextMap () const |
Returns a map with the contexts and their respective values for this property. | |
virtual IExportable::ExportResultFlags | exportBinary (QDataStream &stream) const |
Allows exporting to a QDataStream. | |
virtual IExportable::ExportResultFlags | exportXml (QDomDocument *doc, QDomElement *object_node) const |
Allows exporting to an XML document. A reference to the QDomElement to which the object's information must be added is provided, along with a reference to the QDomDocument. | |
bool | hasContext (int context_id) const |
Checks if this property is defined within the context of the specified observer. | |
virtual IExportable::ExportResultFlags | importBinary (QDataStream &stream, QList< QPointer< QObject > > &import_list) |
Allows importing and reconstruction of the object state from information provided in a QDataStream. | |
virtual IExportable::ExportResultFlags | importXml (QDomDocument *doc, QDomElement *object_node, QList< QPointer< QObject > > &import_list) |
int | lastChangedContext () const |
Returns the context in which the last change took place. | |
QObject * | objectBase () |
const QObject * | objectBase () const |
void | removeContext (int context_id) |
Removes an context ID from the property. | |
virtual bool | setValue (QVariant new_value, int context_id) |
Sets the value of the property. | |
virtual ExportModeFlags | supportedFormats () const |
Provides information about the export format(s) supported by your implementation of IExportable. | |
virtual QVariant | value (int context_id) const |
Returns the value of the property. | |
virtual QString | valueString () const |
Returns a string representation of this property. | |
Public Member Functions inherited from Qtilities::Core::QtilitiesProperty | |
bool | isReadOnly () const |
Indicates if the property is read only. | |
bool | isRemovable () const |
Indicates if the property is removable. | |
bool | isReserved () const |
Indicates if the property is reserved. | |
bool | isValid () |
Function to check if an observer property is valid. | |
void | makeNotRemovable () |
Makes the property non removable. Properties can only be made not removable once, after that they always stay not removable. | |
void | makeReadOnly () |
Makes the property read only. Properties can only be made read only once, after that they always stay read only. | |
void | makeReserved () |
Makes the property reserved. Properties can only be made reserved once, after that they always stay reserved. | |
QString | propertyNameString () const |
Gets the name of this property as a QString. | |
void | setPropertyName (const char *new_name) |
Sets the name of this property. | |
void | setPropertyName (const QString &new_name) |
Sets the name of this property. | |
bool | supportsChangeNotifications () const |
Indicates if this property supports change notifications. | |
Public Member Functions inherited from Qtilities::Core::Interfaces::IExportable | |
quint32 | applicationExportVersion () const |
Returns the application export version currently used by all your application's classes. | |
virtual void | clearExportTask () |
Clears the export task. | |
IExportable * | duplicate (QString *error_msg=0, int properties_to_copy=0, ExportResultFlags *result_flags=0) const |
Function which will create a duplicate (copy) of this object. | |
virtual ITask * | exportTask () const |
Gets the task which must be used to log import/export information to. | |
Qtilities::ExportVersion | exportVersion () const |
Returns the export version currently used by all Qtilities classes. | |
virtual InstanceFactoryInfo | instanceFactoryInfo () const |
The instance factory information which must be used when the exported object is reconstructed during an import. | |
bool | isExportable () const |
Gets if this object must be part of it's parents' exports. | |
virtual void | setApplicationExportVersion (quint32 version) |
Sets the application export version currently used by all your application's classes. | |
virtual void | setExportTask (ITask *task) |
Sets the task which must be used to log import/export information to. | |
virtual void | setExportVersion (Qtilities::ExportVersion version) |
Returns the export version currently used by all Qtilities classes. | |
virtual void | setIsExportable (bool new_is_exportable) |
Sets if this object must be part of it's parents' exports. | |
Public Member Functions inherited from Qtilities::Core::Interfaces::IObjectBase | |
QString | objectOriginID () const |
Allows interfaces to provide some sort of source identification. | |
void | setObjectOriginID (const QString &object_origin_id) |
Allows setting of the object source ID of this interface implementation. |
Additional Inherited Members | |
Static Public Member Functions inherited from Qtilities::Core::QtilitiesProperty | |
static QVariant | constructVariant (const QString &type_string, const QString &value_string) |
Converts a QString type_string and QString value_string to a matching QVariant. | |
static QVariant | constructVariant (QVariant::Type type, const QString &value_string) |
Converts a QVariant::Type and QString value_string to a matching QVariant. | |
static bool | isExportableVariant (QVariant variant) |
Checks if a QVariant is exportable. Thus, if it can be converted to QString. | |
static bool | propertyIsExportable (const char *property_name) |
Function to check if any Qtilities property is exportable. | |
static bool | propertyIsRemovable (const char *property_name) |
Function to check if any Qtilities property is removable. | |
static bool | propertyIsReserved (const char *property_name) |
Function to check if any Qtilities property is reserved. | |
static bool | propertySupportsChangeNotifications (const char *property_name) |
Function to check if any Qtilities property supports change notifications. | |
Static Public Member Functions inherited from Qtilities::Core::Interfaces::IExportable | |
template<typename T > | |
static T * | duplicateInstance (IExportable *obj, QString *error_msg=0, int properties_to_copy=0, ExportResultFlags *result_flags=0) |
Provides an easy to use template based implementation of IExportable::duplicate(). | |
static QString | exportModeToString (ExportMode export_mode) |
Function which returns a string associated with a specific ExportMode. | |
static ExportMode | stringToExportMode (const QString &export_mode_string) |
Function which returns the ExportMode associated with a string. | |
static Result | validateQtilitiesExportVersion (Qtilities::ExportVersion export_version, ITask *task=0) |
Checks the exportVersion() against the supported Qtilities export versions for the current Qtilities version. | |
static Result | validateQtilitiesImportVersion (Qtilities::ExportVersion import_version, ITask *task=0) |
Checks the exportVersion() against the supported Qtilities import versions for the current Qtilities version. |
A MultiContextProperty provides a property which has different values in different contexts.
A complete map of the property's contexts and their respective QVariant() values can be obtained using contextMap(). To get the last context ID for which the property changed use lastChangedContext(). You can check if an MultiContextProperty is valid using the isValid() call. Convenience functions for working with different contexts include hasContext(), addContext(),removeContext() and value().
Getting and setting shared properties are done by the Qtilities::Core::Observer class which provides easy to use functions to set and get properties and their values. For multi context properties we need to know the context to get a value since the value is different for different contexts.
The following example shows how to construct and work with Qtilities::Core::MultiContextProperty.
For more information about how MultiContextProperty are used in the context of Qtilities::Core::Observer, please see Dynamic properties used and managed by Observers.
Note that you can inspect all MultiContextProperty properties on an object through the Qtilities::CoreGui::ObjectDynamicPropertyBrowser widget. See the qti.core.CategoryMap
property as an example below:
|
virtual |
Allows exporting to a QDataStream.
See Serializing Qtilities Data Types Overview for more information about the expected output format.
stream | A reference to the QDataStream to which the object's information must be appended is provided. |
Reimplemented from Qtilities::Core::QtilitiesProperty.
|
virtual |
Allows exporting to an XML document. A reference to the QDomElement to which the object's information must be added is provided, along with a reference to the QDomDocument.
See Serializing Qtilities Data Types Overview for more information about the expected output format.
Reimplemented from Qtilities::Core::QtilitiesProperty.
|
virtual |
Allows importing and reconstruction of the object state from information provided in a QDataStream.
See Serializing Qtilities Data Types Overview for more information about the expected output format.
stream | The QDataStream which contains the object's information. |
import_list | All objects constructed during the import operation must be added to the import list. When the operation fails, all objects in this list will be deleted. |
Reimplemented from Qtilities::Core::QtilitiesProperty.
|
virtual |
This function will add a set of attributes directly to the object_node passed to it.
Reimplemented from Qtilities::Core::QtilitiesProperty.
|
inlinevirtual |
Reimplemented from Qtilities::Core::QtilitiesProperty.
|
inlinevirtual |
Reimplemented from Qtilities::Core::QtilitiesProperty.
|
virtual |
Sets the value of the property.
Sets the value for a specific context ID. If the context ID does not exist, it is created with the specified value assigned to it.
new_value | The new QVariant value which must be assigned to the property. |
context_id | Indicates the context ID for which the property value needs to be set. |
|
virtual |
Provides information about the export format(s) supported by your implementation of IExportable.
Reimplemented from Qtilities::Core::QtilitiesProperty.
|
virtual |
Returns the value of the property.
context_id | Indicates the context ID for which the property value is required. |
|
virtual |
Returns a string representation of this property.
Qtilities : Reference Documentation | Back to top |
Copyright © 2009-2013, Jaco Naudé
|