From 9a5a795449e231c4cc7e41dbc434960e646174e3 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 9 Feb 2014 17:35:43 +0100 Subject: [PATCH] [LocationCompleterModel] Simplify createQuery function It is no longer needed to search for bookmarks in database --- .../completer/locationcompletermodel.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/lib/navigation/completer/locationcompletermodel.cpp b/src/lib/navigation/completer/locationcompletermodel.cpp index d9e458687..3fe8df02d 100644 --- a/src/lib/navigation/completer/locationcompletermodel.cpp +++ b/src/lib/navigation/completer/locationcompletermodel.cpp @@ -186,22 +186,17 @@ QString LocationCompleterModel::completeDomain(const QString &text) QSqlQuery LocationCompleterModel::createQuery(const QString &searchString, const QString &orderBy, const QList &alreadyFound, int limit, bool exactMatch) { - // TODO: As bookmarks are no longer in database, replace table with "history" - QString table = "history"; - QString query = QString("SELECT %1.id, %1.url, %1.title, history.count").arg(table); QStringList searchList; + QString query = QLatin1String("SELECT id, url, title, count FROM history WHERE "); - query.append(QLatin1String(" FROM history ")); - - query.append(QLatin1String("WHERE ")); if (exactMatch) { - query.append(QString("%1.title LIKE ? OR %1.url LIKE ? ").arg(table)); + query.append(QLatin1String("title LIKE ? OR url LIKE ? ")); } else { searchList = searchString.split(QLatin1Char(' '), QString::SkipEmptyParts); const int slSize = searchList.size(); for (int i = 0; i < slSize; ++i) { - query.append(QString("(%1.title LIKE ? OR %1.url LIKE ?) ").arg(table)); + query.append(QLatin1String("(title LIKE ? OR url LIKE ?) ")); if (i < slSize - 1) { query.append(QLatin1String("AND ")); } @@ -209,13 +204,13 @@ QSqlQuery LocationCompleterModel::createQuery(const QString &searchString, const } for (int i = 0; i < alreadyFound.count(); i++) { - query.append(QString("AND (NOT %1.url=?) ").arg(table)); + query.append(QLatin1String("AND (NOT url=?) ")); } - query.append(QString("GROUP BY %1.url ").arg(table)); + query.append(QLatin1String("GROUP BY url ")); if (!orderBy.isEmpty()) { - query.append("ORDER BY " + orderBy); + query.append(QLatin1String("ORDER BY ") + orderBy); } query.append(QLatin1String(" LIMIT ?"));