Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

VIEW::PreferencesEntry Class Reference

Base class for a dialog or a Preferences page. More...

#include <preferencesEntry.h>

Inheritance diagram for VIEW::PreferencesEntry:

VIEW::AmberConfigurationDialog VIEW::CharmmConfigurationDialog VIEW::ColoringSettingsDialog VIEW::DisplayProperties VIEW::DockDialog VIEW::EditSettings VIEW::FDPBDialog VIEW::GeometricFitDialog VIEW::LightSettings VIEW::MainControlPreferences VIEW::MaterialSettings VIEW::MinimizationDialog VIEW::MMFF94ConfigurationDialog VIEW::ModelSettingsDialog VIEW::MolecularDynamicsDialog VIEW::NetworkPreferences VIEW::PythonSettings VIEW::ServerPreferences VIEW::StageSettings List of all members.

Public Types

typedef List< std::pair< QWidget *,
String > > 
StackPages

Public Member Functions

virtual void writePreferenceEntries (INIFile &inifile)
 Store the settings of all registered objects.
virtual void readPreferenceEntries (const INIFile &inifile)
 Restore the settings of all registered objects.
void setINIFileSectionName (const String &name)
 Set the name for the section in the INIFile.
const StringgetINIFileSectionName () const
 Get the name for the section in the INIFile.
void setWidgetStackName (const String &name)
 If the derived class is to be shown in a QStackedWidget, call this method to set the name for its entry.
StackPagesgetStackPages ()
 Return all pages, that are to be shown in a parent QStackedWidget.
void setWidgetStack (QStackedWidget *stack)
 Call this method in the constructor of the derived class has its own QStackedWidget.
virtual void showStackPage (Position nr)
 Show the specified page in the QStackedWidget.
virtual void showStackPage (QWidget *widget)
 Show the specified page in the QStackedWidget.
virtual Position currentStackPage () const
 Get the currently shown page in the QStackedWidget.
virtual void restoreDefaultValues (bool all=false)
 Set all registered objects to their default values.
virtual void storeValues ()
 Store the values for later restoration by the restoreValues method.
virtual void restoreValues (bool all=false)
 Restore the values of the child widgets.
virtual void dump (std::ostream &s=std::cout, Size depth=0) const throw ()
 Internal state dump.

Protected Types

typedef HashMap< const QWidget *,
String
ValueMap

Protected Member Functions

void registerWidgets_ ()
 Register all supported child widgets for the storing of their data.
void registerWidget_ (QWidget *widget)
void unregisterWidget_ (QWidget *widget)
void registerWidgetForHelpSystem_ (const QWidget *widget, const String &url)
 Register a widget for the internal help system.
void restoreValues_ (bool all, const ValueMap &map)
void insertStackEntry_ (QWidget *, const String &name)
bool isSupported_ (QWidget &widget)
bool getValue_ (const QWidget *widget, String &value)
bool setValue_ (QWidget *widget, const String &value)

Protected Attributes

String inifile_section_name_
HashSet< QWidget * > registered_objects_
ValueMap default_values_
ValueMap last_values_
QStackedWidget * widget_stack_
StackPages stack_pages_

Friends

class PreferencesObject

Detailed Description

Base class for a dialog or a Preferences page.

It allows to register child widgets to support reading and writing their data into a INIFile. Also restoring of a default value and the last applied value is supported. Currently the following Qt widgets are supported:

To support more sophisticated items, e.g. color tables, a base class is provided to derive from (see ExtendedPreferencesObject). \ Furthermore this class allows to use QStackedWidget items, like e.g. in the Preferences, where all individual child widgets are then also entries in a QListView. \ \ How to use this class:
  1. Derive from it.
  2. Ensure, that all child widgets have a unique name (see QWidget::setObjectName)
  3. Modify the constructor of the derived class:
  4. Make sure that every GUI element is set to its default value.
  5. Call registerWidgets_(), which automatically registeres all supported child widgets
  6. Call setINIFileSectionName(String)
  7. If the dialog is a page in a QStackedWidget (like in the Preferences dialog) call insertEntry(this, "Name to appear in the listview").
  8. If the dialog itself has a QStackedWidget call setWidgetStack() for it and set the names of the QStackedWidget pages accordingly.
See also:
ModelSettings for an example


Member Function Documentation

virtual void VIEW::PreferencesEntry::dump std::ostream &  s = std::cout,
Size  depth = 0
const throw () [virtual]
 

Internal state dump.

Dump the current internal state of this mainControl to the output ostream s with dumping depth depth.

Parameters:
s output stream where to output the internal state
depth the dumping depth

void VIEW::PreferencesEntry::registerWidgetForHelpSystem_ const QWidget *  widget,
const String url
[protected]
 

Register a widget for the internal help system.

See also:
HelpViewer

void VIEW::PreferencesEntry::registerWidgets_  )  [protected]
 

Register all supported child widgets for the storing of their data.

Must be called at the end of the child classes constructor.

virtual void VIEW::PreferencesEntry::restoreValues bool  all = false  )  [virtual]
 

Restore the values of the child widgets.

Called e.g. when a user presses a Cancel button.

Reimplemented in VIEW::LightSettings.

void VIEW::PreferencesEntry::setWidgetStack QStackedWidget *  stack  ) 
 

Call this method in the constructor of the derived class has its own QStackedWidget.

void VIEW::PreferencesEntry::setWidgetStackName const String name  ) 
 

If the derived class is to be shown in a QStackedWidget, call this method to set the name for its entry.

virtual void VIEW::PreferencesEntry::storeValues  )  [virtual]
 

Store the values for later restoration by the restoreValues method.

Called e.g. by the Preferences dialog apply button.