Computer Assisted Medical Intervention Tool Kit version 6.0
 
Loading...
Searching...
No Matches
QtPropertyFieldEditor.h
Go to the documentation of this file.
1/*****************************************************************************
2 * $CAMITK_LICENCE_BEGIN$
3 *
4 * CamiTK - Computer Assisted Medical Intervention ToolKit
5 * (c) 2001-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
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
27#ifndef __QTPROPERTY_FIELD_EDITOR__
28#define __QTPROPERTY_FIELD_EDITOR__
29
30#include "FieldEditor.h"
31
32#include <QTabWidget>
33#include <QEvent>
34
66 Q_OBJECT
67public:
71 QtPropertyFieldEditor(CamiTKExtensionModelPresenter* presenter, VariantDataModel& dataModel, const QString& name = "", const QString& description = "", const QVariant& defaultValue = QVariant());
72
74 void setReadOnly(bool isReadOnly);
75
77 void setPlaceHolderText(const QString& placeHolderText);
78
80 void setMandatory(bool isMandatory);
81
83 void setTabWidgetTitle(bool isTabWidgetTitle);
84
86 void setLabelToUpdateWithFieldValue(QLabel* labelToUpdate);
87
89 void setEnumValues(const QStringList& enumValues);
90
92 void setEditableEnum(bool editableEnums);
93
95 void setRegExp(const QString& regExp);
96
98 void setTitleCase(bool isTitleCase);
99
101 void setCheckBoxText(QString checkBoxText);
102
104 void setMinimum(QVariant minimum);
105
107 void setMaximum(QVariant maximum);
108
110 void setDecimals(int decimals);
111
113 virtual QWidget* getWidget() override;
114
117 bool eventFilter(QObject* obj, QEvent* event) override;
118
119public slots:
120
122 void valueChangedInPropertyField(QtProperty* property, const QVariant& value);
123
125 void editTextChanged(const QString& newValue);
126
128 void currentIndexChanged(int index);
129
130private:
132 QtVariantPropertyManager* propManager;
133
135 QtVariantEditorFactory* factory;
136
138 QVariant initialValue;
139
141 QStringList enumValues;
142
144 QString regExp;
145
147 bool isTitleCase;
148
150 bool isReadOnly;
151
153 int decimals;
154
156 QVariant minimum, maximum;
157
159 QString placeHolderText;
160
162 QString checkBoxText;
163
165 bool isMandatory;
166
168 bool editableEnums;
169
171 bool isTabWidgetTitle;
172
174 QLabel* labelToUpdate;
175
177 QLineEdit* comboBoxEditableLineEdit;
178
180 QtVariantProperty* myProp;
181
184 void buildProperty(QString name, QVariant value, QStringList enumValues = {});
185
186 // return the first parent that is a tab widget (used only when this is declared as a tab widget title)
187 QTabWidget* findParentTabWidget();
188};
189
190#endif // __QTPROPERTY_FIELD_EDITOR__
Presenter for a CamiTK extension file model.
Definition CamiTKExtensionModelPresenter.h:47
Abstract class for field editor.
Definition FieldEditor.h:51
QString name
Name of the field (displayed as a label)
Definition FieldEditor.h:92
QString description
Description (displayed as tool tip / what's that)
Definition FieldEditor.h:95
CamiTKExtensionModelPresenter * presenter
The presenter that contains the full VariantDataModel.
Definition FieldEditor.h:83
VariantDataModel & dataModel
The edited data model (part of the presenter's full model)
Definition FieldEditor.h:86
Field editor for atomic type QVariant managed using a single line edit using QtPropertyBrowser.
Definition QtPropertyFieldEditor.h:65
void setMinimum(QVariant minimum)
for double/int: set the minimum value
Definition QtPropertyFieldEditor.cpp:104
void setDecimals(int decimals)
for double/int: set the number of decimal values
Definition QtPropertyFieldEditor.cpp:120
void setEnumValues(const QStringList &enumValues)
For enums: set the values.
Definition QtPropertyFieldEditor.cpp:59
void setEditableEnum(bool editableEnums)
if true, the last item is editable
Definition QtPropertyFieldEditor.cpp:94
void currentIndexChanged(int index)
for editable enum: called when the selected item has changed in order to let the user edit only the l...
Definition QtPropertyFieldEditor.cpp:347
void setMaximum(QVariant maximum)
for double/int: set the maximum value
Definition QtPropertyFieldEditor.cpp:112
bool eventFilter(QObject *obj, QEvent *event) override
filters wheel events for enum (edited as QComboBox) as it is too easy to modify the value when the mo...
Definition QtPropertyFieldEditor.cpp:248
void valueChangedInPropertyField(QtProperty *property, const QVariant &value)
for anything but enum: called when the edited value has changed
Definition QtPropertyFieldEditor.cpp:257
void setPlaceHolderText(const QString &placeHolderText)
set the displayed text when the field value is empty
Definition QtPropertyFieldEditor.cpp:74
virtual QWidget * getWidget() override
Build an line edit for the encapsulated VariantDataModel.
Definition QtPropertyFieldEditor.cpp:133
void setCheckBoxText(QString checkBoxText)
for boolean: set the text to appear besides the check box (instead of default True/False) (this is us...
Definition QtPropertyFieldEditor.cpp:99
void setReadOnly(bool isReadOnly)
if isReadOnly is true the field value cannot be modified
Definition QtPropertyFieldEditor.cpp:128
void setTitleCase(bool isTitleCase)
For strings: ensure the value has a title case format.
Definition QtPropertyFieldEditor.cpp:69
void editTextChanged(const QString &newValue)
for editable enum: called when the modifiable value has changed
Definition QtPropertyFieldEditor.cpp:339
void setLabelToUpdateWithFieldValue(QLabel *labelToUpdate)
set the label to update/synchronize when the current field is modified
Definition QtPropertyFieldEditor.cpp:89
void setRegExp(const QString &regExp)
For strings: set the regexp validator for QString properties and editable enums.
Definition QtPropertyFieldEditor.cpp:64
void setTabWidgetTitle(bool isTabWidgetTitle)
it isTabWidgetTitle is true, look for a parent widget that is a TabWidget and sets its text to the cu...
Definition QtPropertyFieldEditor.cpp:84
void setMandatory(bool isMandatory)
if isMandatory is true, the presenter gets a warning message if the value becomes empty
Definition QtPropertyFieldEditor.cpp:79
The QtProperty class encapsulates an instance of a property.
Definition qtpropertybrowser.h:104
The QtVariantEditorFactory class provides widgets for properties created by QtVariantPropertyManager ...
Definition qtvariantproperty.h:212
The QtVariantPropertyManager class provides and manages QVariant based properties.
Definition qtvariantproperty.h:119
The QtVariantProperty class is a convenience class handling QVariant based properties.
Definition qtvariantproperty.h:97
VariantDataModel encapsulates QVariant and can be used as a model for any type of QVariant supported ...
Definition VariantDataModel.h:124