diff --git a/src/ui/3rdparty/sqlite/sqlitedb.cpp b/src/ui/3rdparty/sqlite/sqlitedb.cpp index 37ef76b6..dac2046d 100644 --- a/src/ui/3rdparty/sqlite/sqlitedb.cpp +++ b/src/ui/3rdparty/sqlite/sqlitedb.cpp @@ -120,15 +120,14 @@ bool SqliteDb::executeStr(const QString &sql) return execute(sqlUtf8.data()); } -QVariant SqliteDb::executeEx(const char *sql, const QVariantList &vars, const QVariantMap &varsMap, - int resultCount, bool *ok) +QVariant SqliteDb::executeEx(const char *sql, const QVariantList &vars, int resultCount, bool *ok) { QVariantList list; SqliteStmt stmt; bool success = false; - if (prepare(stmt, sql, vars, varsMap)) { + if (prepare(stmt, sql, vars)) { const auto stepRes = stmt.step(); success = (stepRes != SqliteStmt::StepError); @@ -149,13 +148,7 @@ QVariant SqliteDb::executeEx(const char *sql, const QVariantList &vars, const QV return (listSize == 0) ? QVariant() : (listSize == 1 ? list.at(0) : list); } -QVariant SqliteDb::executeEx(const char *sql, const QVariantList &vars, int resultCount, bool *ok) -{ - return executeEx(sql, vars, {}, resultCount, ok); -} - -bool SqliteDb::prepare( - SqliteStmt &stmt, const char *sql, const QVariantList &vars, const QVariantMap &varsMap) +bool SqliteDb::prepare(SqliteStmt &stmt, const char *sql, const QVariantList &vars) { if (!stmt.prepare(db(), sql)) return false; @@ -163,17 +156,13 @@ bool SqliteDb::prepare( if (!(vars.isEmpty() || stmt.bindVars(vars))) return false; - if (!(varsMap.isEmpty() || stmt.bindVarsMap(varsMap))) - return false; - return true; } -bool SqliteDb::prepare( - SqliteStmt &stmt, const QString &sql, const QVariantList &vars, const QVariantMap &varsMap) +bool SqliteDb::prepare(SqliteStmt &stmt, const QString &sql, const QVariantList &vars) { const auto sqlUtf8 = sql.toUtf8(); - return prepare(stmt, sqlUtf8.constData(), vars, varsMap); + return prepare(stmt, sqlUtf8.constData(), vars); } bool SqliteDb::done(SqliteStmt *stmt) diff --git a/src/ui/3rdparty/sqlite/sqlitedb.h b/src/ui/3rdparty/sqlite/sqlitedb.h index faebb3a6..9edaa5ab 100644 --- a/src/ui/3rdparty/sqlite/sqlitedb.h +++ b/src/ui/3rdparty/sqlite/sqlitedb.h @@ -76,15 +76,11 @@ public: bool execute(const char *sql); bool executeStr(const QString &sql); - QVariant executeEx(const char *sql, const QVariantList &vars, const QVariantMap &varsMap, - int resultCount = 1, bool *ok = nullptr); QVariant executeEx(const char *sql, const QVariantList &vars = {}, int resultCount = 1, bool *ok = nullptr); - bool prepare(SqliteStmt &stmt, const char *sql, const QVariantList &vars = {}, - const QVariantMap &varsMap = {}); - bool prepare(SqliteStmt &stmt, const QString &sql, const QVariantList &vars = {}, - const QVariantMap &varsMap = {}); + bool prepare(SqliteStmt &stmt, const char *sql, const QVariantList &vars = {}); + bool prepare(SqliteStmt &stmt, const QString &sql, const QVariantList &vars = {}); bool done(SqliteStmt *stmt); qint64 lastInsertRowid() const; diff --git a/src/ui/model/applistmodel.cpp b/src/ui/model/applistmodel.cpp index 4df05067..270dc908 100644 --- a/src/ui/model/applistmodel.cpp +++ b/src/ui/model/applistmodel.cpp @@ -297,11 +297,10 @@ QIcon AppListModel::appStateIcon(const AppRow &appRow) return IconCache::icon(appStateIconPath(appRow)); } -bool AppListModel::updateAppRow(const QString &sql, const QVariantList &vars, - const QVariantMap &varsMap, AppRow &appRow) const +bool AppListModel::updateAppRow(const QString &sql, const QVariantList &vars, AppRow &appRow) const { SqliteStmt stmt; - if (!(sqliteDb()->prepare(stmt, sql, vars, varsMap) && stmt.step() == SqliteStmt::StepRow)) { + if (!(sqliteDb()->prepare(stmt, sql, vars) && stmt.step() == SqliteStmt::StepRow)) { appRow.invalidate(); return false; } @@ -335,7 +334,7 @@ const AppRow &AppListModel::appRowAt(int row) const AppRow AppListModel::appRowById(qint64 appId) const { AppRow appRow; - updateAppRow(sqlBase() + " WHERE t.app_id = ?1;", { appId }, {}, appRow); + updateAppRow(sqlBase() + " WHERE t.app_id = ?1;", { appId }, appRow); return appRow; } @@ -344,7 +343,7 @@ AppRow AppListModel::appRowByPath(const QString &appPath) const const QString normPath = FileUtil::normalizePath(appPath); AppRow appRow; - if (!updateAppRow(sqlBase() + " WHERE t.path = ?1;", { normPath }, {}, appRow)) { + if (!updateAppRow(sqlBase() + " WHERE t.path = ?1;", { normPath }, appRow)) { appRow.appOriginPath = appPath; appRow.appPath = normPath; } @@ -353,17 +352,17 @@ AppRow AppListModel::appRowByPath(const QString &appPath) const bool AppListModel::updateTableRow(int row) const { - QVariantMap varsMap; - varsMap.insert(":row", row); - fillSqlVars(varsMap); + QVariantList vars; + fillSqlVars(vars); + vars.append(row); // must be a last one! - return updateAppRow(sql(), {}, varsMap, m_appRow); + return updateAppRow(sql(), vars, m_appRow); } -void AppListModel::fillSqlVars(QVariantMap &varsMap) const +void AppListModel::fillSqlVars(QVariantList &vars) const { if (!ftsFilterMatch().isEmpty()) { - varsMap.insert(":match", ftsFilterMatch()); + vars.append(ftsFilterMatch()); } } diff --git a/src/ui/model/applistmodel.h b/src/ui/model/applistmodel.h index f4ed6263..6d8911ec 100644 --- a/src/ui/model/applistmodel.h +++ b/src/ui/model/applistmodel.h @@ -49,7 +49,7 @@ protected: bool updateTableRow(int row) const override; TableRow &tableRow() const override { return m_appRow; } - void fillSqlVars(QVariantMap &varsMap) const override; + void fillSqlVars(QVariantList &vars) const override; QString sqlBase() const override; QString sqlWhere() const override; @@ -71,8 +71,7 @@ private: static QColor appStateColor(const AppRow &appRow); static QIcon appStateIcon(const AppRow &appRow); - bool updateAppRow(const QString &sql, const QVariantList &vars, const QVariantMap &varsMap, - AppRow &appRow) const; + bool updateAppRow(const QString &sql, const QVariantList &vars, AppRow &appRow) const; private: QString m_ftsFilter; diff --git a/src/ui/util/model/tablesqlmodel.cpp b/src/ui/util/model/tablesqlmodel.cpp index b7a2e7db..fd90d1ff 100644 --- a/src/ui/util/model/tablesqlmodel.cpp +++ b/src/ui/util/model/tablesqlmodel.cpp @@ -33,19 +33,19 @@ void TableSqlModel::invalidateRowCache() emit modelChanged(); } -void TableSqlModel::fillSqlVars(QVariantMap &varsMap) const +void TableSqlModel::fillSqlVars(QVariantList &vars) const { - Q_UNUSED(varsMap); + Q_UNUSED(vars); } int TableSqlModel::doSqlCount() const { - QVariantMap varsMap; - fillSqlVars(varsMap); + QVariantList vars; + fillSqlVars(vars); const auto sqlUtf8 = sqlCount().toUtf8(); - return sqliteDb()->executeEx(sqlUtf8, {}, varsMap).toInt(); + return sqliteDb()->executeEx(sqlUtf8, vars).toInt(); } QString TableSqlModel::sqlCount() const diff --git a/src/ui/util/model/tablesqlmodel.h b/src/ui/util/model/tablesqlmodel.h index a6b53075..c49241dd 100644 --- a/src/ui/util/model/tablesqlmodel.h +++ b/src/ui/util/model/tablesqlmodel.h @@ -24,7 +24,7 @@ signals: protected: void invalidateRowCache() override; - virtual void fillSqlVars(QVariantMap &varsMap) const; + virtual void fillSqlVars(QVariantList &vars) const; virtual int doSqlCount() const; virtual QString sqlCount() const;