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