BALL  1.5.0
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 
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
208  ValueMap default_values_, last_values_;
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
BALL_VIEW_EXPORT
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
BALL::VIEW::PreferencesEntry::getStackPages
StackPages & getStackPages()
Return all pages, that are to be shown in a parent QStackedWidget.
Definition: preferencesEntry.h:122
BALL::HashSet< QObject * >
QWidget
BALL::HashMap< const QObject *, String >
BALL::VIEW::PreferencesEntry::getINIFileSectionName
const String & getINIFileSectionName() const
Get the name for the section in the INIFile.
Definition: preferencesEntry.h:114
BALL::VIEW::PreferencesEntry::setINIFileSectionName
void setINIFileSectionName(const String &name)
Set the name for the section in the INIFile.
Definition: preferencesEntry.h:111
BALL_SIZE_TYPE
BALL::VIEW::PreferencesEntry::ExtendedPreferencesObject::~ExtendedPreferencesObject
virtual ~ExtendedPreferencesObject()
Definition: preferencesEntry.h:86
QObject
BALL
Definition: constants.h:12
BALL::VIEW::PreferencesEntry::stack_pages_
StackPages stack_pages_
Definition: preferencesEntry.h:213
BALL::String
Definition: string.h:56
BALL_DEPRECATED
#define BALL_DEPRECATED
Definition: COMMON/global.h:64
BALL::VIEW::PreferencesEntry
Definition: preferencesEntry.h:68
BALL::VIEW::PreferencesEntry::ValueMap
HashMap< const QObject *, String > ValueMap
Definition: preferencesEntry.h:165
BALL::VIEW::PreferencesEntry::StackPages
std::list< std::pair< QWidget *, String > > StackPages
Definition: preferencesEntry.h:96
hashSet.h
BALL::VIEW::PreferencesEntry::inifile_section_name_
String inifile_section_name_
Definition: preferencesEntry.h:202
INIFile.h
BALL::INIFile
Definition: INIFile.h:28
BALL::VIEW::PreferencesEntry::setValueAllowed
virtual bool setValueAllowed(QObject *)
Allows to prevent restoring of widgets.
Definition: preferencesEntry.h:160
BALL::VIEW::PreferencesEntry::ExtendedPreferencesObject
Definition: preferencesEntry.h:78
BALL::VIEW::PreferencesEntry::ExtendedPreferencesObject::ExtendedPreferencesObject
ExtendedPreferencesObject()
Definition: preferencesEntry.h:83
BALL::VIEW::PreferencesEntry::last_values_
ValueMap last_values_
Definition: preferencesEntry.h:208
BALL::VIEW::PreferencesEntry::registered_objects_
HashSet< QObject * > registered_objects_
Definition: preferencesEntry.h:205
BALL::VIEW::PreferencesEntry::widget_stack_
QStackedWidget * widget_stack_
Definition: preferencesEntry.h:211