BALL  1.4.2
 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 
159  protected:
160 
163 
167  void registerWidgets_();
168 
169  /*_ Registration for objects, that are not automatically supported.
170  Should no be needed, but if the need should arive, call it in the constructor of the derived class.
171  */
172  void registerObject_(QObject* widget);
173 
174  /*_ Unregistration for objects, that are automatically registered.
175  Should no be needed, but if the need should arive, call it in the constructor of the derived class
176  after registerWidgets_()
177  */
178  void unregisterObject_(QObject* widget);
179 
183  void registerWidgetForHelpSystem_(const QWidget* widget, const String& url);
184 
185  //_ Helper function to restore the values of the current stack widget or all values
186  void restoreValues_(bool all, const ValueMap& map);
187 
188  //_ Add a stack entry
189  void insertStackEntry_(QWidget*, const String& name);
190 
191  //_ Check if the object's data can be transformed into a string
192  bool isSupported_(QObject& widget);
193 
194  //_ Transform the object's data into a string
195  bool getValue_(const QObject* widget, String& value);
196 
197  //_ Restore the widget's data from a string
198  bool setValue_(QObject* widget, const String& value);
199 
200  // name for the section in the INIFile
202 
203  // all registered child objects
205 
206  // stored default and last values for each registered object
207  ValueMap default_values_, last_values_;
208 
209  // if the derived class has its own QStackedWidget, it is stored here
210  QStackedWidget* widget_stack_;
211 
213  };
214 
215  } // namespace VIEW
216 } // namespace BALL
217 
218 #endif // BALL_VIEW_KERNEL_PREFERENCES_ENTRY