KConfig

kconfiggroup.cpp
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2006, 2007 Thomas Braxton <[email protected]>
4  SPDX-FileCopyrightText: 1999 Preston Brown <[email protected]>
5  SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #include "kconfiggroup.h"
11 #include "kconfiggroup_p.h"
12 
13 #include "kconfig.h"
14 #include "kconfig_core_log_settings.h"
15 #include "kconfig_p.h"
16 #include "kconfigdata_p.h"
17 #include "ksharedconfig.h"
18 
19 #include <QDate>
20 #include <QDir>
21 #include <QFile>
22 #include <QPoint>
23 #include <QRect>
24 #include <QSharedData>
25 #include <QString>
26 #include <QTextStream>
27 #include <QUrl>
28 #include <QUuid>
29 
30 #include <algorithm>
31 #include <array>
32 #include <math.h>
33 #include <stdlib.h>
34 
35 class KConfigGroupPrivate : public QSharedData
36 {
37 public:
38  KConfigGroupPrivate(KConfig *owner, bool isImmutable, bool isConst, const QByteArray &name)
39  : mOwner(owner)
40  , mName(name)
41  , bImmutable(isImmutable)
42  , bConst(isConst)
43  {
44  }
45 
46  KConfigGroupPrivate(const KSharedConfigPtr &owner, const QByteArray &name)
47  : sOwner(owner)
48  , mOwner(sOwner.data())
49  , mName(name)
50  , bImmutable(name.isEmpty() ? owner->isImmutable() : owner->isGroupImmutable(name))
51  , bConst(false)
52  {
53  }
54 
55  KConfigGroupPrivate(KConfigGroup *parent, bool isImmutable, bool isConst, const QByteArray &name)
56  : sOwner(parent->d->sOwner)
57  , mOwner(parent->d->mOwner)
58  , mName(name)
59  , bImmutable(isImmutable)
60  , bConst(isConst)
61  {
62  if (!parent->d->mName.isEmpty()) {
63  mParent = parent->d;
64  }
65  }
66 
67  KConfigGroupPrivate(const KConfigGroupPrivate *other, bool isImmutable, const QByteArray &name)
68  : sOwner(other->sOwner)
69  , mOwner(other->mOwner)
70  , mName(name)
71  , bImmutable(isImmutable)
72  , bConst(other->bConst)
73  {
74  if (!other->mName.isEmpty()) {
75  mParent = const_cast<KConfigGroupPrivate *>(other);
76  }
77  }
78 
79  KSharedConfig::Ptr sOwner;
80  KConfig *mOwner;
82  QByteArray mName;
83 
84  /* bitfield */
85  const bool bImmutable : 1; // is this group immutable?
86  const bool bConst : 1; // is this group read-only?
87 
88  QByteArray fullName() const
89  {
90  if (!mParent) {
91  return name();
92  }
93  return mParent->fullName(mName);
94  }
95 
96  QByteArray name() const
97  {
98  if (mName.isEmpty()) {
99  return QByteArrayLiteral("<default>");
100  }
101  return mName;
102  }
103 
104  QByteArray fullName(const QByteArray &aGroup) const
105  {
106  if (mName.isEmpty()) {
107  return aGroup;
108  }
109  return fullName() + '\x1d' + aGroup;
110  }
111 
112  static QExplicitlySharedDataPointer<KConfigGroupPrivate> create(KConfigBase *master, const QByteArray &name, bool isImmutable, bool isConst)
113  {
115  if (dynamic_cast<KConfigGroup *>(master)) {
116  data = new KConfigGroupPrivate(static_cast<KConfigGroup *>(master), isImmutable, isConst, name);
117  } else {
118  data = new KConfigGroupPrivate(dynamic_cast<KConfig *>(master), isImmutable, isConst, name);
119  }
120  return data;
121  }
122 
123  static QByteArray serializeList(const QList<QByteArray> &list);
124  static QStringList deserializeList(const QString &data);
125 };
126 
127 QByteArray KConfigGroupPrivate::serializeList(const QList<QByteArray> &list)
128 {
129  QByteArray value;
130 
131  if (!list.isEmpty()) {
132  auto it = list.cbegin();
133  const auto end = list.cend();
134 
135  value = QByteArray(*it).replace('\\', QByteArrayLiteral("\\\\")).replace(',', QByteArrayLiteral("\\,"));
136 
137  while (++it != end) {
138  // In the loop, so it is not done when there is only one element.
139  // Doing it repeatedly is a pretty cheap operation.
140  value.reserve(4096);
141 
142  value += ',';
143  value += QByteArray(*it).replace('\\', QByteArrayLiteral("\\\\")).replace(',', QByteArrayLiteral("\\,"));
144  }
145 
146  // To be able to distinguish an empty list from a list with one empty element.
147  if (value.isEmpty()) {
148  value = QByteArrayLiteral("\\0");
149  }
150  }
151 
152  return value;
153 }
154 
155 QStringList KConfigGroupPrivate::deserializeList(const QString &data)
156 {
157  if (data.isEmpty()) {
158  return QStringList();
159  }
160  if (data == QLatin1String("\\0")) {
161  return QStringList(QString());
162  }
163  QStringList value;
164  QString val;
165  val.reserve(data.size());
166  bool quoted = false;
167  for (int p = 0; p < data.length(); p++) {
168  if (quoted) {
169  val += data[p];
170  quoted = false;
171  } else if (data[p].unicode() == '\\') {
172  quoted = true;
173  } else if (data[p].unicode() == ',') {
174  val.squeeze(); // release any unused memory
175  value.append(val);
176  val.clear();
177  val.reserve(data.size() - p);
178  } else {
179  val += data[p];
180  }
181  }
182  value.append(val);
183  return value;
184 }
185 
186 static QVector<int> asIntList(const QByteArray &string)
187 {
188  const auto &splitString = string.split(',');
189 
191  list.reserve(splitString.count());
192  for (const QByteArray &s : splitString) {
193  list << s.toInt();
194  }
195  return list;
196 }
197 
198 static QVector<qreal> asRealList(const QByteArray &string)
199 {
200  const auto &splitString = string.split(',');
201 
203  list.reserve(splitString.count());
204  for (const QByteArray &s : splitString) {
205  list << s.toDouble();
206  }
207  return list;
208 }
209 
210 static QString errString(const char *pKey, const QByteArray &value, const QVariant &aDefault)
211 {
212  return QStringLiteral("\"%1\" - conversion of \"%3\" to %2 failed")
214 }
215 
216 static QString formatError(int expected, int got)
217 {
218  return QStringLiteral(" (wrong format: expected %1 items, got %2)").arg(expected).arg(got);
219 }
220 
221 QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &value, const QVariant &aDefault)
222 {
223  // if a type handler is added here you must add a QVConversions definition
224  // to conversioncheck.h, or ConversionCheck::to_QVariant will not allow
225  // readEntry<T> to convert to QVariant.
226  switch (static_cast<QMetaType::Type>(aDefault.type())) {
228  return QVariant();
229  case QMetaType::QString:
230  // this should return the raw string not the dollar expanded string.
231  // imho if processed string is wanted should call
232  // readEntry(key, QString) not readEntry(key, QVariant)
233  return QString::fromUtf8(value);
234  case QMetaType::QUuid:
235  return QUuid::fromString(QString::fromUtf8(value));
238  return KConfigGroupPrivate::deserializeList(QString::fromUtf8(value));
240  return value;
241  case QMetaType::Bool: {
242  static const std::array<const char *, 4> negatives = {"false", "no", "off", "0"};
243 
244  return std::all_of(negatives.begin(), negatives.end(), [value](const char *negativeString) {
245  return value.compare(negativeString, Qt::CaseInsensitive) != 0;
246  });
247  }
248  case QMetaType::Double:
249  case QMetaType::Float:
250  case QMetaType::Int:
251  case QMetaType::UInt:
252  case QMetaType::LongLong:
253  case QMetaType::ULongLong: {
254  QVariant tmp = value;
255  if (!tmp.convert(aDefault.type())) {
256  tmp = aDefault;
257  }
258  return tmp;
259  }
260  case QMetaType::QPoint: {
261  const auto list = asIntList(value);
262 
263  if (list.count() != 2) {
264  qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count());
265  return aDefault;
266  }
267  return QPoint(list.at(0), list.at(1));
268  }
269  case QMetaType::QPointF: {
270  const auto list = asRealList(value);
271 
272  if (list.count() != 2) {
273  qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count());
274  return aDefault;
275  }
276  return QPointF(list.at(0), list.at(1));
277  }
278  case QMetaType::QRect: {
279  const auto list = asIntList(value);
280 
281  if (list.count() != 4) {
282  qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(4, list.count());
283  return aDefault;
284  }
285  const QRect rect(list.at(0), list.at(1), list.at(2), list.at(3));
286  if (!rect.isValid()) {
287  qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault);
288  return aDefault;
289  }
290  return rect;
291  }
292  case QMetaType::QRectF: {
293  const auto list = asRealList(value);
294 
295  if (list.count() != 4) {
296  qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(4, list.count());
297  return aDefault;
298  }
299  const QRectF rect(list.at(0), list.at(1), list.at(2), list.at(3));
300  if (!rect.isValid()) {
301  qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault);
302  return aDefault;
303  }
304  return rect;
305  }
306  case QMetaType::QSize: {
307  const auto list = asIntList(value);
308 
309  if (list.count() != 2) {
310  qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count());
311  return aDefault;
312  }
313  const QSize size(list.at(0), list.at(1));
314  if (!size.isValid()) {
315  qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault);
316  return aDefault;
317  }
318  return size;
319  }
320  case QMetaType::QSizeF: {
321  const auto list = asRealList(value);
322 
323  if (list.count() != 2) {
324  qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count());
325  return aDefault;
326  }
327  const QSizeF size(list.at(0), list.at(1));
328  if (!size.isValid()) {
329  qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault);
330  return aDefault;
331  }
332  return size;
333  }
334  case QMetaType::QDateTime: {
335  const auto list = asRealList(value);
336  if (list.count() < 6) {
337  qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(6, list.count());
338  return aDefault;
339  }
340  const QDate date(list.at(0), list.at(1), list.at(2));
341  const qreal totalSeconds = list.at(5);
342  qreal seconds;
343  const qreal fractional = modf(totalSeconds, &seconds);
344  const qreal milliseconds = round(fractional * 1000.0);
345  const QTime time(list.at(3), list.at(4), seconds, milliseconds);
346  const QDateTime dt(date, time);
347  if (!dt.isValid()) {
348  qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault);
349  return aDefault;
350  }
351  return dt;
352  }
353  case QMetaType::QDate: {
354  auto list = asIntList(value);
355  if (list.count() == 6) {
356  list = list.mid(0, 3); // don't break config files that stored QDate as QDateTime
357  }
358  if (list.count() != 3) {
359  qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(3, list.count());
360  return aDefault;
361  }
362  const QDate date(list.at(0), list.at(1), list.at(2));
363  if (!date.isValid()) {
364  qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault);
365  return aDefault;
366  }
367  return date;
368  }
369  case QMetaType::QColor:
370  case QMetaType::QFont:
371  qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::readEntry was passed GUI type '" << aDefault.typeName()
372  << "' but KConfigGui isn't linked! If it is linked to your program, "
373  "this is a platform bug. Please inform the KDE developers";
374  break;
375  case QMetaType::QUrl:
376  return QUrl(QString::fromUtf8(value));
377 
378  default:
379  break;
380  }
381 
382  qCWarning(KCONFIG_CORE_LOG) << "unhandled type " << aDefault.typeName();
383  return QVariant();
384 }
385 
386 #ifdef Q_OS_WIN
387 #include <QDir>
388 #endif
389 
390 static bool cleanHomeDirPath(QString &path, const QString &homeDir)
391 {
392 #ifdef Q_OS_WIN // safer
393  if (!QDir::toNativeSeparators(path).startsWith(QDir::toNativeSeparators(homeDir))) {
394  return false;
395  }
396 #else
397  if (!path.startsWith(homeDir)) {
398  return false;
399  }
400 #endif
401 
402  int len = homeDir.length();
403  // replace by "$HOME" if possible
404  if (len && (path.length() == len || path[len] == QLatin1Char('/'))) {
405  path.replace(0, len, QStringLiteral("$HOME"));
406  return true;
407  }
408 
409  return false;
410 }
411 
412 static QString translatePath(QString path) // krazy:exclude=passbyvalue
413 {
414  if (path.isEmpty()) {
415  return path;
416  }
417 
418  // only "our" $HOME should be interpreted
419  path.replace(QLatin1Char('$'), QLatin1String("$$"));
420 
421  const bool startsWithFile = path.startsWith(QLatin1String("file:"), Qt::CaseInsensitive);
422  path = startsWithFile ? QUrl(path).toLocalFile() : path;
423 
424  if (QDir::isRelativePath(path)) {
425  return path;
426  }
427 
428  // Use the same thing as what expandString() will do, to keep data intact
429 #ifdef Q_OS_WIN
430  const QString homeDir = QDir::homePath();
431 #else
432  const QString homeDir = QFile::decodeName(qgetenv("HOME"));
433 #endif
434  (void)cleanHomeDirPath(path, homeDir);
435 
436  if (startsWithFile) {
437  path = QUrl::fromLocalFile(path).toString();
438  }
439 
440  return path;
441 }
442 
444  : d()
445 {
446 }
447 
449 {
450  return bool(d);
451 }
452 
453 KConfigGroupGui _kde_internal_KConfigGroupGui;
454 static inline bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input, QVariant &output)
455 {
456  if (_kde_internal_KConfigGroupGui.readEntryGui) {
457  return _kde_internal_KConfigGroupGui.readEntryGui(data, key, input, output);
458  }
459  return false;
460 }
461 
462 static inline bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &input, KConfigGroup::WriteConfigFlags flags)
463 {
464  if (_kde_internal_KConfigGroupGui.writeEntryGui) {
465  return _kde_internal_KConfigGroupGui.writeEntryGui(cg, key, input, flags);
466  }
467  return false;
468 }
469 
471  : d(KConfigGroupPrivate::create(master, _group.toUtf8(), master->isGroupImmutable(_group), false))
472 {
473 }
474 
475 KConfigGroup::KConfigGroup(KConfigBase *master, const char *_group)
476  : d(KConfigGroupPrivate::create(master, _group, master->isGroupImmutable(_group), false))
477 {
478 }
479 
480 KConfigGroup::KConfigGroup(const KConfigBase *master, const QString &_group)
481  : d(KConfigGroupPrivate::create(const_cast<KConfigBase *>(master), _group.toUtf8(), master->isGroupImmutable(_group), true))
482 {
483 }
484 
485 KConfigGroup::KConfigGroup(const KConfigBase *master, const char *_group)
486  : d(KConfigGroupPrivate::create(const_cast<KConfigBase *>(master), _group, master->isGroupImmutable(_group), true))
487 {
488 }
489 
491  : d(new KConfigGroupPrivate(master, _group.toUtf8()))
492 {
493 }
494 
495 KConfigGroup::KConfigGroup(const KSharedConfigPtr &master, const char *_group)
496  : d(new KConfigGroupPrivate(master, _group))
497 {
498 }
499 
500 KConfigGroup &KConfigGroup::operator=(const KConfigGroup &rhs)
501 {
502  d = rhs.d;
503  return *this;
504 }
505 
507  : d(rhs.d)
508 {
509 }
510 
511 KConfigGroup::~KConfigGroup()
512 {
513  d.reset();
514 }
515 
517 {
518  Q_ASSERT_X(isValid(), "KConfigGroup::groupImpl", "accessing an invalid group");
519  Q_ASSERT_X(!aGroup.isEmpty(), "KConfigGroup::groupImpl", "can not have an unnamed child group");
520 
521  KConfigGroup newGroup;
522 
523  newGroup.d = new KConfigGroupPrivate(this, isGroupImmutableImpl(aGroup), d->bConst, aGroup);
524 
525  return newGroup;
526 }
527 
529 {
530  Q_ASSERT_X(isValid(), "KConfigGroup::groupImpl", "accessing an invalid group");
531  Q_ASSERT_X(!aGroup.isEmpty(), "KConfigGroup::groupImpl", "can not have an unnamed child group");
532 
533  KConfigGroup newGroup;
534 
535  newGroup.d = new KConfigGroupPrivate(const_cast<KConfigGroup *>(this), isGroupImmutableImpl(aGroup), true, aGroup);
536 
537  return newGroup;
538 }
539 
541 {
542  Q_ASSERT_X(isValid(), "KConfigGroup::parent", "accessing an invalid group");
543 
544  KConfigGroup parentGroup;
545 
546  if (d->mParent) {
547  parentGroup.d = d->mParent;
548  } else {
549  parentGroup.d = new KConfigGroupPrivate(d->mOwner, d->mOwner->isImmutable(), d->bConst, "");
550  // make sure we keep the refcount up on the KConfig object
551  parentGroup.d->sOwner = d->sOwner;
552  }
553 
554  return parentGroup;
555 }
556 
558 {
559  Q_ASSERT_X(isValid(), "KConfigGroup::deleteGroup", "accessing an invalid group");
560  Q_ASSERT_X(!d->bConst, "KConfigGroup::deleteGroup", "deleting a read-only group");
561 
562  config()->deleteGroup(d->fullName(), flags);
563 }
564 
565 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
567 {
568  Q_ASSERT_X(isValid(), "KConfigGroup::changeGroup", "accessing an invalid group");
569  d.detach();
570  d->mName = group.toUtf8();
571 }
572 #endif
573 
574 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
575 void KConfigGroup::changeGroup(const char *group)
576 {
577  Q_ASSERT_X(isValid(), "KConfigGroup::changeGroup", "accessing an invalid group");
578  d.detach();
579  d->mName = group;
580 }
581 #endif
582 
584 {
585  Q_ASSERT_X(isValid(), "KConfigGroup::name", "accessing an invalid group");
586 
587  return QString::fromUtf8(d->name());
588 }
589 
591 {
592  Q_ASSERT_X(isValid(), "KConfigGroup::exists", "accessing an invalid group");
593 
594  return config()->hasGroup(d->fullName());
595 }
596 
598 {
599  Q_ASSERT_X(isValid(), "KConfigGroup::sync", "accessing an invalid group");
600 
601  if (!d->bConst) {
602  return config()->sync();
603  }
604 
605  return false;
606 }
607 
609 {
610  Q_ASSERT_X(isValid(), "KConfigGroup::entryMap", "accessing an invalid group");
611 
612  return config()->entryMap(QString::fromUtf8(d->fullName()));
613 }
614 
616 {
617  Q_ASSERT_X(isValid(), "KConfigGroup::config", "accessing an invalid group");
618 
619  return d->mOwner;
620 }
621 
622 const KConfig *KConfigGroup::config() const
623 {
624  Q_ASSERT_X(isValid(), "KConfigGroup::config", "accessing an invalid group");
625 
626  return d->mOwner;
627 }
628 
629 bool KConfigGroup::isEntryImmutable(const char *key) const
630 {
631  Q_ASSERT_X(isValid(), "KConfigGroup::isEntryImmutable", "accessing an invalid group");
632 
633  return (isImmutable() || !config()->d_func()->canWriteEntry(d->fullName(), key, config()->readDefaults()));
634 }
635 
637 {
638  return isEntryImmutable(key.toUtf8().constData());
639 }
640 
641 QString KConfigGroup::readEntryUntranslated(const QString &pKey, const QString &aDefault) const
642 {
643  return readEntryUntranslated(pKey.toUtf8().constData(), aDefault);
644 }
645 
646 QString KConfigGroup::readEntryUntranslated(const char *key, const QString &aDefault) const
647 {
648  Q_ASSERT_X(isValid(), "KConfigGroup::readEntryUntranslated", "accessing an invalid group");
649 
650  QString result = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchFlags(), nullptr);
651  if (result.isNull()) {
652  return aDefault;
653  }
654  return result;
655 }
656 
657 QString KConfigGroup::readEntry(const char *key, const char *aDefault) const
658 {
659  return readEntry(key, QString::fromUtf8(aDefault));
660 }
661 
662 QString KConfigGroup::readEntry(const QString &key, const char *aDefault) const
663 {
664  return readEntry(key.toUtf8().constData(), aDefault);
665 }
666 
667 QString KConfigGroup::readEntry(const char *key, const QString &aDefault) const
668 {
669  Q_ASSERT_X(isValid(), "KConfigGroup::readEntry", "accessing an invalid group");
670 
671  bool expand = false;
672 
673  // read value from the entry map
674  QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized, &expand);
675  if (aValue.isNull()) {
676  aValue = aDefault;
677  }
678 
679  if (expand) {
680  return KConfigPrivate::expandString(aValue);
681  }
682 
683  return aValue;
684 }
685 
686 QString KConfigGroup::readEntry(const QString &key, const QString &aDefault) const
687 {
688  return readEntry(key.toUtf8().constData(), aDefault);
689 }
690 
691 QStringList KConfigGroup::readEntry(const char *key, const QStringList &aDefault) const
692 {
693  Q_ASSERT_X(isValid(), "KConfigGroup::readEntry", "accessing an invalid group");
694 
695  const QString data = readEntry(key, QString());
696  if (data.isNull()) {
697  return aDefault;
698  }
699 
700  return KConfigGroupPrivate::deserializeList(data);
701 }
702 
703 QStringList KConfigGroup::readEntry(const QString &key, const QStringList &aDefault) const
704 {
705  return readEntry(key.toUtf8().constData(), aDefault);
706 }
707 
708 QVariant KConfigGroup::readEntry(const char *key, const QVariant &aDefault) const
709 {
710  Q_ASSERT_X(isValid(), "KConfigGroup::readEntry", "accessing an invalid group");
711 
712  const QByteArray data = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized);
713  if (data.isNull()) {
714  return aDefault;
715  }
716 
717  QVariant value;
718  if (!readEntryGui(data, key, aDefault, value)) {
719  return convertToQVariant(key, data, aDefault);
720  }
721 
722  return value;
723 }
724 
725 QVariant KConfigGroup::readEntry(const QString &key, const QVariant &aDefault) const
726 {
727  return readEntry(key.toUtf8().constData(), aDefault);
728 }
729 
730 QVariantList KConfigGroup::readEntry(const char *key, const QVariantList &aDefault) const
731 {
732  Q_ASSERT_X(isValid(), "KConfigGroup::readEntry", "accessing an invalid group");
733 
734  const QString data = readEntry(key, QString());
735  if (data.isNull()) {
736  return aDefault;
737  }
738 
739  const auto &list = KConfigGroupPrivate::deserializeList(data);
740 
741  QVariantList value;
742  value.reserve(list.count());
743  for (const QString &v : list) {
744  value << v;
745  }
746 
747  return value;
748 }
749 
750 QVariantList KConfigGroup::readEntry(const QString &key, const QVariantList &aDefault) const
751 {
752  return readEntry(key.toUtf8().constData(), aDefault);
753 }
754 
756 {
757  return readXdgListEntry(key.toUtf8().constData(), aDefault);
758 }
759 
760 QStringList KConfigGroup::readXdgListEntry(const char *key, const QStringList &aDefault) const
761 {
762  Q_ASSERT_X(isValid(), "KConfigGroup::readXdgListEntry", "accessing an invalid group");
763 
764  const QString data = readEntry(key, QString());
765  if (data.isNull()) {
766  return aDefault;
767  }
768 
769  QStringList value;
770  QString val;
771  val.reserve(data.size());
772  // XXX List serialization being a separate layer from low-level parsing is
773  // probably a bug. No affected entries are defined, though.
774  bool quoted = false;
775  for (int p = 0; p < data.length(); p++) {
776  if (quoted) {
777  val += data[p];
778  quoted = false;
779  } else if (data[p] == QLatin1Char('\\')) {
780  quoted = true;
781  } else if (data[p] == QLatin1Char(';')) {
782  value.append(val);
783  val.clear();
784  val.reserve(data.size() - p);
785  } else {
786  val += data[p];
787  }
788  }
789  if (!val.isEmpty()) {
790  value.append(val);
791  }
792  return value;
793 }
794 
795 QString KConfigGroup::readPathEntry(const QString &pKey, const QString &aDefault) const
796 {
797  return readPathEntry(pKey.toUtf8().constData(), aDefault);
798 }
799 
800 QString KConfigGroup::readPathEntry(const char *key, const QString &aDefault) const
801 {
802  Q_ASSERT_X(isValid(), "KConfigGroup::readPathEntry", "accessing an invalid group");
803 
804  bool expand = false;
805 
806  QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized, &expand);
807  if (aValue.isNull()) {
808  aValue = aDefault;
809  }
810 
811  return KConfigPrivate::expandString(aValue);
812 }
813 
814 QStringList KConfigGroup::readPathEntry(const QString &pKey, const QStringList &aDefault) const
815 {
816  return readPathEntry(pKey.toUtf8().constData(), aDefault);
817 }
818 
819 QStringList KConfigGroup::readPathEntry(const char *key, const QStringList &aDefault) const
820 {
821  Q_ASSERT_X(isValid(), "KConfigGroup::readPathEntry", "accessing an invalid group");
822 
823  const QString data = readPathEntry(key, QString());
824  if (data.isNull()) {
825  return aDefault;
826  }
827 
828  return KConfigGroupPrivate::deserializeList(data);
829 }
830 
831 void KConfigGroup::writeEntry(const char *key, const QString &value, WriteConfigFlags flags)
832 {
833  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
834  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
835 
836  writeEntry(key, value.toUtf8(), flags);
837 }
838 
839 void KConfigGroup::writeEntry(const QString &key, const QString &value, WriteConfigFlags flags)
840 {
841  writeEntry(key.toUtf8().constData(), value, flags);
842 }
843 
844 void KConfigGroup::writeEntry(const QString &key, const char *value, WriteConfigFlags pFlags)
845 {
846  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
847  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
848 
849  writeEntry(key.toUtf8().constData(), QVariant(QString::fromLatin1(value)), pFlags);
850 }
851 
852 void KConfigGroup::writeEntry(const char *key, const char *value, WriteConfigFlags pFlags)
853 {
854  writeEntry(key, QVariant(QString::fromLatin1(value)), pFlags);
855 }
856 
857 void KConfigGroup::writeEntry(const char *key, const QByteArray &value, WriteConfigFlags flags)
858 {
859  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
860  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
861 
862  config()->d_func()->putData(d->fullName(), key, value.isNull() ? QByteArray("") : value, flags);
863 }
864 
865 void KConfigGroup::writeEntry(const QString &key, const QByteArray &value, WriteConfigFlags pFlags)
866 {
867  writeEntry(key.toUtf8().constData(), value, pFlags);
868 }
869 
870 void KConfigGroup::writeEntry(const char *key, const QStringList &list, WriteConfigFlags flags)
871 {
872  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
873  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
874 
875  QList<QByteArray> balist;
876  balist.reserve(list.count());
877 
878  for (const QString &entry : list) {
879  balist.append(entry.toUtf8());
880  }
881 
882  writeEntry(key, KConfigGroupPrivate::serializeList(balist), flags);
883 }
884 
885 void KConfigGroup::writeEntry(const QString &key, const QStringList &list, WriteConfigFlags flags)
886 {
887  writeEntry(key.toUtf8().constData(), list, flags);
888 }
889 
890 void KConfigGroup::writeEntry(const char *key, const QVariantList &list, WriteConfigFlags flags)
891 {
892  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
893  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
894 
895  QList<QByteArray> data;
896  data.reserve(list.count());
897 
898  for (const QVariant &v : list) {
899  if (v.type() == QVariant::ByteArray) {
900  data << v.toByteArray();
901  } else {
902  data << v.toString().toUtf8();
903  }
904  }
905 
906  writeEntry(key, KConfigGroupPrivate::serializeList(data), flags);
907 }
908 
909 void KConfigGroup::writeEntry(const char *key, const QVariant &value, WriteConfigFlags flags)
910 {
911  Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
912  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
913 
914  if (writeEntryGui(this, key, value, flags)) {
915  return; // GUI type that was handled
916  }
917 
918  QByteArray data;
919  // if a type handler is added here you must add a QVConversions definition
920  // to conversioncheck.h, or ConversionCheck::to_QVariant will not allow
921  // writeEntry<T> to convert to QVariant.
922  switch (static_cast<QMetaType::Type>(value.type())) {
924  data = "";
925  break;
927  data = value.toByteArray();
928  break;
929  case QMetaType::QString:
930  case QMetaType::Int:
931  case QMetaType::UInt:
932  case QMetaType::Double:
933  case QMetaType::Float:
934  case QMetaType::Bool:
935  case QMetaType::LongLong:
937  data = value.toString().toUtf8();
938  break;
940  if (!value.canConvert(QMetaType::QStringList)) {
941  qCWarning(KCONFIG_CORE_LOG) << "not all types in \"" << key
942  << "\" can convert to QString,"
943  " information will be lost";
944  }
945  Q_FALLTHROUGH();
947  writeEntry(key, value.toList(), flags);
948  return;
949  case QMetaType::QPoint: {
950  const QPoint rPoint = value.toPoint();
951 
952  const QVariantList list{rPoint.x(), rPoint.y()};
953 
954  writeEntry(key, list, flags);
955  return;
956  }
957  case QMetaType::QPointF: {
958  const QPointF point = value.toPointF();
959 
960  const QVariantList list{point.x(), point.y()};
961 
962  writeEntry(key, list, flags);
963  return;
964  }
965  case QMetaType::QRect: {
966  const QRect rRect = value.toRect();
967 
968  const QVariantList list{rRect.left(), rRect.top(), rRect.width(), rRect.height()};
969 
970  writeEntry(key, list, flags);
971  return;
972  }
973  case QMetaType::QRectF: {
974  const QRectF rRectF = value.toRectF();
975 
976  const QVariantList list{rRectF.left(), rRectF.top(), rRectF.width(), rRectF.height()};
977 
978  writeEntry(key, list, flags);
979  return;
980  }
981  case QMetaType::QSize: {
982  const QSize rSize = value.toSize();
983 
984  const QVariantList list{rSize.width(), rSize.height()};
985 
986  writeEntry(key, list, flags);
987  return;
988  }
989  case QMetaType::QUuid: {
990  writeEntry(key, value.toString(), flags);
991  return;
992  }
993  case QMetaType::QSizeF: {
994  const QSizeF rSizeF = value.toSizeF();
995 
996  const QVariantList list{rSizeF.width(), rSizeF.height()};
997 
998  writeEntry(key, list, flags);
999  return;
1000  }
1001  case QMetaType::QDate: {
1002  const QDate date = value.toDate();
1003 
1004  const QVariantList list{date.year(), date.month(), date.day()};
1005 
1006  writeEntry(key, list, flags);
1007  return;
1008  }
1009  case QMetaType::QDateTime: {
1010  const QDateTime rDateTime = value.toDateTime();
1011 
1012  const QTime time = rDateTime.time();
1013  const QDate date = rDateTime.date();
1014 
1015  const QVariantList list{
1016  date.year(),
1017  date.month(),
1018  date.day(),
1019 
1020  time.hour(),
1021  time.minute(),
1022  time.second() + time.msec() / 1000.0,
1023  };
1024 
1025  writeEntry(key, list, flags);
1026  return;
1027  }
1028 
1029  case QMetaType::QColor:
1030  case QMetaType::QFont:
1031  qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::writeEntry was passed GUI type '" << value.typeName()
1032  << "' but KConfigGui isn't linked! If it is linked to your program, this is a platform bug. "
1033  "Please inform the KDE developers";
1034  break;
1035  case QMetaType::QUrl:
1036  data = QUrl(value.toUrl()).toString().toUtf8();
1037  break;
1038  default:
1039  qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::writeEntry - unhandled type" << value.typeName() << "in group" << name();
1040  }
1041 
1042  writeEntry(key, data, flags);
1043 }
1044 
1045 void KConfigGroup::writeEntry(const QString &key, const QVariant &value, WriteConfigFlags flags)
1046 {
1047  writeEntry(key.toUtf8().constData(), value, flags);
1048 }
1049 
1050 void KConfigGroup::writeEntry(const QString &key, const QVariantList &list, WriteConfigFlags flags)
1051 {
1052  writeEntry(key.toUtf8().constData(), list, flags);
1053 }
1054 
1056 {
1057  writeXdgListEntry(key.toUtf8().constData(), value, pFlags);
1058 }
1059 
1060 void KConfigGroup::writeXdgListEntry(const char *key, const QStringList &list, WriteConfigFlags flags)
1061 {
1062  Q_ASSERT_X(isValid(), "KConfigGroup::writeXdgListEntry", "accessing an invalid group");
1063  Q_ASSERT_X(!d->bConst, "KConfigGroup::writeXdgListEntry", "writing to a read-only group");
1064 
1065  QString value;
1066  value.reserve(4096);
1067 
1068  // XXX List serialization being a separate layer from low-level escaping is
1069  // probably a bug. No affected entries are defined, though.
1070  for (QString val : list) { // clazy:exclude=range-loop
1071  val.replace(QLatin1Char('\\'), QLatin1String("\\\\")).replace(QLatin1Char(';'), QLatin1String("\\;"));
1072  value += val + QLatin1Char(';');
1073  }
1074 
1075  writeEntry(key, value, flags);
1076 }
1077 
1078 void KConfigGroup::writePathEntry(const QString &pKey, const QString &path, WriteConfigFlags pFlags)
1079 {
1080  writePathEntry(pKey.toUtf8().constData(), path, pFlags);
1081 }
1082 
1083 void KConfigGroup::writePathEntry(const char *pKey, const QString &path, WriteConfigFlags pFlags)
1084 {
1085  Q_ASSERT_X(isValid(), "KConfigGroup::writePathEntry", "accessing an invalid group");
1086  Q_ASSERT_X(!d->bConst, "KConfigGroup::writePathEntry", "writing to a read-only group");
1087 
1088  config()->d_func()->putData(d->fullName(), pKey, translatePath(path).toUtf8(), pFlags, true);
1089 }
1090 
1091 void KConfigGroup::writePathEntry(const QString &pKey, const QStringList &value, WriteConfigFlags pFlags)
1092 {
1093  writePathEntry(pKey.toUtf8().constData(), value, pFlags);
1094 }
1095 
1096 void KConfigGroup::writePathEntry(const char *pKey, const QStringList &value, WriteConfigFlags pFlags)
1097 {
1098  Q_ASSERT_X(isValid(), "KConfigGroup::writePathEntry", "accessing an invalid group");
1099  Q_ASSERT_X(!d->bConst, "KConfigGroup::writePathEntry", "writing to a read-only group");
1100 
1101  QList<QByteArray> list;
1102  list.reserve(value.length());
1103  for (const QString &path : value) {
1104  list << translatePath(path).toUtf8();
1105  }
1106 
1107  config()->d_func()->putData(d->fullName(), pKey, KConfigGroupPrivate::serializeList(list), pFlags, true);
1108 }
1109 
1110 void KConfigGroup::deleteEntry(const char *key, WriteConfigFlags flags)
1111 {
1112  Q_ASSERT_X(isValid(), "KConfigGroup::deleteEntry", "accessing an invalid group");
1113  Q_ASSERT_X(!d->bConst, "KConfigGroup::deleteEntry", "deleting from a read-only group");
1114 
1115  config()->d_func()->putData(d->fullName(), key, QByteArray(), flags);
1116 }
1117 
1119 {
1120  deleteEntry(key.toUtf8().constData(), flags);
1121 }
1122 
1123 void KConfigGroup::revertToDefault(const char *key)
1124 {
1126 }
1127 
1129 {
1130  Q_ASSERT_X(isValid(), "KConfigGroup::revertToDefault", "accessing an invalid group");
1131  Q_ASSERT_X(!d->bConst, "KConfigGroup::revertToDefault", "writing to a read-only group");
1132 
1133  config()->d_func()->revertEntry(d->fullName(), key, flags);
1134 }
1135 
1137 {
1139 }
1140 
1141 void KConfigGroup::revertToDefault(const QString &key, WriteConfigFlags flags)
1142 {
1143  revertToDefault(key.toUtf8().constData(), flags);
1144 }
1145 
1146 bool KConfigGroup::hasDefault(const char *key) const
1147 {
1148  Q_ASSERT_X(isValid(), "KConfigGroup::hasDefault", "accessing an invalid group");
1149 
1150  KEntryMap::SearchFlags flags = KEntryMap::SearchDefaults | KEntryMap::SearchLocalized;
1151 
1152  return !config()->d_func()->lookupData(d->fullName(), key, flags).isNull();
1153 }
1154 
1155 bool KConfigGroup::hasDefault(const QString &key) const
1156 {
1157  return hasDefault(key.toUtf8().constData());
1158 }
1159 
1160 bool KConfigGroup::hasKey(const char *key) const
1161 {
1162  Q_ASSERT_X(isValid(), "KConfigGroup::hasKey", "accessing an invalid group");
1163 
1164  KEntryMap::SearchFlags flags = KEntryMap::SearchLocalized;
1165  if (config()->readDefaults()) {
1166  flags |= KEntryMap::SearchDefaults;
1167  }
1168 
1169  return !config()->d_func()->lookupData(d->fullName(), key, flags).isNull();
1170 }
1171 
1172 bool KConfigGroup::hasKey(const QString &key) const
1173 {
1174  return hasKey(key.toUtf8().constData());
1175 }
1176 
1178 {
1179  Q_ASSERT_X(isValid(), "KConfigGroup::isImmutable", "accessing an invalid group");
1180 
1181  return d->bImmutable;
1182 }
1183 
1185 {
1186  Q_ASSERT_X(isValid(), "KConfigGroup::groupList", "accessing an invalid group");
1187 
1188  return config()->d_func()->groupList(d->fullName());
1189 }
1190 
1192 {
1193  Q_ASSERT_X(isValid(), "KConfigGroup::keyList", "accessing an invalid group");
1194 
1195  return entryMap().keys();
1196 }
1197 
1199 {
1200  Q_ASSERT_X(isValid(), "KConfigGroup::markAsClean", "accessing an invalid group");
1201 
1202  config()->markAsClean();
1203 }
1204 
1206 {
1207  Q_ASSERT_X(isValid(), "KConfigGroup::accessMode", "accessing an invalid group");
1208 
1209  return config()->accessMode();
1210 }
1211 
1213 {
1214  Q_ASSERT_X(isValid(), "KConfigGroup::hasGroupImpl", "accessing an invalid group");
1215 
1216  return config()->hasGroup(d->fullName(b));
1217 }
1218 
1220 {
1221  Q_ASSERT_X(isValid(), "KConfigGroup::deleteGroupImpl", "accessing an invalid group");
1222  Q_ASSERT_X(!d->bConst, "KConfigGroup::deleteGroupImpl", "deleting from a read-only group");
1223 
1224  config()->deleteGroup(d->fullName(b), flags);
1225 }
1226 
1228 {
1229  Q_ASSERT_X(isValid(), "KConfigGroup::isGroupImmutableImpl", "accessing an invalid group");
1230 
1231  if (!hasGroupImpl(b)) { // group doesn't exist yet
1232  return d->bImmutable; // child groups are immutable if the parent is immutable.
1233  }
1234 
1235  return config()->isGroupImmutable(d->fullName(b));
1236 }
1237 
1239 {
1240  Q_ASSERT_X(isValid(), "KConfigGroup::copyTo", "accessing an invalid group");
1241  Q_ASSERT(other != nullptr);
1242 
1243  if (KConfigGroup *otherGroup = dynamic_cast<KConfigGroup *>(other)) {
1244  config()->d_func()->copyGroup(d->fullName(), otherGroup->d->fullName(), otherGroup, pFlags);
1245  } else if (KConfig *otherConfig = dynamic_cast<KConfig *>(other)) {
1246  KConfigGroup newGroup = otherConfig->group(d->fullName());
1247  otherConfig->d_func()->copyGroup(d->fullName(), d->fullName(), &newGroup, pFlags);
1248  } else {
1249  Q_ASSERT_X(false, "KConfigGroup::copyTo", "unknown type of KConfigBase");
1250  }
1251 }
1252 
1254 {
1255  Q_ASSERT_X(isValid(), "KConfigGroup::reparent", "accessing an invalid group");
1256  Q_ASSERT_X(!d->bConst, "KConfigGroup::reparent", "reparenting a read-only group");
1257  Q_ASSERT_X(!d->bImmutable, "KConfigGroup::reparent", "reparenting an immutable group");
1258  Q_ASSERT(parent != nullptr);
1259 
1260  KConfigGroup oldGroup(*this);
1261 
1262  d = KConfigGroupPrivate::create(parent, d->mName, false, false);
1263  oldGroup.copyTo(this, pFlags);
1264  oldGroup.deleteGroup(); // so that the entries with the old group name are deleted on sync
1265 }
1266 
1268 {
1269  Q_ASSERT(isValid());
1270  Q_ASSERT(other.isValid());
1271 
1272  for (const auto key : keys) {
1273  const QByteArray groupName = name().toLocal8Bit();
1274  const auto entry = config()->d_ptr->lookupInternalEntry(groupName, key, KEntryMap::SearchLocalized);
1275 
1276  // Only write the entry if it is not null, if it is a global enry there is no point in moving it
1277  if (!entry.mValue.isNull() && !entry.bGlobal) {
1278  deleteEntry(key, pFlags);
1279  KEntryMap::EntryOptions options = KEntryMap::EntryOption::EntryDirty;
1280  if (entry.bDeleted) {
1281  options |= KEntryMap::EntryDeleted;
1282  }
1283 
1284  if (entry.bExpand) {
1285  options |= KEntryMap::EntryExpansion;
1286  }
1287 
1288  other.config()->d_ptr->setEntryData(other.name().toLocal8Bit(), key, entry.mValue, options);
1289  }
1290  }
1291 }
QRect toRect() const const
void append(const T &value)
QRectF toRectF() const const
qreal left() const const
bool isNull() const const
void squeeze()
bool isNull() const const
void changeGroup(const QString &group)
Changes the group of the object.
QFlags< WriteConfigFlag > WriteConfigFlags
Stores a combination of WriteConfigFlag values.
Definition: kconfigbase.h:67
int month() const const
qreal height() const const
AccessMode accessMode() const override
Definition: kconfig.cpp:817
AccessMode accessMode() const override
Interface to interact with configuration.
Definition: kconfigbase.h:30
QSizeF toSizeF() const const
void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags=Normal)
Writes a value to the configuration object.
QUrl toUrl() const const
QString fromUtf8(const char *str, int size)
int size() const const
CaseInsensitive
int count(const T &value) const const
QUuid fromString(QStringView text)
QTime time() const const
int year() const const
int length() const const
void clear()
The central class of the KDE configuration data system.
Definition: kconfig.h:56
void markAsClean() override
Definition: kconfig.cpp:522
bool isValid() const
Whether the group is valid.
int width() const const
bool hasGroup(const QString &group) const
Returns true if the specified group is known about.
Definition: kconfigbase.cpp:16
int x() const const
int y() const const
QString homePath()
void reserve(int size)
QByteArray toByteArray() const const
int width() const const
KIOFILEWIDGETS_EXPORT QStringList list(const QString &fileClass)
bool sync() override
Definition: kconfig.cpp:418
void writePathEntry(const QString &pKey, const QString &path, WriteConfigFlags pFlags=Normal)
Writes a file path to the configuration.
QDate toDate() const const
QMap< QString, QString > entryMap() const
Returns a map (tree) of entries for all entries in this group.
bool hasDefault(const QString &key) const
Whether a default is specified for an entry in either the system wide configuration file or the globa...
int left() const const
void moveValuesTo(const QList< const char * > &keys, KConfigGroup &other, WriteConfigFlags pFlags=Normal)
Moves the key-value pairs from one config group to the other.
void markAsClean() override
void reparent(KConfigBase *parent, WriteConfigFlags pFlags=Normal)
Changes the configuration object that this group belongs to.
void reserve(int alloc)
bool exists() const
Check whether the containing KConfig object actually contains a group with this name.
QString toString(QUrl::FormattingOptions options) const const
const char * typeToName(int typeId)
int top() const const
QAction * create(StandardAction id, const QObject *recvr, const char *slot, QObject *parent)
int height() const const
QVariant::Type type() const const
KConfigGroup parent() const
Returns the group that this group belongs to.
QMap< QString, QString > entryMap(const QString &aGroup=QString()) const
Returns a map (tree) of entries in a particular group.
Definition: kconfig.cpp:387
QList< T > mid(int pos, int length) const const
QStringList groupList() const override
Definition: kconfig.cpp:305
void deleteGroup(WriteConfigFlags pFlags=Normal)
Delete all entries in the entire group.
bool isEmpty() const const
void deleteGroup(const QString &group, WriteConfigFlags flags=Normal)
Delete group.
Definition: kconfigbase.cpp:66
QUrl fromLocalFile(const QString &localFile)
QString toNativeSeparators(const QString &pathName)
QByteArray toUtf8() const const
int length() const const
bool isGroupImmutable(const QString &group) const
Can changes be made to the entries in group?
Definition: kconfigbase.cpp:81
void deleteEntry(const QString &pKey, WriteConfigFlags pFlags=Normal)
Deletes the entry specified by pKey in the current group.
const T & at(int i) const const
int msec() const const
bool isEmpty() const const
QString toLocalFile() const const
QList::const_iterator cend() const const
QStringList groupList() const override
T readEntry(const QString &key, const T &aDefault) const
Reads the value of an entry specified by pKey in the current group.
Definition: kconfiggroup.h:258
KDB_EXPORT QStringList deserializeList(const QString &data)
bool convert(int targetTypeId)
bool isEntryImmutable(const QString &key) const
Checks if it is possible to change the given entry.
int hour() const const
QPoint toPoint() const const
QByteArray & replace(int pos, int len, const char *after)
QString & replace(int position, int n, QChar after)
bool canConvert(int targetTypeId) const const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const const
qreal top() const const
void deleteGroupImpl(const QByteArray &group, WriteConfigFlags flags) override
QString readEntryUntranslated(const QString &pKey, const QString &aDefault=QString()) const
Reads an untranslated string entry.
bool hasGroupImpl(const QByteArray &group) const override
QDateTime toDateTime() const const
bool isEmpty() const const
void writeXdgListEntry(const QString &pKey, const QStringList &value, WriteConfigFlags pFlags=Normal)
Writes a list of strings to the config object, following XDG desktop entry spec separator semantics.
int height() const const
qreal x() const const
qreal y() const const
QList< Key > keys() const const
QStringList keyList() const
Returns a list of keys this group contains.
const char * constData() const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
int second() const const
QAction * end(const QObject *recvr, const char *slot, QObject *parent)
QString fromLatin1(const char *str, int size)
AccessMode
Possible return values for accessMode().
Definition: kconfigbase.h:175
qreal width() const const
QSize toSize() const const
QList::const_iterator cbegin() const const
void copyTo(KConfigBase *other, WriteConfigFlags pFlags=Normal) const
Copies the entries in this group to another configuration object.
bool hasKey(const QString &key) const
Checks whether the key has an entry in this group.
const char * name(StandardAction id)
KConfigGroup()
Constructs an invalid group.
QDate date() const const
QList< QVariant > toList() const const
QStringList readXdgListEntry(const QString &pKey, const QStringList &aDefault=QStringList()) const
Reads a list of strings from the config object, following XDG desktop entry spec separator semantics.
void reserve(int size)
QString readPathEntry(const QString &pKey, const QString &aDefault) const
Reads a path.
void revertToDefault(const QString &key)
Reverts an entry to the default settings.
KConfig * config()
Return the config object that this group belongs to.
KDB_EXPORT QString serializeList(const QStringList &list)
bool isRelativePath(const QString &path)
QString name() const
The name of this group.
QPointF toPointF() const const
bool isImmutable() const override
Whether this group may be changed.
bool sync() override
KConfigGroup group(const QString &group)
Returns an object for the named subgroup.
Definition: kconfigbase.cpp:36
QByteArray toLocal8Bit() const const
KConfigGroup groupImpl(const QByteArray &b) override
const char * typeName() const const
int minute() const const
QString fullName(const PartType &type)
bool isGroupImmutableImpl(const QByteArray &aGroup) const override
QString toString() const const
QString decodeName(const QByteArray &localFileName)
qreal width() const const
qreal height() const const
int day() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu May 26 2022 04:06:16 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.