Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Itinerary
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
20
Issues
20
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PIM
Itinerary
Commits
826b834d
Commit
826b834d
authored
May 21, 2018
by
Volker Krause
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use locale-aware address formatting
parent
cfb1e5cb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
6 deletions
+21
-6
src/app/PlaceDelegate.qml
src/app/PlaceDelegate.qml
+2
-6
src/app/localizer.cpp
src/app/localizer.cpp
+18
-0
src/app/localizer.h
src/app/localizer.h
+1
-0
No files found.
src/app/PlaceDelegate.qml
View file @
826b834d
...
...
@@ -19,6 +19,7 @@ import QtQuick 2.5
import
QtQuick
.
Layouts
1.1
import
QtQuick
.
Controls
2.1
as
QQC2
import
org
.
kde
.
kirigami
2.0
as
Kirigami
import
org
.
kde
.
itinerary
1.0
import
"
.
"
as
App
Item
{
...
...
@@ -31,12 +32,7 @@ Item {
QQC2.Label
{
id
:
label
visible
:
!
place
.
address
.
isEmpty
// TODO KContact-based locale-dependent address formatting
text
:
qsTr
(
"
%1
\n
%2 %3
\n
%4
"
)
.
arg
(
place
.
address
.
streetAddress
)
.
arg
(
place
.
address
.
postalCode
)
.
arg
(
place
.
address
.
addressLocality
)
.
arg
(
place
.
address
.
addressCountry
)
text
:
Localizer
.
formatAddress
(
place
.
address
)
color
:
Kirigami
.
Theme
.
textColor
}
...
...
src/app/localizer.cpp
View file @
826b834d
...
...
@@ -18,6 +18,7 @@
#include "localizer.h"
#include <KItinerary/JsonLdDocument>
#include <KItinerary/Place>
#include <KContacts/Address>
...
...
@@ -39,6 +40,23 @@ QString Localizer::countryName(const QString& isoCode) const
return
KContacts
::
Address
::
ISOtoCountry
(
isoCode
);
}
QString
Localizer
::
formatAddress
(
const
QVariant
&
obj
)
const
{
if
(
!
JsonLd
::
isA
<
PostalAddress
>
(
obj
))
{
return
{};
}
const
auto
a
=
obj
.
value
<
PostalAddress
>
();
KContacts
::
Address
address
;
address
.
setStreet
(
a
.
streetAddress
());
address
.
setPostalCode
(
a
.
postalCode
());
address
.
setLocality
(
a
.
addressLocality
());
address
.
setRegion
(
a
.
addressRegion
());
address
.
setCountry
(
KContacts
::
Address
::
ISOtoCountry
(
a
.
addressCountry
()));
return
address
.
formattedAddress
();
}
static
bool
needsTimeZone
(
const
QDateTime
&
dt
)
{
if
(
dt
.
timeSpec
()
==
Qt
::
TimeZone
&&
dt
.
timeZone
().
abbreviation
(
dt
)
!=
QTimeZone
::
systemTimeZone
().
abbreviation
(
dt
))
{
...
...
src/app/localizer.h
View file @
826b834d
...
...
@@ -34,6 +34,7 @@ public:
~
Localizer
();
Q_INVOKABLE
QString
countryName
(
const
QString
&
isoCode
)
const
;
Q_INVOKABLE
QString
formatAddress
(
const
QVariant
&
obj
)
const
;
Q_INVOKABLE
QString
formatTime
(
const
QVariant
&
obj
,
const
QString
&
propertyName
)
const
;
Q_INVOKABLE
QString
formatDateTime
(
const
QVariant
&
obj
,
const
QString
&
propertyName
)
const
;
};
...
...
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