Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Itinerary
Commits
9a9320cb
Commit
9a9320cb
authored
Nov 29, 2021
by
Volker Krause
Browse files
Show currencies in the trip group delegate as well
parent
951ae339
Changes
4
Hide whitespace changes
Inline
Side-by-side
autotests/tripgroupinfoprovidertest.cpp
View file @
9a9320cb
...
...
@@ -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"
)}));
}
};
...
...
src/app/TripGroupDelegate.qml
View file @
9a9320cb
...
...
@@ -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
}
...
...
src/app/tripgroupinfoprovider.cpp
View file @
9a9320cb
...
...
@@ -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"
src/app/tripgroupinfoprovider.h
View file @
9a9320cb
...
...
@@ -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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment