26 #include <QtCore/QByteArray>
27 #include <QtCore/QString>
28 #include <QtCore/QMap>
29 #include <QtCore/QDebug>
89 const QByteArray& _key = QByteArray(),
bool isLocalized=
false,
bool isDefault=
false)
163 Q_DECLARE_FLAGS(EntryOptions, EntryOption)
166 SearchFlags flags = SearchFlags())
178 Iterator
findEntry(
const QByteArray&
group,
const QByteArray& key = QByteArray(),
179 SearchFlags flags = SearchFlags())
187 Iterator it = find(theKey);
196 ConstIterator
findEntry(
const QByteArray& group,
const QByteArray& key = QByteArray(),
197 SearchFlags flags = SearchFlags())
const
205 ConstIterator it = find(theKey);
206 if (it != constEnd())
217 bool setEntry(
const QByteArray& group,
const QByteArray& key,
218 const QByteArray& value, EntryOptions options)
224 const Iterator it =
findExactEntry(group, key, SearchFlags(options>>16));
229 if (options&
EntryDeleted) { qWarning(
"Internal KConfig error: cannot mark groups as deleted"); }
233 }
else if(it.value() == e) {
250 ConstIterator cit = that->
findEntry(group);
251 if (cit == constEnd())
253 else if (cit->bImmutable)
300 KEntryKey theKey(group, key,
true,
false);
310 KEntryKey theKey(group, key,
true,
false);
312 Iterator cit = find(theKey);
319 Iterator cit = find(theKey);
335 void setEntry(
const QByteArray& group,
const QByteArray& key,
336 const QString & value, EntryOptions options)
338 setEntry(group, key, value.toUtf8(), options);
343 SearchFlags flags = SearchFlags(),
344 bool * expand=0)
const
346 const ConstIterator it =
findEntry(group, key, flags);
349 if (it != constEnd() && !it->bDeleted) {
350 if (!it->mValue.isNull()) {
351 const QByteArray data=it->mValue;
352 theValue = QString::fromUtf8(data.constData(), data.length());
354 *expand = it->bExpand;
363 bool hasEntry(
const QByteArray& group,
const QByteArray& key = QByteArray(),
364 SearchFlags flags = SearchFlags())
const
366 const ConstIterator it =
findEntry(group, key, flags);
367 if (it == constEnd())
372 return it->mValue.isNull();
379 if (it != constEnd()) {
384 return it.key().bLocal;
388 return it->bImmutable;
401 SearchFlags flags, EntryOption option)
const
430 void setEntryOption(
const QByteArray& group,
const QByteArray& key, SearchFlags flags,
431 EntryOption option,
bool bf)
436 void revertEntry(
const QByteArray& group,
const QByteArray& key, SearchFlags flags=SearchFlags())
438 Iterator entry =
findEntry(group, key, flags);
439 if (entry != end()) {
441 const ConstIterator defaultEntry(entry+1);
442 if (defaultEntry != constEnd() && defaultEntry.key().bDefault) {
443 *entry = *defaultEntry;
444 entry->bDirty =
true;
445 }
else if (!entry->mValue.isNull()){
446 entry->mValue = QByteArray();
447 entry->bDirty =
true;
448 entry->bDeleted =
true;
454 Q_DECLARE_OPERATORS_FOR_FLAGS(KEntryMap::SearchFlags)
455 Q_DECLARE_OPERATORS_FOR_FLAGS(
KEntryMap::EntryOptions)