Loading...
Searching...
No Matches
preferencesEntry.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: preferencesEntry.h,v 1.10.16.1 2007/03/25 21:26:02 oliver Exp $
//
#ifndef BALL_VIEW_KERNEL_PREFERENCES_ENTRY
#define BALL_VIEW_KERNEL_PREFERENCES_ENTRY
#ifndef BALL_FORMAT_INIFILE_H
# include <BALL/FORMAT/INIFile.h>
#endif
#ifndef BALL_DATATYPE_HASHSET_H
# include <BALL/DATATYPE/hashSet.h>
#endif
class QWidget;
class QObject;
class QStackedWidget;
namespace BALL
{
class INIFile;
namespace VIEW
{
class BALL_VIEW_EXPORT PreferencesEntry
{
public:
class BALL_VIEW_EXPORT ExtendedPreferencesObject
{
public:
ExtendedPreferencesObject() {};
virtual ~ExtendedPreferencesObject() {};
virtual bool getValue(String&) const = 0;
virtual bool setValue(const String&) = 0;
};
typedef std::list<std::pair<QWidget*, String> > StackPages;
PreferencesEntry();
virtual ~PreferencesEntry();
virtual void writePreferenceEntries(INIFile& inifile);
virtual void readPreferenceEntries(const INIFile& inifile);
void setINIFileSectionName(const String& name) { inifile_section_name_ = name;}
const String& getINIFileSectionName() const { return inifile_section_name_;}
void setWidgetStackName(const String& name);
StackPages& getStackPages() { return stack_pages_;}
void setWidgetStack(QStackedWidget* stack);
virtual void showStackPage(Position nr);
virtual void showStackPage(QWidget* widget);
virtual Position currentStackPage() const;
virtual void restoreDefaultValues(bool all = false);
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* /*widget*/) { return true; }
protected:
typedef HashMap<const QObject*, String> ValueMap;
void registerWidgets_();
/*_ Registration for objects, that are not automatically supported.
Should no be needed, but if the need should arive, call it in the constructor of the derived class.
*/
void registerObject_(QObject* widget);
/*_ Unregistration for objects, that are automatically registered.
Should no be needed, but if the need should arive, call it in the constructor of the derived class
after registerWidgets_()
*/
void unregisterObject_(QObject* widget);
BALL_DEPRECATED void registerWidgetForHelpSystem_(const QWidget* /* widget */, const String& /* url */);
//_ Helper function to restore the values of the current stack widget or all values
void restoreValues_(bool all, const ValueMap& map);
//_ Add a stack entry
void insertStackEntry_(QWidget*, const String& name);
//_ Check if the object's data can be transformed into a string
bool isSupported_(QObject& widget);
//_ Transform the object's data into a string
bool getValue_(const QObject* widget, String& value);
//_ Restore the widget's data from a string
bool setValue_(QObject* widget, const String& value);
// name for the section in the INIFile
String inifile_section_name_;
// all registered child objects
HashSet<QObject*> registered_objects_;
// stored default and last values for each registered object
ValueMap default_values_, last_values_;
// if the derived class has its own QStackedWidget, it is stored here
QStackedWidget* widget_stack_;
StackPages stack_pages_;
};
} // namespace VIEW
} // namespace BALL
#endif // BALL_VIEW_KERNEL_PREFERENCES_ENTRY
BALL_DEPRECATED
#define BALL_DEPRECATED
Definition COMMON/global.h:64
BALL_VIEW_EXPORT
#define BALL_VIEW_EXPORT
Definition COMMON/global.h:52
INIFile.h
BALL::HashMap
HashMap class based on the STL map (containing serveral convenience functions).
Definition hashMap.h:74
BALL::HashSet
Definition hashSet.h:46
BALL::INIFile
Definition INIFile.h:29
BALL::String
Definition string.h:57
BALL::VIEW::PreferencesEntry::ExtendedPreferencesObject::getValue
virtual bool getValue(String &) const =0
Overload this in derived classes!
BALL::VIEW::PreferencesEntry::ExtendedPreferencesObject::setValue
virtual bool setValue(const String &)=0
Overload this in derived classes!
BALL::VIEW::PreferencesEntry::ExtendedPreferencesObject::~ExtendedPreferencesObject
virtual ~ExtendedPreferencesObject()
Definition preferencesEntry.h:86
BALL::VIEW::PreferencesEntry::ExtendedPreferencesObject::ExtendedPreferencesObject
ExtendedPreferencesObject()
Definition preferencesEntry.h:83
BALL::VIEW::PreferencesEntry::getValue_
bool getValue_(const QObject *widget, String &value)
BALL::VIEW::PreferencesEntry::default_values_
ValueMap default_values_
Definition preferencesEntry.h:208
BALL::VIEW::PreferencesEntry::isSupported_
bool isSupported_(QObject &widget)
BALL::VIEW::PreferencesEntry::currentStackPage
virtual Position currentStackPage() const
Get the currently shown page in the QStackedWidget.
BALL::VIEW::PreferencesEntry::restoreDefaultValues
virtual void restoreDefaultValues(bool all=false)
Set all registered objects to their default values.
BALL::VIEW::PreferencesEntry::StackPages
std::list< std::pair< QWidget *, String > > StackPages
Definition preferencesEntry.h:96
BALL::VIEW::PreferencesEntry::getINIFileSectionName
const String & getINIFileSectionName() const
Get the name for the section in the INIFile.
Definition preferencesEntry.h:114
BALL::VIEW::PreferencesEntry::~PreferencesEntry
virtual ~PreferencesEntry()
BALL::VIEW::PreferencesEntry::ValueMap
HashMap< const QObject *, String > ValueMap
Definition preferencesEntry.h:165
BALL::VIEW::PreferencesEntry::setWidgetStack
void setWidgetStack(QStackedWidget *stack)
BALL::VIEW::PreferencesEntry::setWidgetStackName
void setWidgetStackName(const String &name)
BALL::VIEW::PreferencesEntry::restoreValues
virtual void restoreValues(bool all=false)
BALL::VIEW::PreferencesEntry::showStackPage
virtual void showStackPage(Position nr)
Show the specified page in the QStackedWidget.
BALL::VIEW::PreferencesEntry::PreferencesEntry
PreferencesEntry()
BALL::VIEW::PreferencesEntry::registerWidgets_
void registerWidgets_()
BALL::VIEW::PreferencesEntry::writePreferenceEntries
virtual void writePreferenceEntries(INIFile &inifile)
Store the settings of all registered objects.
BALL::VIEW::PreferencesEntry::insertStackEntry_
void insertStackEntry_(QWidget *, const String &name)
BALL::VIEW::PreferencesEntry::last_values_
ValueMap last_values_
Definition preferencesEntry.h:208
BALL::VIEW::PreferencesEntry::setValueAllowed
virtual bool setValueAllowed(QObject *)
Allows to prevent restoring of widgets.
Definition preferencesEntry.h:160
BALL::VIEW::PreferencesEntry::inifile_section_name_
String inifile_section_name_
Definition preferencesEntry.h:202
BALL::VIEW::PreferencesEntry::setValue_
bool setValue_(QObject *widget, const String &value)
BALL::VIEW::PreferencesEntry::registered_objects_
HashSet< QObject * > registered_objects_
Definition preferencesEntry.h:205
BALL::VIEW::PreferencesEntry::showStackPage
virtual void showStackPage(QWidget *widget)
Show the specified page in the QStackedWidget.
BALL::VIEW::PreferencesEntry::getStackPages
StackPages & getStackPages()
Return all pages, that are to be shown in a parent QStackedWidget.
Definition preferencesEntry.h:122
BALL::VIEW::PreferencesEntry::stack_pages_
StackPages stack_pages_
Definition preferencesEntry.h:213
BALL::VIEW::PreferencesEntry::setINIFileSectionName
void setINIFileSectionName(const String &name)
Set the name for the section in the INIFile.
Definition preferencesEntry.h:111
BALL::VIEW::PreferencesEntry::unregisterObject_
void unregisterObject_(QObject *widget)
BALL::VIEW::PreferencesEntry::dump
virtual void dump(std::ostream &s=std::cout, Size depth=0) const
BALL::VIEW::PreferencesEntry::readPreferenceEntries
virtual void readPreferenceEntries(const INIFile &inifile)
Restore the settings of all registered objects.
BALL::VIEW::PreferencesEntry::storeValues
virtual void storeValues()
BALL::VIEW::PreferencesEntry::restoreValues_
void restoreValues_(bool all, const ValueMap &map)
BALL::VIEW::PreferencesEntry::registerObject_
void registerObject_(QObject *widget)
BALL::VIEW::PreferencesEntry::registerWidgetForHelpSystem_
BALL_DEPRECATED void registerWidgetForHelpSystem_(const QWidget *, const String &)
BALL::VIEW::PreferencesEntry::widget_stack_
QStackedWidget * widget_stack_
Definition preferencesEntry.h:211
QObject
QWidget
hashSet.h
BALL::VIEW
Definition constraints.h:35
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::Position
BALL_SIZE_TYPE Position
Definition COMMON/global.h:140