/src/kconfig/src/gui/kconfigskeleton.cpp
Line | Count | Source |
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 | 2 | : KCoreConfigSkeleton(configname, parent) |
15 | 2 | { |
16 | 2 | } |
17 | | |
18 | | KConfigSkeleton::KConfigSkeleton(KSharedConfig::Ptr pConfig, QObject *parent) |
19 | 0 | : KCoreConfigSkeleton(std::move(pConfig), parent) |
20 | 0 | { |
21 | 0 | } |
22 | | |
23 | | KConfigSkeleton::ItemColor::ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue) |
24 | 0 | : KConfigSkeletonGenericItem<QColor>(_group, _key, reference, defaultValue) |
25 | 0 | { |
26 | 0 | } |
27 | | |
28 | | KConfigSkeleton::KConfigSkeleton(std::unique_ptr<KConfig> config, KCoreConfigSkeleton::DisambiguateConstructor value, QObject *parent) |
29 | 0 | : KCoreConfigSkeleton(std::move(config), DisambiguateConstructor::IsStdUniqPtr, parent) |
30 | 0 | { |
31 | 0 | Q_UNUSED(value) |
32 | 0 | } |
33 | | |
34 | | void KConfigSkeleton::ItemColor::readConfig(KConfig *config) |
35 | 0 | { |
36 | 0 | KConfigGroup cg = configGroup(config); |
37 | |
|
38 | 0 | mReference = cg.readEntry(mKey, mDefault); |
39 | 0 | mLoadedValue = mReference; |
40 | |
|
41 | 0 | readImmutability(cg); |
42 | 0 | } |
43 | | |
44 | | void KConfigSkeleton::ItemColor::setProperty(const QVariant &p) |
45 | 0 | { |
46 | 0 | mReference = qvariant_cast<QColor>(p); |
47 | 0 | } |
48 | | |
49 | | bool KConfigSkeleton::ItemColor::isEqual(const QVariant &v) const |
50 | 0 | { |
51 | 0 | return mReference == qvariant_cast<QColor>(v); |
52 | 0 | } |
53 | | |
54 | | QVariant KConfigSkeleton::ItemColor::property() const |
55 | 0 | { |
56 | 0 | return QVariant(mReference); |
57 | 0 | } |
58 | | |
59 | | KConfigSkeleton::ItemFont::ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue) |
60 | 0 | : KConfigSkeletonGenericItem<QFont>(_group, _key, reference, defaultValue) |
61 | 0 | { |
62 | 0 | } |
63 | | |
64 | | void KConfigSkeleton::ItemFont::readConfig(KConfig *config) |
65 | 0 | { |
66 | 0 | KConfigGroup cg = configGroup(config); |
67 | |
|
68 | 0 | mReference = cg.readEntry(mKey, mDefault); |
69 | 0 | mLoadedValue = mReference; |
70 | |
|
71 | 0 | readImmutability(cg); |
72 | 0 | } |
73 | | |
74 | | void KConfigSkeleton::ItemFont::setProperty(const QVariant &p) |
75 | 0 | { |
76 | 0 | mReference = qvariant_cast<QFont>(p); |
77 | 0 | } |
78 | | |
79 | | bool KConfigSkeleton::ItemFont::isEqual(const QVariant &v) const |
80 | 0 | { |
81 | 0 | return mReference == qvariant_cast<QFont>(v); |
82 | 0 | } |
83 | | |
84 | | QVariant KConfigSkeleton::ItemFont::property() const |
85 | 0 | { |
86 | 0 | return QVariant(mReference); |
87 | 0 | } |
88 | | |
89 | | KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor(const QString &name, QColor &reference, const QColor &defaultValue, const QString &key) |
90 | 0 | { |
91 | 0 | KConfigSkeleton::ItemColor *item; |
92 | 0 | item = new KConfigSkeleton::ItemColor(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); |
93 | 0 | addItem(item, name); |
94 | 0 | return item; |
95 | 0 | } |
96 | | |
97 | | KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont(const QString &name, QFont &reference, const QFont &defaultValue, const QString &key) |
98 | 0 | { |
99 | 0 | KConfigSkeleton::ItemFont *item; |
100 | 0 | item = new KConfigSkeleton::ItemFont(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue); |
101 | 0 | addItem(item, name); |
102 | 0 | return item; |
103 | 0 | } |
104 | | |
105 | | #include "moc_kconfigskeleton.cpp" |