Changeset View
Changeset View
Standalone View
Standalone View
src/address.cpp
Show First 20 Lines • Show All 582 Lines • ▼ Show 20 Line(s) | 582 | { | |||
---|---|---|---|---|---|
583 | const auto n = QLocale().name(); // this is in the form <lang>_<COUNTRY>, with the exception of 'C' | 583 | const auto n = QLocale().name(); // this is in the form <lang>_<COUNTRY>, with the exception of 'C' | ||
584 | const auto idx = n.indexOf(QLatin1Char('_')); | 584 | const auto idx = n.indexOf(QLatin1Char('_')); | ||
585 | if (idx > 0) { | 585 | if (idx > 0) { | ||
586 | return n.mid(idx + 1).toLower(); | 586 | return n.mid(idx + 1).toLower(); | ||
587 | } | 587 | } | ||
588 | return {}; | 588 | return {}; | ||
589 | } | 589 | } | ||
590 | 590 | | |||
591 | static QString addressFormatRc() | ||||
592 | { | ||||
593 | Q_INIT_RESOURCE(kcontacts); // must be called outside of a namespace | ||||
594 | return QStringLiteral(":/org.kde.kcontacts/addressformatrc"); | ||||
595 | } | ||||
596 | | ||||
591 | QString Address::formattedAddress(const QString &realName, const QString &orgaName) const | 597 | QString Address::formattedAddress(const QString &realName, const QString &orgaName) const | ||
592 | { | 598 | { | ||
593 | QString ciso; | 599 | QString ciso; | ||
594 | QString addrTemplate; | 600 | QString addrTemplate; | ||
595 | QString ret; | 601 | QString ret; | ||
596 | 602 | | |||
597 | // FIXME: first check for iso-country-field and prefer that one | 603 | // FIXME: first check for iso-country-field and prefer that one | ||
598 | if (!country().isEmpty()) { | 604 | if (!country().isEmpty()) { | ||
599 | ciso = countryToISO(country()); | 605 | ciso = countryToISO(country()); | ||
600 | } else { | 606 | } else { | ||
601 | // fall back to our own country | 607 | // fall back to our own country | ||
602 | ciso = countryCodeFromLocale(); | 608 | ciso = countryCodeFromLocale(); | ||
603 | } | 609 | } | ||
604 | static KConfig entry(QStringLiteral(":/org.kde.kcontacts/addressformatrc")); | 610 | static const KConfig entry(addressFormatRc()); | ||
605 | 611 | | |||
606 | KConfigGroup group = entry.group(ciso); | 612 | KConfigGroup group = entry.group(ciso); | ||
607 | // decide whether this needs special business address formatting | 613 | // decide whether this needs special business address formatting | ||
608 | if (orgaName.isEmpty()) { | 614 | if (orgaName.isEmpty()) { | ||
609 | addrTemplate = group.readEntry("AddressFormat"); | 615 | addrTemplate = group.readEntry("AddressFormat"); | ||
610 | } else { | 616 | } else { | ||
611 | addrTemplate = group.readEntry("BusinessAddressFormat"); | 617 | addrTemplate = group.readEntry("BusinessAddressFormat"); | ||
612 | if (addrTemplate.isEmpty()) { | 618 | if (addrTemplate.isEmpty()) { | ||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |