From 2e4227a8875dc9a25dd92d46d2f71eff7ae1499a Mon Sep 17 00:00:00 2001 From: Louie S Date: Tue, 12 Mar 2024 18:49:47 -0400 Subject: Implement removeEntry --- src/backend/db_sqlite.cpp | 20 ++++++++++++++++++++ src/backend/db_sqlite.h | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src/backend') diff --git a/src/backend/db_sqlite.cpp b/src/backend/db_sqlite.cpp index 0d21a05..4319b67 100644 --- a/src/backend/db_sqlite.cpp +++ b/src/backend/db_sqlite.cpp @@ -275,6 +275,26 @@ int BackendDB::removeGroup(const Group &group) { return output; } +// return value: number of affected rows +int BackendDB::removeEntry(const Entry &entry) { + int output; + + { + QSqlDatabase database(this->openDB()); + QSqlQuery query; + + query.prepare("UPDATE entries SET hidden = 1 WHERE id = ?"); + query.bindValue(0, entry.id); + query.exec(); + + // FIXME not sure if this also needs to be called after the first query... + output = query.numRowsAffected(); + } + + QSqlDatabase::removeDatabase("qt_sql_default_connection"); + return output; +} + // permanently delete removed/hidden groups and entries void BackendDB::cleanHidden() { { diff --git a/src/backend/db_sqlite.h b/src/backend/db_sqlite.h index 83b36f9..1db61e8 100644 --- a/src/backend/db_sqlite.h +++ b/src/backend/db_sqlite.h @@ -20,10 +20,10 @@ class BackendDB : QSqlDatabase { int insertEntry(const Entry &new_entry); int insertRule(int new_rule); // param datatype TBD void updateGroup(const Group &group); - void updateEntry(const Entry &entry); // param datatype TBD + void updateEntry(const Entry &entry); void updateRule(int rule); // param datatype TBD int removeGroup(const Group &group); - void removeEntry(int entry); // param datatype TBD + int removeEntry(const Entry &entry); void removeRule(int rule); // param datatype TBD void cleanHidden(); -- cgit