Commit 9a9320cb authored by Volker Krause's avatar Volker Krause
Browse files

Show currencies in the trip group delegate as well

parent 951ae339
......@@ -58,6 +58,9 @@ private Q_SLOTS:
const auto country = countries.at(0).value<LocationInformation>();
QCOMPARE(country.isoCode(), QStringLiteral("CH"));
QCOMPARE(country.powerPlugCompatibility(), LocationInformation::PartiallyCompatible);
QCOMPARE(provider.currencies(mgr.tripGroup(mgr.tripGroups().at(0)), QStringLiteral("EUR")), QStringList({QStringLiteral("CHF")}));
QCOMPARE(provider.currencies(mgr.tripGroup(mgr.tripGroups().at(0)), QStringLiteral("NZD")), QStringList({QStringLiteral("CHF"), QStringLiteral("EUR")}));
}
};
......
......@@ -104,6 +104,12 @@ Kirigami.AbstractCard {
}
}
QQC2.Label {
readonly property var currencies: TripGroupInfoProvider.currencies(tripGroup, Country.fromAlpha2(Settings.homeCountryIsoCode).currencyCode)
text: visible ? i18n("Currencies: %1", currencies.join(", ")) : ""
visible: currencies.length > 0
}
Kirigami.Separator {
visible: root.rangeType == TimelineElement.RangeBegin
}
......
......@@ -17,6 +17,8 @@
#include <KItinerary/Place>
#include <KItinerary/SortUtil>
#include <KCountry>
#include <QDateTime>
#include <QDebug>
......@@ -110,4 +112,25 @@ QVariantList TripGroupInfoProvider::locationInformation(const TripGroup &group,
return l;
}
QStringList TripGroupInfoProvider::currencies(const TripGroup& group, const QString &homeCurrency) const
{
QStringList l;
const auto elems = group.elements();
for (const auto &resId : elems) {
const auto res = m_resMgr->reservation(resId);
if (!LocationUtil::isLocationChange(res)) {
continue;
}
const auto destCountry = LocationUtil::address(LocationUtil::arrivalLocation(res)).addressCountry();
const auto currency = KCountry::fromAlpha2(destCountry).currencyCode();
if (currency.isEmpty() || currency == homeCurrency || l.contains(currency)) {
continue;
}
l.push_back(currency);
}
return l;
}
#include "moc_tripgroupinfoprovider.cpp"
......@@ -27,6 +27,7 @@ public:
Q_INVOKABLE WeatherForecast weatherForecast(const TripGroup &group) const;
Q_INVOKABLE QVariantList locationInformation(const TripGroup &group, const QString &homeCountryIsoCode) const;
Q_INVOKABLE QStringList currencies(const TripGroup &group, const QString &homeCurrency) const;
private:
ReservationManager *m_resMgr = nullptr;
......
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