8 /////////////////////////////////////////////////////////////////
10 /////////////////////////////////////////////////////////////////
11 SimpleSettings::SimpleSettings()
16 SimpleSettings::~SimpleSettings()
20 void SimpleSettings::clear()
26 void SimpleSettings::readSettings (const QString &path)
29 if (!loadStringFromDisk(path,s))
31 qWarning ("SimpleSettings::readSettings() Couldn't read "+path);
35 lines=QStringList::split (QRegExp("\n"),s,false);
37 QStringList::Iterator it=lines.begin();
38 while (it !=lines.end() )
41 keylist.append((*it).left(i));
42 valuelist.append((*it).right((*it).length()-i-1));
47 void SimpleSettings::writeSettings (const QString &path)
50 QStringList::Iterator itk=keylist.begin();
51 QStringList::Iterator itv=valuelist.begin();
53 // First search for value in settings saved in map
54 while (itk !=keylist.end() )
56 s+=*itk+"="+*itv+"\n";
60 if (!saveStringToDisk(path,s))
61 qWarning ("SimpleSettings::writeSettings() Couldn't write "+path);
64 QString SimpleSettings::readEntry (const QString &key)
66 QStringList::Iterator itk=keylist.begin();
67 QStringList::Iterator itv=valuelist.begin();
69 // First search for value in settings saved in map
70 while (itk !=keylist.end() )
77 qWarning ("SimpleSettings::readEntry() Couldn't find key "+key);
81 void SimpleSettings::setEntry (const QString &key, const QString &value)
83 QStringList::Iterator itk=keylist.begin();
84 QStringList::Iterator itv=valuelist.begin();
88 // Search for existing entry first
89 while (itk !=keylist.end() )
104 // If no entry exists, append a new one
105 keylist.append (key);
106 valuelist.append (value);
112 /////////////////////////////////////////////////////////////////
114 /////////////////////////////////////////////////////////////////
120 Settings::Settings(const QString & organization, const QString & application ):QSettings (organization,application)
125 Settings::~Settings()
129 void Settings::clear()
136 void Settings::clearLocal(const QString &s)
138 QStringList::Iterator itp=pathlist.begin();
139 QStringList::Iterator itk=keylist.begin();
140 QStringList::Iterator itv=valuelist.begin();
142 while (itp !=pathlist.end() )
144 if ((*itk).startsWith (s))
146 itp=pathlist.remove (itp);
147 itk=keylist.remove (itk);
148 itv=valuelist.remove (itv);
158 QString Settings::readLocalEntry ( const QString &fpath, const QString & key, const QString & def = QString::null )
160 QStringList::Iterator itp=pathlist.begin();
161 QStringList::Iterator itk=keylist.begin();
162 QStringList::Iterator itv=valuelist.begin();
164 // First search for value in settings saved in map
165 while (itp !=pathlist.end() )
167 if (*itp == fpath && *itk == key)
174 // Fall back to global vym settings
176 return readEntry (key,def, &ok);
179 void Settings::setLocalEntry (const QString &fpath, const QString &key, const QString &value)
181 QStringList::Iterator itp=pathlist.begin();
182 QStringList::Iterator itk=keylist.begin();
183 QStringList::Iterator itv=valuelist.begin();
185 if (!fpath.isEmpty() && !key.isEmpty() && !value.isEmpty() )
187 // Search for existing entry first
188 while (itp !=pathlist.end() )
190 if (*itp == fpath && *itk == key)
200 // If no entry exists, append a new one
201 pathlist.append (fpath);
202 keylist.append (key);
203 valuelist.append (value);
207 QString Settings::getXMLData (const QString &fpath)
210 QStringList::Iterator itp=pathlist.begin();
211 QStringList::Iterator itk=keylist.begin();
212 QStringList::Iterator itv=valuelist.begin();
214 while (itp !=pathlist.end() )
217 if (!(*itv).isEmpty())
220 attribut ("key",*itk)
221 +attribut ("value",*itv)