Computer Assisted Medical Intervention Tool Kit  version 5.2
camitk::PropertyObject Class Reference

This class describes a property object. More...

#include <PropertyObject.h>

+ Inheritance diagram for camitk::PropertyObject:
+ Collaboration diagram for camitk::PropertyObject:

Public Member Functions

virtual bool addProperty (Property *)
 Tag a new CamiTK property to this object. More...
 
virtual unsigned int getNumberOfProperties () const
 get the current number of property More...
 
virtual Q_INVOKABLE camitk::PropertygetProperty (QString name)
 
virtual Q_INVOKABLE const camitk::PropertygetProperty (QString name) const
 Get a Property given its name. More...
 
virtual QString getPropertyName (unsigned int index) const
 get the name of the property at the given index, null string if index is out of bounds (i.e., isNull() == true) More...
 
virtual QVariant getPropertyValue (const QString name) const
 convenient method to get the value of a given property, returns a non valid QVariant if no property with that name exists More...
 
virtual QVariant getPropertyValue (unsigned int index)
 get the value of the property at the given index, a non valid QVariant if the index is out of bounds (i.e., isValid() == false) More...
 
void loadFromSettings (const QString &settingGroupName)
 initializes all property values from setting values found in the given group name More...
 
 PropertyObject (QString name)
 Default constructor. More...
 
virtual void removeProperty (Property *)
 Remove a CamiTK property of this object. More...
 
void saveToSettings (const QString &settingGroupName)
 save setting in the given group name using all the property values More...
 
 ~PropertyObject () override
 Destructor. More...
 
InterfacePersistence
virtual QVariant toVariant () const override
 
virtual void fromVariant (const QVariant &) override
 Load data from a QVariant to initialize the current object. More...
 

Static Public Member Functions

static QString toCamelCase (const QString &)
 utility method to transform property name to camel case. Quite useful to make sure all settings are stored as lowerCamelCase More...
 

Detailed Description

This class describes a property object.

A property object is simply a QObject tagged with some CamiTK Properties The idea is to have an object which implements all the necessary methods to take advantages of the CamiTK Properties within the ObjectController

PropertyObject can be saved/loaded from settings. A typical use in this case is to

// set default value
propertyObject->addProperty(...);
propertyObject->addProperty(...);
propertyObject->addProperty(...);
// load values from settings
loadFromSettings("mySection");
...
saveToSettings("mySection")
void loadFromSettings(const QString &settingGroupName)
initializes all property values from setting values found in the given group name
Definition: PropertyObject.cpp:140
PropertyObject(QString name)
Default constructor.
Definition: PropertyObject.cpp:40

See the Application class for an example of a property object load/save to settings.

See also
ObjectController, Property

Constructor & Destructor Documentation

◆ PropertyObject()

camitk::PropertyObject::PropertyObject ( QString  name)

Default constructor.

Parameters
nameThe name of the PropertyObject instance. This one would be displayed in any SettingsDialog entries.

References camitk::setObjectName().

+ Here is the call graph for this function:

◆ ~PropertyObject()

camitk::PropertyObject::~PropertyObject ( )
override

Destructor.

Member Function Documentation

◆ addProperty()

bool camitk::PropertyObject::addProperty ( Property prop)
virtual

Tag a new CamiTK property to this object.

If the property already exist, it will just change its value.

Note
The object takes ownership of the Property instance.
Returns
false if the Qt Meta Object property was added by this method (otherwise the property was already defined and true is returned if it was successfully updated)

References camitk::Property::getInitialValue(), and camitk::Property::getName().

Referenced by camitk::InteractiveViewer::createProperties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromVariant()

void camitk::PropertyObject::fromVariant ( const QVariant &  variant)
overridevirtual

Load data from a QVariant to initialize the current object.

Implements InterfacePersistence.

References camitk::PersistenceManager::loadProperties().

Referenced by camitk::PersistenceManager::loadWorkspace().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNumberOfProperties()

unsigned int camitk::PropertyObject::getNumberOfProperties ( ) const
virtual

get the current number of property

Referenced by loadFromSettings(), and saveToSettings().

+ Here is the caller graph for this function:

◆ getProperty() [1/2]

camitk::Property * camitk::PropertyObject::getProperty ( QString  name)
virtual

◆ getProperty() [2/2]

const Property * camitk::PropertyObject::getProperty ( QString  name) const
virtual

Get a Property given its name.

Parameters
namethe property name
Returns
nullptr if the name does not match any property name
Note
This method is required so that the ObjectController can take advantage of the camitk properties.
See also
Property, ObjectController

Referenced by loadFromSettings(), and toVariant().

+ Here is the caller graph for this function:

◆ getPropertyName()

QString camitk::PropertyObject::getPropertyName ( unsigned int  index) const
virtual

get the name of the property at the given index, null string if index is out of bounds (i.e., isNull() == true)

Referenced by getPropertyValue(), loadFromSettings(), and saveToSettings().

+ Here is the caller graph for this function:

◆ getPropertyValue() [1/2]

QVariant camitk::PropertyObject::getPropertyValue ( const QString  name) const
virtual

convenient method to get the value of a given property, returns a non valid QVariant if no property with that name exists

◆ getPropertyValue() [2/2]

QVariant camitk::PropertyObject::getPropertyValue ( unsigned int  index)
virtual

get the value of the property at the given index, a non valid QVariant if the index is out of bounds (i.e., isValid() == false)

References getPropertyName().

Referenced by camitk::Action::applyTargetPosition(), loadFromSettings(), saveToSettings(), and toVariant().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadFromSettings()

void camitk::PropertyObject::loadFromSettings ( const QString &  settingGroupName)

initializes all property values from setting values found in the given group name

References getNumberOfProperties(), getProperty(), getPropertyName(), getPropertyValue(), camitk::Application::getSettings(), and toCamelCase().

Referenced by camitk::Application::Application().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeProperty()

void camitk::PropertyObject::removeProperty ( Property prop)
virtual

Remove a CamiTK property of this object.

References camitk::Property::getName().

+ Here is the call graph for this function:

◆ saveToSettings()

void camitk::PropertyObject::saveToSettings ( const QString &  settingGroupName)

save setting in the given group name using all the property values

References getNumberOfProperties(), getPropertyName(), getPropertyValue(), camitk::Application::getSettings(), and toCamelCase().

Referenced by camitk::Application::eventFilter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toCamelCase()

QString camitk::PropertyObject::toCamelCase ( const QString &  s)
static

utility method to transform property name to camel case. Quite useful to make sure all settings are stored as lowerCamelCase

Referenced by loadFromSettings(), and saveToSettings().

+ Here is the caller graph for this function:

◆ toVariant()

QVariant camitk::PropertyObject::toVariant ( ) const
overridevirtual

Convert all data from the object to a QVariant (usually a QVariantMap)

Implements InterfacePersistence.

References getProperty(), and getPropertyValue().

Referenced by camitk::PersistenceManager::saveWorkspace().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: