The preference widget class. More...
#include <PrefWidgets.h>
Public Member Functions | |
QByteArray | entryName () const |
Returns the widget's preference name. More... | |
virtual void | OnChange (Base::Subject< const char * > &rCaller, const char *sReason) |
This method is called if one or more values in the parameter settings are changed where getParamGrp() points to. More... | |
void | onRestore () |
Restores the preferences of the widget. More... | |
void | onSave () |
Saves the current preferences of the widget. More... | |
QByteArray | paramGrpPath () const |
Returns the widget's preferences path. More... | |
void | setEntryName (const QByteArray &name) |
Sets the preference name to name. More... | |
void | setParamGrpPath (const QByteArray &path) |
Sets the preference path to path. More... | |
void | setPrefEntry (const QByteArray &name) |
Does the same as setEntryName(). More... | |
void | setPrefPath (const QByteArray &name) |
Does the same as setParamGrpPath(). More... | |
Public Member Functions inherited from Gui::WindowParameter | |
ParameterGrp::handle | getWindowParameter (void) |
return the parameter group of this window More... | |
void | OnChange (Base::Subject< const char * > &rCaller, const char *sReason) |
bool | setGroupName (const char *name) |
Sets the group of the window to name. More... | |
WindowParameter (const char *name) | |
virtual | ~WindowParameter () |
Protected Member Functions | |
void | failedToRestore (const QString &) const |
Print warning that restoring failed. More... | |
void | failedToSave (const QString &) const |
Print warning that saving failed. More... | |
PrefWidget () | |
Constructs a preference widget. More... | |
virtual void | restorePreferences ()=0 |
Restores the preferences Must be reimplemented in any subclasses. More... | |
virtual void | savePreferences ()=0 |
Save the preferences Must be reimplemented in any subclasses. More... | |
virtual | ~PrefWidget () |
Destroys the widget and detaches it from its parameter group. More... | |
Friends | |
class | Gui::WidgetFactoryInst |
Additional Inherited Members | |
Static Public Member Functions inherited from Gui::WindowParameter | |
static ParameterGrp::handle | getDefaultParameter (void) |
get the parameters More... | |
The preference widget class.
If you want to extend a QWidget class to save/restore its data you just have to derive from this class and implement the methods restorePreferences() and savePreferences().
To restore and save the settings of any widgets in own dialogs you have call onRestore() e.g. in the dialog's constructor and call onSave() e.g. in accept() for each widget you want to enable this mechanism.
For more information of how to use these widgets in normal container widgets which are again in a dialog refer to the description of Gui::Dialog::DlgPreferencesImp.
|
protected |
Constructs a preference widget.
|
protectedvirtual |
Destroys the widget and detaches it from its parameter group.
References Base::Subject< _MessageType >::Detach(), Gui::WindowParameter::getWindowParameter(), and femsolver.elmer.sifio::isValid().
QByteArray PrefWidget::entryName | ( | ) | const |
Returns the widget's preference name.
Referenced by onSave(), Gui::PrefSpinBox::restorePreferences(), Gui::PrefDoubleSpinBox::restorePreferences(), Gui::PrefLineEdit::restorePreferences(), Gui::PrefTextEdit::restorePreferences(), Gui::PrefFileChooser::restorePreferences(), Gui::PrefComboBox::restorePreferences(), Gui::PrefCheckBox::restorePreferences(), Gui::PrefRadioButton::restorePreferences(), Gui::PrefSlider::restorePreferences(), Gui::PrefColorButton::restorePreferences(), Gui::PrefUnitSpinBox::restorePreferences(), Gui::PrefQuantitySpinBox::restorePreferences(), Gui::PrefFontBox::restorePreferences(), Gui::PrefSpinBox::savePreferences(), Gui::PrefDoubleSpinBox::savePreferences(), Gui::PrefLineEdit::savePreferences(), Gui::PrefTextEdit::savePreferences(), Gui::PrefFileChooser::savePreferences(), Gui::PrefComboBox::savePreferences(), Gui::PrefCheckBox::savePreferences(), Gui::PrefRadioButton::savePreferences(), Gui::PrefSlider::savePreferences(), Gui::PrefColorButton::savePreferences(), Gui::PrefUnitSpinBox::savePreferences(), Gui::PrefQuantitySpinBox::savePreferences(), and Gui::PrefFontBox::savePreferences().
|
protected |
Print warning that restoring failed.
References Base::ConsoleSingleton::Warning().
Referenced by Gui::PrefSpinBox::restorePreferences(), Gui::PrefDoubleSpinBox::restorePreferences(), Gui::PrefLineEdit::restorePreferences(), Gui::PrefTextEdit::restorePreferences(), Gui::PrefFileChooser::restorePreferences(), Gui::PrefComboBox::restorePreferences(), Gui::PrefCheckBox::restorePreferences(), Gui::PrefRadioButton::restorePreferences(), Gui::PrefSlider::restorePreferences(), Gui::PrefColorButton::restorePreferences(), Gui::PrefUnitSpinBox::restorePreferences(), Gui::PrefQuantitySpinBox::restorePreferences(), and Gui::PrefFontBox::restorePreferences().
|
protected |
Print warning that saving failed.
References Base::ConsoleSingleton::Warning().
Referenced by Gui::PrefSpinBox::savePreferences(), Gui::PrefDoubleSpinBox::savePreferences(), Gui::PrefLineEdit::savePreferences(), Gui::PrefTextEdit::savePreferences(), Gui::PrefFileChooser::savePreferences(), Gui::PrefComboBox::savePreferences(), Gui::PrefCheckBox::savePreferences(), Gui::PrefRadioButton::savePreferences(), Gui::PrefSlider::savePreferences(), Gui::PrefColorButton::savePreferences(), Gui::PrefUnitSpinBox::savePreferences(), Gui::PrefQuantitySpinBox::savePreferences(), and Gui::PrefFontBox::savePreferences().
|
virtual |
This method is called if one or more values in the parameter settings are changed where getParamGrp() points to.
Note: This method is called for each parameter inside the parameter group. So you have to filter out the appropriate parameter with the name sReason. rCaller calls this method.
References restorePreferences().
void PrefWidget::onRestore | ( | ) |
Restores the preferences of the widget.
References Gui::WindowParameter::getWindowParameter(), draftgeoutils.general::isNull(), and restorePreferences().
Referenced by FemGui::DlgSettingsFemExportAbaqusImp::loadSettings(), FemGui::DlgSettingsFemInOutVtkImp::loadSettings(), and MeshGui::DlgSettingsImportExport::loadSettings().
void PrefWidget::onSave | ( | ) |
Saves the current preferences of the widget.
All preference widget attached to the same parameter group are notified.
References entryName(), Gui::WindowParameter::getWindowParameter(), femsolver.elmer.sifio::isValid(), Base::Subject< _MessageType >::Notify(), and savePreferences().
Referenced by Gui::PrefQuantitySpinBox::pushToHistory(), FemGui::DlgSettingsFemExportAbaqusImp::saveSettings(), FemGui::DlgSettingsFemInOutVtkImp::saveSettings(), and MeshGui::DlgSettingsImportExport::saveSettings().
QByteArray PrefWidget::paramGrpPath | ( | ) | const |
Returns the widget's preferences path.
Referenced by setParamGrpPath().
|
protectedpure virtual |
Restores the preferences Must be reimplemented in any subclasses.
Implemented in Gui::PrefSpinBox, Gui::PrefDoubleSpinBox, Gui::PrefLineEdit, Gui::PrefTextEdit, Gui::PrefFileChooser, Gui::PrefComboBox, Gui::PrefCheckBox, Gui::PrefRadioButton, Gui::PrefSlider, Gui::PrefColorButton, Gui::PrefUnitSpinBox, Gui::PrefQuantitySpinBox, and Gui::PrefFontBox.
Referenced by Gui::WidgetFactoryInst::createPrefWidget(), OnChange(), and onRestore().
|
protectedpure virtual |
Save the preferences Must be reimplemented in any subclasses.
Implemented in Gui::PrefSpinBox, Gui::PrefDoubleSpinBox, Gui::PrefLineEdit, Gui::PrefTextEdit, Gui::PrefFileChooser, Gui::PrefComboBox, Gui::PrefCheckBox, Gui::PrefRadioButton, Gui::PrefSlider, Gui::PrefColorButton, Gui::PrefUnitSpinBox, Gui::PrefQuantitySpinBox, and Gui::PrefFontBox.
Referenced by onSave().
void PrefWidget::setEntryName | ( | const QByteArray & | name | ) |
Sets the preference name to name.
Referenced by Gui::WidgetFactoryInst::createPrefWidget(), and setPrefEntry().
void PrefWidget::setParamGrpPath | ( | const QByteArray & | path | ) |
Sets the preference path to path.
References Base::Subject< _MessageType >::Attach(), Base::Console(), Gui::WindowParameter::getWindowParameter(), femsolver.elmer.sifio::isValid(), paramGrpPath(), Gui::WindowParameter::setGroupName(), and Base::ConsoleSingleton::Warning().
Referenced by setPrefPath().
void PrefWidget::setPrefEntry | ( | const QByteArray & | name | ) |
Does the same as setEntryName().
Sets the preference name to name.
This function is added for convenience because the ui compiler will use this function if the attribute stdset isn't set to 0 in a .ui file.
References setEntryName().
void PrefWidget::setPrefPath | ( | const QByteArray & | name | ) |
Does the same as setParamGrpPath().
Sets the preference path to path.
This function is added for convenience because the ui compiler will use this function if the attribute stdset isn't set to 0 in a .ui file.
References setParamGrpPath().
|
friend |