00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 00005 #ifndef BALL_VIEW_DIALOGS_PREFERENCES_H 00006 #define BALL_VIEW_DIALOGS_PREFERENCES_H 00007 00008 #ifndef BALL_COMMON_GLOBAL_H 00009 # include <BALL/COMMON/global.h> 00010 #endif 00011 00012 #ifndef BALL_DATATYPE_STRING_H 00013 # include <BALL/DATATYPE/string.h> 00014 #endif 00015 00016 #ifndef BALL_DATATYPE_HASHSET_H 00017 # include <BALL/DATATYPE/hashSet.h> 00018 #endif 00019 00020 #ifndef BALL_DATATYPE_HASHMAP_H 00021 # include <BALL/DATATYPE/hashMap.h> 00022 #endif 00023 00024 #include <BALL/VIEW/UIC/ui_preferences.h> 00025 00026 namespace BALL 00027 { 00028 class INIFile; 00029 00030 namespace VIEW 00031 { 00032 class PreferencesEntry; 00033 00040 class BALL_VIEW_EXPORT Preferences 00041 : public QDialog, 00042 public Ui_PreferencesData 00043 { 00044 Q_OBJECT 00045 00046 public: 00047 00051 00062 Preferences(QWidget *parent = NULL, const char *name = "Preferences"); 00063 00065 Preferences(const Preferences& preferences); 00066 00068 virtual ~Preferences(); 00069 00071 00074 00078 bool hasPages(); 00079 00086 void insertEntry(PreferencesEntry *child); 00087 00093 void removeEntry(PreferencesEntry *child); 00094 00100 void fetchPreferences(INIFile &inifile); 00101 00107 void writePreferences(INIFile &inifile); 00108 00110 const QWidget* currentEntry() const; 00111 00113 const QWidget* currentPage() const; 00114 00115 public slots: 00116 00118 00121 00124 void show(); 00125 00127 void showEntry(QWidget* page); 00128 00130 void entrySelected(); 00131 00133 void setDefaultValues(); 00134 00136 void cancelPreferences(); 00137 00139 void applyPreferences(); 00140 00142 void showHelp(); 00143 00144 protected: 00145 00146 void removeItem_(QTreeWidgetItem* item, bool update); 00147 00148 HashSet<PreferencesEntry*> entries_; 00149 HashMap<QTreeWidgetItem*, QWidget*> item_to_widget_; 00150 HashMap<QTreeWidgetItem*, PreferencesEntry*> item_to_entry_; 00151 HashMap<QWidget*, QTreeWidgetItem*> widget_to_item_; 00152 00154 }; 00155 00156 } // namespace VIEW 00157 } // namespace BALL 00158 00159 #endif // BALL_VIEW_DIALOGS_PREFERENCES_H