diff --git a/src/lib/navigation/completer/locationcompletermodel.cpp b/src/lib/navigation/completer/locationcompletermodel.cpp index e18c76f60..583079dea 100644 --- a/src/lib/navigation/completer/locationcompletermodel.cpp +++ b/src/lib/navigation/completer/locationcompletermodel.cpp @@ -46,29 +46,6 @@ void LocationCompleterModel::setCompletions(const QList &items) appendColumn(items); } -void LocationCompleterModel::showMostVisited() -{ - clear(); - - QSqlQuery query; - query.exec("SELECT id, url, title FROM history ORDER BY count DESC LIMIT 15"); - - while (query.next()) { - QStandardItem* item = new QStandardItem(); - const QUrl url = query.value(1).toUrl(); - - item->setIcon(IconProvider::iconForUrl(url)); - item->setText(url.toEncoded()); - item->setData(query.value(0), IdRole); - item->setData(query.value(2), TitleRole); - item->setData(url, UrlRole); - item->setData(QVariant(false), BookmarkRole); - setTabPosition(item); - - appendRow(item); - } -} - QSqlQuery LocationCompleterModel::createDomainQuery(const QString &text) { if (text.isEmpty() || text == QLatin1String("www.")) { @@ -85,7 +62,7 @@ QSqlQuery LocationCompleterModel::createDomainQuery(const QString &text) query.append(QLatin1String("url LIKE ? OR url LIKE ? OR ")); } - query.append(QLatin1String("(url LIKE ? OR url LIKE ?) ORDER BY count DESC LIMIT 1")); + query.append(QLatin1String("(url LIKE ? OR url LIKE ?) LIMIT 1")); QSqlQuery sqlQuery; sqlQuery.prepare(query); @@ -125,7 +102,7 @@ QSqlQuery LocationCompleterModel::createHistoryQuery(const QString &searchString } } - query.append(QLatin1String("LIMIT ?")); + query.append(QLatin1String("ORDER BY date DESC LIMIT ?")); QSqlQuery sqlQuery; sqlQuery.prepare(query); diff --git a/src/lib/navigation/completer/locationcompletermodel.h b/src/lib/navigation/completer/locationcompletermodel.h index 137eea7ae..14fb400b6 100644 --- a/src/lib/navigation/completer/locationcompletermodel.h +++ b/src/lib/navigation/completer/locationcompletermodel.h @@ -44,7 +44,6 @@ public: explicit LocationCompleterModel(QObject* parent = 0); void setCompletions(const QList &items); - void showMostVisited(); static QSqlQuery createHistoryQuery(const QString &searchString, int limit, bool exactMatch = false); static QSqlQuery createDomainQuery(const QString &text); diff --git a/src/lib/navigation/completer/locationcompleterrefreshjob.cpp b/src/lib/navigation/completer/locationcompleterrefreshjob.cpp index a39e59728..7ce27a645 100644 --- a/src/lib/navigation/completer/locationcompleterrefreshjob.cpp +++ b/src/lib/navigation/completer/locationcompleterrefreshjob.cpp @@ -77,15 +77,9 @@ void LocationCompleterRefreshJob::slotFinished() static bool countBiggerThan(const QStandardItem* i1, const QStandardItem* i2) { - // Move bookmarks up - bool i1Bookmark = i1->data(LocationCompleterModel::BookmarkRole).toBool(); - bool i2Bookmark = i2->data(LocationCompleterModel::BookmarkRole).toBool(); - - if (i1Bookmark && i2Bookmark) { - return i1->data(LocationCompleterModel::CountRole).toInt() > - i2->data(LocationCompleterModel::CountRole).toInt(); - } - return i1Bookmark; + int i1Count = i1->data(LocationCompleterModel::CountRole).toInt(); + int i2Count = i2->data(LocationCompleterModel::CountRole).toInt(); + return i1Count > i2Count; } void LocationCompleterRefreshJob::runJob() @@ -121,9 +115,6 @@ void LocationCompleterRefreshJob::runJob() } } - // Sort by count - qSort(m_items.begin(), m_items.end(), countBiggerThan); - // Get domain completion if (!m_searchString.isEmpty() && qzSettings->useInlineCompletion) { QSqlQuery domainQuery = LocationCompleterModel::createDomainQuery(m_searchString); @@ -167,6 +158,9 @@ void LocationCompleterRefreshJob::completeFromHistory() } } + // Sort by count + qSort(m_items.begin(), m_items.end(), countBiggerThan); + // Search in history if (showType == HistoryAndBookmarks || showType == History) { const int historyLimit = 20;