Computer Assisted Medical Intervention Tool Kit  version 5.2
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 class QRegularExpression;
53 
54 typedef QMap<int, QIcon> QtIconMap;
55 
58 
98 public:
99  ~QtVariantProperty() override;
100  QVariant value() const;
101  QVariant attributeValue(const QString& attribute) const;
102  int valueType() const;
103  int propertyType() const;
104 
105  void setValue(const QVariant& value);
106  void setAttribute(const QString& attribute, const QVariant& value);
107  // Added in CamiTK for enum icon management
108  virtual void setAttribute(const QString& attribute, const QMap<int, QIcon>& value);
109 
110 protected:
112 private:
115 };
116 
118 
120  Q_OBJECT
121 public:
122  QtVariantPropertyManager(QObject* parent = nullptr);
123  ~QtVariantPropertyManager() override;
124 
125  virtual QtVariantProperty* addProperty(int propertyType, const QString& name = QString());
126 
127  int propertyType(const QtProperty* property) const;
128  int valueType(const QtProperty* property) const;
129  QtVariantProperty* variantProperty(const QtProperty* property) const;
130 
131  virtual bool isPropertyTypeSupported(int propertyType) const;
132  virtual int valueType(int propertyType) const;
133  virtual QStringList attributes(int propertyType) const;
134  virtual int attributeType(int propertyType, const QString& attribute) const;
135 
136  virtual QVariant value(const QtProperty* property) const;
137  virtual QVariant attributeValue(const QtProperty* property, const QString& attribute) const;
138 
139  static int enumTypeId();
140  static int flagTypeId();
141  static int groupTypeId();
142  static int iconMapTypeId();
143 public Q_SLOTS:
144  virtual void setValue(QtProperty* property, const QVariant& val);
145  virtual void setAttribute(QtProperty* property,
146  const QString& attribute, const QVariant& value);
147  // Added in CamiTK for enum icon management
148  virtual void setAttribute(QtProperty* property,
149  const QString& attribute, const QMap<int, QIcon>& value);
150 Q_SIGNALS:
151  void valueChanged(QtProperty* property, const QVariant& val);
152  void attributeChanged(QtProperty* property,
153  const QString& attribute, const QVariant& val);
154 protected:
155  bool hasValue(const QtProperty* property) const override;
156  QString valueText(const QtProperty* property) const override;
157  QIcon valueIcon(const QtProperty* property) const override;
158  void initializeProperty(QtProperty* property) override;
159  void uninitializeProperty(QtProperty* property) override;
160  QtProperty* createProperty() override;
161 private:
163  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, int))
164  Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, int, int))
165  Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty*, int))
166  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, double))
167  Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, double, double))
168  Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty*, double))
169  Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty*, int))
170  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, bool))
171  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QString&))
172  Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty*, const QRegularExpression&))
173  Q_PRIVATE_SLOT(d_func(), void slotEchoModeChanged(QtProperty*, int))
174  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QDate&))
175  Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, const QDate&, const QDate&))
176  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QTime&))
177  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QDateTime&))
178  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QKeySequence&))
179  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QChar&))
180  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QLocale&))
181  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QPoint&))
182  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QPointF&))
183  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QVector3D&))
184  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QSize&))
185  Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, const QSize&, const QSize&))
186  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QSizeF&))
187  Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty*, const QSizeF&, const QSizeF&))
188  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QRect&))
189  Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty*, const QRect&))
190  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QRectF&))
191  Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty*, const QRectF&))
192  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QColor&))
193  Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty*, const QStringList&))
194  Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty*, const QMap<int, QIcon>&))
195  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QSizePolicy&))
196  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QFont&))
197  Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty*, const QCursor&))
198  Q_PRIVATE_SLOT(d_func(), void slotFlagNamesChanged(QtProperty*, const QStringList&))
199 
200  Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty*, QtProperty*, QtProperty*))
201  Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty*, QtProperty*))
202  Q_DECLARE_PRIVATE(QtVariantPropertyManager)
203 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
204  Q_DISABLE_COPY_MOVE(QtVariantPropertyManager)
205 #else
206  Q_DISABLE_COPY(QtVariantPropertyManager)
207 #endif
208 };
209 
211 
213  Q_OBJECT
214 public:
215  QtVariantEditorFactory(QObject* parent = nullptr);
216  ~QtVariantEditorFactory() override;
217 protected:
218  void connectPropertyManager(QtVariantPropertyManager* manager) override;
219  QWidget* createEditor(QtVariantPropertyManager* manager, QtProperty* property,
220  QWidget* parent) override;
221  void disconnectPropertyManager(QtVariantPropertyManager* manager) override;
222 private:
224  Q_DECLARE_PRIVATE(QtVariantEditorFactory)
225 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
226  Q_DISABLE_COPY_MOVE(QtVariantEditorFactory)
227 #else
228  Q_DISABLE_COPY(QtVariantEditorFactory)
229 #endif
230 };
231 
232 #if QT_VERSION >= 0x040400
233 QT_END_NAMESPACE
234 #endif
235 
236 Q_DECLARE_METATYPE(QIcon)
237 Q_DECLARE_METATYPE(QtIconMap)
238 #endif
The QtAbstractEditorFactory is the base template class for editor factories.
Definition: qtpropertybrowser.h:207
The QtAbstractPropertyManager provides an interface for property managers.
Definition: qtpropertybrowser.h:153
The QtProperty class encapsulates an instance of a property.
Definition: qtpropertybrowser.h:113
bool hasValue() const
Definition: qtpropertybrowser.cpp:259
QIcon valueIcon() const
Definition: qtpropertybrowser.cpp:271
QString valueText() const
Definition: qtpropertybrowser.cpp:283
Definition: qtvariantproperty.cpp:2027
The QtVariantEditorFactory class provides widgets for properties created by QtVariantPropertyManager ...
Definition: qtvariantproperty.h:212
Definition: qtvariantproperty.cpp:290
The QtVariantPropertyManager class provides and manages QVariant based properties.
Definition: qtvariantproperty.h:119
void valueChanged(QtProperty *property, const QVariant &val)
void attributeChanged(QtProperty *property, const QString &attribute, const QVariant &val)
Definition: qtvariantproperty.cpp:140
The QtVariantProperty class is a convenience class handling QVariant based properties.
Definition: qtvariantproperty.h:97
#define QT_QTPROPERTYBROWSER_EXPORT
Definition: qtpropertybrowser.h:59
QMap< int, QIcon > QtIconMap
Definition: qtvariantproperty.h:52