Changeset View
Changeset View
Standalone View
Standalone View
src/core/kcoreconfigskeleton.cpp
Show First 20 Lines • Show All 569 Lines • ▼ Show 20 Line(s) | |||||
570 | } | 570 | } | ||
571 | 571 | | |||
572 | void KCoreConfigSkeleton::ItemLongLong::setMaxValue(qint64 v) | 572 | void KCoreConfigSkeleton::ItemLongLong::setMaxValue(qint64 v) | ||
573 | { | 573 | { | ||
574 | mHasMax = true; | 574 | mHasMax = true; | ||
575 | mMax = v; | 575 | mMax = v; | ||
576 | } | 576 | } | ||
577 | 577 | | |||
578 | QString KCoreConfigSkeleton::ItemEnum::valueForChoice(QString name) const | ||||
579 | { | ||||
580 | // TODO KF6 move value to ItemEnum::Choice and remove KCoreConfigSkeleton::ItemEnum::mValues | ||||
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. | |||||
581 | const auto inHash = mValues.value(name); | ||||
You mean KConfigSkeletonItemPrivate aren't you? (instead of KCoreConfigSkeletonPrivate) ervin: You mean KConfigSkeletonItemPrivate aren't you? (instead of KCoreConfigSkeletonPrivate) | |||||
582 | return !inHash.isEmpty() ? inHash : name; | ||||
583 | } | ||||
584 | | ||||
585 | /** | ||||
586 | * Stores a choice value for name | ||||
ervin: This comment should go away | |||||
587 | */ | ||||
588 | void KCoreConfigSkeleton::ItemEnum::setValueForChoice(QString name, QString value) | ||||
589 | { | ||||
590 | mValues.insert(name, value); | ||||
591 | } | ||||
592 | | ||||
578 | KCoreConfigSkeleton::ItemEnum::ItemEnum(const QString &_group, const QString &_key, | 593 | KCoreConfigSkeleton::ItemEnum::ItemEnum(const QString &_group, const QString &_key, | ||
579 | qint32 &reference, | 594 | qint32 &reference, | ||
580 | const QList<Choice> &choices, | 595 | const QList<Choice> &choices, | ||
581 | qint32 defaultValue) | 596 | qint32 defaultValue) | ||
582 | : ItemInt(_group, _key, reference, defaultValue), mChoices(choices) | 597 | : ItemInt(_group, _key, reference, defaultValue), mChoices(choices) | ||
583 | { | 598 | { | ||
584 | } | 599 | } | ||
585 | 600 | | |||
586 | void KCoreConfigSkeleton::ItemEnum::readConfig(KConfig *config) | 601 | void KCoreConfigSkeleton::ItemEnum::readConfig(KConfig *config) | ||
587 | { | 602 | { | ||
588 | KConfigGroup cg(config, mGroup); | 603 | KConfigGroup cg(config, mGroup); | ||
589 | if (!cg.hasKey(mKey)) { | 604 | if (!cg.hasKey(mKey)) { | ||
590 | mReference = mDefault; | 605 | mReference = mDefault; | ||
591 | } else { | 606 | } else { | ||
592 | int i = 0; | 607 | int i = 0; | ||
593 | mReference = -1; | 608 | mReference = -1; | ||
594 | QString tmp = cg.readEntry(mKey, QString()).toLower(); | 609 | QString tmp = cg.readEntry(mKey, QString()).toLower(); | ||
595 | for (QList<Choice>::ConstIterator it = mChoices.constBegin(); | 610 | for (QList<Choice>::ConstIterator it = mChoices.constBegin(); | ||
596 | it != mChoices.constEnd(); ++it, ++i) { | 611 | it != mChoices.constEnd(); ++it, ++i) { | ||
597 | if ((*it).name.toLower() == tmp) { | 612 | QString choiceName = (*it).name; | ||
613 | if (valueForChoice(choiceName).toLower() == tmp) { | ||||
598 | mReference = i; | 614 | mReference = i; | ||
599 | break; | 615 | break; | ||
600 | } | 616 | } | ||
601 | } | 617 | } | ||
602 | if (mReference == -1) { | 618 | if (mReference == -1) { | ||
603 | mReference = cg.readEntry(mKey, mDefault); | 619 | mReference = cg.readEntry(mKey, mDefault); | ||
604 | } | 620 | } | ||
605 | } | 621 | } | ||
606 | mLoadedValue = mReference; | 622 | mLoadedValue = mReference; | ||
607 | 623 | | |||
608 | readImmutability(cg); | 624 | readImmutability(cg); | ||
609 | } | 625 | } | ||
610 | 626 | | |||
611 | void KCoreConfigSkeleton::ItemEnum::writeConfig(KConfig *config) | 627 | void KCoreConfigSkeleton::ItemEnum::writeConfig(KConfig *config) | ||
612 | { | 628 | { | ||
613 | if (mReference != mLoadedValue) { // WABA: Is this test needed? | 629 | if (mReference != mLoadedValue) { // WABA: Is this test needed? | ||
614 | KConfigGroup cg(config, mGroup); | 630 | KConfigGroup cg(config, mGroup); | ||
615 | if ((mDefault == mReference) && !cg.hasDefault(mKey)) { | 631 | if ((mDefault == mReference) && !cg.hasDefault(mKey)) { | ||
616 | cg.revertToDefault(mKey, writeFlags()); | 632 | cg.revertToDefault(mKey, writeFlags()); | ||
617 | } else if ((mReference >= 0) && (mReference < mChoices.count())) { | 633 | } else if ((mReference >= 0) && (mReference < mChoices.count())) { | ||
618 | cg.writeEntry(mKey, mChoices[mReference].name, writeFlags()); | 634 | cg.writeEntry(mKey, valueForChoice(mChoices.at(mReference).name), writeFlags()); | ||
619 | } else { | 635 | } else { | ||
620 | cg.writeEntry(mKey, mReference, writeFlags()); | 636 | cg.writeEntry(mKey, mReference, writeFlags()); | ||
621 | } | 637 | } | ||
622 | mLoadedValue = mReference; | 638 | mLoadedValue = mReference; | ||
623 | } | 639 | } | ||
624 | } | 640 | } | ||
625 | 641 | | |||
626 | QList<KCoreConfigSkeleton::ItemEnum::Choice> KCoreConfigSkeleton::ItemEnum::choices() const | 642 | QList<KCoreConfigSkeleton::ItemEnum::Choice> KCoreConfigSkeleton::ItemEnum::choices() const | ||
▲ Show 20 Lines • Show All 991 Lines • Show Last 20 Lines |
Will need an update