1 | /* |
2 | This file is part of KOrganizer. |
3 | SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-or-later |
7 | */ |
8 | |
9 | #include "kconfigskeleton.h" |
10 | |
11 | #include <kcoreconfigskeleton_p.h> |
12 | |
13 | KConfigSkeleton::KConfigSkeleton(const QString &configname, QObject *parent) |
14 | : KCoreConfigSkeleton(configname, parent) |
15 | { |
16 | } |
17 | |
18 | KConfigSkeleton::KConfigSkeleton(KSharedConfig::Ptr pConfig, QObject *parent) |
19 | : KCoreConfigSkeleton(std::move(pConfig), parent) |
20 | { |
21 | } |
22 | |
23 | KConfigSkeleton::ItemColor::ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue) |
24 | : KConfigSkeletonGenericItem<QColor>(_group, _key, reference, defaultValue) |
25 | { |
26 | } |
27 | |
28 | void KConfigSkeleton::ItemColor::readConfig(KConfig *config) |
29 | { |
30 | KConfigGroup cg = configGroup(config); |
31 | |
32 | mReference = cg.readEntry(key: mKey, aDefault: mDefault); |
33 | mLoadedValue = mReference; |
34 | |
35 | readImmutability(group: cg); |
36 | } |
37 | |
38 | void KConfigSkeleton::ItemColor::setProperty(const QVariant &p) |
39 | { |
40 | mReference = qvariant_cast<QColor>(v: p); |
41 | } |
42 | |
43 | bool KConfigSkeleton::ItemColor::isEqual(const QVariant &v) const |
44 | { |
45 | return mReference == qvariant_cast<QColor>(v); |
46 | } |
47 | |
48 | QVariant KConfigSkeleton::ItemColor::property() const |
49 | { |
50 | return QVariant(mReference); |
51 | } |
52 | |
53 | KConfigSkeleton::ItemFont::ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue) |
54 | : KConfigSkeletonGenericItem<QFont>(_group, _key, reference, defaultValue) |
55 | { |
56 | } |
57 | |
58 | void KConfigSkeleton::ItemFont::readConfig(KConfig *config) |
59 | { |
60 | KConfigGroup cg = configGroup(config); |
61 | |
62 | mReference = cg.readEntry(key: mKey, aDefault: mDefault); |
63 | mLoadedValue = mReference; |
64 | |
65 | readImmutability(group: cg); |
66 | } |
67 | |
68 | void KConfigSkeleton::ItemFont::setProperty(const QVariant &p) |
69 | { |
70 | mReference = qvariant_cast<QFont>(v: p); |
71 | } |
72 | |
73 | bool KConfigSkeleton::ItemFont::isEqual(const QVariant &v) const |
74 | { |
75 | return mReference == qvariant_cast<QFont>(v); |
76 | } |
77 | |
78 | QVariant KConfigSkeleton::ItemFont::property() const |
79 | { |
80 | return QVariant(mReference); |
81 | } |
82 | |
83 | KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor(const QString &name, QColor &reference, const QColor &defaultValue, const QString &key) |
84 | { |
85 | KConfigSkeleton::ItemColor *item; |
86 | item = new KConfigSkeleton::ItemColor(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); |
87 | addItem(item, name); |
88 | return item; |
89 | } |
90 | |
91 | KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont(const QString &name, QFont &reference, const QFont &defaultValue, const QString &key) |
92 | { |
93 | KConfigSkeleton::ItemFont *item; |
94 | item = new KConfigSkeleton::ItemFont(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); |
95 | addItem(item, name); |
96 | return item; |
97 | } |
98 | |
99 | #include "moc_kconfigskeleton.cpp" |
100 | |