Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 984b2832 authored by Stefan Brüns's avatar Stefan Brüns

[Bookmarks Runner] Initialize Chrome favicon query only once per profile

Summary:
The db scheme will not change during the FetchSqlite livetime. Query
the scheme just once per krunner invocation instead of once per result.

Test Plan: make

Reviewers: #frameworks, davidedmundson

Reviewed By: davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D15489
parent 0ac6c595
......@@ -47,31 +47,26 @@ private:
const QString m_query;
};
class ChromeQuery : public BuildQuery {
public:
ChromeQuery() {}
QString query(QSqlDatabase *database) const override {
//qDebug() << "tables: " << database->tables();
if(database->tables().contains(QStringLiteral("favicon_bitmaps"))) {
return QStringLiteral("SELECT * FROM favicons " \
"inner join icon_mapping on icon_mapping.icon_id = favicons.id " \
"inner join favicon_bitmaps on icon_mapping.icon_id = favicon_bitmaps.icon_id " \
"WHERE page_url = :url ORDER BY height desc LIMIT 1;");
}
return QStringLiteral("SELECT * FROM favicons inner join icon_mapping " \
"on icon_mapping.icon_id = favicons.id " \
"WHERE page_url = :url LIMIT 1;");
}
};
FaviconFromBlob *FaviconFromBlob::chrome(const QString &profileDirectory, QObject *parent)
{
QString profileName = QFileInfo(profileDirectory).fileName();
QString faviconCache = QStringLiteral("%1/KRunner-Chrome-Favicons-%2.sqlite")
.arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation), profileName);
FetchSqlite *fetchSqlite = new FetchSqlite(profileDirectory + QStringLiteral("/Favicons"), faviconCache, parent);
return new FaviconFromBlob(profileName, new ChromeQuery(), QStringLiteral("image_data"), fetchSqlite, parent);
QString faviconQuery;
if(fetchSqlite->tables().contains(QStringLiteral("favicon_bitmaps"))) {
faviconQuery = QLatin1String("SELECT * FROM favicons " \
"inner join icon_mapping on icon_mapping.icon_id = favicons.id " \
"inner join favicon_bitmaps on icon_mapping.icon_id = favicon_bitmaps.icon_id " \
"WHERE page_url = :url ORDER BY height desc LIMIT 1;");
} else {
faviconQuery = QLatin1String("SELECT * FROM favicons " \
"inner join icon_mapping on icon_mapping.icon_id = favicons.id " \
"WHERE page_url = :url LIMIT 1;");
}
return new FaviconFromBlob(profileName, new StaticQuery(faviconQuery), QStringLiteral("image_data"), fetchSqlite, parent);
}
FaviconFromBlob *FaviconFromBlob::firefox(FetchSqlite *fetchSqlite, QObject *parent)
......
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