1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

LocationCompleterRefreshJob: Use IconProvider to load icons

IconProvider can now be used from different threads
This commit is contained in:
David Rosca 2016-12-20 12:19:35 +01:00
parent 34cc74ab18
commit c7fa3101db

View File

@ -19,6 +19,7 @@
#include "locationcompletermodel.h" #include "locationcompletermodel.h"
#include "mainapplication.h" #include "mainapplication.h"
#include "bookmarkitem.h" #include "bookmarkitem.h"
#include "iconprovider.h"
#include "sqldatabase.h" #include "sqldatabase.h"
#include "qzsettings.h" #include "qzsettings.h"
#include "bookmarks.h" #include "bookmarks.h"
@ -94,23 +95,13 @@ void LocationCompleterRefreshJob::runJob()
} }
// Load all icons into QImage // Load all icons into QImage
QSqlQuery query;
query.prepare(QSL("SELECT icon FROM icons WHERE url LIKE ? ESCAPE ? LIMIT 1"));
foreach (QStandardItem* item, m_items) { foreach (QStandardItem* item, m_items) {
if (m_jobCancelled) { if (m_jobCancelled) {
return; return;
} }
const QUrl url = item->data(LocationCompleterModel::UrlRole).toUrl(); const QUrl url = item->data(LocationCompleterModel::UrlRole).toUrl();
item->setData(IconProvider::imageForUrl(url), LocationCompleterModel::ImageRole);
query.bindValue(0, QString(QL1S("%1%")).arg(QzTools::escapeSqlString(QString::fromUtf8(url.toEncoded(QUrl::RemoveFragment)))));
query.bindValue(1, QL1S("!"));
SqlDatabase::instance()->exec(query);
if (query.next()) {
item->setData(QImage::fromData(query.value(0).toByteArray()), LocationCompleterModel::ImageRole);
}
} }
// Get domain completion // Get domain completion