00001 #ifndef _CONFIG_EX_H_ 00002 #define _CONFIG_EX_H_ 00003 00004 #include <qstringlist.h> 00005 #include <qdatetime.h> 00006 #include <qfileinfo.h> 00007 #include <qtextstream.h> 00008 #include <qtextcodec.h> 00009 00010 #define QTOPIA_INTERNAL_LANGLIST 00011 #include <qpe/config.h> 00012 #include <qpe/global.h> 00013 00014 #define CONFIG_MULTICODEC 00015 00016 /* Singleton Object */ 00017 class ConfigEx : public Config 00018 { 00019 public: 00020 static ConfigEx& getInstance(const QString& name){ 00021 static ConfigEx cfg(name); 00022 if(/*cfg.flush() ||*/cfg.m_lastRead < cfg.lastModified()){ 00023 cfg.load(&cfg); 00024 } 00025 return(cfg); 00026 } 00027 00028 #if 0 00029 bool flush(){ 00030 if(changed){ 00031 write(); 00032 return(true); 00033 } else { 00034 return(false); 00035 } 00036 } 00037 #endif 00038 00039 const QString& getGroup(){ 00040 return(git.key()); 00041 } 00042 00043 void load(ConfigEx* cfg){ 00044 cfg->read(); 00045 cfg->decode(); 00046 cfg->m_lastRead = QDateTime::currentDateTime(); 00047 } 00048 00049 void setConfig(const QString& name){ 00050 if(name == QString::null){ 00051 return; 00052 } 00053 /*flush();*/ 00054 filename = configFilename(name, User); 00055 load(this); 00056 } 00057 00058 void reload() { 00059 /*flush();*/ 00060 load(this); 00061 } 00062 00063 QStringList getKeys(); 00064 QDateTime lastModified(); 00065 QDateTime lastRead(){ 00066 return(m_lastRead); 00067 } 00068 00069 friend class Dummy; /* for compie warning */ 00070 private: 00071 ConfigEx(const QString& name, Domain domain=User); 00072 ConfigEx& operator=(const ConfigEx&); 00073 virtual ~ConfigEx(){changed = false;} 00074 00075 class Dummy{}; /* for compile warning */ 00076 00077 00078 void read(); 00079 void decode(); 00080 //void removeComment(); 00081 00082 QDateTime m_lastRead; 00083 #ifdef CONFIG_MULTICODEC 00084 QString m_charset; 00085 #endif 00086 }; 00087 00088 #endif /* _CONFIG_EX_H_ */ 00089
1.4.2