Computer Assited Medical Intervention Tool Kit  version 4.1
PropertyObject.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 #ifndef PROPERTYOBJECT_H
27 #define PROPERTYOBJECT_H
28 
29 // Qt includes
30 #include <QObject>
31 
32 // CamiTK includes
33 #include "CamiTKAPI.h"
34 #include "Property.h"
35 
36 namespace camitk {
37 
64 
71 class CAMITK_API PropertyObject : public QObject {
72 
73  Q_OBJECT
74 
75 public:
80  PropertyObject(QString name);
81 
83  ~PropertyObject() override;
84 
95  virtual bool addProperty(Property*);
96 
107  Q_INVOKABLE virtual Property* getProperty(QString name);
108 
112  virtual void removeProperty(Property*);
113 
115  virtual unsigned int getNumberOfProperties() const;
116 
118  virtual QString getPropertyName(unsigned int index) const;
119 
121  virtual QVariant getPropertyValue(unsigned int index);
122 
124  virtual QVariant getPropertyValue(const QString name);
125 
127  void loadFromSettings(const QString& settingGroupName);
128 
130  void saveToSettings(const QString& settingGroupName);
131 
133  static QString toCamelCase(const QString&);
134 
135 private:
139  QMap<QString, Property*> propertiesMap;
141 };
142 
143 }
144 
145 #endif // PROPERTYOBJECT_H
camitk::PropertyObject::toCamelCase
static QString toCamelCase(const QString &)
utility method to transform property name to camel case. Quite useful to make sure all settings are s...
Definition: PropertyObject.cpp:130
CamiTKAPI.h
camitk::Application::getSettings
static QSettings & getSettings()
Get the Core wide settings.
Definition: Application.cpp:300
camitk::PropertyObject::saveToSettings
void saveToSettings(const QString &settingGroupName)
save setting in the given group name using all the property values
Definition: PropertyObject.cpp:239
camitk::PropertyObject::loadFromSettings
void loadFromSettings(const QString &settingGroupName)
initializes all property values from setting values found in the given group name
Definition: PropertyObject.cpp:142
PropertyObject.h
camitk::PropertyObject::PropertyObject
PropertyObject(QString name)
Default constructor.
Definition: PropertyObject.cpp:62
camitk::PropertyObject::getNumberOfProperties
virtual unsigned int getNumberOfProperties() const
get the current number of property
Definition: PropertyObject.cpp:96
camitk::Property
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:314
camitk::Property::getName
const QString & getName() const
get the name of the property
Definition: Property.cpp:73
Property.h
camitk::PropertyObject::getPropertyName
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....
Definition: PropertyObject.cpp:101
camitk::PropertyObject::~PropertyObject
~PropertyObject() override
Destructor.
Definition: PropertyObject.cpp:67
camitk::PropertyObject::propertiesMap
QMap< QString, Property * > propertiesMap
Definition: PropertyObject.h:185
camitk::setObjectName
setObjectName("RendererWidget")
camitk::PropertyObject::removeProperty
virtual void removeProperty(Property *)
Remove a CamiTK property of this object.
Definition: PropertyObject.cpp:90
camitk::PropertyObject::addProperty
virtual bool addProperty(Property *)
Tag a new CamiTK property to this object.
Definition: PropertyObject.cpp:76
camitk::PropertyObject::getProperty
virtual Q_INVOKABLE Property * getProperty(QString name)
Get a Property given its name.
Definition: PropertyObject.cpp:85
Application.h
camitk::PropertyObject::getPropertyValue
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 ...
Definition: PropertyObject.cpp:111
CAMITK_API
#define CAMITK_API
Definition: CamiTKAPI.h:49
camitk
Definition: Action.cpp:36