Computer Assisted Medical Intervention Tool Kit version 6.0
 
Loading...
Searching...
No Matches
QtPropertyFieldEditor Class Reference

Field editor for atomic type QVariant managed using a single line edit using QtPropertyBrowser. More...

#include <QtPropertyFieldEditor.h>

+ Inheritance diagram for QtPropertyFieldEditor:
+ Collaboration diagram for QtPropertyFieldEditor:

Public Slots

void currentIndexChanged (int index)
 for editable enum: called when the selected item has changed in order to let the user edit only the last line (not the other values)
 
void editTextChanged (const QString &newValue)
 for editable enum: called when the modifiable value has changed
 
void valueChangedInPropertyField (QtProperty *property, const QVariant &value)
 for anything but enum: called when the edited value has changed
 

Public Member Functions

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 mouse is just hovering on the QComboBox and could have disastrous consequences
 
virtual QWidget * getWidget () override
 Build an line edit for the encapsulated VariantDataModel.
 
 QtPropertyFieldEditor (CamiTKExtensionModelPresenter *presenter, VariantDataModel &dataModel, const QString &name="", const QString &description="", const QVariant &defaultValue=QVariant())
 Constructor If the model value is invalid (not yet present in the CamiTKExtensionModel), use the provided default value to create a new data model.
 
void setCheckBoxText (QString checkBoxText)
 for boolean: set the text to appear besides the check box (instead of default True/False) (this is useful for compact field editor)
 
void setDecimals (int decimals)
 for double/int: set the number of decimal values
 
void setEditableEnum (bool editableEnums)
 if true, the last item is editable
 
void setEnumValues (const QStringList &enumValues)
 For enums: set the values.
 
void setLabelToUpdateWithFieldValue (QLabel *labelToUpdate)
 set the label to update/synchronize when the current field is modified
 
void setMandatory (bool isMandatory)
 if isMandatory is true, the presenter gets a warning message if the value becomes empty
 
void setMaximum (QVariant maximum)
 for double/int: set the maximum value
 
void setMinimum (QVariant minimum)
 for double/int: set the minimum value
 
void setPlaceHolderText (const QString &placeHolderText)
 set the displayed text when the field value is empty
 
void setReadOnly (bool isReadOnly)
 if isReadOnly is true the field value cannot be modified
 
void setRegExp (const QString &regExp)
 For strings: set the regexp validator for QString properties and editable enums.
 
void setTabWidgetTitle (bool isTabWidgetTitle)
 it isTabWidgetTitle is true, look for a parent widget that is a TabWidget and sets its text to the current field value every time it changes
 
void setTitleCase (bool isTitleCase)
 For strings: ensure the value has a title case format.
 
- Public Member Functions inherited from FieldEditor
virtual void appendRowTo (QGridLayout *layout, bool canBeDeleted=false)
 Adds a row at the end of the given layout with two columns:
 
 FieldEditor (CamiTKExtensionModelPresenter *presenter, VariantDataModel &dataModel, const QString &name="", const QString &description="")
 Constructor Creates a field for the given data model inside the given presenter A name and description can be associated with the field (it will be used when the field is added to a gridlayout,.
 
void setEnabled (bool isEnabled)
 Is the widget and labels currently enabled.
 
virtual ~FieldEditor ()
 Destructor (delete myWidget)
 

Additional Inherited Members

- Signals inherited from FieldEditor
void valueChanged (VariantDataModel &changedDataModel)
 emitted when the edited value has changed (useful to synchronize other field editor depending of this editor current value)
 
- Protected Slots inherited from FieldEditor
virtual void deleteButtonClicked ()
 Called when the (optional) delete button is called This will make user the user knows what she/he does If deletion is confirmed by the user, remove the data model.
 
- Protected Attributes inherited from FieldEditor
VariantDataModeldataModel
 The edited data model (part of the presenter's full model)
 
QString description
 Description (displayed as tool tip / what's that)
 
QGridLayout * myGridLayout
 where the widget is added
 
QWidget * myWidget
 The created widget (inheriting must use this to create their widgets)
 
QString name
 Name of the field (displayed as a label)
 
CamiTKExtensionModelPresenterpresenter
 The presenter that contains the full VariantDataModel.
 
QLabel * rowLabel
 the row label widget (that contains the name of the row) the label text can be modified (see CamiTKPropertyFieldEditor.h for an example)
 

Detailed Description

Field editor for atomic type QVariant managed using a single line edit using QtPropertyBrowser.

Note
with a little revamp this can become a full replacement for QtPropertyBrowser.

This field editor can manage

  • enum (editable or not)
  • string (with regexp or titleCase constraints or not)
  • boolean (with custom checkbox text)
  • double/int values (with min/max/decimals constraints or not)

A QtPropertyFieldEditor

  • can be read only or not
  • can have a place holder text (displayed when the value is empty) or not
  • can be declared as mandatory. In this case if the field value is empty a warning message is sent to the CamiTKExtensionModelPresenter presenter
  • can be declared as tab widget title. In this case its parent tab widget title will be interactively modified when the field edited value changes
  • can be given a label to interactively update when the field edited value changes

For string setting a specific format will modify the user input to follow a given regexp everytime the user modify the field value (e.g. to ensure the field starts with an upper case letter or a number use setFormat(R"(^[A-Z0-9].*)"))

Usage example:

maximumValueEditor = new QtPropertyFieldEditor(presenter, dataModel["maximum"], "Maximum Value", "If set this will constrain the parameter maximum value", maxValue);
maximumValueEditor->setPlaceHolderText("Maximum Value");
... // use desired set methods here
myLayout->addWidget(maximumValueEditor->getWidget());
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

Constructor & Destructor Documentation

◆ QtPropertyFieldEditor()

QtPropertyFieldEditor::QtPropertyFieldEditor ( CamiTKExtensionModelPresenter presenter,
VariantDataModel dataModel,
const QString &  name = "",
const QString &  description = "",
const QVariant &  defaultValue = QVariant() 
)

Constructor If the model value is invalid (not yet present in the CamiTKExtensionModel), use the provided default value to create a new data model.

Parameters
defaultValueif given, used to set the data model if it does not exist yet

References FieldEditor::dataModel, and VariantDataModel::getValue().

+ Here is the call graph for this function:

Member Function Documentation

◆ currentIndexChanged

void QtPropertyFieldEditor::currentIndexChanged ( int  index)
slot

for editable enum: called when the selected item has changed in order to let the user edit only the last line (not the other values)

References FieldEditor::myWidget.

Referenced by getWidget().

+ Here is the caller graph for this function:

◆ editTextChanged

void QtPropertyFieldEditor::editTextChanged ( const QString &  newValue)
slot

for editable enum: called when the modifiable value has changed

References FieldEditor::dataModel, CamiTKExtensionModelPresenter::modelUpdated(), FieldEditor::presenter, and FieldEditor::valueChanged().

Referenced by getWidget().

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

◆ eventFilter()

bool QtPropertyFieldEditor::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 mouse is just hovering on the QComboBox and could have disastrous consequences

◆ getWidget()

QWidget * QtPropertyFieldEditor::getWidget ( )
overridevirtual

Build an line edit for the encapsulated VariantDataModel.

Implements FieldEditor.

References QtAbstractEditorFactory< PropertyManager >::addPropertyManager(), CAMITK_WARNING, currentIndexChanged(), FieldEditor::dataModel, FieldEditor::description, editTextChanged(), VariantDataModel::getName(), FieldEditor::myWidget, QtVariantProperty::setAttribute(), QtBoolEdit::setTextVisible(), VariantDataModel::toString(), QtVariantPropertyManager::valueChanged(), and valueChangedInPropertyField().

Referenced by CamiTKPropertyFieldEditor::buildTypeDependentEditors(), and CamiTKPropertyFieldEditor::getWidget().

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

◆ setCheckBoxText()

void QtPropertyFieldEditor::setCheckBoxText ( QString  checkBoxText)

for boolean: set the text to appear besides the check box (instead of default True/False) (this is useful for compact field editor)

Referenced by CamiTKPropertyFieldEditor::getWidget().

+ Here is the caller graph for this function:

◆ setDecimals()

void QtPropertyFieldEditor::setDecimals ( int  decimals)

for double/int: set the number of decimal values

References QtVariantProperty::setAttribute().

Referenced by CamiTKPropertyFieldEditor::buildTypeDependentEditors().

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

◆ setEditableEnum()

void QtPropertyFieldEditor::setEditableEnum ( bool  editableEnums)

if true, the last item is editable

Referenced by ActionTabPresenter::ActionTabPresenter(), and ExtensionTabPresenter::ExtensionTabPresenter().

+ Here is the caller graph for this function:

◆ setEnumValues()

void QtPropertyFieldEditor::setEnumValues ( const QStringList &  enumValues)

For enums: set the values.

Referenced by ActionTabPresenter::ActionTabPresenter(), CppActionTabPresenter::CppActionTabPresenter(), ExtensionTabPresenter::ExtensionTabPresenter(), CamiTKPropertyFieldEditor::getWidget(), and PythonActionTabPresenter::PythonActionTabPresenter().

+ Here is the caller graph for this function:

◆ setLabelToUpdateWithFieldValue()

void QtPropertyFieldEditor::setLabelToUpdateWithFieldValue ( QLabel *  labelToUpdate)

set the label to update/synchronize when the current field is modified

Referenced by CamiTKPropertyFieldEditor::appendRowTo().

+ Here is the caller graph for this function:

◆ setMandatory()

void QtPropertyFieldEditor::setMandatory ( bool  isMandatory)

if isMandatory is true, the presenter gets a warning message if the value becomes empty

Referenced by CamiTKPropertyFieldEditor::getWidget().

+ Here is the caller graph for this function:

◆ setMaximum()

void QtPropertyFieldEditor::setMaximum ( QVariant  maximum)

for double/int: set the maximum value

References QtVariantProperty::setAttribute().

Referenced by CamiTKPropertyFieldEditor::buildTypeDependentEditors().

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

◆ setMinimum()

void QtPropertyFieldEditor::setMinimum ( QVariant  minimum)

for double/int: set the minimum value

References QtVariantProperty::setAttribute().

Referenced by CamiTKPropertyFieldEditor::buildTypeDependentEditors().

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

◆ setPlaceHolderText()

void QtPropertyFieldEditor::setPlaceHolderText ( const QString &  placeHolderText)

set the displayed text when the field value is empty

Referenced by ActionTabPresenter::ActionTabPresenter(), CamiTKPropertyFieldEditor::buildTypeDependentEditors(), ExtensionTabPresenter::ExtensionTabPresenter(), and CamiTKPropertyFieldEditor::getWidget().

+ Here is the caller graph for this function:

◆ setReadOnly()

void QtPropertyFieldEditor::setReadOnly ( bool  isReadOnly)

if isReadOnly is true the field value cannot be modified

Referenced by ActionTabPresenter::ActionTabPresenter(), and ExtensionTabPresenter::ExtensionTabPresenter().

+ Here is the caller graph for this function:

◆ setRegExp()

void QtPropertyFieldEditor::setRegExp ( const QString &  regExp)

For strings: set the regexp validator for QString properties and editable enums.

Referenced by ActionTabPresenter::ActionTabPresenter(), CamiTKPropertyFieldEditor::buildTypeDependentEditors(), and ExtensionTabPresenter::ExtensionTabPresenter().

+ Here is the caller graph for this function:

◆ setTabWidgetTitle()

void QtPropertyFieldEditor::setTabWidgetTitle ( bool  isTabWidgetTitle)

it isTabWidgetTitle is true, look for a parent widget that is a TabWidget and sets its text to the current field value every time it changes

◆ setTitleCase()

void QtPropertyFieldEditor::setTitleCase ( bool  isTitleCase)

For strings: ensure the value has a title case format.

Referenced by CamiTKPropertyFieldEditor::getWidget().

+ Here is the caller graph for this function:

◆ valueChangedInPropertyField

void QtPropertyFieldEditor::valueChangedInPropertyField ( QtProperty property,
const QVariant &  value 
)
slot

for anything but enum: called when the edited value has changed

References FieldEditor::dataModel, CamiTKExtensionModelPresenter::emitShowMessage(), isDigit, CamiTKExtensionModelPresenter::modelUpdated(), FieldEditor::myWidget, FieldEditor::name, FieldEditor::presenter, and FieldEditor::valueChanged().

Referenced by getWidget().

+ 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: