KConfig

kcoreconfigskeleton.cpp
1 /*
2  This file is part of KOrganizer.
3  SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher <[email protected]>
4  SPDX-FileCopyrightText: 2003 Waldo Bastian <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #include "kcoreconfigskeleton.h"
10 #include "kcoreconfigskeleton_p.h"
11 
12 #include <QUrl>
13 
14 static QString obscuredString(const QString &str)
15 {
16  QString result;
17  const QChar *unicode = str.unicode();
18  for (int i = 0; i < str.length(); ++i)
19  // yes, no typo. can't encode ' ' or '!' because
20  // they're the unicode BOM. stupid scrambling. stupid.
21  result += (unicode[ i ].unicode() <= 0x21) ? unicode[ i ]
22  : QChar(0x1001F - unicode[ i ].unicode());
23 
24  return result;
25 }
26 
27 KConfigSkeletonItemPrivate::~KConfigSkeletonItemPrivate() = default;
28 
30  const QString &_key)
31  : mGroup(_group)
32  , mKey(_key)
33  , d_ptr(new KConfigSkeletonItemPrivate)
34 {
35 }
36 
37 KConfigSkeletonItem::KConfigSkeletonItem(KConfigSkeletonItemPrivate &dd, const QString &_group, const QString &_key)
38  : mGroup(_group)
39  , mKey(_key)
40  , d_ptr(&dd)
41 {
42 }
43 
45 {
46  delete d_ptr;
47 }
48 
50 {
51  mGroup = _group;
52 }
53 
55 {
57  d->mConfigGroup = cg;
58 }
59 
61 {
62  Q_D(const KConfigSkeletonItem);
63  if (d->mConfigGroup.isValid()) {
64  return d->mConfigGroup;
65  }
66  return KConfigGroup(config, mGroup);
67 }
68 
70 {
71  return mGroup;
72 }
73 
75 {
76  mKey = _key;
77 }
78 
80 {
81  return mKey;
82 }
83 
85 {
86  mName = _name;
87 }
88 
90 {
91  return mName;
92 }
93 
95 {
97  d->mLabel = l;
98 }
99 
101 {
102  Q_D(const KConfigSkeletonItem);
103  return d->mLabel;
104 }
105 
107 {
108  Q_D(KConfigSkeletonItem);
109  d->mToolTip = t;
110 }
111 
113 {
114  Q_D(const KConfigSkeletonItem);
115  return d->mToolTip;
116 }
117 
119 {
120  Q_D(KConfigSkeletonItem);
121  d->mWhatsThis = w;
122 }
123 
125 {
126  Q_D(const KConfigSkeletonItem);
127  return d->mWhatsThis;
128 }
129 
131 {
132  Q_D(KConfigSkeletonItem);
133  d->mWriteFlags = flags;
134 }
135 
137 {
138  Q_D(const KConfigSkeletonItem);
139  return d->mWriteFlags;
140 }
141 
143 {
144  return QVariant();
145 }
146 
148 {
149  return QVariant();
150 }
151 
153 {
154  Q_D(const KConfigSkeletonItem);
155  return d->mIsImmutable;
156 }
157 
159 {
160  Q_D(const KConfigSkeletonItem);
161  return d->mIsDefaultImpl();
162 }
163 
165 {
166  Q_D(const KConfigSkeletonItem);
167  return d->mIsSaveNeededImpl();
168 }
169 
171 {
172  Q_D(const KConfigSkeletonItem);
173  return d->mGetDefaultImpl();
174 }
175 
177 {
178  Q_D(KConfigSkeletonItem);
179  d->mIsImmutable = group.isEntryImmutable(mKey);
180 }
181 
182 void KConfigSkeletonItem::setIsDefaultImpl(const std::function<bool ()> &impl)
183 {
184  Q_D(KConfigSkeletonItem);
185  d->mIsDefaultImpl = impl;
186 }
187 
188 void KConfigSkeletonItem::setIsSaveNeededImpl(const std::function<bool ()> &impl)
189 {
190  Q_D(KConfigSkeletonItem);
191  d->mIsSaveNeededImpl = impl;
192 }
193 
194 void KConfigSkeletonItem::setGetDefaultImpl(const std::function<QVariant ()> &impl)
195 {
196  Q_D(KConfigSkeletonItem);
197  d->mGetDefaultImpl = impl;
198 }
199 
200 KPropertySkeletonItem::KPropertySkeletonItem(QObject *object, const QByteArray &propertyName, const QVariant &defaultValue)
201  : KConfigSkeletonItem(*new KPropertySkeletonItemPrivate(object, propertyName, defaultValue), {}, {})
202 {
203  setIsDefaultImpl([this] {
204  Q_D(const KPropertySkeletonItem);
205  return d->mReference == d->mDefaultValue;
206  });
207  setIsSaveNeededImpl([this] {
208  Q_D(const KPropertySkeletonItem);
209  return d->mReference != d->mLoadedValue;
210  });
211  setGetDefaultImpl([this] {
212  Q_D(const KPropertySkeletonItem);
213  return d->mDefaultValue;
214  });
215 }
216 
218 {
219  Q_D(const KPropertySkeletonItem);
220  return d->mReference;
221 }
222 
224 {
226  if (d->mReference == p) {
227  return;
228  }
229  d->mReference = p;
230  if (d->mNotifyFunction) {
231  d->mNotifyFunction();
232  }
233 }
234 
236 {
237  Q_D(const KPropertySkeletonItem);
238  return d->mReference == p;
239 }
240 
242 {
244  setProperty(d->mObject->property(d->mPropertyName.constData()));
245  d->mLoadedValue = d->mReference;
246 }
247 
249 {
251  d->mObject->setProperty(d->mPropertyName.constData(), d->mReference);
252  d->mLoadedValue = d->mReference;
253 }
254 
256 {
258  setProperty(d->mConstDefaultValue);
259 }
260 
262 {
264  setProperty(d->mDefaultValue);
265 }
266 
268 {
270  if (d->mReference == d->mDefaultValue) {
271  return;
272  }
273  std::swap(d->mReference, d->mDefaultValue);
274  if (d->mNotifyFunction) {
275  d->mNotifyFunction();
276  }
277 }
278 
279 void KPropertySkeletonItem::setNotifyFunction(const std::function<void ()> &impl)
280 {
282  d->mNotifyFunction = impl;
283 }
284 
286  QString &reference,
287  const QString &defaultValue,
288  Type type)
289  : KConfigSkeletonGenericItem<QString>(_group, _key, reference, defaultValue),
290  mType(type)
291 {
292 }
293 
295 {
296  if (mReference != mLoadedValue) { // WABA: Is this test needed?
297  KConfigGroup cg = configGroup(config);
298  if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
300  } else if (mType == Path) {
301  cg.writePathEntry(mKey, mReference, writeFlags());
302  } else if (mType == Password) {
303  cg.writeEntry(mKey, obscuredString(mReference), writeFlags());
304  } else {
305  cg.writeEntry(mKey, mReference, writeFlags());
306  }
307  mLoadedValue = mReference;
308  }
309 }
310 
312 {
313  KConfigGroup cg = configGroup(config);
314 
315  if (mType == Path) {
316  mReference = cg.readPathEntry(mKey, mDefault);
317  } else if (mType == Password) {
318  QString val = cg.readEntry(mKey, obscuredString(mDefault));
319  mReference = obscuredString(val);
320  } else {
321  mReference = cg.readEntry(mKey, mDefault);
322  }
323 
324  mLoadedValue = mReference;
325 
326  readImmutability(cg);
327 }
328 
330 {
331  mReference = p.toString();
332 }
333 
335 {
336  return mReference == v.toString();
337 }
338 
340 {
341  return QVariant(mReference);
342 }
343 
345  QString &reference,
346  const QString &defaultValue)
347  : ItemString(_group, _key, reference, defaultValue, Password)
348 {
349 }
350 
352  QString &reference,
353  const QString &defaultValue)
354  : ItemString(_group, _key, reference, defaultValue, Path)
355 {
356 }
357 
359  QUrl &reference,
360  const QUrl &defaultValue)
361  : KConfigSkeletonGenericItem<QUrl>(_group, _key, reference, defaultValue)
362 {
363 }
364 
366 {
367  if (mReference != mLoadedValue) { // WABA: Is this test needed?
368  KConfigGroup cg = configGroup(config);
369  if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
371  } else {
372  cg.writeEntry<QString>(mKey, mReference.toString(), writeFlags());
373  }
374  mLoadedValue = mReference;
375  }
376 }
377 
379 {
380  KConfigGroup cg = configGroup(config);
381 
382  mReference = QUrl(cg.readEntry<QString>(mKey, mDefault.toString()));
383  mLoadedValue = mReference;
384 
385  readImmutability(cg);
386 }
387 
389 {
390  mReference = qvariant_cast<QUrl>(p);
391 }
392 
394 {
395  return mReference == qvariant_cast<QUrl>(v);
396 }
397 
399 {
400  return QVariant::fromValue<QUrl>(mReference);
401 }
402 
404  const QString &_key,
405  QVariant &reference,
406  const QVariant &defaultValue)
407  : KConfigSkeletonGenericItem<QVariant>(_group, _key, reference, defaultValue)
408 {
409 }
410 
412 {
413  KConfigGroup cg = configGroup(config);
414  mReference = cg.readEntry(mKey, mDefault);
415  mLoadedValue = mReference;
416 
417  readImmutability(cg);
418 }
419 
421 {
422  mReference = p;
423 }
424 
426 {
427  //this might cause problems if the QVariants are not of default types
428  return mReference == v;
429 }
430 
432 {
433  return mReference;
434 }
435 
437  bool &reference, bool defaultValue)
438  : KConfigSkeletonGenericItem<bool>(_group, _key, reference, defaultValue)
439 {
440 }
441 
443 {
444  KConfigGroup cg = configGroup(config);
445  mReference = cg.readEntry(mKey, mDefault);
446  mLoadedValue = mReference;
447 
448  readImmutability(cg);
449 }
450 
452 {
453  mReference = p.toBool();
454 }
455 
457 {
458  return mReference == v.toBool();
459 }
460 
462 {
463  return QVariant(mReference);
464 }
465 
467  qint32 &reference, qint32 defaultValue)
468  : KConfigSkeletonGenericItem<qint32>(_group, _key, reference, defaultValue)
469  , mHasMin(false), mHasMax(false)
470 {
471 }
472 
474 {
475  KConfigGroup cg = configGroup(config);
476  mReference = cg.readEntry(mKey, mDefault);
477  if (mHasMin) {
478  mReference = qMax(mReference, mMin);
479  }
480  if (mHasMax) {
481  mReference = qMin(mReference, mMax);
482  }
483  mLoadedValue = mReference;
484 
485  readImmutability(cg);
486 }
487 
489 {
490  mReference = p.toInt();
491 }
492 
494 {
495  return mReference == v.toInt();
496 }
497 
499 {
500  return QVariant(mReference);
501 }
502 
504 {
505  if (mHasMin) {
506  return QVariant(mMin);
507  }
508  return QVariant();
509 }
510 
512 {
513  if (mHasMax) {
514  return QVariant(mMax);
515  }
516  return QVariant();
517 }
518 
520 {
521  mHasMin = true;
522  mMin = v;
523 }
524 
526 {
527  mHasMax = true;
528  mMax = v;
529 }
530 
532  qint64 &reference, qint64 defaultValue)
533  : KConfigSkeletonGenericItem<qint64>(_group, _key, reference, defaultValue)
534  , mHasMin(false), mHasMax(false)
535 {
536 }
537 
539 {
540  KConfigGroup cg = configGroup(config);
541  mReference = cg.readEntry(mKey, mDefault);
542  if (mHasMin) {
543  mReference = qMax(mReference, mMin);
544  }
545  if (mHasMax) {
546  mReference = qMin(mReference, mMax);
547  }
548  mLoadedValue = mReference;
549 
550  readImmutability(cg);
551 }
552 
554 {
555  mReference = p.toLongLong();
556 }
557 
559 {
560  return mReference == v.toLongLong();
561 }
562 
564 {
565  return QVariant(mReference);
566 }
567 
569 {
570  if (mHasMin) {
571  return QVariant(mMin);
572  }
573  return QVariant();
574 }
575 
577 {
578  if (mHasMax) {
579  return QVariant(mMax);
580  }
581  return QVariant();
582 }
583 
585 {
586  mHasMin = true;
587  mMin = v;
588 }
589 
591 {
592  mHasMax = true;
593  mMax = v;
594 }
595 
597 {
598  // HACK for BC concerns
599  // TODO KF6: remove KConfigSkeletonItemPrivate::mValues and add a value field to KCoreConfigSkeleton::ItemEnum::Choice
600  const auto inHash = d_ptr->mValues.value(name);
601  return !inHash.isEmpty() ? inHash : name;
602 }
603 
605 {
606  d_ptr->mValues.insert(name, value);
607 }
608 
610  qint32 &reference,
611  const QList<Choice> &choices,
612  qint32 defaultValue)
613  : ItemInt(_group, _key, reference, defaultValue), mChoices(choices)
614 {
615 }
616 
618 {
619  KConfigGroup cg = configGroup(config);
620  if (!cg.hasKey(mKey)) {
621  mReference = mDefault;
622  } else {
623  int i = 0;
624  mReference = -1;
625  QString tmp = cg.readEntry(mKey, QString()).toLower();
626  for (QList<Choice>::ConstIterator it = mChoices.constBegin();
627  it != mChoices.constEnd(); ++it, ++i) {
628  QString choiceName = (*it).name;
629  if (valueForChoice(choiceName).toLower() == tmp) {
630  mReference = i;
631  break;
632  }
633  }
634  if (mReference == -1) {
635  mReference = cg.readEntry(mKey, mDefault);
636  }
637  }
638  mLoadedValue = mReference;
639 
640  readImmutability(cg);
641 }
642 
644 {
645  if (mReference != mLoadedValue) { // WABA: Is this test needed?
646  KConfigGroup cg = configGroup(config);
647  if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
649  } else if ((mReference >= 0) && (mReference < mChoices.count())) {
650  cg.writeEntry(mKey, valueForChoice(mChoices.at(mReference).name), writeFlags());
651  } else {
652  cg.writeEntry(mKey, mReference, writeFlags());
653  }
654  mLoadedValue = mReference;
655  }
656 }
657 
658 QList<KCoreConfigSkeleton::ItemEnum::Choice> KCoreConfigSkeleton::ItemEnum::choices() const
659 {
660  return mChoices;
661 }
662 
663 QList<KCoreConfigSkeleton::ItemEnum::Choice> KCoreConfigSkeleton::ItemEnum::choices2() const
664 {
665  return mChoices;
666 }
667 
669  quint32 &reference,
670  quint32 defaultValue)
671  : KConfigSkeletonGenericItem<quint32>(_group, _key, reference, defaultValue)
672  , mHasMin(false), mHasMax(false)
673 {
674 }
675 
677 {
678  KConfigGroup cg = configGroup(config);
679  mReference = cg.readEntry(mKey, mDefault);
680  if (mHasMin) {
681  mReference = qMax(mReference, mMin);
682  }
683  if (mHasMax) {
684  mReference = qMin(mReference, mMax);
685  }
686  mLoadedValue = mReference;
687 
688  readImmutability(cg);
689 }
690 
692 {
693  mReference = p.toUInt();
694 }
695 
697 {
698  return mReference == v.toUInt();
699 }
700 
702 {
703  return QVariant(mReference);
704 }
705 
707 {
708  if (mHasMin) {
709  return QVariant(mMin);
710  }
711  return QVariant();
712 }
713 
715 {
716  if (mHasMax) {
717  return QVariant(mMax);
718  }
719  return QVariant();
720 }
721 
723 {
724  mHasMin = true;
725  mMin = v;
726 }
727 
729 {
730  mHasMax = true;
731  mMax = v;
732 }
733 
735  quint64 &reference, quint64 defaultValue)
736  : KConfigSkeletonGenericItem<quint64>(_group, _key, reference, defaultValue)
737  , mHasMin(false), mHasMax(false)
738 {
739 }
740 
742 {
743  KConfigGroup cg = configGroup(config);
744  mReference = cg.readEntry(mKey, mDefault);
745  if (mHasMin) {
746  mReference = qMax(mReference, mMin);
747  }
748  if (mHasMax) {
749  mReference = qMin(mReference, mMax);
750  }
751  mLoadedValue = mReference;
752 
753  readImmutability(cg);
754 }
755 
757 {
758  mReference = p.toULongLong();
759 }
760 
762 {
763  return mReference == v.toULongLong();
764 }
765 
767 {
768  return QVariant(mReference);
769 }
770 
772 {
773  if (mHasMin) {
774  return QVariant(mMin);
775  }
776  return QVariant();
777 }
778 
780 {
781  if (mHasMax) {
782  return QVariant(mMax);
783  }
784  return QVariant();
785 }
786 
788 {
789  mHasMin = true;
790  mMin = v;
791 }
792 
794 {
795  mHasMax = true;
796  mMax = v;
797 }
798 
800  double &reference, double defaultValue)
801  : KConfigSkeletonGenericItem<double>(_group, _key, reference, defaultValue)
802  , mHasMin(false), mHasMax(false)
803 {
804 }
805 
807 {
808  KConfigGroup cg = configGroup(config);
809  mReference = cg.readEntry(mKey, mDefault);
810  if (mHasMin) {
811  mReference = qMax(mReference, mMin);
812  }
813  if (mHasMax) {
814  mReference = qMin(mReference, mMax);
815  }
816  mLoadedValue = mReference;
817 
818  readImmutability(cg);
819 }
820 
822 {
823  mReference = p.toDouble();
824 }
825 
827 {
828  return mReference == v.toDouble();
829 }
830 
832 {
833  return QVariant(mReference);
834 }
835 
837 {
838  if (mHasMin) {
839  return QVariant(mMin);
840  }
841  return QVariant();
842 }
843 
845 {
846  if (mHasMax) {
847  return QVariant(mMax);
848  }
849  return QVariant();
850 }
851 
853 {
854  mHasMin = true;
855  mMin = v;
856 }
857 
859 {
860  mHasMax = true;
861  mMax = v;
862 }
863 
865  QRect &reference,
866  const QRect &defaultValue)
867  : KConfigSkeletonGenericItem<QRect>(_group, _key, reference, defaultValue)
868 {
869 }
870 
872 {
873  KConfigGroup cg = configGroup(config);
874  mReference = cg.readEntry(mKey, mDefault);
875  mLoadedValue = mReference;
876 
877  readImmutability(cg);
878 }
879 
881 {
882  mReference = p.toRect();
883 }
884 
886 {
887  return mReference == v.toRect();
888 }
889 
891 {
892  return QVariant(mReference);
893 }
894 
896  QPoint &reference,
897  const QPoint &defaultValue)
898  : KConfigSkeletonGenericItem<QPoint>(_group, _key, reference, defaultValue)
899 {
900 }
901 
903 {
904  KConfigGroup cg = configGroup(config);
905  mReference = cg.readEntry(mKey, mDefault);
906  mLoadedValue = mReference;
907 
908  readImmutability(cg);
909 }
910 
912 {
913  mReference = p.toPoint();
914 }
915 
917 {
918  return mReference == v.toPoint();
919 }
920 
922 {
923  return QVariant(mReference);
924 }
925 
927  QSize &reference,
928  const QSize &defaultValue)
929  : KConfigSkeletonGenericItem<QSize>(_group, _key, reference, defaultValue)
930 {
931 }
932 
934 {
935  KConfigGroup cg = configGroup(config);
936  mReference = cg.readEntry(mKey, mDefault);
937  mLoadedValue = mReference;
938 
939  readImmutability(cg);
940 }
941 
943 {
944  mReference = p.toSize();
945 }
946 
948 {
949  return mReference == v.toSize();
950 }
951 
953 {
954  return QVariant(mReference);
955 }
956 
958  QDateTime &reference,
959  const QDateTime &defaultValue)
960  : KConfigSkeletonGenericItem<QDateTime>(_group, _key, reference, defaultValue)
961 {
962 }
963 
965 {
966  KConfigGroup cg = configGroup(config);
967  mReference = cg.readEntry(mKey, mDefault);
968  mLoadedValue = mReference;
969 
970  readImmutability(cg);
971 }
972 
974 {
975  mReference = p.toDateTime();
976 }
977 
979 {
980  return mReference == v.toDateTime();
981 }
982 
984 {
985  return QVariant(mReference);
986 }
987 
989  QStringList &reference,
990  const QStringList &defaultValue)
991  : KConfigSkeletonGenericItem<QStringList>(_group, _key, reference, defaultValue)
992 {
993 }
994 
996 {
997  KConfigGroup cg = configGroup(config);
998  if (!cg.hasKey(mKey)) {
999  mReference = mDefault;
1000  } else {
1001  mReference = cg.readEntry(mKey, mDefault);
1002  }
1003  mLoadedValue = mReference;
1004 
1005  readImmutability(cg);
1006 }
1007 
1009 {
1010  mReference = p.toStringList();
1011 }
1012 
1014 {
1015  return mReference == v.toStringList();
1016 }
1017 
1019 {
1020  return QVariant(mReference);
1021 }
1022 
1024  QStringList &reference,
1025  const QStringList &defaultValue)
1026  : ItemStringList(_group, _key, reference, defaultValue)
1027 {
1028 }
1029 
1031 {
1032  KConfigGroup cg = configGroup(config);
1033  if (!cg.hasKey(mKey)) {
1034  mReference = mDefault;
1035  } else {
1036  mReference = cg.readPathEntry(mKey, QStringList());
1037  }
1038  mLoadedValue = mReference;
1039 
1040  readImmutability(cg);
1041 }
1042 
1044 {
1045  if (mReference != mLoadedValue) { // WABA: Is this test needed?
1046  KConfigGroup cg = configGroup(config);
1047  if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
1049  } else {
1050  QStringList sl = mReference;
1051  cg.writePathEntry(mKey, sl, writeFlags());
1052  }
1053  mLoadedValue = mReference;
1054  }
1055 }
1056 
1058  QList<QUrl> &reference,
1059  const QList<QUrl> &defaultValue)
1060  : KConfigSkeletonGenericItem<QList<QUrl> >(_group, _key, reference, defaultValue)
1061 {
1062 }
1063 
1065 {
1066  KConfigGroup cg = configGroup(config);
1067  if (!cg.hasKey(mKey)) {
1068  mReference = mDefault;
1069  } else {
1070  QStringList strList;
1071  for (const QUrl &url : qAsConst(mDefault)) {
1072  strList.append(url.toString());
1073  }
1074  mReference.clear();
1075  const QStringList readList = cg.readEntry<QStringList>(mKey, strList);
1076  for (const QString &str : readList) {
1077  mReference.append(QUrl(str));
1078  }
1079  }
1080  mLoadedValue = mReference;
1081 
1082  readImmutability(cg);
1083 }
1084 
1086 {
1087  if (mReference != mLoadedValue) { // WABA: Is this test needed?
1088  KConfigGroup cg = configGroup(config);
1089  if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
1091  } else {
1092  QStringList strList;
1093  for (const QUrl &url : qAsConst(mReference)) {
1094  strList.append(url.toString());
1095  }
1096  cg.writeEntry<QStringList>(mKey, strList, writeFlags());
1097  }
1098  mLoadedValue = mReference;
1099  }
1100 }
1101 
1103 {
1104  mReference = qvariant_cast<QList<QUrl> >(p);
1105 }
1106 
1108 {
1109  return mReference == qvariant_cast<QList<QUrl> >(v);
1110 }
1111 
1113 {
1114  return QVariant::fromValue<QList<QUrl> >(mReference);
1115 }
1116 
1118  QList<int> &reference,
1119  const QList<int> &defaultValue)
1120  : KConfigSkeletonGenericItem<QList<int> >(_group, _key, reference, defaultValue)
1121 {
1122 }
1123 
1125 {
1126  KConfigGroup cg = configGroup(config);
1127  if (!cg.hasKey(mKey)) {
1128  mReference = mDefault;
1129  } else {
1130  mReference = cg.readEntry(mKey, mDefault);
1131  }
1132  mLoadedValue = mReference;
1133 
1134  readImmutability(cg);
1135 }
1136 
1138 {
1139  mReference = qvariant_cast< QList<int> >(p);
1140 }
1141 
1143 {
1144  return mReference == qvariant_cast< QList<int> >(v);
1145 }
1146 
1148 {
1149  return QVariant::fromValue< QList<int> >(mReference);
1150 }
1151 
1152 //static int kCoreConfigSkeletionDebugArea() { static int s_area = KDebug::registerArea("kdecore (KConfigSkeleton)"); return s_area; }
1153 
1155  : QObject(parent),
1156  d(new KCoreConfigSkeletonPrivate)
1157 {
1158  //qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
1159 
1160  d->mConfig = KSharedConfig::openConfig(configname, KConfig::FullConfig);
1161 }
1162 
1164  : QObject(parent),
1165  d(new KCoreConfigSkeletonPrivate)
1166 {
1167  //qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
1168  d->mConfig = std::move(pConfig);
1169 }
1170 
1172 {
1173  delete d;
1174 }
1175 
1177 {
1178  d->mCurrentGroup = group;
1179 }
1180 
1182 {
1183  return d->mCurrentGroup;
1184 }
1185 
1187 {
1188  return d->mConfig.data();
1189 }
1190 
1192 {
1193  return d->mConfig.data();
1194 }
1195 
1197 {
1198  return d->mConfig;
1199 }
1200 
1202 {
1203  d->mConfig = std::move(pConfig);
1204 }
1205 
1207 {
1208  return d->mItems;
1209 }
1210 
1212 {
1213  if (b == d->mUseDefaults) {
1214  return d->mUseDefaults;
1215  }
1216 
1217  d->mUseDefaults = b;
1219  for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
1220  (*it)->swapDefault();
1221  }
1222  usrUseDefaults(b);
1223  return !d->mUseDefaults;
1224 }
1225 
1227 {
1229  for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
1230  (*it)->setDefault();
1231  }
1232  usrSetDefaults();
1233 }
1234 
1236 {
1237  d->mConfig->reparseConfiguration();
1238  read();
1239 }
1240 
1242 {
1244  for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
1245  (*it)->readConfig(d->mConfig.data());
1246  }
1247  usrRead();
1248 }
1249 
1251 {
1253  for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
1254  if (!(*it)->isDefault()) {
1255  return false;
1256  }
1257  }
1258  return true;
1259 }
1260 
1262 {
1264  for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
1265  if ((*it)->isSaveNeeded()) {
1266  return true;
1267  }
1268  }
1269  return false;
1270 }
1271 
1273 {
1274  //qDebug();
1276  for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
1277  (*it)->writeConfig(d->mConfig.data());
1278  }
1279  if (!usrSave()) {
1280  return false;
1281  }
1282 
1283  if (d->mConfig->isDirty()) {
1284  if (!d->mConfig->sync()) {
1285  return false;
1286  }
1287  emit configChanged();
1288  }
1289  return true;
1290 }
1291 
1293 {
1294  return false;
1295 }
1296 
1298 {
1299 }
1300 
1302 {
1303 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
1304  usrReadConfig();
1305 #endif
1306 }
1307 
1308 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
1310 {
1311 }
1312 #endif
1313 
1315 {
1316 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
1317  return usrWriteConfig();
1318 #else
1319  return true;
1320 #endif
1321 }
1322 
1323 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
1325 {
1326  return true;
1327 }
1328 #endif
1329 
1331 {
1332  if (d->mItems.contains(item)) {
1333  if (item->name() == name ||
1334  (name.isEmpty() && item->name() == item->key())) {
1335  // nothing to do -> it is already in our collection
1336  // and the name isn't changing
1337  return;
1338  }
1339 
1340  d->mItemDict.remove(item->name());
1341  } else {
1342  d->mItems.append(item);
1343  }
1344 
1345  item->setName(name.isEmpty() ? item->key() : name);
1346  d->mItemDict.insert(item->name(), item);
1347  item->readDefault(d->mConfig.data());
1348  item->readConfig(d->mConfig.data());
1349 }
1350 
1352 {
1353  KConfigSkeletonItem *item = d->mItemDict.value(name);
1354  if (item) {
1355  d->mItems.removeAll(item);
1356  d->mItemDict.remove(item->name());
1357  delete item;
1358  }
1359 }
1360 
1362 {
1363  KConfigSkeletonItem::List items = d->mItems;
1364  d->mItems.clear();
1365  d->mItemDict.clear();
1366  qDeleteAll(items);
1367 }
1368 
1370  const QString &defaultValue, const QString &key)
1371 {
1373  item = new KCoreConfigSkeleton::ItemString(d->mCurrentGroup, key.isEmpty() ? name : key,
1374  reference, defaultValue,
1376  addItem(item, name);
1377  return item;
1378 }
1379 
1381  const QString &defaultValue, const QString &key)
1382 {
1384  item = new KCoreConfigSkeleton::ItemPassword(d->mCurrentGroup, key.isNull() ? name : key,
1385  reference, defaultValue);
1386  addItem(item, name);
1387  return item;
1388 }
1389 
1391  const QString &defaultValue, const QString &key)
1392 {
1394  item = new KCoreConfigSkeleton::ItemPath(d->mCurrentGroup, key.isNull() ? name : key,
1395  reference, defaultValue);
1396  addItem(item, name);
1397  return item;
1398 }
1399 
1401  const QVariant &defaultValue, const QString &key)
1402 {
1404  item = new KCoreConfigSkeleton::ItemProperty(d->mCurrentGroup, key.isNull() ? name : key,
1405  reference, defaultValue);
1406  addItem(item, name);
1407  return item;
1408 }
1409 
1411  bool defaultValue, const QString &key)
1412 {
1414  item = new KCoreConfigSkeleton::ItemBool(d->mCurrentGroup, key.isNull() ? name : key,
1415  reference, defaultValue);
1416  addItem(item, name);
1417  return item;
1418 }
1419 
1421  qint32 defaultValue, const QString &key)
1422 {
1424  item = new KCoreConfigSkeleton::ItemInt(d->mCurrentGroup, key.isNull() ? name : key,
1425  reference, defaultValue);
1426  addItem(item, name);
1427  return item;
1428 }
1429 
1431  quint32 defaultValue, const QString &key)
1432 {
1434  item = new KCoreConfigSkeleton::ItemUInt(d->mCurrentGroup, key.isNull() ? name : key,
1435  reference, defaultValue);
1436  addItem(item, name);
1437  return item;
1438 }
1439 
1441  qint64 defaultValue, const QString &key)
1442 {
1444  item = new KCoreConfigSkeleton::ItemLongLong(d->mCurrentGroup, key.isNull() ? name : key,
1445  reference, defaultValue);
1446  addItem(item, name);
1447  return item;
1448 }
1449 
1450 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
1452  const QString &name,
1453  qint64 &reference,
1454  qint64 defaultValue,
1455  const QString &key)
1456 {
1457  return addItemLongLong(name, reference, defaultValue, key);
1458 }
1459 #endif
1460 
1462  quint64 defaultValue, const QString &key)
1463 {
1465  item = new KCoreConfigSkeleton::ItemULongLong(d->mCurrentGroup, key.isNull() ? name : key,
1466  reference, defaultValue);
1467  addItem(item, name);
1468  return item;
1469 }
1470 
1471 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
1473  const QString &name,
1474  quint64 &reference,
1475  quint64 defaultValue,
1476  const QString &key)
1477 {
1478  return addItemULongLong(name, reference, defaultValue, key);
1479 }
1480 #endif
1481 
1483  double defaultValue, const QString &key)
1484 {
1486  item = new KCoreConfigSkeleton::ItemDouble(d->mCurrentGroup, key.isNull() ? name : key,
1487  reference, defaultValue);
1488  addItem(item, name);
1489  return item;
1490 }
1491 
1493  const QRect &defaultValue, const QString &key)
1494 {
1496  item = new KCoreConfigSkeleton::ItemRect(d->mCurrentGroup, key.isNull() ? name : key,
1497  reference, defaultValue);
1498  addItem(item, name);
1499  return item;
1500 }
1501 
1503  const QPoint &defaultValue, const QString &key)
1504 {
1506  item = new KCoreConfigSkeleton::ItemPoint(d->mCurrentGroup, key.isNull() ? name : key,
1507  reference, defaultValue);
1508  addItem(item, name);
1509  return item;
1510 }
1511 
1513  const QSize &defaultValue, const QString &key)
1514 {
1516  item = new KCoreConfigSkeleton::ItemSize(d->mCurrentGroup, key.isNull() ? name : key,
1517  reference, defaultValue);
1518  addItem(item, name);
1519  return item;
1520 }
1521 
1523  const QDateTime &defaultValue, const QString &key)
1524 {
1526  item = new KCoreConfigSkeleton::ItemDateTime(d->mCurrentGroup, key.isNull() ? name : key,
1527  reference, defaultValue);
1528  addItem(item, name);
1529  return item;
1530 }
1531 
1533  const QStringList &defaultValue, const QString &key)
1534 {
1536  item = new KCoreConfigSkeleton::ItemStringList(d->mCurrentGroup, key.isNull() ? name : key,
1537  reference, defaultValue);
1538  addItem(item, name);
1539  return item;
1540 }
1541 
1543  const QList<int> &defaultValue, const QString &key)
1544 {
1546  item = new KCoreConfigSkeleton::ItemIntList(d->mCurrentGroup, key.isNull() ? name : key,
1547  reference, defaultValue);
1548  addItem(item, name);
1549  return item;
1550 }
1551 
1553 {
1554  KConfigSkeletonItem *item = findItem(name);
1555  return !item || item->isImmutable();
1556 }
1557 
1559 {
1560  return d->mItemDict.value(name);
1561 }
1562 
1563 KConfigCompilerSignallingItem::KConfigCompilerSignallingItem(KConfigSkeletonItem* item, QObject* object,
1564  KConfigCompilerSignallingItem::NotifyFunction targetFunction, quint64 userData)
1565  : KConfigSkeletonItem(item->group(), item->key()), mItem(item), mTargetFunction(targetFunction),
1566  mObject(object), mUserData(userData)
1567 {
1568  Q_ASSERT(mTargetFunction);
1569  Q_ASSERT(mItem);
1570  Q_ASSERT(mObject);
1571 
1572  setIsDefaultImpl([this] { return mItem->isDefault(); });
1573  setIsSaveNeededImpl([this] { return mItem->isSaveNeeded(); });
1574  setGetDefaultImpl([this] {return mItem->getDefault(); });
1575 }
1576 
1577 KConfigCompilerSignallingItem::~KConfigCompilerSignallingItem()
1578 {
1579 }
1580 
1581 bool KConfigCompilerSignallingItem::isEqual(const QVariant& p) const
1582 {
1583  return mItem->isEqual(p);
1584 }
1585 
1586 QVariant KConfigCompilerSignallingItem::property() const
1587 {
1588  return mItem->property();
1589 }
1590 
1591 void KConfigCompilerSignallingItem::readConfig(KConfig* c)
1592 {
1593  QVariant oldValue = mItem->property();
1594  mItem->readConfig(c);
1595  //readConfig() changes mIsImmutable, update it here as well
1596  KConfigGroup cg = configGroup(c);
1597  readImmutability(cg);
1598  if (!mItem->isEqual(oldValue)) {
1599  invokeNotifyFunction();
1600  }
1601 }
1602 
1603 void KConfigCompilerSignallingItem::readDefault(KConfig* c)
1604 {
1605  mItem->readDefault(c);
1606  //readDefault() changes mIsImmutable, update it here as well
1607  KConfigGroup cg = configGroup(c);
1608  readImmutability(cg);
1609 }
1610 
1611 void KConfigCompilerSignallingItem::writeConfig(KConfig* c)
1612 {
1613  mItem->writeConfig(c);
1614 }
1615 
1616 void KConfigCompilerSignallingItem::setDefault()
1617 {
1618  QVariant oldValue = mItem->property();
1619  mItem->setDefault();
1620  if (!mItem->isEqual(oldValue)) {
1621  invokeNotifyFunction();
1622  }
1623 }
1624 
1625 void KConfigCompilerSignallingItem::setProperty(const QVariant& p)
1626 {
1627  if (!mItem->isEqual(p)) {
1628  mItem->setProperty(p);
1629  invokeNotifyFunction();
1630  }
1631 }
1632 
1633 void KConfigCompilerSignallingItem::swapDefault()
1634 {
1635  QVariant oldValue = mItem->property();
1636  mItem->swapDefault();
1637  if (!mItem->isEqual(oldValue)) {
1638  invokeNotifyFunction();
1639  }
1640 }
1641 
1642 void KConfigCompilerSignallingItem::setWriteFlags(KConfigBase::WriteConfigFlags flags)
1643 {
1644  mItem->setWriteFlags(flags);
1645 }
1646 
1647 KConfigBase::WriteConfigFlags KConfigCompilerSignallingItem::writeFlags() const
1648 {
1649  return mItem->writeFlags();
1650 }
1651 
1652 void KConfigCompilerSignallingItem::setGroup(const KConfigGroup &cg)
1653 {
1654  mItem->setGroup(cg);
1655 }
1656 
1657 KConfigGroup KConfigCompilerSignallingItem::configGroup(KConfig *config) const
1658 {
1659  return mItem->configGroup(config);
1660 }
void writeConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to write the value of this setting to a config file...
void setProperty(const QVariant &p) override
Set item to p.
Class for handling unsigned 64-bit integer preferences item.
void readConfig(KConfig *) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
qlonglong toLongLong(bool *ok) const const
QString readPathEntry(const QString &pKey, const QString &aDefault) const
Reads a path.
KConfig * config()
Return the KConfig object used for reading and writing the settings.
ItemInt(const QString &_group, const QString &_key, qint32 &reference, qint32 defaultValue=0)
Class for proxying a QObject property as a preferences setting.
ItemSize * addItemSize(const QString &name, QSize &reference, const QSize &defaultValue=QSize(), const QString &key=QString())
Register an item of type QSize.
void setDefault() override
Sets the current value to the default value.
virtual bool usrSave()
Perform the actual writing of the configuration file.
void writePathEntry(const QString &pKey, const QString &path, WriteConfigFlags pFlags=Normal)
Writes a file path to the configuration.
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
void writeConfig(KConfig *) override
This function is called by KCoreConfigSkeleton to write the value of this setting to a config file...
Class for handling a floating point preference item.
Class for handling a string preferences item.
QString group() const
Return config file group.
void setProperty(const QVariant &p) override
Set item to p.
void read()
Read preferences from the KConfig object.
void setMaxValue(quint32)
Set the maximum value for the item.
QVariant property() const override
Return item as property.
virtual void readDefault(KConfig *)=0
Read global default value.
QVariant property() const override
Return item as property.
bool hasDefault(const QString &key) const
Whether a default is specified for an entry in either the system wide configuration file or the globa...
QDateTime toDateTime() const const
ItemPathList(const QString &_group, const QString &_key, QStringList &reference, const QStringList &defaultValue=QStringList())
void removeItem(const QString &name)
Removes and deletes an item by name.
ItemLongLong * addItemInt64(const QString &name, qint64 &reference, qint64 defaultValue=0, const QString &key=QString())
bool isImmutable() const
Return if the entry can be modified.
QVariant property() const override
Return item as property.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
QVariant maxValue() const override
Get the maximum value this is allowed to be stored in this item.
QVariant minValue() const override
Get the minimum value that is allowed to be stored in this item.
bool isEntryImmutable(const QString &key) const
Checks if it is possible to change the given entry.
const T & at(int i) const const
bool isSaveNeeded() const
Indicates if the item has a different value than the previously loaded value.
void setProperty(const QVariant &p) override
Set item to p.
ItemEnum(const QString &_group, const QString &_key, qint32 &reference, const QList< Choice > &choices, qint32 defaultValue=0)
ItemPoint(const QString &_group, const QString &_key, QPoint &reference, const QPoint &defaultValue=QPoint())
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
void setCurrentGroup(const QString &group)
Set the config file group for subsequent addItem() calls.
void writeConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to write the value of this setting to a config file...
QVariant property() const override
Return item as property.
bool isDefaults() const
Indicates if all the registered items are set to their default value.
void setProperty(const QVariant &p) override
Set item to p.
QVariant maxValue() const override
Get the maximum value this is allowed to be stored in this item.
ItemDateTime(const QString &_group, const QString &_key, QDateTime &reference, const QDateTime &defaultValue=QDateTime())
void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags=Normal)
Writes a value to the configuration object.
bool save()
Write preferences to config file.
QString toolTip() const
Return ToolTip description of item.
bool isSaveNeeded() const
Indicates if any registered item has a different value than the previously loaded value...
Class for handling a QDateTime preferences item.
ItemBool(const QString &_group, const QString &_key, bool &reference, bool defaultValue=true)
void setProperty(const QVariant &p) override
Set item to p.
Class for handling a 64-bit integer preferences item.
QVariant property() const override
Return item as property.
void setKey(const QString &_key)
Set config file key.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
A path to a file or directory.
void setProperty(const QVariant &p) override
Set item to p.
virtual void usrSetDefaults()
Perform the actual setting of default values.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
virtual QVariant maxValue() const
Return maximum value of item or invalid if not specified.
ItemUrlList(const QString &_group, const QString &_key, QList< QUrl > &reference, const QList< QUrl > &defaultValue=QList< QUrl >())
QVariant property() const override
Return item as property.
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
qulonglong toULongLong(bool *ok) const const
Class for handling a password preferences item.
void setProperty(const QVariant &p) override
Set item to p.
void setValueForChoice(const QString &name, const QString &valueForChoice)
Stores a choice value for name.
void configChanged()
This signal is emitted when the configuration change.
ItemDateTime * addItemDateTime(const QString &name, QDateTime &reference, const QDateTime &defaultValue=QDateTime(), const QString &key=QString())
Register an item of type QDateTime.
void writeConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to write the value of this setting to a config file...
ItemUInt * addItemUInt(const QString &name, quint32 &reference, quint32 defaultValue=0, const QString &key=QString())
Register an item of type quint32.
void readDefault(KConfig *) override
Read global default value.
bool isNull() const const
QVariant property() const override
Return item as property.
ItemIntList * addItemIntList(const QString &name, QList< int > &reference, const QList< int > &defaultValue=QList< int >(), const QString &key=QString())
Register an item of type QList<int>.
KConfigSkeletonItem * findItem(const QString &name) const
Lookup item by name.
ItemStringList(const QString &_group, const QString &_key, QStringList &reference, const QStringList &defaultValue=QStringList())
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
virtual void readConfig(KConfig *)=0
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
QVariant property() const override
Return item as property.
void setWhatsThis(const QString &w)
Set WhatsThis description of item.
bool isDefault() const
Indicates if the item is set to its default value.
ItemUrl(const QString &_group, const QString &_key, QUrl &reference, const QUrl &defaultValue=QUrl())
Class for handling a QVariant preferences item.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
ItemUInt(const QString &_group, const QString &_key, quint32 &reference, quint32 defaultValue=0)
bool isEqual(const QVariant &p) const override
void setProperty(const QVariant &p) override
Set item to p.
int count(const T &value) const const
void append(const T &value)
QVariant property() const override
Return item as property.
uint toUInt(bool *ok) const const
void setWriteFlags(KConfigBase::WriteConfigFlags flags)
The write flags to be used when writing configuration.
Class for handling a bool preferences item.
void setProperty(const QVariant &p) override
Set item to p.
Type
The type of string that is held in this item.
int toInt(bool *ok) const const
ItemInt * addItemInt(const QString &name, qint32 &reference, qint32 defaultValue=0, const QString &key=QString())
Register an item of type qint32.
KConfigGroup configGroup(KConfig *config) const
Return a KConfigGroup, the one provided by setGroup(KConfigGroup) if it&#39;s valid, or make one from...
Class for handling an unsigned 32-bit integer preferences item.
void setMaxValue(double)
Set the maximum value for the item.
QString label() const
Return label of item.
ItemIntList(const QString &_group, const QString &_key, QList< int > &reference, const QList< int > &defaultValue=QList< int >())
void setToolTip(const QString &t)
Set ToolTip description of item.
void setProperty(const QVariant &p) override
Set item to p.
QVariant getDefault() const
Returns the default value.
void setProperty(const QVariant &p) override
Set item to p.
bool isEmpty() const const
void setLabel(const QString &l)
Set label providing a translated one-line description of the item.
void setMinValue(double)
Set the minimum value for the item.
ItemBool * addItemBool(const QString &name, bool &reference, bool defaultValue=false, const QString &key=QString())
Register an item of type bool.
QVariant property() const override
Return item as property.
ItemPath * addItemPath(const QString &name, QString &reference, const QString &defaultValue=QLatin1String(""), const QString &key=QString())
Register a path item of type QString.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
ItemULongLong * addItemULongLong(const QString &name, quint64 &reference, quint64 defaultValue=0, const QString &key=QString())
Register an item of type quint64.
QVariant minValue() const override
Get the minimum value that is allowed to be stored in this item.
void setMinValue(qint32)
Set the minimum value for the item.
void setProperty(const QVariant &p) override
Set item to p.
QVariant maxValue() const override
Get the maximum value this is allowed to be stored in this item.
void load()
Read preferences from config file.
QString name() const
Return internal name of entry.
ItemLongLong * addItemLongLong(const QString &name, qint64 &reference, qint64 defaultValue=0, const QString &key=QString())
Register an item of type qint64.
Class for handling a QRect preferences item.
void setProperty(const QVariant &p) override
Set item to p.
ItemStringList * addItemStringList(const QString &name, QStringList &reference, const QStringList &defaultValue=QStringList(), const QString &key=QString())
Register an item of type QStringList.
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
QSize toSize() const const
QVariant property() const override
Return item as property.
void setProperty(const QVariant &p) override
Set item to p.
ItemDouble(const QString &_group, const QString &_key, double &reference, double defaultValue=0)
void setMinValue(qint64)
Set the minimum value for the item.
QString toLower() const const
ItemPassword(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue=QLatin1String(""))
QString key() const
Return config file key.
ItemRect * addItemRect(const QString &name, QRect &reference, const QRect &defaultValue=QRect(), const QString &key=QString())
Register an item of type QRect.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
KConfigSkeletonItem(const QString &_group, const QString &_key)
Constructor.
void setProperty(const QVariant &p) override
Set item to p.
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
Creates a KSharedConfig object to manipulate a configuration file.
QString mName
The name of this item.
Class for handling a 32-bit integer preferences item.
bool hasKey(const QString &key) const
Checks whether the key has an entry in this group.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
ItemPoint * addItemPoint(const QString &name, QPoint &reference, const QPoint &defaultValue=QPoint(), const QString &key=QString())
Register an item of type QPoint.
void setMinValue(quint64)
Set the minimum value for the item.
A class for one specific group in a KConfig object.
Definition: kconfiggroup.h:38
ItemULongLong * addItemUInt64(const QString &name, quint64 &reference, quint64 defaultValue=0, const QString &key=QString())
QVariant minValue() const override
Get the minimum value that is allowed to be stored in this item.
void swapDefault() override
Exchanges the current value with the default value Used by KCoreConfigSkeleton::useDefaults(bool);.
void setMinValue(quint32)
Set the minimum value for the item.
ItemLongLong(const QString &_group, const QString &_key, qint64 &reference, qint64 defaultValue=0)
const QChar * unicode() const const
void writeConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to write the value of this setting to a config file...
QVariant property() const override
Return item as property.
Class for handling a QPoint preferences item.
The central class of the KDE configuration data system.
Definition: kconfig.h:56
void readImmutability(const KConfigGroup &group)
sets mIsImmutable to true if mKey in config is immutable
QString valueForChoice(const QString &name) const
Returns the value for for the choice with the given name.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
QStringList toStringList() const const
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
QVariant minValue() const override
Get the minimum value that is allowed to be stored in this item.
QVariant property() const override
Return item as property.
void setSharedConfig(KSharedConfig::Ptr pConfig)
Set the KSharedConfig object used for reading and writing the settings.
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
void setMaxValue(qint64)
Set the maximum value for the item.
Class for handling a QSize preferences item.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
virtual void setDefaults()
Set all registered items to their default values.
KCoreConfigSkeleton(const QString &configname=QString(), QObject *parent=nullptr)
Constructor.
ItemRect(const QString &_group, const QString &_key, QRect &reference, const QRect &defaultValue=QRect())
ItemPath(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue=QString())
void clearItems()
Removes and deletes all items.
void setNotifyFunction(const std::function< void()> &impl)
Set a notify function, it will be invoked when the value of the property changes. ...
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
ItemDouble * addItemDouble(const QString &name, double &reference, double defaultValue=0.0, const QString &key=QString())
Register an item of type double.
void writeConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to write the value of this setting to a config file...
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
void setProperty(const QVariant &p) override
Set item to p.
QString mKey
The config key for this item.
ItemULongLong(const QString &_group, const QString &_key, quint64 &reference, quint64 defaultValue=0)
QVariant maxValue() const override
Get the maximum value this is allowed to be stored in this item.
void addItem(KConfigSkeletonItem *, const QString &name=QString())
Register a custom KConfigSkeletonItem with a given name.
ItemPassword * addItemPassword(const QString &name, QString &reference, const QString &defaultValue=QLatin1String(""), const QString &key=QString())
Register a password item of type QString.
typedef ConstIterator
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
QVariant maxValue() const override
Get the maximum value this is allowed to be stored in this item.
void setProperty(const QVariant &p) override
Set item to p.
void setName(const QString &_name)
Set internal name of entry.
QString whatsThis() const
Return WhatsThis description of item.
ItemString * addItemString(const QString &name, QString &reference, const QString &defaultValue=QLatin1String(""), const QString &key=QString())
Register an item of type QString.
int length() const const
void setMaxValue(qint32)
Set the maximum value for the item.
bool toBool() const const
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
virtual void usrRead()
Perform the actual reading of the configuration file.
Class for handling a string list preferences item.
QPoint toPoint() const const
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
double toDouble(bool *ok) const const
Class for storing a preferences setting.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
virtual ~KCoreConfigSkeleton()
Destructor.
QVariant property() const override
Return item as property.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
QString mGroup
The group name for this item.
KSharedConfig::Ptr sharedConfig() const
Return the KConfig object used for reading and writing the settings.
QRect toRect() const const
QList::const_iterator constEnd() const const
Fully-fledged config, including globals and cascading to system settings.
Definition: kconfig.h:89
QList::const_iterator constBegin() const const
QVariant property() const override
Return item as property.
KPropertySkeletonItem(QObject *object, const QByteArray &propertyName, const QVariant &defaultValue)
Constructor.
virtual ~KConfigSkeletonItem()
Destructor.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
QObject * parent() const const
Class for handling an integer list preferences item.
KConfigBase::WriteConfigFlags writeFlags() const
Return write flags to be used when writing configuration.
void setGroup(const QString &_group)
Set config file group.
QVariant property() const override
Return item as property.
QString toString() const const
QString currentGroup() const
Returns the current group used for addItem() calls.
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
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:250
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
virtual bool usrUseDefaults(bool b)
Implemented by subclasses that use special defaults.
void revertToDefault(const QString &key)
Reverts an entry to the default settings.
QVariant property() const override
Return item as property.
void setMaxValue(quint64)
Set the maximum value for the item.
KConfigSkeletonItem::List items() const
Return list of items managed by this KCoreConfigSkeleton object.
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
void readConfig(KConfig *config) override
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
Q_INVOKABLE bool isImmutable(const QString &name) const
Return whether a certain item is immutable.
bool isEqual(const QVariant &p) const override
Check whether the item is equal to p.
ItemSize(const QString &_group, const QString &_key, QSize &reference, const QSize &defaultValue=QSize())
Class for handling a path preferences item.
ItemProperty * addItemProperty(const QString &name, QVariant &reference, const QVariant &defaultValue=QVariant(), const QString &key=QString())
Register a property item of type QVariant.
QVariant minValue() const override
Get the minimum value that is allowed to be stored in this item.
virtual QVariant minValue() const
Return minimum value of item or invalid if not specified.
ItemProperty(const QString &_group, const QString &_key, QVariant &reference, const QVariant &defaultValue=QVariant())
ItemString(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue=QLatin1String(""), Type type=Normal)
virtual bool useDefaults(bool b)
Specify whether this object should reflect the actual values or the default values.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 16 2021 22:50:01 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.