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
Plasma
Plasma Add-ons
Commits
ffe2d3a5
Commit
ffe2d3a5
authored
Jan 29, 2021
by
Alexander Lohnau
💬
Browse files
comicupdater: Port away from deprecated KNSCore::DownloadManager
Discussion:
https://phabricator.kde.org/T14010
parent
0ecdecaa
Changes
2
Hide whitespace changes
Inline
Side-by-side
applets/comic/comicupdater.cpp
View file @
ffe2d3a5
...
...
@@ -13,13 +13,14 @@
#include <KConfigDialog>
#include <KNS3/DownloadDialog>
#include <KNSCore/
DownloadManager
>
#include <KNSCore/
Engine
>
ComicUpdater
::
ComicUpdater
(
QObject
*
parent
)
:
QObject
(
parent
)
,
m
DownloadManager
(
nullptr
)
,
m
Engine
(
nullptr
)
,
mUpdateIntervall
(
3
)
,
m_updateTimer
(
nullptr
)
,
mProvidersLoaded
(
false
)
{
}
...
...
@@ -69,23 +70,33 @@ void ComicUpdater::checkForUpdate()
if
(
!
mLastUpdate
.
isValid
()
||
(
mLastUpdate
.
addDays
(
mUpdateIntervall
)
<
QDateTime
::
currentDateTime
()))
{
mLastUpdate
=
QDateTime
::
currentDateTime
();
mGroup
.
writeEntry
(
"lastUpdate"
,
mLastUpdate
);
downloadManager
()
->
checkForUpdates
();
if
(
mProvidersLoaded
)
{
engine
()
->
checkForUpdates
();
}
else
{
connect
(
engine
(),
&
KNSCore
::
Engine
::
signalProvidersLoaded
,
this
,
[
this
]()
{
engine
()
->
checkForUpdates
();
});
}
}
}
void
ComicUpdater
::
slotUpdatesFound
(
const
KNSCore
::
EntryInternal
::
List
&
entries
)
{
for
(
int
i
=
0
;
i
<
entries
.
count
();
++
i
)
{
downloadManager
()
->
install
Entry
(
entries
[
i
]);
engine
()
->
install
(
entries
[
i
]);
}
}
KNSCore
::
DownloadManager
*
ComicUpdater
::
downloadManager
()
KNSCore
::
Engine
*
ComicUpdater
::
engine
()
{
if
(
!
mDownloadManager
)
{
mDownloadManager
=
new
KNSCore
::
DownloadManager
(
QStringLiteral
(
"comic.knsrc"
),
this
);
connect
(
mDownloadManager
,
&
KNSCore
::
DownloadManager
::
searchResult
,
this
,
&
ComicUpdater
::
slotUpdatesFound
);
if
(
!
mEngine
)
{
mEngine
=
new
KNSCore
::
Engine
(
this
);
if
(
mEngine
->
init
(
QStringLiteral
(
"comic.knsrc"
)))
{
connect
(
mEngine
,
&
KNSCore
::
Engine
::
signalUpdateableEntriesLoaded
,
this
,
&
ComicUpdater
::
slotUpdatesFound
);
connect
(
mEngine
,
&
KNSCore
::
Engine
::
signalProvidersLoaded
,
this
,
[
this
]()
{
mProvidersLoaded
=
true
;
});
}
}
return
mDownloadManager
;
return
mEngine
;
}
applets/comic/comicupdater.h
View file @
ffe2d3a5
...
...
@@ -19,7 +19,7 @@ namespace KNS3
}
namespace
KNSCore
{
class
DownloadManager
;
class
Engine
;
}
namespace
Plasma
...
...
@@ -51,14 +51,15 @@ private Q_SLOTS:
void
slotUpdatesFound
(
const
KNSCore
::
EntryInternal
::
List
&
entries
);
private:
KNSCore
::
DownloadManager
*
downloadManager
();
KNSCore
::
Engine
*
engine
();
private:
KNSCore
::
DownloadManager
*
mDownloadManager
;
KNSCore
::
Engine
*
mEngine
;
KConfigGroup
mGroup
;
int
mUpdateIntervall
;
QDateTime
mLastUpdate
;
QTimer
*
m_updateTimer
;
bool
mProvidersLoaded
;
};
#endif
Write
Preview
Supports
Markdown
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