Commit 5cdcb313 authored by Volker Krause's avatar Volker Krause
Browse files

Show all available holiday regions

Summary:
The previous approach was forcing unique labels, which fails in many cases
where we have multiple holiday files for a country. In most cases their
disambiguation is only in the description, not the (country) name.

This would be nicer if name() would actually contain the full region name,
not just the country, but lacking that I didn't see an alternative to
squeezing the description into the combo box as well.

As a result I can now actually pick from about a dozen holiday regions for
Germany for example, rather than getting a random one of those.

Reviewers: dvratil

Reviewed By: dvratil

Subscribers: kde-pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D29416
parent 7493049c
......@@ -266,7 +266,8 @@ public:
mHolidayCheckCombo->setWhatsThis(KOPrefs::instance()->holidaysItem()->whatsThis());
const QStringList regions = KHolidays::HolidayRegion::regionCodes();
QMap<QString, QString> regionsMap;
std::vector<std::pair<QString, QString>> regionsMap;
regionsMap.reserve(regions.size());
for (const QString &regionCode : regions) {
const QString name = KHolidays::HolidayRegion::name(regionCode);
......@@ -279,15 +280,18 @@ public:
label = i18nc("@item:inlistbox Holiday region, region language", "%1 (%2)",
name, languageName);
}
regionsMap.insert(label, regionCode);
const auto desc = KHolidays::HolidayRegion::description(regionCode);
if (!desc.isEmpty()) {
label = i18nc("@item:inlistbox holiday region, region description", "%1 - %2", label, desc);
}
regionsMap.push_back(std::make_pair(label, regionCode));
}
std::sort(regionsMap.begin(), regionsMap.end(), [](const auto &lhs, const auto &rhs) { return lhs.first < rhs.first; });
mHolidayCheckCombo->clear();
mHolidayCheckCombo->setDefaultText(i18nc("@item:inlistbox", "Select Holiday Regions"));
QMapIterator<QString, QString> i(regionsMap);
while (i.hasNext()) {
i.next();
mHolidayCheckCombo->addItem(i.key(), i.value());
for (const auto &entry : regionsMap) {
mHolidayCheckCombo->addItem(entry.first, entry.second);
}
//QString regionStr = KHolidays::HolidayRegion::defaultRegionCode();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment