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(KConfigSkeletonItem);
173  d->mIsImmutable = group.isEntryImmutable(mKey);
174 }
175 
176 void KConfigSkeletonItem::setIsDefaultImpl(const std::function<bool ()> &impl)
177 {
178  Q_D(KConfigSkeletonItem);
179  d->mIsDefaultImpl = impl;
180 }
181 
182 void KConfigSkeletonItem::setIsSaveNeededImpl(const std::function<bool ()> &impl)
183 {
184  Q_D(KConfigSkeletonItem);
185  d->mIsSaveNeededImpl = impl;
186 }
187 
188 KPropertySkeletonItem::KPropertySkeletonItem(QObject *object, const QByteArray &propertyName, const QVariant &defaultValue)
189  : KConfigSkeletonItem(*new KPropertySkeletonItemPrivate(object, propertyName, defaultValue), {}, {})
190 {
191  setIsDefaultImpl([this] {
192  Q_D(const KPropertySkeletonItem);
193  return d->mReference == d->mDefaultValue;
194  });
195  setIsSaveNeededImpl([this] {
196  Q_D(const KPropertySkeletonItem);
197  return d->mReference != d->mLoadedValue;
198  });
199 }
200 
202 {
203  Q_D(const KPropertySkeletonItem);
204  return d->mReference;
205 }
206 
208 {
210  if (d->mReference == p) {
211  return;
212  }
213  d->mReference = p;
214  if (d->mNotifyFunction) {
215  d->mNotifyFunction();
216  }
217 }
218 
220 {
221  Q_D(const KPropertySkeletonItem);
222  return d->mReference == p;
223 }
224 
226 {
228  setProperty(d->mObject->property(d->mPropertyName.constData()));
229  d->mLoadedValue = d->mReference;
230 }
231 
233 {
235  d->mObject->setProperty(d->mPropertyName.constData(), d->mReference);
236  d->mLoadedValue = d->mReference;
237 }
238 
240 {
242  setProperty(d->mConstDefaultValue);
243 }
244 
246 {
248  setProperty(d->mDefaultValue);
249 }
250 
252 {
254  if (d->mReference == d->mDefaultValue) {
255  return;
256  }
257  std::swap(d->mReference, d->mDefaultValue);
258  if (d->mNotifyFunction) {
259  d->mNotifyFunction();
260  }
261 }
262 
263 void KPropertySkeletonItem::setNotifyFunction(const std::function<void ()> &impl)
264 {
266  d->mNotifyFunction = impl;
267 }
268 
270  QString &reference,
271  const QString &defaultValue,
272  Type type)
273  : KConfigSkeletonGenericItem<QString>(_group, _key, reference, defaultValue),
274  mType(type)
275 {
276 }
277 
279 {
280  if (mReference != mLoadedValue) { // WABA: Is this test needed?
281  KConfigGroup cg = configGroup(config);
282  if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
284  } else if (mType == Path) {
285  cg.writePathEntry(mKey, mReference, writeFlags());
286  } else if (mType == Password) {
287  cg.writeEntry(mKey, obscuredString(mReference), writeFlags());
288  } else {
289  cg.writeEntry(mKey, mReference, writeFlags());
290  }
291  mLoadedValue = mReference;
292  }
293 }
294 
296 {
297  KConfigGroup cg = configGroup(config);
298 
299  if (mType == Path) {
300  mReference = cg.readPathEntry(mKey, mDefault);
301  } else if (mType == Password) {
302  QString val = cg.readEntry(mKey, obscuredString(mDefault));
303  mReference = obscuredString(val);
304  } else {
305  mReference = cg.readEntry(mKey, mDefault);
306  }
307 
308  mLoadedValue = mReference;
309 
310  readImmutability(cg);
311 }
312 
314 {
315  mReference = p.toString();
316 }
317 
319 {
320  return mReference == v.toString();
321 }
322 
324 {
325  return QVariant(mReference);
326 }
327 
329  QString &reference,
330  const QString &defaultValue)
331  : ItemString(_group, _key, reference, defaultValue, Password)
332 {
333 }
334 
336  QString &reference,
337  const QString &defaultValue)
338  : ItemString(_group, _key, reference, defaultValue, Path)
339 {
340 }
341 
343  QUrl &reference,
344  const QUrl &defaultValue)
345  : KConfigSkeletonGenericItem<QUrl>(_group, _key, reference, defaultValue)
346 {
347 }
348 
350 {
351  if (mReference != mLoadedValue) { // WABA: Is this test needed?
352  KConfigGroup cg = configGroup(config);
353  if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
355  } else {
356  cg.writeEntry<QString>(mKey, mReference.toString(), writeFlags());
357  }
358  mLoadedValue = mReference;
359  }
360 }
361 
363 {
364  KConfigGroup cg = configGroup(config);
365 
366  mReference = QUrl(cg.readEntry<QString>(mKey, mDefault.toString()));
367  mLoadedValue = mReference;
368 
369  readImmutability(cg);
370 }
371 
373 {
374  mReference = qvariant_cast<QUrl>(p);
375 }
376 
378 {
379  return mReference == qvariant_cast<QUrl>(v);
380 }
381 
383 {
384  return QVariant::fromValue<QUrl>(mReference);
385 }
386 
388  const QString &_key,
389  QVariant &reference,
390  const QVariant &defaultValue)
391  : KConfigSkeletonGenericItem<QVariant>(_group, _key, reference, defaultValue)
392 {
393 }
394 
396 {
397  KConfigGroup cg = configGroup(config);
398  mReference = cg.readEntry(mKey, mDefault);
399  mLoadedValue = mReference;
400 
401  readImmutability(cg);
402 }
403 
405 {
406  mReference = p;
407 }
408 
410 {
411  //this might cause problems if the QVariants are not of default types
412  return mReference == v;
413 }
414 
416 {
417  return mReference;
418 }
419 
421  bool &reference, bool defaultValue)
422  : KConfigSkeletonGenericItem<bool>(_group, _key, reference, defaultValue)
423 {
424 }
425 
427 {
428  KConfigGroup cg = configGroup(config);
429  mReference = cg.readEntry(mKey, mDefault);
430  mLoadedValue = mReference;
431 
432  readImmutability(cg);
433 }
434 
436 {
437  mReference = p.toBool();
438 }
439 
441 {
442  return mReference == v.toBool();
443 }
444 
446 {
447  return QVariant(mReference);
448 }
449 
451  qint32 &reference, qint32 defaultValue)
452  : KConfigSkeletonGenericItem<qint32>(_group, _key, reference, defaultValue)
453  , mHasMin(false), mHasMax(false)
454 {
455 }
456 
458 {
459  KConfigGroup cg = configGroup(config);
460  mReference = cg.readEntry(mKey, mDefault);
461  if (mHasMin) {
462  mReference = qMax(mReference, mMin);
463  }
464  if (mHasMax) {
465  mReference = qMin(mReference, mMax);
466  }
467  mLoadedValue = mReference;
468 
469  readImmutability(cg);
470 }
471 
473 {
474  mReference = p.toInt();
475 }
476 
478 {
479  return mReference == v.toInt();
480 }
481 
483 {
484  return QVariant(mReference);
485 }
486 
488 {
489  if (mHasMin) {
490  return QVariant(mMin);
491  }
492  return QVariant();
493 }
494 
496 {
497  if (mHasMax) {
498  return QVariant(mMax);
499  }
500  return QVariant();
501 }
502 
504 {
505  mHasMin = true;
506  mMin = v;
507 }
508 
510 {
511  mHasMax = true;
512  mMax = v;
513 }
514 
516  qint64 &reference, qint64 defaultValue)
517  : KConfigSkeletonGenericItem<qint64>(_group, _key, reference, defaultValue)
518  , mHasMin(false), mHasMax(false)
519 {
520 }
521 
523 {
524  KConfigGroup cg = configGroup(config);
525  mReference = cg.readEntry(mKey, mDefault);
526  if (mHasMin) {
527  mReference = qMax(mReference, mMin);
528  }
529  if (mHasMax) {
530  mReference = qMin(mReference, mMax);
531  }
532  mLoadedValue = mReference;
533 
534  readImmutability(cg);
535 }
536 
538 {
539  mReference = p.toLongLong();
540 }
541 
543 {
544  return mReference == v.toLongLong();
545 }
546 
548 {
549  return QVariant(mReference);
550 }
551 
553 {
554  if (mHasMin) {
555  return QVariant(mMin);
556  }
557  return QVariant();
558 }
559 
561 {
562  if (mHasMax) {
563  return QVariant(mMax);
564  }
565  return QVariant();
566 }
567 
569 {
570  mHasMin = true;
571  mMin = v;
572 }
573 
575 {
576  mHasMax = true;
577  mMax = v;
578 }
579 
581 {
582  // HACK for BC concerns
583  // TODO KF6: remove KConfigSkeletonItemPrivate::mValues and add a value field to KCoreConfigSkeleton::ItemEnum::Choice
584  const auto inHash = d_ptr->mValues.value(name);
585  return !inHash.isEmpty() ? inHash : name;
586 }
587 
589 {
590  d_ptr->mValues.insert(name, value);
591 }
592 
594  qint32 &reference,
595  const QList<Choice> &choices,
596  qint32 defaultValue)
597  : ItemInt(_group, _key, reference, defaultValue), mChoices(choices)
598 {
599 }
600 
602 {
603  KConfigGroup cg = configGroup(config);
604  if (!cg.hasKey(mKey)) {
605  mReference = mDefault;
606  } else {
607  int i = 0;
608  mReference = -1;
609  QString tmp = cg.readEntry(mKey, QString()).toLower();
610  for (QList<Choice>::ConstIterator it = mChoices.constBegin();
611  it != mChoices.constEnd(); ++it, ++i) {
612  QString choiceName = (*it).name;
613  if (valueForChoice(choiceName).toLower() == tmp) {
614  mReference = i;
615  break;
616  }
617  }
618  if (mReference == -1) {
619  mReference = cg.readEntry(mKey, mDefault);
620  }
621  }
622  mLoadedValue = mReference;
623 
624  readImmutability(cg);
625 }
626 
628 {
629  if (mReference != mLoadedValue) { // WABA: Is this test needed?
630  KConfigGroup cg = configGroup(config);
631  if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
633  } else if ((mReference >= 0) && (mReference < mChoices.count())) {
634  cg.writeEntry(mKey, valueForChoice(mChoices.at(mReference).name), writeFlags());
635  } else {
636  cg.writeEntry(mKey, mReference, writeFlags());
637  }
638  mLoadedValue = mReference;
639  }
640 }
641 
642 QList<KCoreConfigSkeleton::ItemEnum::Choice> KCoreConfigSkeleton::ItemEnum::choices() const
643 {
644  return mChoices;
645 }
646 
647 QList<KCoreConfigSkeleton::ItemEnum::Choice> KCoreConfigSkeleton::ItemEnum::choices2() const
648 {
649  return mChoices;
650 }
651 
653  quint32 &reference,
654  quint32 defaultValue)
655  : KConfigSkeletonGenericItem<quint32>(_group, _key, reference, defaultValue)
656  , mHasMin(false), mHasMax(false)
657 {
658 }
659 
661 {
662  KConfigGroup cg = configGroup(config);
663  mReference = cg.readEntry(mKey, mDefault);
664  if (mHasMin) {
665  mReference = qMax(mReference, mMin);
666  }
667  if (mHasMax) {
668  mReference = qMin(mReference, mMax);
669  }
670  mLoadedValue = mReference;
671 
672  readImmutability(cg);
673 }
674 
676 {
677  mReference = p.toUInt();
678 }
679 
681 {
682  return mReference == v.toUInt();
683 }
684 
686 {
687  return QVariant(mReference);
688 }
689 
691 {
692  if (mHasMin) {
693  return QVariant(mMin);
694  }
695  return QVariant();
696 }
697 
699 {
700  if (mHasMax) {
701  return QVariant(mMax);
702  }
703  return QVariant();
704 }
705 
707 {
708  mHasMin = true;
709  mMin = v;
710 }
711 
713 {
714  mHasMax = true;
715  mMax = v;
716 }
717 
719  quint64 &reference, quint64 defaultValue)
720  : KConfigSkeletonGenericItem<quint64>(_group, _key, reference, defaultValue)
721  , mHasMin(false), mHasMax(false)
722 {
723 }
724 
726 {
727  KConfigGroup cg = configGroup(config);
728  mReference = cg.readEntry(mKey, mDefault);
729  if (mHasMin) {
730  mReference = qMax(mReference, mMin);
731  }
732  if (mHasMax) {
733  mReference = qMin(mReference, mMax);
734  }
735  mLoadedValue = mReference;
736 
737  readImmutability(cg);
738 }
739 
741 {
742  mReference = p.toULongLong();
743 }
744 
746 {
747  return mReference == v.toULongLong();
748 }
749 
751 {
752  return QVariant(mReference);
753 }
754 
756 {
757  if (mHasMin) {
758  return QVariant(mMin);
759  }
760  return QVariant();
761 }
762 
764 {
765  if (mHasMax) {
766  return QVariant(mMax);
767  }
768  return QVariant();
769 }
770 
772 {
773  mHasMin = true;
774  mMin = v;
775 }
776 
778 {
779  mHasMax = true;
780  mMax = v;
781 }
782 
784  double &reference, double defaultValue)
785  : KConfigSkeletonGenericItem<double>(_group, _key, reference, defaultValue)
786  , mHasMin(false), mHasMax(false)
787 {
788 }
789 
791 {
792  KConfigGroup cg = configGroup(config);
793  mReference = cg.readEntry(mKey, mDefault);
794  if (mHasMin) {
795  mReference = qMax(mReference, mMin);
796  }
797  if (mHasMax) {
798  mReference = qMin(mReference, mMax);
799  }
800  mLoadedValue = mReference;
801 
802  readImmutability(cg);
803 }
804 
806 {
807  mReference = p.toDouble();
808 }
809 
811 {
812  return mReference == v.toDouble();
813 }
814 
816 {
817  return QVariant(mReference);
818 }
819 
821 {
822  if (mHasMin) {
823  return QVariant(mMin);
824  }
825  return QVariant();
826 }
827 
829 {
830  if (mHasMax) {
831  return QVariant(mMax);
832  }
833  return QVariant();
834 }
835 
837 {
838  mHasMin = true;
839  mMin = v;
840 }
841 
843 {
844  mHasMax = true;
845  mMax = v;
846 }
847 
849  QRect &reference,
850  const QRect &defaultValue)
851  : KConfigSkeletonGenericItem<QRect>(_group, _key, reference, defaultValue)
852 {
853 }
854 
856 {
857  KConfigGroup cg = configGroup(config);
858  mReference = cg.readEntry(mKey, mDefault);
859  mLoadedValue = mReference;
860 
861  readImmutability(cg);
862 }
863 
865 {
866  mReference = p.toRect();
867 }
868 
870 {
871  return mReference == v.toRect();
872 }
873 
875 {
876  return QVariant(mReference);
877 }
878 
880  QPoint &reference,
881  const QPoint &defaultValue)
882  : KConfigSkeletonGenericItem<QPoint>(_group, _key, reference, defaultValue)
883 {
884 }
885 
887 {
888  KConfigGroup cg = configGroup(config);
889  mReference = cg.readEntry(mKey, mDefault);
890  mLoadedValue = mReference;
891 
892  readImmutability(cg);
893 }
894 
896 {
897  mReference = p.toPoint();
898 }
899 
901 {
902  return mReference == v.toPoint();
903 }
904 
906 {
907  return QVariant(mReference);
908 }
909 
911  QSize &reference,
912  const QSize &defaultValue)
913  : KConfigSkeletonGenericItem<QSize>(_group, _key, reference, defaultValue)
914 {
915 }
916 
918 {
919  KConfigGroup cg = configGroup(config);
920  mReference = cg.readEntry(mKey, mDefault);
921  mLoadedValue = mReference;
922 
923  readImmutability(cg);
924 }
925 
927 {
928  mReference = p.toSize();
929 }
930 
932 {
933  return mReference == v.toSize();
934 }
935 
937 {
938  return QVariant(mReference);
939 }
940 
942  QDateTime &reference,
943  const QDateTime &defaultValue)
944  : KConfigSkeletonGenericItem<QDateTime>(_group, _key, reference, defaultValue)
945 {
946 }
947 
949 {
950  KConfigGroup cg = configGroup(config);
951  mReference = cg.readEntry(mKey, mDefault);
952  mLoadedValue = mReference;
953 
954  readImmutability(cg);
955 }
956 
958 {
959  mReference = p.toDateTime();
960 }
961 
963 {
964  return mReference == v.toDateTime();
965 }
966 
968 {
969  return QVariant(mReference);
970 }
971 
973  QStringList &reference,
974  const QStringList &defaultValue)
975  : KConfigSkeletonGenericItem<QStringList>(_group, _key, reference, defaultValue)
976 {
977 }
978 
980 {
981  KConfigGroup cg = configGroup(config);
982  if (!cg.hasKey(mKey)) {
983  mReference = mDefault;
984  } else {
985  mReference = cg.readEntry(mKey, mDefault);
986  }
987  mLoadedValue = mReference;
988 
989  readImmutability(cg);
990 }
991 
993 {
994  mReference = p.toStringList();
995 }
996 
998 {
999  return mReference == v.toStringList();
1000 }
1001 
1003 {
1004  return QVariant(mReference);
1005 }
1006 
1008  QStringList &reference,
1009  const QStringList &defaultValue)
1010  : ItemStringList(_group, _key, reference, defaultValue)
1011 {
1012 }
1013 
1015 {
1016  KConfigGroup cg = configGroup(config);
1017  if (!cg.hasKey(mKey)) {
1018  mReference = mDefault;
1019  } else {
1020  mReference = cg.readPathEntry(mKey, QStringList());
1021  }
1022  mLoadedValue = mReference;
1023 
1024  readImmutability(cg);
1025 }
1026 
1028 {
1029  if (mReference != mLoadedValue) { // WABA: Is this test needed?
1030  KConfigGroup cg = configGroup(config);
1031  if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
1033  } else {
1034  QStringList sl = mReference;
1035  cg.writePathEntry(mKey, sl, writeFlags());
1036  }
1037  mLoadedValue = mReference;
1038  }
1039 }
1040 
1042  QList<QUrl> &reference,
1043  const QList<QUrl> &defaultValue)
1044  : KConfigSkeletonGenericItem<QList<QUrl> >(_group, _key, reference, defaultValue)
1045 {
1046 }
1047 
1049 {
1050  KConfigGroup cg = configGroup(config);
1051  if (!cg.hasKey(mKey)) {
1052  mReference = mDefault;
1053  } else {
1054  QStringList strList;
1055  for (const QUrl &url : qAsConst(mDefault)) {
1056  strList.append(url.toString());
1057  }
1058  mReference.clear();
1059  const QStringList readList = cg.readEntry<QStringList>(mKey, strList);
1060  for (const QString &str : readList) {
1061  mReference.append(QUrl(str));
1062  }
1063  }
1064  mLoadedValue = mReference;
1065 
1066  readImmutability(cg);
1067 }
1068 
1070 {
1071  if (mReference != mLoadedValue) { // WABA: Is this test needed?
1072  KConfigGroup cg = configGroup(config);
1073  if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
1075  } else {
1076  QStringList strList;
1077  for (const QUrl &url : qAsConst(mReference)) {
1078  strList.append(url.toString());
1079  }
1080  cg.writeEntry<QStringList>(mKey, strList, writeFlags());
1081  }
1082  mLoadedValue = mReference;
1083  }
1084 }
1085 
1087 {
1088  mReference = qvariant_cast<QList<QUrl> >(p);
1089 }
1090 
1092 {
1093  return mReference == qvariant_cast<QList<QUrl> >(v);
1094 }
1095 
1097 {
1098  return QVariant::fromValue<QList<QUrl> >(mReference);
1099 }
1100 
1102  QList<int> &reference,
1103  const QList<int> &defaultValue)
1104  : KConfigSkeletonGenericItem<QList<int> >(_group, _key, reference, defaultValue)
1105 {
1106 }
1107 
1109 {
1110  KConfigGroup cg = configGroup(config);
1111  if (!cg.hasKey(mKey)) {
1112  mReference = mDefault;
1113  } else {
1114  mReference = cg.readEntry(mKey, mDefault);
1115  }
1116  mLoadedValue = mReference;
1117 
1118  readImmutability(cg);
1119 }
1120 
1122 {
1123  mReference = qvariant_cast< QList<int> >(p);
1124 }
1125 
1127 {
1128  return mReference == qvariant_cast< QList<int> >(v);
1129 }
1130 
1132 {
1133  return QVariant::fromValue< QList<int> >(mReference);
1134 }
1135 
1136 //static int kCoreConfigSkeletionDebugArea() { static int s_area = KDebug::registerArea("kdecore (KConfigSkeleton)"); return s_area; }
1137 
1139  : QObject(parent),
1140  d(new KCoreConfigSkeletonPrivate)
1141 {
1142  //qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
1143 
1144  d->mConfig = KSharedConfig::openConfig(configname, KConfig::FullConfig);
1145 }
1146 
1148  : QObject(parent),
1149  d(new KCoreConfigSkeletonPrivate)
1150 {
1151  //qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
1152  d->mConfig = std::move(pConfig);
1153 }
1154 
1156 {
1157  delete d;
1158 }
1159 
1161 {
1162  d->mCurrentGroup = group;
1163 }
1164 
1166 {
1167  return d->mCurrentGroup;
1168 }
1169 
1171 {
1172  return d->mConfig.data();
1173 }
1174 
1176 {
1177  return d->mConfig.data();
1178 }
1179 
1181 {
1182  return d->mConfig;
1183 }
1184 
1186 {
1187  d->mConfig = std::move(pConfig);
1188 }
1189 
1191 {
1192  return d->mItems;
1193 }
1194 
1196 {
1197  if (b == d->mUseDefaults) {
1198  return d->mUseDefaults;
1199  }
1200 
1201  d->mUseDefaults = b;
1203  for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
1204  (*it)->swapDefault();
1205  }
1206  usrUseDefaults(b);
1207  return !d->mUseDefaults;
1208 }
1209 
1211 {
1213  for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
1214  (*it)->setDefault();
1215  }
1216  usrSetDefaults();
1217 }
1218 
1220 {
1221  d->mConfig->reparseConfiguration();
1222  read();
1223 }
1224 
1226 {
1228  for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
1229  (*it)->readConfig(d->mConfig.data());
1230  }
1231  usrRead();
1232 }
1233 
1235 {
1237  for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
1238  if (!(*it)->isDefault()) {
1239  return false;
1240  }
1241  }
1242  return true;
1243 }
1244 
1246 {
1248  for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
1249  if ((*it)->isSaveNeeded()) {
1250  return true;
1251  }
1252  }
1253  return false;
1254 }
1255 
1257 {
1258  //qDebug();
1260  for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
1261  (*it)->writeConfig(d->mConfig.data());
1262  }
1263  if (!usrSave()) {
1264  return false;
1265  }
1266 
1267  if (d->mConfig->isDirty()) {
1268  if (!d->mConfig->sync()) {
1269  return false;
1270  }
1271  emit configChanged();
1272  }
1273  return true;
1274 }
1275 
1277 {
1278  return false;
1279 }
1280 
1282 {
1283 }
1284 
1286 {
1287 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
1288  usrReadConfig();
1289 #endif
1290 }
1291 
1292 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
1294 {
1295 }
1296 #endif
1297 
1299 {
1300 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
1301  return usrWriteConfig();
1302 #else
1303  return true;
1304 #endif
1305 }
1306 
1307 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
1309 {
1310  return true;
1311 }
1312 #endif
1313 
1315 {
1316  if (d->mItems.contains(item)) {
1317  if (item->name() == name ||
1318  (name.isEmpty() && item->name() == item->key())) {
1319  // nothing to do -> it is already in our collection
1320  // and the name isn't changing
1321  return;
1322  }
1323 
1324  d->mItemDict.remove(item->name());
1325  } else {
1326  d->mItems.append(item);
1327  }
1328 
1329  item->setName(name.isEmpty() ? item->key() : name);
1330  d->mItemDict.insert(item->name(), item);
1331  item->readDefault(d->mConfig.data());
1332  item->readConfig(d->mConfig.data());
1333 }
1334 
1336 {
1337  KConfigSkeletonItem *item = d->mItemDict.value(name);
1338  if (item) {
1339  d->mItems.removeAll(item);
1340  d->mItemDict.remove(item->name());
1341  delete item;
1342  }
1343 }
1344 
1346 {
1347  KConfigSkeletonItem::List items = d->mItems;
1348  d->mItems.clear();
1349  d->mItemDict.clear();
1350  qDeleteAll(items);
1351 }
1352 
1354  const QString &defaultValue, const QString &key)
1355 {
1357  item = new KCoreConfigSkeleton::ItemString(d->mCurrentGroup, key.isEmpty() ? name : key,
1358  reference, defaultValue,
1360  addItem(item, name);
1361  return item;
1362 }
1363 
1365  const QString &defaultValue, const QString &key)
1366 {
1368  item = new KCoreConfigSkeleton::ItemPassword(d->mCurrentGroup, key.isNull() ? name : key,
1369  reference, defaultValue);
1370  addItem(item, name);
1371  return item;
1372 }
1373 
1375  const QString &defaultValue, const QString &key)
1376 {
1378  item = new KCoreConfigSkeleton::ItemPath(d->mCurrentGroup, key.isNull() ? name : key,
1379  reference, defaultValue);
1380  addItem(item, name);
1381  return item;
1382 }
1383 
1385  const QVariant &defaultValue, const QString &key)
1386 {
1388  item = new KCoreConfigSkeleton::ItemProperty(d->mCurrentGroup, key.isNull() ? name : key,
1389  reference, defaultValue);
1390  addItem(item, name);
1391  return item;
1392 }
1393 
1395  bool defaultValue, const QString &key)
1396 {
1398  item = new KCoreConfigSkeleton::ItemBool(d->mCurrentGroup, key.isNull() ? name : key,
1399  reference, defaultValue);
1400  addItem(item, name);
1401  return item;
1402 }
1403 
1405  qint32 defaultValue, const QString &key)
1406 {
1408  item = new KCoreConfigSkeleton::ItemInt(d->mCurrentGroup, key.isNull() ? name : key,
1409  reference, defaultValue);
1410  addItem(item, name);
1411  return item;
1412 }
1413 
1415  quint32 defaultValue, const QString &key)
1416 {
1418  item = new KCoreConfigSkeleton::ItemUInt(d->mCurrentGroup, key.isNull() ? name : key,
1419  reference, defaultValue);
1420  addItem(item, name);
1421  return item;
1422 }
1423 
1425  qint64 defaultValue, const QString &key)
1426 {
1428  item = new KCoreConfigSkeleton::ItemLongLong(d->mCurrentGroup, key.isNull() ? name : key,
1429  reference, defaultValue);
1430  addItem(item, name);
1431  return item;
1432 }
1433 
1434 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
1436  const QString &name,
1437  qint64 &reference,
1438  qint64 defaultValue,
1439  const QString &key)
1440 {
1441  return addItemLongLong(name, reference, defaultValue, key);
1442 }
1443 #endif
1444 
1446  quint64 defaultValue, const QString &key)
1447 {
1449  item = new KCoreConfigSkeleton::ItemULongLong(d->mCurrentGroup, key.isNull() ? name : key,
1450  reference, defaultValue);
1451  addItem(item, name);
1452  return item;
1453 }
1454 
1455 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
1457  const QString &name,
1458  quint64 &reference,
1459  quint64 defaultValue,
1460  const QString &key)
1461 {
1462  return addItemULongLong(name, reference, defaultValue, key);
1463 }
1464 #endif
1465 
1467  double defaultValue, const QString &key)
1468 {
1470  item = new KCoreConfigSkeleton::ItemDouble(d->mCurrentGroup, key.isNull() ? name : key,
1471  reference, defaultValue);
1472  addItem(item, name);
1473  return item;
1474 }
1475 
1477  const QRect &defaultValue, const QString &key)
1478 {
1480  item = new KCoreConfigSkeleton::ItemRect(d->mCurrentGroup, key.isNull() ? name : key,
1481  reference, defaultValue);
1482  addItem(item, name);
1483  return item;
1484 }
1485 
1487  const QPoint &defaultValue, const QString &key)
1488 {
1490  item = new KCoreConfigSkeleton::ItemPoint(d->mCurrentGroup, key.isNull() ? name : key,
1491  reference, defaultValue);
1492  addItem(item, name);
1493  return item;
1494 }
1495 
1497  const QSize &defaultValue, const QString &key)
1498 {
1500  item = new KCoreConfigSkeleton::ItemSize(d->mCurrentGroup, key.isNull() ? name : key,
1501  reference, defaultValue);
1502  addItem(item, name);
1503  return item;
1504 }
1505 
1507  const QDateTime &defaultValue, const QString &key)
1508 {
1510  item = new KCoreConfigSkeleton::ItemDateTime(d->mCurrentGroup, key.isNull() ? name : key,
1511  reference, defaultValue);
1512  addItem(item, name);
1513  return item;
1514 }
1515 
1517  const QStringList &defaultValue, const QString &key)
1518 {
1520  item = new KCoreConfigSkeleton::ItemStringList(d->mCurrentGroup, key.isNull() ? name : key,
1521  reference, defaultValue);
1522  addItem(item, name);
1523  return item;
1524 }
1525 
1527  const QList<int> &defaultValue, const QString &key)
1528 {
1530  item = new KCoreConfigSkeleton::ItemIntList(d->mCurrentGroup, key.isNull() ? name : key,
1531  reference, defaultValue);
1532  addItem(item, name);
1533  return item;
1534 }
1535 
1537 {
1538  KConfigSkeletonItem *item = findItem(name);
1539  return !item || item->isImmutable();
1540 }
1541 
1543 {
1544  return d->mItemDict.value(name);
1545 }
1546 
1547 KConfigCompilerSignallingItem::KConfigCompilerSignallingItem(KConfigSkeletonItem* item, QObject* object,
1548  KConfigCompilerSignallingItem::NotifyFunction targetFunction, quint64 userData)
1549  : KConfigSkeletonItem(item->group(), item->key()), mItem(item), mTargetFunction(targetFunction),
1550  mObject(object), mUserData(userData)
1551 {
1552  Q_ASSERT(mTargetFunction);
1553  Q_ASSERT(mItem);
1554  Q_ASSERT(mObject);
1555 
1556  setIsDefaultImpl([this] { return mItem->isDefault(); });
1557  setIsSaveNeededImpl([this] { return mItem->isSaveNeeded(); });
1558 }
1559 
1560 KConfigCompilerSignallingItem::~KConfigCompilerSignallingItem()
1561 {
1562 }
1563 
1564 bool KConfigCompilerSignallingItem::isEqual(const QVariant& p) const
1565 {
1566  return mItem->isEqual(p);
1567 }
1568 
1569 QVariant KConfigCompilerSignallingItem::property() const
1570 {
1571  return mItem->property();
1572 }
1573 
1574 void KConfigCompilerSignallingItem::readConfig(KConfig* c)
1575 {
1576  QVariant oldValue = mItem->property();
1577  mItem->readConfig(c);
1578  //readConfig() changes mIsImmutable, update it here as well
1579  KConfigGroup cg = configGroup(c);
1580  readImmutability(cg);
1581  if (!mItem->isEqual(oldValue)) {
1582  invokeNotifyFunction();
1583  }
1584 }
1585 
1586 void KConfigCompilerSignallingItem::readDefault(KConfig* c)
1587 {
1588  mItem->readDefault(c);
1589  //readDefault() changes mIsImmutable, update it here as well
1590  KConfigGroup cg = configGroup(c);
1591  readImmutability(cg);
1592 }
1593 
1594 void KConfigCompilerSignallingItem::writeConfig(KConfig* c)
1595 {
1596  mItem->writeConfig(c);
1597 }
1598 
1599 void KConfigCompilerSignallingItem::setDefault()
1600 {
1601  QVariant oldValue = mItem->property();
1602  mItem->setDefault();
1603  if (!mItem->isEqual(oldValue)) {
1604  invokeNotifyFunction();
1605  }
1606 }
1607 
1608 void KConfigCompilerSignallingItem::setProperty(const QVariant& p)
1609 {
1610  if (!mItem->isEqual(p)) {
1611  mItem->setProperty(p);
1612  invokeNotifyFunction();
1613  }
1614 }
1615 
1616 void KConfigCompilerSignallingItem::swapDefault()
1617 {
1618  QVariant oldValue = mItem->property();
1619  mItem->swapDefault();
1620  if (!mItem->isEqual(oldValue)) {
1621  invokeNotifyFunction();
1622  }
1623 }
1624 
1625 void KConfigCompilerSignallingItem::setWriteFlags(KConfigBase::WriteConfigFlags flags)
1626 {
1627  mItem->setWriteFlags(flags);
1628 }
1629 
1630 KConfigBase::WriteConfigFlags KConfigCompilerSignallingItem::writeFlags() const
1631 {
1632  return mItem->writeFlags();
1633 }
1634 
1635 void KConfigCompilerSignallingItem::setGroup(const KConfigGroup &cg)
1636 {
1637  mItem->setGroup(cg);
1638 }
1639 
1640 KConfigGroup KConfigCompilerSignallingItem::configGroup(KConfig *config) const
1641 {
1642  return mItem->configGroup(config);
1643 }
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.
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:236
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-2020 The KDE developers.
Generated on Sat Jul 4 2020 22:48:19 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.