00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef PREFERENCES_H
00050 #define PREFERENCES_H
00051
00052 #include <qapplication.h>
00053 #include <qstring.h>
00054 #include <qmap.h>
00055 #include "teglobal.h"
00056
00057 class QColor;
00058 class QDomElement;
00059
00060 class LIB_EXPORT Preferences {
00061 public:
00062
00063 Preferences(const QString& filename, const QString& format, const QString& version);
00064
00065 virtual ~Preferences();
00066
00067
00068 const QString& file();
00069 const QString& format();
00070 const QString& version();
00071
00072 bool fileState();
00073
00074 bool formatState();
00075
00076
00077 const QString& getGroup();
00078 void setGroup(const QString& group);
00079
00080
00081 bool getBool(const QString& key, bool def = false);
00082 void setBool(const QString& key, bool value);
00083
00084 long getNumber(const QString& key, long def = 0);
00085 void setNumber(const QString& key, long value);
00086
00087 double getDouble(const QString& key, double def = 0.0);
00088 void setDouble(const QString& key, double value);
00089
00090 QString getString(const QString& key, const QString& def = "NULL");
00091 void setString(const QString& key, const QString& value);
00092
00093
00094 void removeKey(const QString& key);
00095
00096 void removeGroup();
00097
00098
00099 void flush();
00100
00101 protected:
00102
00103 void readData();
00104 void writeData();
00105 void processGroup(QDomElement group);
00106
00107 private:
00108 bool dirty_;
00109 QString currentgroup_;
00110 QString file_;
00111 QString format_;
00112 QString version_;
00113 QString buffer_;
00114 bool filestate_;
00115 bool formatstate_;
00116
00117
00118 typedef QMap<QString, QString> PrefMap;
00119
00120 #include "templexports.h"
00121
00122 QMap<QString, PrefMap> groups_;
00123 };
00124
00125
00126
00128
00129
00130 inline const QString& Preferences::file() { return file_; };
00131
00132 inline const QString& Preferences::format() { return format_; }
00133
00134 inline bool Preferences::fileState() { return filestate_; }
00135
00136 inline bool Preferences::formatState() { return formatstate_; }
00137
00138 inline void Preferences::setGroup(const QString& group) { currentgroup_ = group; }
00139
00140 inline const QString& Preferences::getGroup() { return currentgroup_; }
00141
00142 #endif // PREFERENCES