KConfig

kcoreconfigskeleton.h
1 /*
2  This file is part of KDE.
3 
4  SPDX-FileCopyrightText: 2001, 2002, 2003 Cornelius Schumacher <[email protected]>
5  SPDX-FileCopyrightText: 2003 Waldo Bastian <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #ifndef KCORECONFIGSKELETON_H
11 #define KCORECONFIGSKELETON_H
12 
13 #include <kconfigcore_export.h>
14 
15 #include <ksharedconfig.h>
16 #include <kconfiggroup.h>
17 
18 #include <QDate>
19 #include <QHash>
20 #include <QRect>
21 #include <QStringList>
22 #include <QVariant>
23 #include <QUrl>
24 
25 class KCoreConfigSkeletonPrivate;
26 
27 class KConfigSkeletonItemPrivate;
41 class KCONFIGCORE_EXPORT KConfigSkeletonItem
42 {
43  Q_DECLARE_PRIVATE(KConfigSkeletonItem)
44 public:
48 
55  KConfigSkeletonItem(const QString &_group, const QString &_key);
56 
60  virtual ~KConfigSkeletonItem();
61 
65  void setGroup(const QString &_group);
66 
70  QString group() const;
71 
77  void setGroup(const KConfigGroup &cg);
78 
86  KConfigGroup configGroup(KConfig *config) const;
87 
91  void setKey(const QString &_key);
92 
96  QString key() const;
97 
101  void setName(const QString &_name);
102 
106  QString name() const;
107 
111  void setLabel(const QString &l);
112 
116  QString label() const;
117 
122  void setToolTip(const QString &t);
123 
128  QString toolTip() const;
129 
133  void setWhatsThis(const QString &w);
134 
138  QString whatsThis() const;
139 
144  void setWriteFlags(KConfigBase::WriteConfigFlags flags);
145 
151  KConfigBase::WriteConfigFlags writeFlags() const;
152 
157  virtual void readConfig(KConfig *) = 0;
158 
164  virtual void writeConfig(KConfig *) = 0;
165 
169  virtual void readDefault(KConfig *) = 0;
170 
174  virtual void setProperty(const QVariant &p) = 0;
175 
185  virtual bool isEqual(const QVariant &p) const = 0;
186 
190  virtual QVariant property() const = 0;
191 
195  virtual QVariant minValue() const;
196 
200  virtual QVariant maxValue() const;
201 
205  virtual void setDefault() = 0;
206 
211  virtual void swapDefault() = 0;
212 
216  bool isImmutable() const;
217 
223  bool isDefault() const;
224 
231  bool isSaveNeeded() const;
232 
233 protected:
234  explicit KConfigSkeletonItem(KConfigSkeletonItemPrivate &dd, const QString &_group, const QString &_key);
235 
240  void readImmutability(const KConfigGroup &group);
241 
245 
246  // HACK: Necessary to avoid introducing new virtuals in KConfigSkeletonItem
247  // KF6: Use proper pure virtuals in KConfigSkeletonItem
248  void setIsDefaultImpl(const std::function<bool()> &impl);
249  void setIsSaveNeededImpl(const std::function<bool()> &impl);
250 
251  KConfigSkeletonItemPrivate *const d_ptr;
252 };
253 
254 class KPropertySkeletonItemPrivate;
255 
270 class KCONFIGCORE_EXPORT KPropertySkeletonItem : public KConfigSkeletonItem
271 {
272  Q_DECLARE_PRIVATE(KPropertySkeletonItem)
273 public:
281  KPropertySkeletonItem(QObject *object, const QByteArray &propertyName, const QVariant &defaultValue);
282 
284  QVariant property() const override;
286  void setProperty(const QVariant &p) override;
288  bool isEqual(const QVariant &p) const override;
289 
291  void readConfig(KConfig *) override;
293  void writeConfig(KConfig *) override;
294 
296  void readDefault(KConfig *) override;
298  void setDefault() override;
300  void swapDefault() override;
301 
306  void setNotifyFunction(const std::function<void ()> &impl);
307 };
308 
309 
313 template < typename T > class KConfigSkeletonGenericItem: public KConfigSkeletonItem
314 {
315 public:
320  KConfigSkeletonGenericItem(const QString &_group, const QString &_key, T &reference,
321  T defaultValue)
322  : KConfigSkeletonItem(_group, _key), mReference(reference),
323  mDefault(defaultValue), mLoadedValue(defaultValue)
324  {
325  setIsDefaultImpl([this] { return mReference == mDefault; });
326  setIsSaveNeededImpl([this] { return mReference != mLoadedValue; });
327  }
328 
332  void setValue(const T &v)
333  {
334  mReference = v;
335  }
336 
340  T &value()
341  {
342  return mReference;
343  }
344 
348  const T &value() const
349  {
350  return mReference;
351  }
352 
356  virtual void setDefaultValue(const T &v)
357  {
358  mDefault = v;
359  }
360 
364  void setDefault() override
365  {
366  mReference = mDefault;
367  }
368 
370  void writeConfig(KConfig *config) override
371  {
372  if (mReference != mLoadedValue) { // Is this needed?
373  KConfigGroup cg = configGroup(config);
374  if ((mDefault == mReference) && !cg.hasDefault(mKey)) {
375  cg.revertToDefault(mKey, writeFlags());
376  } else {
377  cg.writeEntry(mKey, mReference, writeFlags());
378  }
379  mLoadedValue = mReference;
380  }
381  }
382 
384  void readDefault(KConfig *config) override
385  {
386  config->setReadDefaults(true);
387  readConfig(config);
388  config->setReadDefaults(false);
389  mDefault = mReference;
390  }
391 
393  void swapDefault() override
394  {
395  T tmp = mReference;
396  mReference = mDefault;
397  mDefault = tmp;
398  }
399 
400 protected:
401  T &mReference;
402  T mDefault;
403  T mLoadedValue;
404 };
405 
419 class KCONFIGCORE_EXPORT KConfigCompilerSignallingItem : public KConfigSkeletonItem
420 {
421 public:
422  typedef void (QObject::* NotifyFunction)(quint64 arg);
431  KConfigCompilerSignallingItem(KConfigSkeletonItem *item, QObject* object,
432  NotifyFunction targetFunction, quint64 userData);
433  ~KConfigCompilerSignallingItem() override;
434 
435  void readConfig(KConfig *) override;
436  void writeConfig(KConfig *) override;
437  void readDefault(KConfig *) override;
438  void setProperty(const QVariant &p) override;
439  bool isEqual(const QVariant &p) const override;
440  QVariant property() const override;
441  void setDefault() override;
442  void swapDefault() override;
443  // KF6 TODO - fix this
444  // Ideally we would do this in an overload of KConfigSkeletonItem, but
445  // given we can't, I've shadowed the method. This isn't pretty, but given
446  // the docs say it should generally only be used from auto generated code,
447  // should be fine.
448  void setWriteFlags(KConfigBase::WriteConfigFlags flags);
449  KConfigBase::WriteConfigFlags writeFlags() const;
450  void setGroup(const KConfigGroup &cg);
451  KConfigGroup configGroup(KConfig *config) const;
452  // END TODO
453 
454 private:
455  inline void invokeNotifyFunction()
456  {
457  // call the pointer to member function using the strange ->* operator
458  (mObject->*mTargetFunction)(mUserData);
459  }
460 private:
462  NotifyFunction mTargetFunction;
463  QObject* mObject;
464  quint64 mUserData;
465 };
466 
467 
527 class KCONFIGCORE_EXPORT KCoreConfigSkeleton : public QObject
528 {
529  Q_OBJECT
530 public:
534  class KCONFIGCORE_EXPORT ItemString: public KConfigSkeletonGenericItem < QString >
535  {
536  public:
537  enum Type { Normal, Password, Path };
538 
555  ItemString(const QString &_group, const QString &_key,
556  QString &reference,
557  const QString &defaultValue = QLatin1String(""), // NOT QString() !!
558  Type type = Normal);
559 
561  void writeConfig(KConfig *config) override;
562 
564  void readConfig(KConfig *config) override;
565 
567  void setProperty(const QVariant &p) override;
568 
570  bool isEqual(const QVariant &p) const override;
571 
573  QVariant property() const override;
574 
575  private:
576  Type mType;
577  };
578 
582  class KCONFIGCORE_EXPORT ItemPassword: public ItemString
583  {
584  public:
586  ItemPassword(const QString &_group, const QString &_key,
587  QString &reference,
588  const QString &defaultValue = QLatin1String("")); // NOT QString() !!
589  };
590 
594  class KCONFIGCORE_EXPORT ItemPath: public ItemString
595  {
596  public:
598  ItemPath(const QString &_group, const QString &_key,
599  QString &reference,
600  const QString &defaultValue = QString());
601  };
602 
606  class KCONFIGCORE_EXPORT ItemUrl: public KConfigSkeletonGenericItem < QUrl >
607  {
608  public:
609 
612  ItemUrl(const QString &_group, const QString &_key,
613  QUrl &reference,
614  const QUrl &defaultValue = QUrl());
615 
617  void writeConfig(KConfig *config) override;
618 
620  void readConfig(KConfig *config) override;
621 
623  void setProperty(const QVariant &p) override;
624 
626  bool isEqual(const QVariant &p) const override;
627 
629  QVariant property() const override;
630  };
631 
635  class KCONFIGCORE_EXPORT ItemProperty: public KConfigSkeletonGenericItem < QVariant >
636  {
637  public:
639  ItemProperty(const QString &_group, const QString &_key,
640  QVariant &reference, const QVariant &defaultValue = QVariant());
641 
642  void readConfig(KConfig *config) override;
643  void setProperty(const QVariant &p) override;
644 
646  bool isEqual(const QVariant &p) const override;
647 
649  QVariant property() const override;
650  };
651 
655  class KCONFIGCORE_EXPORT ItemBool: public KConfigSkeletonGenericItem < bool >
656  {
657  public:
659  ItemBool(const QString &_group, const QString &_key, bool &reference,
660  bool defaultValue = true);
661 
663  void readConfig(KConfig *config) override;
664 
666  void setProperty(const QVariant &p) override;
667 
669  bool isEqual(const QVariant &p) const override;
670 
672  QVariant property() const override;
673  };
674 
678  class KCONFIGCORE_EXPORT ItemInt: public KConfigSkeletonGenericItem < qint32 >
679  {
680  public:
682  ItemInt(const QString &_group, const QString &_key, qint32 &reference,
683  qint32 defaultValue = 0);
684 
686  void readConfig(KConfig *config) override;
687 
689  void setProperty(const QVariant &p) override;
690 
692  bool isEqual(const QVariant &p) const override;
693 
695  QVariant property() const override;
696 
698  QVariant minValue() const override;
699 
701  QVariant maxValue() const override;
702 
706  void setMinValue(qint32);
707 
711  void setMaxValue(qint32);
712 
713  private:
714  bool mHasMin : 1;
715  bool mHasMax : 1;
716  qint32 mMin;
717  qint32 mMax;
718  };
719 
723  class KCONFIGCORE_EXPORT ItemLongLong: public KConfigSkeletonGenericItem < qint64 >
724  {
725  public:
727  ItemLongLong(const QString &_group, const QString &_key, qint64 &reference,
728  qint64 defaultValue = 0);
729 
731  void readConfig(KConfig *config) override;
732 
734  void setProperty(const QVariant &p) override;
735 
737  bool isEqual(const QVariant &p) const override;
738 
740  QVariant property() const override;
741 
743  QVariant minValue() const override;
744 
746  QVariant maxValue() const override;
747 
749  void setMinValue(qint64);
750 
752  void setMaxValue(qint64);
753 
754  private:
755  bool mHasMin : 1;
756  bool mHasMax : 1;
757  qint64 mMin;
758  qint64 mMax;
759  };
760 #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0)
761  typedef KCONFIGCORE_DEPRECATED_VERSION(5, 0, "Use ItemLongLong") ItemLongLong ItemInt64;
762 #endif
763 
767  class KCONFIGCORE_EXPORT ItemEnum: public ItemInt
768  {
769  public:
770  struct Choice {
771  QString name;
772  QString label;
773  QString toolTip;
774  QString whatsThis;
775  };
776 
780  ItemEnum(const QString &_group, const QString &_key, qint32 &reference,
781  const QList<Choice> &choices, qint32 defaultValue = 0);
782 
783  QList<Choice> choices() const;
784 
786  void readConfig(KConfig *config) override;
787 
789  void writeConfig(KConfig *config) override;
790 
791  // Source compatibility with 4.x
792  // TODO KF6 remove
793  typedef Choice Choice2;
794  QList<Choice> choices2() const;
795 
799  QString valueForChoice(const QString &name) const;
800 
804  void setValueForChoice(const QString &name, const QString &valueForChoice);
805 
806  private:
807  QList<Choice> mChoices;
808  };
809 
813  class KCONFIGCORE_EXPORT ItemUInt: public KConfigSkeletonGenericItem < quint32 >
814  {
815  public:
817  ItemUInt(const QString &_group, const QString &_key,
818  quint32 &reference, quint32 defaultValue = 0);
819 
821  void readConfig(KConfig *config) override;
822 
824  void setProperty(const QVariant &p) override;
825 
827  bool isEqual(const QVariant &p) const override;
828 
830  QVariant property() const override;
831 
833  QVariant minValue() const override;
834 
836  QVariant maxValue() const override;
837 
839  void setMinValue(quint32);
840 
842  void setMaxValue(quint32);
843 
844  private:
845  bool mHasMin : 1;
846  bool mHasMax : 1;
847  quint32 mMin;
848  quint32 mMax;
849  };
850 
854  class KCONFIGCORE_EXPORT ItemULongLong: public KConfigSkeletonGenericItem < quint64 >
855  {
856  public:
858  ItemULongLong(const QString &_group, const QString &_key, quint64 &reference,
859  quint64 defaultValue = 0);
860 
862  void readConfig(KConfig *config) override;
863 
865  void setProperty(const QVariant &p) override;
866 
868  bool isEqual(const QVariant &p) const override;
869 
871  QVariant property() const override;
872 
874  QVariant minValue() const override;
875 
877  QVariant maxValue() const override;
878 
880  void setMinValue(quint64);
881 
883  void setMaxValue(quint64);
884 
885  private:
886  bool mHasMin : 1;
887  bool mHasMax : 1;
888  quint64 mMin;
889  quint64 mMax;
890  };
891 #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0)
892  typedef KCONFIGCORE_DEPRECATED_VERSION(5, 0, "Use ItemULongLong") ItemULongLong ItemUInt64;
893 #endif
894 
898  class KCONFIGCORE_EXPORT ItemDouble: public KConfigSkeletonGenericItem < double >
899  {
900  public:
902  ItemDouble(const QString &_group, const QString &_key,
903  double &reference, double defaultValue = 0);
904 
906  void readConfig(KConfig *config) override;
907 
909  void setProperty(const QVariant &p) override;
910 
912  bool isEqual(const QVariant &p) const override;
913 
915  QVariant property() const override;
916 
918  QVariant minValue() const override;
919 
921  QVariant maxValue() const override;
922 
924  void setMinValue(double);
925 
927  void setMaxValue(double);
928 
929  private:
930  bool mHasMin : 1;
931  bool mHasMax : 1;
932  double mMin;
933  double mMax;
934  };
935 
939  class KCONFIGCORE_EXPORT ItemRect: public KConfigSkeletonGenericItem < QRect >
940  {
941  public:
943  ItemRect(const QString &_group, const QString &_key, QRect &reference,
944  const QRect &defaultValue = QRect());
945 
947  void readConfig(KConfig *config) override;
948 
950  void setProperty(const QVariant &p) override;
951 
953  bool isEqual(const QVariant &p) const override;
954 
956  QVariant property() const override;
957  };
958 
962  class KCONFIGCORE_EXPORT ItemPoint: public KConfigSkeletonGenericItem < QPoint >
963  {
964  public:
966  ItemPoint(const QString &_group, const QString &_key, QPoint &reference,
967  const QPoint &defaultValue = QPoint());
968 
970  void readConfig(KConfig *config) override;
971 
973  void setProperty(const QVariant &p) override;
974 
976  bool isEqual(const QVariant &p) const override;
977 
979  QVariant property() const override;
980  };
981 
985  class KCONFIGCORE_EXPORT ItemSize: public KConfigSkeletonGenericItem < QSize >
986  {
987  public:
989  ItemSize(const QString &_group, const QString &_key, QSize &reference,
990  const QSize &defaultValue = QSize());
991 
993  void readConfig(KConfig *config) override;
994 
996  void setProperty(const QVariant &p) override;
997 
999  bool isEqual(const QVariant &p) const override;
1000 
1002  QVariant property() const override;
1003  };
1004 
1008  class KCONFIGCORE_EXPORT ItemDateTime: public KConfigSkeletonGenericItem < QDateTime >
1009  {
1010  public:
1012  ItemDateTime(const QString &_group, const QString &_key,
1013  QDateTime &reference,
1014  const QDateTime &defaultValue = QDateTime());
1015 
1017  void readConfig(KConfig *config) override;
1018 
1020  void setProperty(const QVariant &p) override;
1021 
1023  bool isEqual(const QVariant &p) const override;
1024 
1026  QVariant property() const override;
1027  };
1028 
1032  class KCONFIGCORE_EXPORT ItemStringList: public KConfigSkeletonGenericItem < QStringList >
1033  {
1034  public:
1036  ItemStringList(const QString &_group, const QString &_key,
1037  QStringList &reference,
1038  const QStringList &defaultValue = QStringList());
1039 
1041  void readConfig(KConfig *config) override;
1042 
1044  void setProperty(const QVariant &p) override;
1045 
1047  bool isEqual(const QVariant &p) const override;
1048 
1050  QVariant property() const override;
1051  };
1052 
1056  class KCONFIGCORE_EXPORT ItemPathList: public ItemStringList
1057  {
1058  public:
1060  ItemPathList(const QString &_group, const QString &_key,
1061  QStringList &reference,
1062  const QStringList &defaultValue = QStringList());
1063 
1065  void readConfig(KConfig *config) override;
1067  void writeConfig(KConfig *config) override;
1068  };
1069 
1073  class KCONFIGCORE_EXPORT ItemUrlList: public KConfigSkeletonGenericItem < QList<QUrl> >
1074  {
1075  public:
1077  ItemUrlList(const QString &_group, const QString &_key,
1078  QList<QUrl> &reference,
1079  const QList<QUrl> &defaultValue = QList<QUrl>());
1080 
1082  void readConfig(KConfig *config) override;
1083 
1085  void writeConfig(KConfig *config) override;
1086 
1088  void setProperty(const QVariant &p) override;
1089 
1091  bool isEqual(const QVariant &p) const override;
1092 
1094  QVariant property() const override;
1095  };
1096 
1100  class KCONFIGCORE_EXPORT ItemIntList: public KConfigSkeletonGenericItem < QList < int > >
1101  {
1102  public:
1104  ItemIntList(const QString &_group, const QString &_key,
1105  QList < int > &reference,
1106  const QList < int > &defaultValue = QList < int >());
1107 
1109  void readConfig(KConfig *config) override;
1110 
1112  void setProperty(const QVariant &p) override;
1113 
1115  bool isEqual(const QVariant &p) const override;
1116 
1118  QVariant property() const override;
1119  };
1120 
1121 public:
1129  explicit KCoreConfigSkeleton(const QString &configname = QString(), QObject *parent = nullptr);
1130 
1137  explicit KCoreConfigSkeleton(KSharedConfig::Ptr config, QObject *parent = nullptr);
1138 
1142  virtual ~KCoreConfigSkeleton();
1143 
1152  virtual void setDefaults();
1153 
1161  void load();
1162 
1163 #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0)
1164 
1168  KCONFIGCORE_DEPRECATED_VERSION(5, 0, "Use KCoreConfigSkeleton::load() or KCoreConfigSkeleton::read()")
1169  void readConfig()
1170  {
1171  load();
1172  }
1173 #endif
1174 
1185  void read();
1186 
1192  bool isDefaults() const;
1193 
1200  bool isSaveNeeded() const;
1201 
1207  void setCurrentGroup(const QString &group);
1208 
1212  QString currentGroup() const;
1213 
1223  void addItem(KConfigSkeletonItem *, const QString &name = QString());
1224 
1236  ItemString *addItemString(const QString &name, QString &reference,
1237  const QString &defaultValue = QLatin1String(""), // NOT QString() !!
1238  const QString &key = QString());
1239 
1253  ItemPassword *addItemPassword(const QString &name, QString &reference,
1254  const QString &defaultValue = QLatin1String(""),
1255  const QString &key = QString());
1256 
1270  ItemPath *addItemPath(const QString &name, QString &reference,
1271  const QString &defaultValue = QLatin1String(""),
1272  const QString &key = QString());
1273 
1287  ItemProperty *addItemProperty(const QString &name, QVariant &reference,
1288  const QVariant &defaultValue = QVariant(),
1289  const QString &key = QString());
1301  ItemBool *addItemBool(const QString &name, bool &reference,
1302  bool defaultValue = false,
1303  const QString &key = QString());
1304 
1316  ItemInt *addItemInt(const QString &name, qint32 &reference, qint32 defaultValue = 0,
1317  const QString &key = QString());
1318 
1330  ItemUInt *addItemUInt(const QString &name, quint32 &reference,
1331  quint32 defaultValue = 0,
1332  const QString &key = QString());
1333 
1345  ItemLongLong *addItemLongLong(const QString &name, qint64 &reference,
1346  qint64 defaultValue = 0,
1347  const QString &key = QString());
1348 
1349 #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0)
1350 
1353  KCONFIGCORE_DEPRECATED_VERSION(5, 0, "Use KCoreConfigSkeleton::addItemLongLong(...)")
1354  ItemLongLong *addItemInt64(const QString &name, qint64 &reference,
1355  qint64 defaultValue = 0,
1356  const QString &key = QString());
1357 #endif
1358 
1370  ItemULongLong *addItemULongLong(const QString &name, quint64 &reference,
1371  quint64 defaultValue = 0,
1372  const QString &key = QString());
1373 
1374 #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0)
1375 
1378  KCONFIGCORE_DEPRECATED_VERSION(5, 0, "Use KCoreConfigSkeleton::addItemULongLong(...)")
1379  ItemULongLong *addItemUInt64(const QString &name, quint64 &reference,
1380  quint64 defaultValue = 0,
1381  const QString &key = QString());
1382 #endif
1383 
1395  ItemDouble *addItemDouble(const QString &name, double &reference,
1396  double defaultValue = 0.0,
1397  const QString &key = QString());
1398 
1410  ItemRect *addItemRect(const QString &name, QRect &reference,
1411  const QRect &defaultValue = QRect(),
1412  const QString &key = QString());
1413 
1425  ItemPoint *addItemPoint(const QString &name, QPoint &reference,
1426  const QPoint &defaultValue = QPoint(),
1427  const QString &key = QString());
1428 
1440  ItemSize *addItemSize(const QString &name, QSize &reference,
1441  const QSize &defaultValue = QSize(),
1442  const QString &key = QString());
1443 
1455  ItemDateTime *addItemDateTime(const QString &name, QDateTime &reference,
1456  const QDateTime &defaultValue = QDateTime(),
1457  const QString &key = QString());
1458 
1470  ItemStringList *addItemStringList(const QString &name, QStringList &reference,
1471  const QStringList &defaultValue = QStringList(),
1472  const QString &key = QString());
1473 
1485  ItemIntList *addItemIntList(const QString &name, QList < int > &reference,
1486  const QList < int > &defaultValue =
1487  QList < int >(),
1488  const QString &key = QString());
1489 
1493  KConfig *config();
1494 
1498  const KConfig *config() const;
1499 
1504  KSharedConfig::Ptr sharedConfig() const;
1505 
1509  void setSharedConfig(KSharedConfig::Ptr pConfig);
1510 
1514  KConfigSkeletonItem::List items() const;
1515 
1520  void removeItem(const QString &name);
1521 
1525  void clearItems();
1526 
1531  Q_INVOKABLE bool isImmutable(const QString &name) const;
1532 
1537  KConfigSkeletonItem *findItem(const QString &name) const;
1538 
1551  virtual bool useDefaults(bool b);
1552 
1553 public Q_SLOTS:
1561  bool save();
1562 
1563 #if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0)
1564 
1567  KCONFIGCORE_DEPRECATED_VERSION(5, 0, "Use KCoreConfigSkeleton::save()")
1568  void writeConfig()
1569  {
1570  save();
1571  }
1572 #endif
1573 
1574 Q_SIGNALS:
1578  void configChanged();
1579 
1580 protected:
1589  virtual bool usrUseDefaults(bool b);
1590 
1596  virtual void usrSetDefaults();
1597 
1603  virtual void usrRead();
1604 
1610  virtual bool usrSave();
1611 
1612 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
1613 
1617  KCONFIGCORE_DEPRECATED_VERSION(5, 0, "Override KCoreConfigSkeleton::usrRead()")
1618  virtual void usrReadConfig();
1619 #endif
1620 
1621 #if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
1622 
1626  KCONFIGCORE_DEPRECATED_VERSION(5, 0, "Override KCoreConfigSkeleton::usrSave()")
1627  virtual bool usrWriteConfig();
1628 #endif
1629 
1630 private:
1631  KCoreConfigSkeletonPrivate *const d;
1632  friend class KConfigSkeleton;
1633 
1634 };
1635 
1636 #endif
Class for handling unsigned 64-bit integer preferences item.
virtual void setProperty(const QVariant &p)=0
Set item to p.
virtual void setDefault()=0
Sets the current value to the default value.
Class for proxying a QObject property as a preferences setting.
Class for handling a floating point preference item.
Class for handling a string preferences item.
void setReadDefaults(bool b)
defaults
Definition: kconfig.cpp:838
virtual void readDefault(KConfig *)=0
Read global default value.
bool hasDefault(const QString &key) const
Whether a default is specified for an entry in either the system wide configuration file or the globa...
virtual void writeConfig(KConfig *)=0
This function is called by KCoreConfigSkeleton to write the value of this setting to a config file...
void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags=Normal)
Writes a value to the configuration object.
Class for handling a QDateTime preferences item.
Class for handling a 64-bit integer preferences item.
Class for handling preferences settings for an application.
Class for handling a url list preferences item.
Class for handling a password preferences item.
virtual void readConfig(KConfig *)=0
This function is called by KCoreConfigSkeleton to read the value for this setting from a config file...
Class for handling a QVariant preferences item.
virtual bool isEqual(const QVariant &p) const =0
Check whether the item is equal to p.
Class for handling a bool preferences item.
Type
The type of string that is held in this item.
Class for handling an unsigned 32-bit integer preferences item.
Class for handling preferences settings for an application.
virtual void swapDefault()=0
Exchanges the current value with the default value Used by KCoreConfigSkeleton::useDefaults(bool);.
Class for handling a path list preferences item.
Class for handling a QRect preferences item.
QString mName
The name of this item.
Class for handling a 32-bit integer preferences item.
A class for one specific group in a KConfig object.
Definition: kconfiggroup.h:38
Class for handling a QPoint preferences item.
The central class of the KDE configuration data system.
Definition: kconfig.h:56
Class for handling a QSize preferences item.
QString mKey
The config key for this item.
Class for handling a string list preferences item.
Class for storing a preferences setting.
QString mGroup
The group name for this item.
Class for handling an integer list preferences item.
QCA_EXPORT void setProperty(const QString &name, const QVariant &value)
virtual QVariant property() const =0
Return item as property.
Class for handling a url preferences item.
void revertToDefault(const QString &key)
Reverts an entry to the default settings.
Class for handling a path preferences item.
Class for handling enums.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Aug 6 2020 22:47:20 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.