Commit 55cd2fef authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Port Q_PRIVATE_SLOTs in comicprovider

parent b7b83edd
...@@ -25,7 +25,10 @@ class ComicProvider::Private ...@@ -25,7 +25,10 @@ class ComicProvider::Private
mTimer = new QTimer(parent); mTimer = new QTimer(parent);
mTimer->setSingleShot(true); mTimer->setSingleShot(true);
mTimer->setInterval(15000);//timeout after 15 seconds mTimer->setInterval(15000);//timeout after 15 seconds
connect(mTimer, SIGNAL(timeout()), mParent, SLOT(slotTimeout())); connect(mTimer, &QTimer::timeout, mParent, [this](){
//operation took too long, abort it
emit mParent->error(mParent);
});
} }
void jobDone(KJob *job) void jobDone(KJob *job)
...@@ -38,12 +41,7 @@ class ComicProvider::Private ...@@ -38,12 +41,7 @@ class ComicProvider::Private
} }
} }
void slotRedirection(KIO::Job *job, QUrl newUrl) void slotRedirection(KIO::Job *job, const QUrl& oldUrl, const QUrl& newUrl)
{
slotRedirection(job, QUrl(), newUrl);
}
void slotRedirection(KIO::Job *job, QUrl oldUrl, QUrl newUrl)
{ {
Q_UNUSED(oldUrl) Q_UNUSED(oldUrl)
...@@ -64,18 +62,6 @@ class ComicProvider::Private ...@@ -64,18 +62,6 @@ class ComicProvider::Private
} }
} }
void slotTimeout()
{
//operation took too long, abort it
emit mParent->error(mParent);
}
void slotFinished()
{
//everything finished, stop the timeout timer
mTimer->stop();
}
ComicProvider *mParent; ComicProvider *mParent;
QString mRequestedId; QString mRequestedId;
QString mRequestedComicName; QString mRequestedComicName;
...@@ -115,7 +101,10 @@ ComicProvider::ComicProvider(QObject *parent, const QVariantList &args) ...@@ -115,7 +101,10 @@ ComicProvider::ComicProvider(QObject *parent, const QVariantList &args)
} }
d->mTimer->start(); d->mTimer->start();
connect(this, SIGNAL(finished(ComicProvider*)), this, SLOT(slotFinished())); connect(this, &ComicProvider::finished, this, [this](){
//everything finished, stop the timeout timer
d->mTimer->stop();
});
} }
ComicProvider::~ComicProvider() ComicProvider::~ComicProvider()
...@@ -238,7 +227,9 @@ void ComicProvider::requestPage(const QUrl &url, int id, const MetaInfos &infos) ...@@ -238,7 +227,9 @@ void ComicProvider::requestPage(const QUrl &url, int id, const MetaInfos &infos)
job = KIO::storedGet(url, KIO::Reload, KIO::HideProgressInfo); job = KIO::storedGet(url, KIO::Reload, KIO::HideProgressInfo);
} }
job->setProperty("uid", id); job->setProperty("uid", id);
connect(job, SIGNAL(result(KJob*)), this, SLOT(jobDone(KJob*))); connect(job, &KJob::result, this, [this](KJob *job) {
d->jobDone(job);
});
if (!infos.isEmpty()) { if (!infos.isEmpty()) {
QMapIterator<QString, QString> it(infos); QMapIterator<QString, QString> it(infos);
...@@ -257,9 +248,15 @@ void ComicProvider::requestRedirectedUrl(const QUrl &url, int id, const MetaInfo ...@@ -257,9 +248,15 @@ void ComicProvider::requestRedirectedUrl(const QUrl &url, int id, const MetaInfo
KIO::MimetypeJob *job = KIO::mimetype(url, KIO::HideProgressInfo); KIO::MimetypeJob *job = KIO::mimetype(url, KIO::HideProgressInfo);
job->setProperty("uid", id); job->setProperty("uid", id);
d->mRedirections[job] = url; d->mRedirections[job] = url;
connect(job, SIGNAL(redirection(KIO::Job*,QUrl)), this, SLOT(slotRedirection(KIO::Job*,QUrl))); connect(job, &KIO::MimetypeJob::redirection, this, [this](KIO::Job *job, const QUrl &newUrl) {
connect(job, SIGNAL(permanentRedirection(KIO::Job*,QUrl,QUrl)), this, SLOT(slotRedirection(KIO::Job*,QUrl,QUrl))); d->slotRedirection(job, QUrl(), newUrl);
connect(job, SIGNAL(result(KJob*)), this, SLOT(slotRedirectionDone(KJob*))); });
connect(job, &KIO::MimetypeJob::permanentRedirection, this, [this](KIO::Job *job, const QUrl &oldUrl, const QUrl &newUrl) {
d->slotRedirection(job, oldUrl, newUrl);
});
connect(job, &KIO::MimetypeJob::result, this, [this](KJob *job) {
d->slotRedirectionDone(job);
});
if (!infos.isEmpty()) { if (!infos.isEmpty()) {
QMapIterator<QString, QString> it(infos); QMapIterator<QString, QString> it(infos);
......
...@@ -273,13 +273,6 @@ class PLASMA_COMIC_EXPORT ComicProvider : public QObject ...@@ -273,13 +273,6 @@ class PLASMA_COMIC_EXPORT ComicProvider : public QObject
private: private:
class Private; class Private;
Private* const d; Private* const d;
Q_PRIVATE_SLOT(d, void jobDone(KJob*))
Q_PRIVATE_SLOT(d, void slotRedirection(KIO::Job*, QUrl))
Q_PRIVATE_SLOT(d, void slotRedirection(KIO::Job*, QUrl, QUrl))
Q_PRIVATE_SLOT(d, void slotRedirectionDone(KJob*))
Q_PRIVATE_SLOT(d, void slotTimeout())
Q_PRIVATE_SLOT(d, void slotFinished())
}; };
#endif #endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment