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>

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
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),...
Definition QtPropertyFieldEditor.cpp:35

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, FieldEditor::description, FieldEditor::FieldEditor(), FieldEditor::name, and FieldEditor::presenter.

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().

◆ editTextChanged

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

for editable enum: called when the modifiable value has changed

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

Referenced by getWidget().

◆ 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()

◆ 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().

◆ setDecimals()

void QtPropertyFieldEditor::setDecimals ( int decimals)

for double/int: set the number of decimal values

Referenced by CamiTKPropertyFieldEditor::buildTypeDependentEditors().

◆ setEditableEnum()

void QtPropertyFieldEditor::setEditableEnum ( bool editableEnums)

if true, the last item is editable

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

◆ setEnumValues()

void QtPropertyFieldEditor::setEnumValues ( const QStringList & enumValues)

◆ setLabelToUpdateWithFieldValue()

void QtPropertyFieldEditor::setLabelToUpdateWithFieldValue ( QLabel * labelToUpdate)

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

◆ setMandatory()

void QtPropertyFieldEditor::setMandatory ( bool isMandatory)

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

◆ setMaximum()

void QtPropertyFieldEditor::setMaximum ( QVariant maximum)

for double/int: set the maximum value

Referenced by CamiTKPropertyFieldEditor::buildTypeDependentEditors().

◆ setMinimum()

void QtPropertyFieldEditor::setMinimum ( QVariant minimum)

for double/int: set the minimum value

Referenced by CamiTKPropertyFieldEditor::buildTypeDependentEditors().

◆ setPlaceHolderText()

void QtPropertyFieldEditor::setPlaceHolderText ( const QString & placeHolderText)

◆ setReadOnly()

void QtPropertyFieldEditor::setReadOnly ( bool isReadOnly)

if isReadOnly is true the field value cannot be modified

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

◆ 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().

◆ 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.

◆ valueChangedInPropertyField

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

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

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

Referenced by getWidget().


The documentation for this class was generated from the following files: