The preference widget class. More...
#include <PrefWidgets.h>
Public Member Functions | |
virtual QByteArray | entryName () const |
Returns the widget's preference name. | |
virtual void | OnChange (Base::Subject< const char * > &rCaller, const char *sReason) |
This method is called if one ore more values in the parameter settings are changed where getParamGrp() points to. | |
void | onRestore () |
Restores the preferences of the widget. | |
void | onSave () |
Saves the current preferences of the widget. | |
virtual QByteArray | paramGrpPath () const |
Returns the widget's preferences path. | |
virtual void | setEntryName (const QByteArray &name) |
Sets the preference name to name. | |
virtual void | setParamGrpPath (const QByteArray &path) |
Sets the preference path to path. | |
Protected Member Functions | |
PrefWidget () | |
Constructs a preference widget. | |
virtual void | restorePreferences ()=0 |
Restores the preferences Must be reimplemented in any subclasses. | |
virtual void | savePreferences ()=0 |
Save the preferences Must be reimplemented in any subclasses. | |
virtual | ~PrefWidget () |
Destroys the widget and detaches it from its parameter group. | |
Friends | |
class | Gui::WidgetFactoryInst |
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.
Definition at line 54 of file PrefWidgets.h.
PrefWidget::PrefWidget | ( | ) | [protected] |
Constructs a preference widget.
Definition at line 37 of file PrefWidgets.cpp.
PrefWidget::~PrefWidget | ( | ) | [protected, virtual] |
Destroys the widget and detaches it from its parameter group.
Definition at line 45 of file PrefWidgets.cpp.
References Gui::WindowParameter::getWindowParameter().
QByteArray PrefWidget::entryName | ( | ) | const [virtual] |
Returns the widget's preference name.
Reimplemented in Gui::PrefSpinBox, Gui::PrefDoubleSpinBox, Gui::PrefLineEdit, Gui::PrefFileChooser, Gui::PrefComboBox, Gui::PrefCheckBox, Gui::PrefRadioButton, Gui::PrefSlider, and Gui::PrefColorButton.
Definition at line 58 of file PrefWidgets.cpp.
Referenced by onSave().
void PrefWidget::OnChange | ( | Base::Subject< const char * > & | rCaller, | |
const char * | sReason | |||
) | [virtual] |
This method is called if one ore 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.
Reimplemented from Gui::WindowParameter.
Definition at line 98 of file PrefWidgets.cpp.
References restorePreferences().
void PrefWidget::onRestore | ( | ) |
Restores the preferences of the widget.
Definition at line 122 of file PrefWidgets.cpp.
References Gui::WindowParameter::getWindowParameter(), draftlibs::fcgeo::isNull(), and restorePreferences().
Referenced by InspectionGui::VisualInspection::loadSettings(), Gui::Dialog::DlgSettingsViewColor::loadSettings(), RaytracingGui::DlgSettingsRayImp::loadSettings(), MeshGui::DlgSettingsMeshView::loadSettings(), Gui::Dialog::DlgSettingsMacroImp::loadSettings(), Gui::Dialog::DlgSettingsDocumentImp::loadSettings(), Gui::Dialog::DlgSettings3DViewImp::loadSettings(), Gui::Dialog::DlgReportViewImp::loadSettings(), Gui::Dialog::DlgOnlineHelpImp::loadSettings(), Gui::Dialog::DlgGeneralImp::loadSettings(), and Gui::Dialog::DlgSettingsEditorImp::loadSettings().
void PrefWidget::onSave | ( | ) |
Saves the current preferences of the widget.
All preference widget attached to the same parameter group are notified.
Definition at line 108 of file PrefWidgets.cpp.
References entryName(), Gui::WindowParameter::getWindowParameter(), and savePreferences().
Referenced by InspectionGui::VisualInspection::saveSettings(), Gui::Dialog::DlgSettingsViewColor::saveSettings(), RaytracingGui::DlgSettingsRayImp::saveSettings(), MeshGui::DlgSettingsMeshView::saveSettings(), Gui::Dialog::DlgSettingsMacroImp::saveSettings(), Gui::Dialog::DlgSettingsDocumentImp::saveSettings(), Gui::Dialog::DlgSettings3DViewImp::saveSettings(), Gui::Dialog::DlgReportViewImp::saveSettings(), Gui::Dialog::DlgOnlineHelpImp::saveSettings(), Gui::Dialog::DlgGeneralImp::saveSettings(), and Gui::Dialog::DlgSettingsEditorImp::saveSettings().
QByteArray PrefWidget::paramGrpPath | ( | ) | const [virtual] |
Returns the widget's preferences path.
Reimplemented in Gui::PrefSpinBox, Gui::PrefDoubleSpinBox, Gui::PrefLineEdit, Gui::PrefFileChooser, Gui::PrefComboBox, Gui::PrefCheckBox, Gui::PrefRadioButton, Gui::PrefSlider, and Gui::PrefColorButton.
Definition at line 86 of file PrefWidgets.cpp.
Referenced by setParamGrpPath().
virtual void Gui::PrefWidget::restorePreferences | ( | ) | [protected, pure virtual] |
Restores the preferences Must be reimplemented in any subclasses.
Implemented in Gui::PrefSpinBox, Gui::PrefDoubleSpinBox, Gui::PrefLineEdit, Gui::PrefFileChooser, Gui::PrefComboBox, Gui::PrefCheckBox, Gui::PrefRadioButton, Gui::PrefSlider, and Gui::PrefColorButton.
Referenced by OnChange(), and onRestore().
virtual void Gui::PrefWidget::savePreferences | ( | ) | [protected, pure virtual] |
Save the preferences Must be reimplemented in any subclasses.
Implemented in Gui::PrefSpinBox, Gui::PrefDoubleSpinBox, Gui::PrefLineEdit, Gui::PrefFileChooser, Gui::PrefComboBox, Gui::PrefCheckBox, Gui::PrefRadioButton, Gui::PrefSlider, and Gui::PrefColorButton.
Referenced by onSave().
void PrefWidget::setEntryName | ( | const QByteArray & | name | ) | [virtual] |
Sets the preference name to name.
Reimplemented in Gui::PrefSpinBox, Gui::PrefDoubleSpinBox, Gui::PrefLineEdit, Gui::PrefFileChooser, Gui::PrefComboBox, Gui::PrefCheckBox, Gui::PrefRadioButton, Gui::PrefSlider, and Gui::PrefColorButton.
Definition at line 52 of file PrefWidgets.cpp.
void PrefWidget::setParamGrpPath | ( | const QByteArray & | path | ) | [virtual] |
Sets the preference path to path.
Reimplemented in Gui::PrefSpinBox, Gui::PrefDoubleSpinBox, Gui::PrefLineEdit, Gui::PrefFileChooser, Gui::PrefComboBox, Gui::PrefCheckBox, Gui::PrefRadioButton, Gui::PrefSlider, and Gui::PrefColorButton.
Definition at line 64 of file PrefWidgets.cpp.
References Base::Console(), Gui::WindowParameter::getWindowParameter(), paramGrpPath(), and Gui::WindowParameter::setGroupName().
friend class Gui::WidgetFactoryInst [friend] |
Definition at line 85 of file PrefWidgets.h.