Computer Assited Medical Intervention Tool Kit  version 4.1
qtvariantproperty.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 **
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 **
8 ** This file is part of a Qt Solutions component.
9 **
10 ** You may use this file under the terms of the BSD license as follows:
11 **
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
14 ** met:
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
20 ** distribution.
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22 ** the names of its contributors may be used to endorse or promote
23 ** products derived from this software without specific prior written
24 ** permission.
25 **
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
37 **
38 ****************************************************************************/
39 
40 
41 #ifndef QTVARIANTPROPERTY_H
42 #define QTVARIANTPROPERTY_H
43 
44 #include "qtpropertybrowser.h"
45 #include <QtCore/QVariant>
46 #include <QtGui/QIcon>
47 
48 #if QT_VERSION >= 0x040400
49 QT_BEGIN_NAMESPACE
50 #endif
51 
52 typedef QMap<int, QIcon> QtIconMap;
53 
56 
96 public:
97  ~QtVariantProperty() override;
98  QVariant value() const;
99  QVariant attributeValue(const QString& attribute) const;
100  int valueType() const;
101  int propertyType() const;
102 
103  void setValue(const QVariant& value);
104  void setAttribute(const QString& attribute, const QVariant& value);
105  // Added in CamiTK for enum icon management
106  virtual void setAttribute(const QString& attribute, const QMap<int, QIcon>& value);
107 
108 protected:
110 private:
113 };
114 
116 
118  Q_OBJECT
119 public:
120  QtVariantPropertyManager(QObject* parent = nullptr);
121  ~QtVariantPropertyManager() override;
122 
123  virtual QtVariantProperty* addProperty(int propertyType, const QString& name = QString());
124 
125  int propertyType(const QtProperty* property) const;
126  int valueType(const QtProperty* property) const;
127  QtVariantProperty* variantProperty(const QtProperty* property) const;
128 
129  virtual bool isPropertyTypeSupported(int propertyType) const;
130  virtual int valueType(int propertyType) const;
131  virtual QStringList attributes(int propertyType) const;
132  virtual int attributeType(int propertyType, const QString& attribute) const;
133 
134  virtual QVariant value(const QtProperty* property) const;
135  virtual QVariant attributeValue(const QtProperty* property, const QString& attribute) const;
136 
137  static int enumTypeId();
138  static int flagTypeId();
139  static int groupTypeId();
140  static int iconMapTypeId();
141 public Q_SLOTS:
142  virtual void setValue(QtProperty* property, const QVariant& val);
143  virtual void setAttribute(QtProperty* property,
144  const QString& attribute, const QVariant& value);
145  // Added in CamiTK for enum icon management
146  virtual void setAttribute(QtProperty* property,
147  const QString& attribute, const QMap<int, QIcon>& value);
148 Q_SIGNALS:
149  void valueChanged(QtProperty* property, const QVariant& val);
150  void attributeChanged(QtProperty* property,
151  const QString& attribute, const QVariant& val);
152 protected:
153  bool hasValue(const QtProperty* property) const override;
154  QString valueText(const QtProperty* property) const override;
155  QIcon valueIcon(const QtProperty* property) const override;
156  void initializeProperty(QtProperty* property) override;
157  void uninitializeProperty(QtProperty* property) override;
158  QtProperty* createProperty() override;
159 private:
161  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, int))
162  Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, int, int))
163  Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty*, int))
164  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, double))
165  Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, double, double))
166  Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty*, double))
167  Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty*, int))
168  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, bool))
169  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QString&))
170  Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty*, const QRegExp&))
171  Q_PRIVATE_SLOT(d_func(), void slotEchoModeChanged(QtProperty*, int))
172  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QDate&))
173  Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, const QDate&, const QDate&))
174  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QTime&))
175  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QDateTime&))
176  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QKeySequence&))
177  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QChar&))
178  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QLocale&))
179  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QPoint&))
180  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QPointF&))
181  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QVector3D&))
182  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QSize&))
183  Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, const QSize&, const QSize&))
184  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QSizeF&))
185  Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, const QSizeF&, const QSizeF&))
186  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QRect&))
187  Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty*, const QRect&))
188  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QRectF&))
189  Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty*, const QRectF&))
190  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QColor&))
191  Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty*, const QStringList&))
192  Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty*, const QMap<int, QIcon>&))
193  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QSizePolicy&))
194  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QFont&))
195  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QCursor&))
196  Q_PRIVATE_SLOT(d_func(), void slotFlagNamesChanged(QtProperty*, const QStringList&))
197 
198  Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty*, QtProperty*, QtProperty*))
199  Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty*, QtProperty*))
200  Q_DECLARE_PRIVATE(QtVariantPropertyManager)
201  Q_DISABLE_COPY(QtVariantPropertyManager)
202 };
203 
205 
207  Q_OBJECT
208 public:
209  QtVariantEditorFactory(QObject* parent = nullptr);
210  ~QtVariantEditorFactory() override;
211 protected:
212  void connectPropertyManager(QtVariantPropertyManager* manager) override;
213  QWidget* createEditor(QtVariantPropertyManager* manager, QtProperty* property,
214  QWidget* parent) override;
215  void disconnectPropertyManager(QtVariantPropertyManager* manager) override;
216 private:
218  Q_DECLARE_PRIVATE(QtVariantEditorFactory)
219  Q_DISABLE_COPY(QtVariantEditorFactory)
220 };
221 
222 #if QT_VERSION >= 0x040400
223 QT_END_NAMESPACE
224 #endif
225 
226 Q_DECLARE_METATYPE(QIcon)
227 Q_DECLARE_METATYPE(QtIconMap)
228 #endif
virtual QtProperty * createProperty()
Definition: qtpropertybrowser.cpp:767
QtVariantPropertyPrivate * d_ptr
Definition: qtvariantproperty.h:112
The QtVariantPropertyManager class provides and manages QVariant based properties.
Definition: qtvariantproperty.h:117
The QtAbstractPropertyManager provides an interface for property managers.
Definition: qtpropertybrowser.h:153
The QtAbstractEditorFactory is the base template class for editor factories.
Definition: qtpropertybrowser.h:203
QtProperty * addProperty(const QString &name=QString())
Definition: qtpropertybrowser.cpp:748
virtual void initializeProperty(QtProperty *property)=0
Definition: qtvariantproperty.cpp:290
virtual void uninitializeProperty(QtProperty *property)
Definition: qtpropertybrowser.cpp:799
virtual bool hasValue(const QtProperty *property) const
Definition: qtpropertybrowser.cpp:680
QtVariantEditorFactoryPrivate * d_ptr
Definition: qtvariantproperty.h:217
QMap< int, QIcon > QtIconMap
Definition: qtvariantproperty.h:52
Definition: qtvariantproperty.cpp:2027
Definition: qtvariantproperty.cpp:139
#define QT_QTPROPERTYBROWSER_EXPORT
Definition: qtpropertybrowser.h:59
QtVariantPropertyManagerPrivate * d_ptr
Definition: qtvariantproperty.h:160
The QtVariantProperty class is a convenience class handling QVariant based properties.
Definition: qtvariantproperty.h:95
virtual QString valueText(const QtProperty *property) const
Definition: qtpropertybrowser.cpp:708
QWidget * createEditor(QtProperty *property, QWidget *parent)
Definition: qtpropertybrowser.h:206
The QtProperty class encapsulates an instance of a property.
Definition: qtpropertybrowser.h:113
virtual void disconnectPropertyManager(PropertyManager *manager)=0
The QtVariantEditorFactory class provides widgets for properties created by QtVariantPropertyManager ...
Definition: qtvariantproperty.h:206
virtual void connectPropertyManager(PropertyManager *manager)=0
virtual QIcon valueIcon(const QtProperty *property) const
Definition: qtpropertybrowser.cpp:694