All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions
Qtilities::Core::SharedProperty Class Reference

A SharedProperty is a basic implementation of QtilitiesProperty. More...

#include <QtilitiesProperty.h>

Inheritance diagram for Qtilities::Core::SharedProperty:
Inheritance graph
[legend]

List of all members.

Public Member Functions

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.
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)
QObject * objectBase ()
const QObject * objectBase () const
virtual bool setValue (QVariant new_value)
 Sets the value of the property.
ExportModeFlags supportedFormats () const
 Provides information about the export format(s) supported by your implementation of IExportable.
virtual QVariant value () const
 Returns the value of the 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.
IExportableduplicate (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 ITaskexportTask () 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.

Detailed Description

A SharedProperty is a basic implementation of QtilitiesProperty.

A SharedProperty is a basic implementation of QtilitiesProperty which stored a single QVariant value set with setValue() and can be obtained using 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 shared properties it is easy to get and set the value of the property because we do not need to know the context since the value is the same for all contexts.

The following example shows how to construct and work with Qtilities::Core::SharedProperty.

QObject* obj = new QObject();
Observer* obs = new Observer("My Observer","Example observer description");
// Create shared property
QString property_name = "Example Property Name";
SharedProperty string_property(property_name,"Example text");
// For this example we don't need to make the property exportable. By default all properties are exportable.
string_property.setIsExportable(false);
// Set the property using the static convenience function provided by the object manager:
ObjectManager::setSharedProperty(obj,string_property);
// Attach the object to the observer
obs->attachSubject(obj);
// Now we can get the value of the property using the observer reference
QString text = obs->getMultiContextPropertyValue(obj,property_name).toString();
// Or get the value of the property without the observer reference: Option 1
SharedProperty shared_property1 = ObjectManager::getSharedProperty(property_name);
if (shared_property1.isValid()) {
QString text1 = shared_property1->value().toString();
}
// Or get the value of the property without the observer reference: Option 2
QVariant prop = obj->property(property_name);
if (prop.isValid() && prop.canConvert<SharedProperty>()) {
QString text2 = (prop.value<SharedProperty>()).value().toString();
}

For information about how SharedProperty are used in the context of Qtilities::Core::Observer, please see Dynamic properties used and managed by Observers.

Note that you can inspect all SharedProperty properties on an object through the Qtilities::CoreGui::ObjectDynamicPropertyBrowser widget. See the example below:

debugging_dynamic_properties.jpg
Dynamic Properties Browser
See also:
Qtilities::Core::MultiContextProperty

Member Function Documentation

Qtilities::Core::Interfaces::IExportable::ExportResultFlags Qtilities::Core::SharedProperty::exportBinary ( QDataStream &  stream) const
virtual

Allows exporting to a QDataStream.

See Serializing Qtilities Data Types Overview for more information about the expected output format.

Parameters:
streamA reference to the QDataStream to which the object's information must be appended is provided.

Reimplemented from Qtilities::Core::QtilitiesProperty.

Qtilities::Core::Interfaces::IExportable::ExportResultFlags Qtilities::Core::SharedProperty::exportXml ( QDomDocument *  doc,
QDomElement *  object_node 
) const
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.

Qtilities::Core::Interfaces::IExportable::ExportResultFlags Qtilities::Core::SharedProperty::importBinary ( QDataStream &  stream,
QList< QPointer< QObject > > &  import_list 
)
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.

Parameters:
streamThe QDataStream which contains the object's information.
import_listAll 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.

Qtilities::Core::Interfaces::IExportable::ExportResultFlags Qtilities::Core::SharedProperty::importXml ( QDomDocument *  doc,
QDomElement *  object_node,
QList< QPointer< QObject > > &  import_list 
)
virtual

This function will add a set of attributes directly to the object_node passed to it.

Reimplemented from Qtilities::Core::QtilitiesProperty.

QObject* Qtilities::Core::SharedProperty::objectBase ( )
inlinevirtual
Note:
SharedProperty is not a QObject, thus it returns 0.

Reimplemented from Qtilities::Core::QtilitiesProperty.

const QObject* Qtilities::Core::SharedProperty::objectBase ( ) const
inlinevirtual
Note:
SharedProperty is not a QObject, thus it returns 0.

Reimplemented from Qtilities::Core::QtilitiesProperty.

bool Qtilities::Core::SharedProperty::setValue ( QVariant  new_value)
virtual

Sets the value of the property.

Parameters:
new_valueThe new QVariant value which must be assigned to the property.
Qtilities::Core::Interfaces::IExportable::ExportModeFlags Qtilities::Core::SharedProperty::supportedFormats ( ) const
virtual

Provides information about the export format(s) supported by your implementation of IExportable.

Note:
It is important to note that you need to check the exportVersion() when you return the supported formats.

Reimplemented from Qtilities::Core::QtilitiesProperty.



Qtilities : Reference Documentation Back to top Copyright © 2009-2013, Jaco Naudé