Changeset View
Changeset View
Standalone View
Standalone View
src/core/kcoreconfigskeleton.cpp
Show First 20 Lines • Show All 584 Lines • ▼ Show 20 Line(s) | |||||
585 | } | 585 | } | ||
586 | 586 | | |||
587 | void KCoreConfigSkeleton::ItemLongLong::setMaxValue(qint64 v) | 587 | void KCoreConfigSkeleton::ItemLongLong::setMaxValue(qint64 v) | ||
588 | { | 588 | { | ||
589 | mHasMax = true; | 589 | mHasMax = true; | ||
590 | mMax = v; | 590 | mMax = v; | ||
591 | } | 591 | } | ||
592 | 592 | | |||
593 | QString KCoreConfigSkeleton::ItemEnum::valueForChoice(const QString &name) const | ||||
594 | { | ||||
595 | // HACK for BC concerns | ||||
ervin: Will need an update | |||||
You mean I should prepare this and put it in KF6 waiting for merge queue ? meven: You mean I should prepare this and put it in KF6 waiting for merge queue ? | |||||
No I meant the comment needs to be adjusted due to the changes (fields changing place and such) sorry if I was unclear. ervin: No I meant the comment needs to be adjusted due to the changes (fields changing place and such)… | |||||
meven: I updated the comment since your first comment, I think it is ok now. | |||||
596 | // TODO KF6: remove KConfigSkeletonItemPrivate::mValues and add a value field to KCoreConfigSkeleton::ItemEnum::Choice | ||||
You mean KConfigSkeletonItemPrivate aren't you? (instead of KCoreConfigSkeletonPrivate) ervin: You mean KConfigSkeletonItemPrivate aren't you? (instead of KCoreConfigSkeletonPrivate) | |||||
597 | const auto inHash = d_ptr->mValues.value(name); | ||||
598 | return !inHash.isEmpty() ? inHash : name; | ||||
599 | } | ||||
600 | | ||||
601 | void KCoreConfigSkeleton::ItemEnum::setValueForChoice(const QString &name, const QString &value) | ||||
ervin: This comment should go away | |||||
602 | { | ||||
603 | d_ptr->mValues.insert(name, value); | ||||
604 | } | ||||
605 | | ||||
593 | KCoreConfigSkeleton::ItemEnum::ItemEnum(const QString &_group, const QString &_key, | 606 | KCoreConfigSkeleton::ItemEnum::ItemEnum(const QString &_group, const QString &_key, | ||
594 | qint32 &reference, | 607 | qint32 &reference, | ||
595 | const QList<Choice> &choices, | 608 | const QList<Choice> &choices, | ||
596 | qint32 defaultValue) | 609 | qint32 defaultValue) | ||
597 | : ItemInt(_group, _key, reference, defaultValue), mChoices(choices) | 610 | : ItemInt(_group, _key, reference, defaultValue), mChoices(choices) | ||
598 | { | 611 | { | ||
599 | } | 612 | } | ||
600 | 613 | | |||
601 | void KCoreConfigSkeleton::ItemEnum::readConfig(KConfig *config) | 614 | void KCoreConfigSkeleton::ItemEnum::readConfig(KConfig *config) | ||
602 | { | 615 | { | ||
603 | KConfigGroup cg = configGroup(config); | 616 | KConfigGroup cg = configGroup(config); | ||
604 | if (!cg.hasKey(mKey)) { | 617 | if (!cg.hasKey(mKey)) { | ||
605 | mReference = mDefault; | 618 | mReference = mDefault; | ||
606 | } else { | 619 | } else { | ||
607 | int i = 0; | 620 | int i = 0; | ||
608 | mReference = -1; | 621 | mReference = -1; | ||
609 | QString tmp = cg.readEntry(mKey, QString()).toLower(); | 622 | QString tmp = cg.readEntry(mKey, QString()).toLower(); | ||
610 | for (QList<Choice>::ConstIterator it = mChoices.constBegin(); | 623 | for (QList<Choice>::ConstIterator it = mChoices.constBegin(); | ||
611 | it != mChoices.constEnd(); ++it, ++i) { | 624 | it != mChoices.constEnd(); ++it, ++i) { | ||
612 | if ((*it).name.toLower() == tmp) { | 625 | QString choiceName = (*it).name; | ||
626 | if (valueForChoice(choiceName).toLower() == tmp) { | ||||
613 | mReference = i; | 627 | mReference = i; | ||
614 | break; | 628 | break; | ||
615 | } | 629 | } | ||
616 | } | 630 | } | ||
617 | if (mReference == -1) { | 631 | if (mReference == -1) { | ||
618 | mReference = cg.readEntry(mKey, mDefault); | 632 | mReference = cg.readEntry(mKey, mDefault); | ||
619 | } | 633 | } | ||
620 | } | 634 | } | ||
621 | mLoadedValue = mReference; | 635 | mLoadedValue = mReference; | ||
622 | 636 | | |||
623 | readImmutability(cg); | 637 | readImmutability(cg); | ||
624 | } | 638 | } | ||
625 | 639 | | |||
626 | void KCoreConfigSkeleton::ItemEnum::writeConfig(KConfig *config) | 640 | void KCoreConfigSkeleton::ItemEnum::writeConfig(KConfig *config) | ||
627 | { | 641 | { | ||
628 | if (mReference != mLoadedValue) { // WABA: Is this test needed? | 642 | if (mReference != mLoadedValue) { // WABA: Is this test needed? | ||
629 | KConfigGroup cg = configGroup(config); | 643 | KConfigGroup cg = configGroup(config); | ||
630 | if ((mDefault == mReference) && !cg.hasDefault(mKey)) { | 644 | if ((mDefault == mReference) && !cg.hasDefault(mKey)) { | ||
631 | cg.revertToDefault(mKey, writeFlags()); | 645 | cg.revertToDefault(mKey, writeFlags()); | ||
632 | } else if ((mReference >= 0) && (mReference < mChoices.count())) { | 646 | } else if ((mReference >= 0) && (mReference < mChoices.count())) { | ||
633 | cg.writeEntry(mKey, mChoices[mReference].name, writeFlags()); | 647 | cg.writeEntry(mKey, valueForChoice(mChoices.at(mReference).name), writeFlags()); | ||
634 | } else { | 648 | } else { | ||
635 | cg.writeEntry(mKey, mReference, writeFlags()); | 649 | cg.writeEntry(mKey, mReference, writeFlags()); | ||
636 | } | 650 | } | ||
637 | mLoadedValue = mReference; | 651 | mLoadedValue = mReference; | ||
638 | } | 652 | } | ||
639 | } | 653 | } | ||
640 | 654 | | |||
641 | QList<KCoreConfigSkeleton::ItemEnum::Choice> KCoreConfigSkeleton::ItemEnum::choices() const | 655 | QList<KCoreConfigSkeleton::ItemEnum::Choice> KCoreConfigSkeleton::ItemEnum::choices() const | ||
▲ Show 20 Lines • Show All 1001 Lines • Show Last 20 Lines |
Will need an update