BALL  1.4.79
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
BALL::VIEW::PreferencesEntry Class Reference

#include <BALL/VIEW/KERNEL/preferencesEntry.h>

Inheritance diagram for BALL::VIEW::PreferencesEntry:
BALL::VIEW::AmberConfigurationDialog BALL::VIEW::AssignBondOrderConfigurationDialog BALL::VIEW::CharmmConfigurationDialog BALL::VIEW::ColoringSettingsDialog BALL::VIEW::ConfigDialog BALL::VIEW::DisplayProperties BALL::VIEW::DockDialog BALL::VIEW::EditSettings BALL::VIEW::FDPBDialog BALL::VIEW::GeometricFitDialog BALL::VIEW::LightSettings BALL::VIEW::MainControlPreferences BALL::VIEW::MaterialSettings BALL::VIEW::MinimizationDialog BALL::VIEW::MMFF94ConfigurationDialog BALL::VIEW::ModelSettingsDialog BALL::VIEW::MolecularDynamicsDialog BALL::VIEW::NetworkPreferences BALL::VIEW::OpenSavePreferences BALL::VIEW::PluginDialog BALL::VIEW::PythonSettings BALL::VIEW::ServerPreferences BALL::VIEW::ShortcutDialog BALL::VIEW::StageSettings

Classes

class  ExtendedPreferencesObject
 

Public Types

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

Public Member Functions

 PreferencesEntry ()
 
virtual ~PreferencesEntry ()
 
virtual void writePreferenceEntries (INIFile &inifile)
 Store the settings of all registered objects. More...
 
virtual void readPreferenceEntries (const INIFile &inifile)
 Restore the settings of all registered objects. More...
 
void setINIFileSectionName (const String &name)
 Set the name for the section in the INIFile. More...
 
const StringgetINIFileSectionName () const
 Get the name for the section in the INIFile. More...
 
void setWidgetStackName (const String &name)
 
StackPagesgetStackPages ()
 Return all pages, that are to be shown in a parent QStackedWidget. More...
 
void setWidgetStack (QStackedWidget *stack)
 
virtual void showStackPage (Position nr)
 Show the specified page in the QStackedWidget. More...
 
virtual void showStackPage (QWidget *widget)
 Show the specified page in the QStackedWidget. More...
 
virtual Position currentStackPage () const
 Get the currently shown page in the QStackedWidget. More...
 
virtual void restoreDefaultValues (bool all=false)
 Set all registered objects to their default values. More...
 
virtual void storeValues ()
 
virtual void restoreValues (bool all=false)
 
virtual void dump (std::ostream &s=std::cout, Size depth=0) const
 
virtual bool setValueAllowed (QObject *)
 Allows to prevent restoring of widgets. More...
 

Protected Types

typedef HashMap< const QObject *, StringValueMap
 

Protected Member Functions

void registerWidgets_ ()
 
void registerObject_ (QObject *widget)
 
void unregisterObject_ (QObject *widget)
 
void registerWidgetForHelpSystem_ (const QWidget *widget, const String &url)
 
void restoreValues_ (bool all, const ValueMap &map)
 
void insertStackEntry_ (QWidget *, const String &name)
 
bool isSupported_ (QObject &widget)
 
bool getValue_ (const QObject *widget, String &value)
 
bool setValue_ (QObject *widget, const String &value)
 

Protected Attributes

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

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). This object only needs to be a QObject with the PreferencesEntry as parent. \ 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

Definition at line 68 of file preferencesEntry.h.

Member Typedef Documentation

§ StackPages

typedef std::list<std::pair<QWidget*, String> > BALL::VIEW::PreferencesEntry::StackPages

Definition at line 96 of file preferencesEntry.h.

§ ValueMap

Definition at line 165 of file preferencesEntry.h.

Constructor & Destructor Documentation

§ PreferencesEntry()

BALL::VIEW::PreferencesEntry::PreferencesEntry ( )

§ ~PreferencesEntry()

virtual BALL::VIEW::PreferencesEntry::~PreferencesEntry ( )
virtual

Member Function Documentation

§ currentStackPage()

virtual Position BALL::VIEW::PreferencesEntry::currentStackPage ( ) const
virtual

Get the currently shown page in the QStackedWidget.

§ dump()

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

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

Parameters
soutput stream where to output the internal state
depththe dumping depth

§ getINIFileSectionName()

const String& BALL::VIEW::PreferencesEntry::getINIFileSectionName ( ) const
inline

Get the name for the section in the INIFile.

Definition at line 114 of file preferencesEntry.h.

§ getStackPages()

StackPages& BALL::VIEW::PreferencesEntry::getStackPages ( )
inline

Return all pages, that are to be shown in a parent QStackedWidget.

Definition at line 122 of file preferencesEntry.h.

§ getValue_()

bool BALL::VIEW::PreferencesEntry::getValue_ ( const QObject widget,
String value 
)
protected

§ insertStackEntry_()

void BALL::VIEW::PreferencesEntry::insertStackEntry_ ( QWidget ,
const String name 
)
protected

§ isSupported_()

bool BALL::VIEW::PreferencesEntry::isSupported_ ( QObject widget)
protected

§ readPreferenceEntries()

virtual void BALL::VIEW::PreferencesEntry::readPreferenceEntries ( const INIFile inifile)
virtual

Restore the settings of all registered objects.

Reimplemented in BALL::VIEW::PluginDialog, BALL::VIEW::MainControlPreferences, and BALL::VIEW::PythonSettings.

§ registerObject_()

void BALL::VIEW::PreferencesEntry::registerObject_ ( QObject widget)
protected

§ registerWidgetForHelpSystem_()

void BALL::VIEW::PreferencesEntry::registerWidgetForHelpSystem_ ( const QWidget widget,
const String url 
)
protected

Register a widget for the internal help system

See also
HelpViewer

§ registerWidgets_()

void BALL::VIEW::PreferencesEntry::registerWidgets_ ( )
protected

Register all supported child objects for the storing of their data. Must be called at the end of the child classes constructor.

§ restoreDefaultValues()

virtual void BALL::VIEW::PreferencesEntry::restoreDefaultValues ( bool  all = false)
virtual

Set all registered objects to their default values.

Reimplemented in BALL::VIEW::LightSettings.

§ restoreValues()

virtual void BALL::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 BALL::VIEW::LightSettings.

§ restoreValues_()

void BALL::VIEW::PreferencesEntry::restoreValues_ ( bool  all,
const ValueMap map 
)
protected

§ setINIFileSectionName()

void BALL::VIEW::PreferencesEntry::setINIFileSectionName ( const String name)
inline

Set the name for the section in the INIFile.

Definition at line 111 of file preferencesEntry.h.

§ setValue_()

bool BALL::VIEW::PreferencesEntry::setValue_ ( QObject widget,
const String value 
)
protected

§ setValueAllowed()

virtual bool BALL::VIEW::PreferencesEntry::setValueAllowed ( QObject )
inlinevirtual

Allows to prevent restoring of widgets.

Reimplemented in BALL::VIEW::StageSettings.

Definition at line 160 of file preferencesEntry.h.

§ setWidgetStack()

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

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

§ setWidgetStackName()

void BALL::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.

§ showStackPage() [1/2]

virtual void BALL::VIEW::PreferencesEntry::showStackPage ( Position  nr)
virtual

Show the specified page in the QStackedWidget.

§ showStackPage() [2/2]

virtual void BALL::VIEW::PreferencesEntry::showStackPage ( QWidget widget)
virtual

Show the specified page in the QStackedWidget.

§ storeValues()

virtual void BALL::VIEW::PreferencesEntry::storeValues ( )
virtual

Store the values for later restoration by the restoreValues method. Called e.g. by the Preferences dialog apply button.

Reimplemented in BALL::VIEW::OpenSavePreferences.

§ unregisterObject_()

void BALL::VIEW::PreferencesEntry::unregisterObject_ ( QObject widget)
protected

§ writePreferenceEntries()

virtual void BALL::VIEW::PreferencesEntry::writePreferenceEntries ( INIFile inifile)
virtual

Member Data Documentation

§ default_values_

ValueMap BALL::VIEW::PreferencesEntry::default_values_
protected

Definition at line 210 of file preferencesEntry.h.

§ inifile_section_name_

String BALL::VIEW::PreferencesEntry::inifile_section_name_
protected

Definition at line 204 of file preferencesEntry.h.

§ last_values_

ValueMap BALL::VIEW::PreferencesEntry::last_values_
protected

Definition at line 210 of file preferencesEntry.h.

§ registered_objects_

HashSet<QObject*> BALL::VIEW::PreferencesEntry::registered_objects_
protected

Definition at line 207 of file preferencesEntry.h.

§ stack_pages_

StackPages BALL::VIEW::PreferencesEntry::stack_pages_
protected

Definition at line 215 of file preferencesEntry.h.

§ widget_stack_

QStackedWidget* BALL::VIEW::PreferencesEntry::widget_stack_
protected

Definition at line 213 of file preferencesEntry.h.