BALL 1.5.0
Loading...
Searching...
No Matches
preferencesEntry.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 2; -*-
2// vi: set ts=2:
3//
4// $Id: preferencesEntry.h,v 1.10.16.1 2007/03/25 21:26:02 oliver Exp $
5//
6
7#ifndef BALL_VIEW_KERNEL_PREFERENCES_ENTRY
8#define BALL_VIEW_KERNEL_PREFERENCES_ENTRY
9
10#ifndef BALL_FORMAT_INIFILE_H
11# include <BALL/FORMAT/INIFile.h>
12#endif
13
14#ifndef BALL_DATATYPE_HASHSET_H
16#endif
17
18
19class QWidget;
20class QObject;
21class QStackedWidget;
22
23namespace BALL
24{
25 class INIFile;
26
27 namespace VIEW
28 {
69 {
70 public:
71
79 {
80 public:
81
84
87
89 virtual bool getValue(String&) const = 0;
90
92 virtual bool setValue(const String&) = 0;
93 };
94
96 typedef std::list<std::pair<QWidget*, String> > StackPages;
97
100
103
105 virtual void writePreferenceEntries(INIFile& inifile);
106
108 virtual void readPreferenceEntries(const INIFile& inifile);
109
111 void setINIFileSectionName(const String& name) { inifile_section_name_ = name;}
112
114 const String& getINIFileSectionName() const { return inifile_section_name_;}
115
119 void setWidgetStackName(const String& name);
120
122 StackPages& getStackPages() { return stack_pages_;}
123
127 void setWidgetStack(QStackedWidget* stack);
128
130 virtual void showStackPage(Position nr);
131
133 virtual void showStackPage(QWidget* widget);
134
136 virtual Position currentStackPage() const;
137
139 virtual void restoreDefaultValues(bool all = false);
140
144 virtual void storeValues();
145
149 virtual void restoreValues(bool all = false);
150
157 virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
158
160 virtual bool setValueAllowed(QObject* /*widget*/) { return true; }
161
162 protected:
163
166
171
172 /*_ Registration for objects, that are not automatically supported.
173 Should no be needed, but if the need should arive, call it in the constructor of the derived class.
174 */
176
177 /*_ Unregistration for objects, that are automatically registered.
178 Should no be needed, but if the need should arive, call it in the constructor of the derived class
179 after registerWidgets_()
180 */
182
184 BALL_DEPRECATED void registerWidgetForHelpSystem_(const QWidget* /* widget */, const String& /* url */);
185
186 //_ Helper function to restore the values of the current stack widget or all values
187 void restoreValues_(bool all, const ValueMap& map);
188
189 //_ Add a stack entry
190 void insertStackEntry_(QWidget*, const String& name);
191
192 //_ Check if the object's data can be transformed into a string
193 bool isSupported_(QObject& widget);
194
195 //_ Transform the object's data into a string
196 bool getValue_(const QObject* widget, String& value);
197
198 //_ Restore the widget's data from a string
199 bool setValue_(QObject* widget, const String& value);
200
201 // name for the section in the INIFile
203
204 // all registered child objects
206
207 // stored default and last values for each registered object
209
210 // if the derived class has its own QStackedWidget, it is stored here
211 QStackedWidget* widget_stack_;
212
214 };
215
216 } // namespace VIEW
217} // namespace BALL
218
219#endif // BALL_VIEW_KERNEL_PREFERENCES_ENTRY
HashMap class based on the STL map (containing serveral convenience functions)
bool getValue_(const QObject *widget, String &value)
bool isSupported_(QObject &widget)
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.
const String & getINIFileSectionName() const
Get the name for the section in the INIFile.
void setWidgetStack(QStackedWidget *stack)
void setWidgetStackName(const String &name)
virtual void restoreValues(bool all=false)
virtual void showStackPage(Position nr)
Show the specified page in the QStackedWidget.
virtual void writePreferenceEntries(INIFile &inifile)
Store the settings of all registered objects.
void insertStackEntry_(QWidget *, const String &name)
virtual bool setValueAllowed(QObject *)
Allows to prevent restoring of widgets.
bool setValue_(QObject *widget, const String &value)
HashSet< QObject * > registered_objects_
virtual void showStackPage(QWidget *widget)
Show the specified page in the QStackedWidget.
StackPages & getStackPages()
Return all pages, that are to be shown in a parent QStackedWidget.
void setINIFileSectionName(const String &name)
Set the name for the section in the INIFile.
void unregisterObject_(QObject *widget)
HashMap< const QObject *, String > ValueMap
virtual void dump(std::ostream &s=std::cout, Size depth=0) const
virtual void readPreferenceEntries(const INIFile &inifile)
Restore the settings of all registered objects.
void restoreValues_(bool all, const ValueMap &map)
void registerObject_(QObject *widget)
BALL_DEPRECATED void registerWidgetForHelpSystem_(const QWidget *, const String &)
std::list< std::pair< QWidget *, String > > StackPages
virtual bool getValue(String &) const =0
Overload this in derived classes!
virtual bool setValue(const String &)=0
Overload this in derived classes!
#define BALL_DEPRECATED
#define BALL_VIEW_EXPORT