Commit a7d36991 authored by David Faure's avatar David Faure
Browse files

Convert to QUrl as early as possible and warn if invalid.

Better here than deep down in KIO::SimpleJob.
parent c19326c8
......@@ -372,8 +372,12 @@ Feed::~Feed()
void Feed::loadFavicon(const QString &url, bool downloadFavicon)
{
QUrl u(url);
if (u.scheme().isEmpty()) {
qCWarning(AKREGATOR_LOG) << "Invalid url" << url;
}
Akregator::DownloadFeedIconJob *job = new Akregator::DownloadFeedIconJob(this);
job->setFeedIconUrl(url);
job->setFeedIconUrl(u);
job->setDownloadFavicon(downloadFavicon);
connect(job, &DownloadFeedIconJob::result, this, [this](const QString &result) {
setFaviconUrl(result);
......
......@@ -21,7 +21,6 @@
#include <KIO/FavIconRequestJob>
#include <QUrl>
using namespace Akregator;
DownloadFeedIconJob::DownloadFeedIconJob(QObject *parent)
: QObject(parent)
......@@ -39,9 +38,9 @@ bool DownloadFeedIconJob::start()
return false;
}
KIO::FavIconRequestJob *job = new KIO::FavIconRequestJob(QUrl(mFeedIconUrl));
KIO::FavIconRequestJob *job = new KIO::FavIconRequestJob(mFeedIconUrl);
if (!mDownloadFavicon) {
job->setIconUrl(QUrl(mFeedIconUrl));
job->setIconUrl(mFeedIconUrl);
}
connect(job, &KIO::FavIconRequestJob::result, this, [job, this](KJob *) {
if (!job->error()) {
......@@ -57,12 +56,12 @@ bool DownloadFeedIconJob::canStart() const
return !mFeedIconUrl.isEmpty();
}
QString DownloadFeedIconJob::feedIconUrl() const
QUrl DownloadFeedIconJob::feedIconUrl() const
{
return mFeedIconUrl;
}
void DownloadFeedIconJob::setFeedIconUrl(const QString &feedIconUrl)
void DownloadFeedIconJob::setFeedIconUrl(const QUrl &feedIconUrl)
{
mFeedIconUrl = feedIconUrl;
}
......
......@@ -21,6 +21,7 @@
#define DOWNLOADFEEDICONJOB_H
#include <QObject>
#include <QUrl>
#include "akregator_export.h"
namespace Akregator {
......@@ -33,8 +34,8 @@ public:
Q_REQUIRED_RESULT bool start();
Q_REQUIRED_RESULT bool canStart() const;
Q_REQUIRED_RESULT QString feedIconUrl() const;
void setFeedIconUrl(const QString &feedIconUrl);
Q_REQUIRED_RESULT QUrl feedIconUrl() const;
void setFeedIconUrl(const QUrl &feedIconUrl);
Q_REQUIRED_RESULT bool downloadFavicon() const;
void setDownloadFavicon(bool downloadFavicon);
......@@ -42,7 +43,7 @@ public:
Q_SIGNALS:
void result(const QString &fileName);
private:
QString mFeedIconUrl;
QUrl mFeedIconUrl;
bool mDownloadFavicon = true;
};
}
......
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