BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
15 # include <BALL/DATATYPE/hashSet.h>
16 #endif
17 
18 
19 class QWidget;
20 class QObject;
21 class QStackedWidget;
22 
23 namespace 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 
102  virtual ~PreferencesEntry();
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 
170  void registerWidgets_();
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  */
175  void registerObject_(QObject* widget);
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  */
181  void unregisterObject_(QObject* widget);
182 
186  void registerWidgetForHelpSystem_(const QWidget* widget, const String& url);
187 
188  //_ Helper function to restore the values of the current stack widget or all values
189  void restoreValues_(bool all, const ValueMap& map);
190 
191  //_ Add a stack entry
192  void insertStackEntry_(QWidget*, const String& name);
193 
194  //_ Check if the object's data can be transformed into a string
195  bool isSupported_(QObject& widget);
196 
197  //_ Transform the object's data into a string
198  bool getValue_(const QObject* widget, String& value);
199 
200  //_ Restore the widget's data from a string
201  bool setValue_(QObject* widget, const String& value);
202 
203  // name for the section in the INIFile
205 
206  // all registered child objects
208 
209  // stored default and last values for each registered object
210  ValueMap default_values_, last_values_;
211 
212  // if the derived class has its own QStackedWidget, it is stored here
213  QStackedWidget* widget_stack_;
214 
216  };
217 
218  } // namespace VIEW
219 } // namespace BALL
220 
221 #endif // BALL_VIEW_KERNEL_PREFERENCES_ENTRY
StackPages & getStackPages()
Return all pages, that are to be shown in a parent QStackedWidget.
const String & getINIFileSectionName() const
Get the name for the section in the INIFile.
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
virtual bool setValueAllowed(QObject *)
Allows to prevent restoring of widgets.
std::list< std::pair< QWidget *, String > > StackPages
HashMap< const QObject *, String > ValueMap
void setINIFileSectionName(const String &name)
Set the name for the section in the INIFile.
HashSet< QObject * > registered_objects_