Changeset View
Changeset View
Standalone View
Standalone View
src/core/kcoreconfigskeleton.cpp
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. | ||
3 | SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher <schumacher@kde.org> | ||
4 | SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org> | 4 | SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org> | ||
5 | 5 | | |||
6 | SPDX-License-Identifier: LGPL-2.0-or-later | 6 | SPDX-License-Identifier: LGPL-2.0-or-later | ||
7 | */ | 7 | */ | ||
8 | 8 | | |||
9 | #include "kcoreconfigskeleton.h" | 9 | #include "kcoreconfigskeleton.h" | ||
10 | #include "kcoreconfigskeleton_p.h" | 10 | #include "kcoreconfigskeleton_p.h" | ||
11 | 11 | | |||
12 | #include <QUrl> | 12 | #include <QUrl> | ||
13 | 13 | | |||
ervin: Looks like this include is unused | |||||
14 | static QString obscuredString(const QString &str) | 14 | static QString obscuredString(const QString &str) | ||
15 | { | 15 | { | ||
16 | QString result; | 16 | QString result; | ||
17 | const QChar *unicode = str.unicode(); | 17 | const QChar *unicode = str.unicode(); | ||
18 | for (int i = 0; i < str.length(); ++i) | 18 | for (int i = 0; i < str.length(); ++i) | ||
19 | // yes, no typo. can't encode ' ' or '!' because | 19 | // yes, no typo. can't encode ' ' or '!' because | ||
20 | // they're the unicode BOM. stupid scrambling. stupid. | 20 | // they're the unicode BOM. stupid scrambling. stupid. | ||
21 | result += (unicode[ i ].unicode() <= 0x21) ? unicode[ i ] | 21 | result += (unicode[ i ].unicode() <= 0x21) ? unicode[ i ] | ||
▲ Show 20 Lines • Show All 252 Lines • ▼ Show 20 Line(s) | 273 | : KConfigSkeletonGenericItem<QString>(_group, _key, reference, defaultValue), | |||
274 | mType(type) | 274 | mType(type) | ||
275 | { | 275 | { | ||
276 | } | 276 | } | ||
277 | 277 | | |||
278 | void KCoreConfigSkeleton::ItemString::writeConfig(KConfig *config) | 278 | void KCoreConfigSkeleton::ItemString::writeConfig(KConfig *config) | ||
279 | { | 279 | { | ||
280 | if (mReference != mLoadedValue) { // WABA: Is this test needed? | 280 | if (mReference != mLoadedValue) { // WABA: Is this test needed? | ||
281 | KConfigGroup cg = configGroup(config); | 281 | KConfigGroup cg = configGroup(config); | ||
282 | if ((mDefault == mReference) && !cg.hasDefault(mKey)) { | 282 | if (mDefault == mReference) { | ||
283 | cg.revertToDefault(mKey, writeFlags()); | 283 | cg.revertToDefault(mKey, writeFlags()); | ||
284 | } else if (mType == Path) { | 284 | } else if (mType == Path) { | ||
285 | cg.writePathEntry(mKey, mReference, writeFlags()); | 285 | cg.writePathEntry(mKey, mReference, writeFlags()); | ||
286 | } else if (mType == Password) { | 286 | } else if (mType == Password) { | ||
287 | cg.writeEntry(mKey, obscuredString(mReference), writeFlags()); | 287 | cg.writeEntry(mKey, obscuredString(mReference), writeFlags()); | ||
288 | } else { | 288 | } else { | ||
289 | cg.writeEntry(mKey, mReference, writeFlags()); | 289 | cg.writeEntry(mKey, mReference, writeFlags()); | ||
290 | } | 290 | } | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 342 | KCoreConfigSkeleton::ItemUrl::ItemUrl(const QString &_group, const QString &_key, | |||
345 | : KConfigSkeletonGenericItem<QUrl>(_group, _key, reference, defaultValue) | 345 | : KConfigSkeletonGenericItem<QUrl>(_group, _key, reference, defaultValue) | ||
346 | { | 346 | { | ||
347 | } | 347 | } | ||
348 | 348 | | |||
349 | void KCoreConfigSkeleton::ItemUrl::writeConfig(KConfig *config) | 349 | void KCoreConfigSkeleton::ItemUrl::writeConfig(KConfig *config) | ||
350 | { | 350 | { | ||
351 | if (mReference != mLoadedValue) { // WABA: Is this test needed? | 351 | if (mReference != mLoadedValue) { // WABA: Is this test needed? | ||
352 | KConfigGroup cg = configGroup(config); | 352 | KConfigGroup cg = configGroup(config); | ||
353 | if ((mDefault == mReference) && !cg.hasDefault(mKey)) { | 353 | if (mDefault == mReference) { | ||
354 | cg.revertToDefault(mKey, writeFlags()); | 354 | cg.revertToDefault(mKey, writeFlags()); | ||
355 | } else { | 355 | } else { | ||
356 | cg.writeEntry<QString>(mKey, mReference.toString(), writeFlags()); | 356 | cg.writeEntry<QString>(mKey, mReference.toString(), writeFlags()); | ||
357 | } | 357 | } | ||
358 | mLoadedValue = mReference; | 358 | mLoadedValue = mReference; | ||
359 | } | 359 | } | ||
360 | } | 360 | } | ||
361 | 361 | | |||
▲ Show 20 Lines • Show All 261 Lines • ▼ Show 20 Line(s) | 602 | { | |||
623 | 623 | | |||
624 | readImmutability(cg); | 624 | readImmutability(cg); | ||
625 | } | 625 | } | ||
626 | 626 | | |||
627 | void KCoreConfigSkeleton::ItemEnum::writeConfig(KConfig *config) | 627 | void KCoreConfigSkeleton::ItemEnum::writeConfig(KConfig *config) | ||
628 | { | 628 | { | ||
629 | if (mReference != mLoadedValue) { // WABA: Is this test needed? | 629 | if (mReference != mLoadedValue) { // WABA: Is this test needed? | ||
630 | KConfigGroup cg = configGroup(config); | 630 | KConfigGroup cg = configGroup(config); | ||
631 | if ((mDefault == mReference) && !cg.hasDefault(mKey)) { | 631 | if (mDefault == mReference) { | ||
632 | cg.revertToDefault(mKey, writeFlags()); | 632 | cg.revertToDefault(mKey, writeFlags()); | ||
633 | } else if ((mReference >= 0) && (mReference < mChoices.count())) { | 633 | } else if ((mReference >= 0) && (mReference < mChoices.count())) { | ||
634 | cg.writeEntry(mKey, valueForChoice(mChoices.at(mReference).name), writeFlags()); | 634 | cg.writeEntry(mKey, valueForChoice(mChoices.at(mReference).name), writeFlags()); | ||
635 | } else { | 635 | } else { | ||
636 | cg.writeEntry(mKey, mReference, writeFlags()); | 636 | cg.writeEntry(mKey, mReference, writeFlags()); | ||
637 | } | 637 | } | ||
638 | mLoadedValue = mReference; | 638 | mLoadedValue = mReference; | ||
639 | } | 639 | } | ||
▲ Show 20 Lines • Show All 383 Lines • ▼ Show 20 Line(s) | 1015 | { | |||
1023 | 1023 | | |||
1024 | readImmutability(cg); | 1024 | readImmutability(cg); | ||
1025 | } | 1025 | } | ||
1026 | 1026 | | |||
1027 | void KCoreConfigSkeleton::ItemPathList::writeConfig(KConfig *config) | 1027 | void KCoreConfigSkeleton::ItemPathList::writeConfig(KConfig *config) | ||
1028 | { | 1028 | { | ||
1029 | if (mReference != mLoadedValue) { // WABA: Is this test needed? | 1029 | if (mReference != mLoadedValue) { // WABA: Is this test needed? | ||
1030 | KConfigGroup cg = configGroup(config); | 1030 | KConfigGroup cg = configGroup(config); | ||
1031 | if ((mDefault == mReference) && !cg.hasDefault(mKey)) { | 1031 | if (mDefault == mReference) { | ||
1032 | cg.revertToDefault(mKey, writeFlags()); | 1032 | cg.revertToDefault(mKey, writeFlags()); | ||
1033 | } else { | 1033 | } else { | ||
1034 | QStringList sl = mReference; | 1034 | QStringList sl = mReference; | ||
1035 | cg.writePathEntry(mKey, sl, writeFlags()); | 1035 | cg.writePathEntry(mKey, sl, writeFlags()); | ||
1036 | } | 1036 | } | ||
1037 | mLoadedValue = mReference; | 1037 | mLoadedValue = mReference; | ||
1038 | } | 1038 | } | ||
1039 | } | 1039 | } | ||
Show All 25 Lines | 1049 | { | |||
1065 | 1065 | | |||
1066 | readImmutability(cg); | 1066 | readImmutability(cg); | ||
1067 | } | 1067 | } | ||
1068 | 1068 | | |||
1069 | void KCoreConfigSkeleton::ItemUrlList::writeConfig(KConfig *config) | 1069 | void KCoreConfigSkeleton::ItemUrlList::writeConfig(KConfig *config) | ||
1070 | { | 1070 | { | ||
1071 | if (mReference != mLoadedValue) { // WABA: Is this test needed? | 1071 | if (mReference != mLoadedValue) { // WABA: Is this test needed? | ||
1072 | KConfigGroup cg = configGroup(config); | 1072 | KConfigGroup cg = configGroup(config); | ||
1073 | if ((mDefault == mReference) && !cg.hasDefault(mKey)) { | 1073 | if (mDefault == mReference) { | ||
1074 | cg.revertToDefault(mKey, writeFlags()); | 1074 | cg.revertToDefault(mKey, writeFlags()); | ||
1075 | } else { | 1075 | } else { | ||
1076 | QStringList strList; | 1076 | QStringList strList; | ||
1077 | for (const QUrl &url : qAsConst(mReference)) { | 1077 | for (const QUrl &url : qAsConst(mReference)) { | ||
1078 | strList.append(url.toString()); | 1078 | strList.append(url.toString()); | ||
1079 | } | 1079 | } | ||
1080 | cg.writeEntry<QStringList>(mKey, strList, writeFlags()); | 1080 | cg.writeEntry<QStringList>(mKey, strList, writeFlags()); | ||
1081 | } | 1081 | } | ||
▲ Show 20 Lines • Show All 562 Lines • Show Last 20 Lines |
Looks like this include is unused