Skip to content
GitLab
Menu
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
8f5f1218
Commit
8f5f1218
authored
Nov 28, 2021
by
Volker Krause
Browse files
Allow to show currency conversion rates
This is optional and off by default due to its need for online access.
parent
da9aea35
Pipeline
#102150
passed with stage
in 1 minute and 9 seconds
Changes
20
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
8f5f1218
...
...
@@ -47,7 +47,7 @@ set(QT_MIN_VERSION 5.15.2)
find_package
(
Qt5
${
QT_MIN_VERSION
}
REQUIRED COMPONENTS Test Quick Positioning Location QuickControls2
)
find_package
(
Qt5 CONFIG QUIET OPTIONAL_COMPONENTS QuickCompiler
)
find_package
(
KF5
${
KF5_MIN_VERSION
}
REQUIRED COMPONENTS I18n CoreAddons Contacts Notifications
)
find_package
(
KF5
${
KF5_MIN_VERSION
}
OPTIONAL_COMPONENTS Holidays NetworkManagerQt
)
find_package
(
KF5
${
KF5_MIN_VERSION
}
OPTIONAL_COMPONENTS Holidays
UnitConversion
NetworkManagerQt
)
find_package
(
KPimPkPass CONFIG REQUIRED
)
find_package
(
KPimItinerary 5.18.0 CONFIG REQUIRED
)
find_package
(
KPublicTransport CONFIG REQUIRED
)
...
...
@@ -89,6 +89,9 @@ endif()
if
(
TARGET KHealthCertificate
)
set
(
HAVE_KHEALTHCERTIFICATE TRUE
)
endif
()
if
(
TARGET KF5::UnitConversion
)
set
(
HAVE_KUNITCONVERSION TRUE
)
endif
()
add_definitions
(
-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00
)
add_definitions
(
-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055600
)
...
...
autotests/data/timeline/daychange-r2.model
View file @
8f5f1218
...
...
@@ -67,8 +67,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "GBP",
"currencyDiffers": true,
"currencyName": "GBP",
"drivingSide": "Left",
"drivingSideDiffers": true,
"isoCode": "GB",
...
...
@@ -151,8 +151,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "USD",
"currencyDiffers": true,
"currencyName": "USD",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "US",
...
...
autotests/data/timeline/daychange-r3.model
View file @
8f5f1218
...
...
@@ -67,8 +67,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "GBP",
"currencyDiffers": true,
"currencyName": "GBP",
"drivingSide": "Left",
"drivingSideDiffers": true,
"isoCode": "GB",
...
...
@@ -151,8 +151,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "USD",
"currencyDiffers": true,
"currencyName": "USD",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "US",
...
...
autotests/data/timeline/multi-traveler-merge-with-countryinfo.model
View file @
8f5f1218
...
...
@@ -318,8 +318,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "EUR",
"currencyDiffers": false,
"currencyName": "EUR",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "IT",
...
...
autotests/data/tripgroupproxy/current-r0.model
View file @
8f5f1218
...
...
@@ -101,8 +101,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "CHF",
"currencyDiffers": true,
"currencyName": "CHF",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "CH",
...
...
autotests/data/tripgroupproxy/current-r1.model
View file @
8f5f1218
...
...
@@ -94,8 +94,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "CHF",
"currencyDiffers": true,
"currencyName": "CHF",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "CH",
...
...
autotests/data/tripgroupproxy/expand-collapse-r0.model
View file @
8f5f1218
...
...
@@ -284,8 +284,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "EUR",
"currencyDiffers": false,
"currencyName": "EUR",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "IT",
...
...
@@ -484,8 +484,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "USD",
"currencyDiffers": true,
"currencyName": "USD",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "US",
...
...
@@ -643,8 +643,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "USD",
"currencyDiffers": true,
"currencyName": "USD",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "US",
...
...
@@ -775,8 +775,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "CHF",
"currencyDiffers": true,
"currencyName": "CHF",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "CH",
...
...
autotests/data/tripgroupproxy/expand-collapse-r1.model
View file @
8f5f1218
...
...
@@ -191,8 +191,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "USD",
"currencyDiffers": true,
"currencyName": "USD",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "US",
...
...
@@ -350,8 +350,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "USD",
"currencyDiffers": true,
"currencyName": "USD",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "US",
...
...
@@ -482,8 +482,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "CHF",
"currencyDiffers": true,
"currencyName": "CHF",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "CH",
...
...
autotests/data/tripgroupproxy/expand-collapse-r2.model
View file @
8f5f1218
...
...
@@ -143,8 +143,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyCode": "CHF",
"currencyDiffers": true,
"currencyName": "CHF",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "CH",
...
...
src/app/CMakeLists.txt
View file @
8f5f1218
...
...
@@ -79,6 +79,7 @@ target_sources(itinerary-app PRIVATE
countrymodel.cpp
developmentmodecontroller.cpp
documentsmodel.cpp
locationinformationdelegatecontroller.cpp
mapdownloadmanager.cpp
notificationconfigcontroller.cpp
notifyrc.qrc
...
...
@@ -196,6 +197,9 @@ endif()
if
(
TARGET KF5::Crash
)
target_link_libraries
(
itinerary-app PRIVATE KF5::Crash
)
endif
()
if
(
TARGET KF5::UnitConversion
)
target_link_libraries
(
itinerary-app PRIVATE KF5::UnitConversion
)
endif
()
install
(
TARGETS itinerary-app
${
INSTALL_TARGETS_DEFAULT_ARGS
}
)
ecm_install_icons
(
ICONS sc-apps-org.kde.itinerary.svg DESTINATION
${
KDE_INSTALL_ICONDIR
}
)
...
...
src/app/LocationInfoDelegate.qml
View file @
8f5f1218
...
...
@@ -15,7 +15,12 @@ import "." as App
Kirigami.AbstractCard
{
id
:
root
property
var
locationInfo
;
property
alias
locationInfo
:
_controller
.
locationInformation
property
QtObject
controller
:
LocationInformationDelegateController
{
id
:
_controller
homeCurrencyCode
:
Country
.
fromAlpha2
(
Settings
.
homeCountryIsoCode
).
currencyCode
performCurrencyConversion
:
Settings
.
performCurrencyConversion
}
header
:
Rectangle
{
id
:
headerBackground
...
...
@@ -94,7 +99,7 @@ Kirigami.AbstractCard {
QQC2.Label
{
width
:
topLayout
.
width
text
:
i18n
(
"
Currency: %1
"
,
locationInfo
.
currency
Nam
e
)
text
:
i18n
(
"
Currency: %1
"
,
controller
.
hasCurrencyConversion
?
controller
.
currencyConversionLabel
:
locationInfo
.
currency
Cod
e
)
color
:
Kirigami
.
Theme
.
neutralTextColor
visible
:
locationInfo
.
currencyDiffers
wrapMode
:
Text
.
WordWrap
...
...
src/app/SettingsPage.qml
View file @
8f5f1218
...
...
@@ -138,6 +138,23 @@ Kirigami.ScrollablePage {
font
:
Kirigami
.
Theme
.
smallFont
}
QQC2.CheckBox
{
id
:
currencyConversion
text
:
i18n
(
"
Currency Conversion
"
)
checked
:
Settings
.
performCurrencyConversion
onToggled
:
Settings
.
performCurrencyConversion
=
checked
Layout.fillWidth
:
true
visible
:
Settings
.
hasCurrencyConversion
}
QQC2.Label
{
Kirigami.FormData.isSection
:
true
Layout.fillWidth
:
true
wrapMode
:
Text
.
WordWrap
text
:
i18n
(
"
Enabling this will perform online queries for exchange rates to currencies at travel destinations.
"
)
font
:
Kirigami
.
Theme
.
smallFont
visible
:
Settings
.
hasCurrencyConversion
}
// Transfer assistant
Kirigami.Separator
{
Kirigami.FormData.isSection
:
true
...
...
src/app/config-itinerary.h.in
View file @
8f5f1218
...
...
@@ -6,3 +6,4 @@
#cmakedefine01 HAVE_KCRASH
#cmakedefine01 HAVE_KHEALTHCERTIFICATE
#cmakedefine01 HAVE_KUNITCONVERSION
src/app/locationinformation.cpp
View file @
8f5f1218
...
...
@@ -193,7 +193,7 @@ bool LocationInformation::currencyDiffers() const
return
m_currencyDiffers
;
}
QString
LocationInformation
::
currency
Nam
e
()
const
QString
LocationInformation
::
currency
Cod
e
()
const
{
return
m_currency
;
}
src/app/locationinformation.h
View file @
8f5f1218
...
...
@@ -34,7 +34,7 @@ class LocationInformation
Q_PROPERTY
(
int
timeZoneOffsetDelta
READ
timeZoneOffsetDelta
)
Q_PROPERTY
(
bool
currencyDiffers
READ
currencyDiffers
)
Q_PROPERTY
(
QString
currency
Nam
e
READ
currency
Nam
e
)
Q_PROPERTY
(
QString
currency
Cod
e
READ
currency
Cod
e
)
public:
LocationInformation
();
...
...
@@ -68,7 +68,7 @@ public:
int
timeZoneOffsetDelta
()
const
;
bool
currencyDiffers
()
const
;
QString
currency
Nam
e
()
const
;
QString
currency
Cod
e
()
const
;
private:
void
setDrivingSide
(
KItinerary
::
KnowledgeDb
::
DrivingSide
drivingSide
);
...
...
src/app/locationinformationdelegatecontroller.cpp
0 → 100644
View file @
8f5f1218
/*
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "config-itinerary.h"
#include "locationinformationdelegatecontroller.h"
#if HAVE_KUNITCONVERSION
#include <KUnitConversion/Value>
#endif
#include <KLocalizedString>
#include <QDebug>
LocationInformationDelegateController
::
LocationInformationDelegateController
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
LocationInformationDelegateController
::~
LocationInformationDelegateController
()
=
default
;
LocationInformation
LocationInformationDelegateController
::
locationInformation
()
const
{
return
m_info
;
}
void
LocationInformationDelegateController
::
setLocationInformation
(
const
LocationInformation
&
info
)
{
m_info
=
info
;
Q_EMIT
infoChanged
();
recheckCurrencyConversion
();
}
QString
LocationInformationDelegateController
::
homeCurrencyCode
()
const
{
return
m_homeCurrency
;
}
void
LocationInformationDelegateController
::
setHomeCurrencyCode
(
const
QString
&
currencyCode
)
{
if
(
m_homeCurrency
==
currencyCode
)
{
return
;
}
m_homeCurrency
=
currencyCode
;
Q_EMIT
homeCurrencyCodeChanged
();
recheckCurrencyConversion
();
}
bool
LocationInformationDelegateController
::
performCurrencyConversion
()
const
{
return
m_performCurrencyConverion
;
}
void
LocationInformationDelegateController
::
setPerformCurrencyConversion
(
bool
enable
)
{
if
(
m_performCurrencyConverion
==
enable
)
{
return
;
}
m_performCurrencyConverion
=
enable
;
Q_EMIT
performCurrencyConversionChanged
();
recheckCurrencyConversion
();
}
bool
LocationInformationDelegateController
::
hasCurrencyConversion
()
const
{
return
m_performCurrencyConverion
&&
m_conversionRate
>
0.0
f
;
}
QString
LocationInformationDelegateController
::
currencyConversionLabel
()
const
{
return
i18nc
(
"currency conversion rate"
,
"1 %1 = %2 %3"
,
m_homeCurrency
,
m_conversionRate
,
m_info
.
currencyCode
());
}
void
LocationInformationDelegateController
::
recheckCurrencyConversion
()
{
float
rate
=
0.0
f
;
#if HAVE_KUNITCONVERSION
if
(
m_performCurrencyConverion
&&
m_info
.
currencyDiffers
()
&&
!
m_homeCurrency
.
isEmpty
())
{
const
auto
value
=
KUnitConversion
::
Value
(
1.0
,
m_homeCurrency
).
convertTo
(
m_info
.
currencyCode
());
if
(
value
.
isValid
())
{
rate
=
value
.
number
();
}
}
#endif
if
(
rate
!=
m_conversionRate
)
{
m_conversionRate
=
rate
;
Q_EMIT
currencyConversionChanged
();
}
}
src/app/locationinformationdelegatecontroller.h
0 → 100644
View file @
8f5f1218
/*
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef LOCATIONINFORMATIONDELEGATECONTROLLER_H
#define LOCATIONINFORMATIONDELEGATECONTROLLER_H
#include "locationinformation.h"
#include <QObject>
/** Logic for location information delegates. */
class
LocationInformationDelegateController
:
public
QObject
{
Q_OBJECT
Q_PROPERTY
(
LocationInformation
locationInformation
READ
locationInformation
WRITE
setLocationInformation
NOTIFY
infoChanged
)
Q_PROPERTY
(
QString
homeCurrencyCode
READ
homeCurrencyCode
WRITE
setHomeCurrencyCode
NOTIFY
homeCurrencyCodeChanged
)
Q_PROPERTY
(
bool
performCurrencyConversion
READ
performCurrencyConversion
WRITE
setPerformCurrencyConversion
NOTIFY
performCurrencyConversionChanged
)
Q_PROPERTY
(
bool
hasCurrencyConversion
READ
hasCurrencyConversion
NOTIFY
currencyConversionChanged
)
Q_PROPERTY
(
QString
currencyConversionLabel
READ
currencyConversionLabel
NOTIFY
currencyConversionChanged
)
public:
explicit
LocationInformationDelegateController
(
QObject
*
parent
=
nullptr
);
~
LocationInformationDelegateController
();
LocationInformation
locationInformation
()
const
;
void
setLocationInformation
(
const
LocationInformation
&
info
);
QString
homeCurrencyCode
()
const
;
void
setHomeCurrencyCode
(
const
QString
&
currencyCode
);
bool
performCurrencyConversion
()
const
;
void
setPerformCurrencyConversion
(
bool
enable
);
bool
hasCurrencyConversion
()
const
;
QString
currencyConversionLabel
()
const
;
Q_SIGNALS:
void
infoChanged
();
void
homeCurrencyCodeChanged
();
void
currencyConversionChanged
();
void
performCurrencyConversionChanged
();
private:
void
recheckCurrencyConversion
();
LocationInformation
m_info
;
QString
m_homeCurrency
;
float
m_conversionRate
=
0.0
f
;
bool
m_performCurrencyConverion
=
false
;
};
#endif // LOCATIONINFORMATIONDELEGATECONTROLLER_H
src/app/main.cpp
View file @
8f5f1218
...
...
@@ -18,6 +18,7 @@
#include "livedatamanager.h"
#include "localizer.h"
#include "locationinformation.h"
#include "locationinformationdelegatecontroller.h"
#include "mapdownloadmanager.h"
#include "navigationcontroller.h"
#include "notificationconfigcontroller.h"
...
...
@@ -111,6 +112,7 @@ void registerApplicationTypes()
qmlRegisterType
<
CountryModel
>
(
"org.kde.itinerary"
,
1
,
0
,
"CountryModel"
);
qmlRegisterType
<
DocumentsModel
>
(
"org.kde.itinerary"
,
1
,
0
,
"DocumentsModel"
);
qmlRegisterType
<
LocationInformationDelegateController
>
(
"org.kde.itinerary"
,
1
,
0
,
"LocationInformationDelegateController"
);
qmlRegisterType
<
QSortFilterProxyModel
>
(
"org.kde.itinerary"
,
1
,
0
,
"SortFilterProxyModel"
);
// TODO use this from kitemmodels?
qmlRegisterType
<
StatisticsModel
>
(
"org.kde.itinerary"
,
1
,
0
,
"StatisticsModel"
);
qmlRegisterType
<
StatisticsTimeRangeModel
>
(
"org.kde.itinerary"
,
1
,
0
,
"StatisticsTimeRangeModel"
);
...
...
src/app/settings.cpp
View file @
8f5f1218
...
...
@@ -4,6 +4,7 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "config-itinerary.h"
#include "settings.h"
#include <KCountry>
...
...
@@ -26,6 +27,8 @@ Settings::Settings(QObject *parent)
m_preloadMapData
=
s
.
value
(
QLatin1String
(
"PreloadMapData"
),
false
).
toBool
();
m_currencyConversion
=
s
.
value
(
QLatin1String
(
"PerformCurrencyConversion"
),
false
).
toBool
();
m_autoAddTransfers
=
s
.
value
(
QLatin1String
(
"AutoAddTransfers"
),
true
).
toBool
();
m_autoFillTransfers
=
s
.
value
(
QLatin1String
(
"AutoFillTransfers"
),
false
).
toBool
()
&&
m_queryLiveData
&&
m_autoAddTransfers
;
...
...
@@ -116,6 +119,34 @@ void Settings::setPreloadMapData(bool preload)
Q_EMIT
preloadMapDataChanged
(
preload
);
}
bool
Settings
::
hasCurrencyConversion
()
const
{
#if HAVE_KUNITCONVERSION
return
true
;
#else
return
false
;
#endif
}
bool
Settings
::
performCurrencyConversion
()
const
{
return
m_currencyConversion
;
}
void
Settings
::
setPerformCurrencyConversion
(
bool
enable
)
{
if
(
m_currencyConversion
==
enable
)
{
return
;
}
m_currencyConversion
=
enable
;
QSettings
s
;
s
.
beginGroup
(
QLatin1String
(
"Settings"
));
s
.
setValue
(
QLatin1String
(
"PerformCurrencyConversion"
),
enable
);
Q_EMIT
performCurrencyConversionChanged
(
enable
);
}
bool
Settings
::
autoAddTransfers
()
const
{
return
m_autoAddTransfers
;
...
...
src/app/settings.h
View file @
8f5f1218
...
...
@@ -18,6 +18,9 @@ class Settings : public QObject
Q_PROPERTY
(
bool
queryLiveData
READ
queryLiveData
WRITE
setQueryLiveData
NOTIFY
queryLiveDataChanged
)
Q_PROPERTY
(
bool
preloadMapData
READ
preloadMapData
WRITE
setPreloadMapData
NOTIFY
preloadMapDataChanged
)
Q_PROPERTY
(
bool
hasCurrencyConversion
READ
hasCurrencyConversion
CONSTANT
)
Q_PROPERTY
(
bool
performCurrencyConversion
READ
performCurrencyConversion
WRITE
setPerformCurrencyConversion
NOTIFY
performCurrencyConversionChanged
)
Q_PROPERTY
(
bool
autoAddTransfers
READ
autoAddTransfers
WRITE
setAutoAddTransfers
NOTIFY
autoAddTransfersChanged
)
Q_PROPERTY
(
bool
autoFillTransfers
READ
autoFillTransfers
WRITE
setAutoFillTransfers
NOTIFY
autoFillTransfersChanged
)
...
...
@@ -41,6 +44,10 @@ public:
bool
preloadMapData
()
const
;
void
setPreloadMapData
(
bool
preload
);
bool
hasCurrencyConversion
()
const
;
bool
performCurrencyConversion
()
const
;
void
setPerformCurrencyConversion
(
bool
enable
);
bool
autoAddTransfers
()
const
;
void
setAutoAddTransfers
(
bool
autoAdd
);
bool
autoFillTransfers
()
const
;
...
...
@@ -57,6 +64,7 @@ Q_SIGNALS:
void
homeCountryIsoCodeChanged
(
const
QString
&
isoCode
);
void
queryLiveDataChanged
(
bool
enabled
);
void
preloadMapDataChanged
(
bool
preload
);
void
performCurrencyConversionChanged
(
bool
enabled
);
void
autoAddTransfersChanged
(
bool
autoAdd
);
void
autoFillTransfersChanged
(
bool
autoFill
);
void
showNotificationOnLockScreenChanged
(
bool
enabled
);
...
...
@@ -67,6 +75,7 @@ private:
bool
m_weatherEnabled
=
false
;
bool
m_queryLiveData
=
false
;
bool
m_preloadMapData
=
false
;
bool
m_currencyConversion
=
false
;
bool
m_autoAddTransfers
=
true
;
bool
m_autoFillTransfers
=
false
;
bool
m_showNotificationOnLockScreen
=
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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