summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouie S <louie@example.com>2024-03-12 18:49:47 -0400
committerLouie S <louie@example.com>2024-03-12 18:49:47 -0400
commit2e4227a8875dc9a25dd92d46d2f71eff7ae1499a (patch)
tree92a2ccaaf0cfaff3effa519b69496bfe3147cdca
parente0608b1e0891c5782ffbc291788268e76d494d4e (diff)
Implement removeEntry
-rw-r--r--src/backend/db_sqlite.cpp20
-rw-r--r--src/backend/db_sqlite.h4
-rw-r--r--src/entryLayout.cpp5
3 files changed, 26 insertions, 3 deletions
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();
diff --git a/src/entryLayout.cpp b/src/entryLayout.cpp
index eff8f1e..48b2888 100644
--- a/src/entryLayout.cpp
+++ b/src/entryLayout.cpp
@@ -135,5 +135,8 @@ void EntryLayout::toggleDone() {
}
void EntryLayout::removeEntry() {
- qDebug() << "WIP";
+ BackendDB database;
+
+ if(database.removeEntry(this->entry) > 0)
+ getMainWindow()->displayWidgets();
}