Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
PIM
Itinerary
Commits
b49195d4
Commit
b49195d4
authored
Dec 24, 2018
by
Volker Krause
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better location request cache key generation
parent
0f75989d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
+21
-3
autotests/cachetest.cpp
autotests/cachetest.cpp
+14
-0
src/publictransport/locationrequest.cpp
src/publictransport/locationrequest.cpp
+7
-3
No files found.
autotests/cachetest.cpp
View file @
b49195d4
...
...
@@ -67,6 +67,20 @@ private slots:
QCOMPARE
(
entry
.
data
[
0
].
identifier
(
QLatin1String
(
"uic"
)),
QLatin1String
(
"85xxxxx"
));
QCOMPARE
(
entry
.
data
[
0
].
timeZone
().
isValid
(),
false
);
}
void
testLocationCacheKey
()
{
{
LocationRequest
req
;
req
.
setCoordinate
(
-
52.5
,
-
13.5
);
QCOMPARE
(
req
.
cacheKey
(),
QLatin1String
(
"-52500000x-13500000_"
));
}
{
LocationRequest
req
;
req
.
setName
(
QLatin1String
(
"Randa"
));
QCOMPARE
(
req
.
cacheKey
(),
QLatin1String
(
"nanxnan_randa"
));
}
}
};
QTEST_GUILESS_MAIN
(
CacheTest
)
...
...
src/publictransport/locationrequest.cpp
View file @
b49195d4
...
...
@@ -80,10 +80,14 @@ QString LocationRequest::cacheKey() const
normalizedName
.
reserve
(
d
->
name
.
size
());
for
(
const
auto
c
:
qAsConst
(
d
->
name
))
{
if
(
c
.
isLetter
()
||
c
.
isDigit
())
{
normalizedName
.
push_back
(
c
);
normalizedName
.
push_back
(
c
.
toCaseFolded
()
);
}
}
return
QString
::
number
((
int
)(
latitude
()
*
1000000
))
+
QLatin1Char
(
'x'
)
+
QString
::
number
((
int
)(
longitude
()
*
1000000
))
+
QLatin1Char
(
'_'
)
+
normalizedName
;
if
(
hasCoordinate
())
{
return
QString
::
number
((
int
)(
latitude
()
*
1000000
))
+
QLatin1Char
(
'x'
)
+
QString
::
number
((
int
)(
longitude
()
*
1000000
))
+
QLatin1Char
(
'_'
)
+
normalizedName
;
}
else
{
return
QLatin1String
(
"nanxnan_"
)
+
normalizedName
;
}
}
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