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
P
Plasma Workspace
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Merge Requests
63
Merge Requests
63
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
Plasma
Plasma Workspace
Commits
9f914401
Commit
9f914401
authored
Jan 04, 2018
by
Friedrich W. H. Kossebau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[weather] avoid some string allocations
parent
e17a7a86
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
17 deletions
+17
-17
dataengines/weather/ions/wetter.com/ion_wettercom.cpp
dataengines/weather/ions/wetter.com/ion_wettercom.cpp
+16
-16
dataengines/weather/weatherengine.cpp
dataengines/weather/weatherengine.cpp
+1
-1
No files found.
dataengines/weather/ions/wetter.com/ion_wettercom.cpp
View file @
9f914401
...
...
@@ -308,12 +308,12 @@ bool WetterComIon::updateIonSource(const QString& source)
void
WetterComIon
::
findPlace
(
const
QString
&
place
,
const
QString
&
source
)
{
QCryptographicHash
md5
(
QCryptographicHash
::
Md5
);
md5
.
addData
(
Q
String
::
fromLatin1
(
PROJECTNAME
).
toUtf8
(
));
md5
.
addData
(
Q
String
::
fromLatin1
(
APIKEY
).
toUtf8
(
));
md5
.
addData
(
Q
ByteArray
(
PROJECTNAME
));
md5
.
addData
(
Q
ByteArray
(
APIKEY
));
md5
.
addData
(
place
.
toUtf8
());
const
QString
encodedKey
=
QString
::
fromLatin1
(
md5
.
result
().
toHex
());
const
QUrl
url
(
QString
::
fromLatin1
(
SEARCH_URL
).
arg
(
place
,
encodedKey
));
const
QUrl
url
(
QString
Literal
(
SEARCH_URL
).
arg
(
place
,
encodedKey
));
KIO
::
TransferJob
*
getJob
=
KIO
::
get
(
url
,
KIO
::
Reload
,
KIO
::
HideProgressInfo
);
getJob
->
addMetaData
(
QStringLiteral
(
"cookies"
),
QStringLiteral
(
"none"
));
// Disable displaying cookies
...
...
@@ -424,7 +424,7 @@ void WetterComIon::validate(const QString& source, bool parseError)
if
(
m_place
[
invalidPlace
].
name
.
isEmpty
())
{
setData
(
source
,
QStringLiteral
(
"validate"
),
QVariant
(
Q
StringLiteral
(
"wettercom|invalid|multiple|"
)
+
invalidPlace
));
QVariant
(
Q
Latin1String
(
"wettercom|invalid|multiple|"
)
+
invalidPlace
));
}
m_locations
.
clear
();
...
...
@@ -435,7 +435,7 @@ void WetterComIon::validate(const QString& source, bool parseError)
QString
placeList
;
foreach
(
const
QString
&
place
,
m_locations
)
{
// Extra data format: placeCode;displayName
placeList
.
append
(
Q
StringLiteral
(
"|place|"
)
+
place
+
QStringLiteral
(
"|extra|"
)
+
placeList
.
append
(
Q
Latin1String
(
"|place|"
)
+
place
+
QLatin1String
(
"|extra|"
)
+
m_place
[
place
].
placeCode
+
QLatin1Char
(
';'
)
+
m_place
[
place
].
displayName
);
}
...
...
@@ -468,12 +468,12 @@ void WetterComIon::fetchForecast(const QString& source)
}
QCryptographicHash
md5
(
QCryptographicHash
::
Md5
);
md5
.
addData
(
Q
String
::
fromLatin1
(
PROJECTNAME
).
toUtf8
(
));
md5
.
addData
(
Q
String
::
fromLatin1
(
APIKEY
).
toUtf8
(
));
md5
.
addData
(
Q
ByteArray
(
PROJECTNAME
));
md5
.
addData
(
Q
ByteArray
(
APIKEY
));
md5
.
addData
(
m_place
[
source
].
placeCode
.
toUtf8
());
const
QString
encodedKey
=
QString
::
fromLatin1
(
md5
.
result
().
toHex
());
const
QUrl
url
(
QString
::
fromLatin1
(
FORECAST_URL
).
arg
(
m_place
[
source
].
placeCode
,
encodedKey
));
const
QUrl
url
(
QString
Literal
(
FORECAST_URL
).
arg
(
m_place
[
source
].
placeCode
,
encodedKey
));
KIO
::
TransferJob
*
getJob
=
KIO
::
get
(
url
,
KIO
::
Reload
,
KIO
::
HideProgressInfo
);
getJob
->
addMetaData
(
QStringLiteral
(
"cookies"
),
QStringLiteral
(
"none"
));
...
...
@@ -514,7 +514,7 @@ void WetterComIon::forecast_slotJobFinished(KJob *job)
if
(
m_sourcesToReset
.
contains
(
source
))
{
m_sourcesToReset
.
removeAll
(
source
);
const
QString
weatherSource
=
QString
::
fromLatin1
(
"wettercom|weather|%1|%2;%3"
)
const
QString
weatherSource
=
QString
Literal
(
"wettercom|weather|%1|%2;%3"
)
.
arg
(
source
).
arg
(
m_place
[
source
].
placeCode
)
.
arg
(
m_place
[
source
].
displayName
);
...
...
@@ -681,7 +681,7 @@ void WetterComIon::updateWeather(const QString& source, bool parseError)
{
qCDebug
(
IONENGINE_WETTERCOM
)
<<
"Source:"
<<
source
;
QString
weatherSource
=
QString
::
fromLatin1
(
"wettercom|weather|%1|%2;%3"
)
QString
weatherSource
=
QString
Literal
(
"wettercom|weather|%1|%2;%3"
)
.
arg
(
source
).
arg
(
m_place
[
source
].
placeCode
)
.
arg
(
m_place
[
source
].
displayName
);
...
...
@@ -699,8 +699,8 @@ void WetterComIon::updateWeather(const QString& source, bool parseError)
if
(
i
>
0
)
{
WeatherData
::
ForecastInfo
weather
=
forecastPeriod
->
getWeather
();
data
.
insert
(
QString
::
fromLatin1
(
"Short Forecast Day %1"
).
arg
(
i
),
QString
::
fromLatin1
(
"%1|%2|%3|%4|%5|%6"
)
data
.
insert
(
QString
Literal
(
"Short Forecast Day %1"
).
arg
(
i
),
QString
Literal
(
"%1|%2|%3|%4|%5|%6"
)
.
arg
(
QLocale
().
toString
(
weather
.
period
.
date
().
day
()))
.
arg
(
weather
.
iconName
).
arg
(
weather
.
summary
)
.
arg
(
weather
.
tempHigh
).
arg
(
weather
.
tempLow
)
...
...
@@ -709,8 +709,8 @@ void WetterComIon::updateWeather(const QString& source, bool parseError)
}
else
{
WeatherData
::
ForecastInfo
dayWeather
=
forecastPeriod
->
getDayWeather
();
data
.
insert
(
QString
::
fromLatin1
(
"Short Forecast Day %1"
).
arg
(
i
),
QString
::
fromLatin1
(
"%1|%2|%3|%4|%5|%6"
)
data
.
insert
(
QString
Literal
(
"Short Forecast Day %1"
).
arg
(
i
),
QString
Literal
(
"%1|%2|%3|%4|%5|%6"
)
.
arg
(
i18n
(
"Day"
)).
arg
(
dayWeather
.
iconName
)
.
arg
(
dayWeather
.
summary
).
arg
(
dayWeather
.
tempHigh
)
.
arg
(
dayWeather
.
tempLow
).
arg
(
dayWeather
.
probability
));
...
...
@@ -718,8 +718,8 @@ void WetterComIon::updateWeather(const QString& source, bool parseError)
if
(
forecastPeriod
->
hasNightWeather
())
{
WeatherData
::
ForecastInfo
nightWeather
=
forecastPeriod
->
getNightWeather
();
data
.
insert
(
QString
::
fromLatin1
(
"Short Forecast Day %1"
).
arg
(
i
),
QString
::
fromLatin1
(
"%1 nt|%2|%3|%4|%5|%6"
)
data
.
insert
(
QString
Literal
(
"Short Forecast Day %1"
).
arg
(
i
),
QString
Literal
(
"%1 nt|%2|%3|%4|%5|%6"
)
.
arg
(
i18n
(
"Night"
)).
arg
(
nightWeather
.
iconName
)
.
arg
(
nightWeather
.
summary
)
.
arg
(
nightWeather
.
tempHigh
)
...
...
dataengines/weather/weatherengine.cpp
View file @
9f914401
...
...
@@ -61,7 +61,7 @@ void WeatherEngine::updateIonList(const QStringList &changedResources)
{
if
(
changedResources
.
isEmpty
()
||
changedResources
.
contains
(
QStringLiteral
(
"services"
)))
{
removeAllData
(
QStringLiteral
(
"ions"
));
foreach
(
const
KPluginInfo
&
info
,
Plasma
::
PluginLoader
::
self
()
->
listEngineInfo
(
Q
Latin1String
(
"weatherengine"
)))
{
foreach
(
const
KPluginInfo
&
info
,
Plasma
::
PluginLoader
::
self
()
->
listEngineInfo
(
Q
StringLiteral
(
"weatherengine"
)))
{
const
QString
data
=
info
.
name
()
+
QLatin1Char
(
'|'
)
+
info
.
pluginName
();
setData
(
QStringLiteral
(
"ions"
),
info
.
pluginName
(),
data
);
}
...
...
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