From 848cdae813648f0a2c39942dc01d8f991787b338 Mon Sep 17 00:00:00 2001 From: Louie S Date: Sat, 9 Mar 2024 18:15:46 -0500 Subject: accept for edit group form --- src/backend/db_sqlite.cpp | 24 ++++++++++++++++++++++++ src/backend/db_sqlite.h | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src/backend') diff --git a/src/backend/db_sqlite.cpp b/src/backend/db_sqlite.cpp index 8a612a0..6490bb1 100644 --- a/src/backend/db_sqlite.cpp +++ b/src/backend/db_sqlite.cpp @@ -196,6 +196,30 @@ int BackendDB::insertEntry(const Entry &new_entry) { return output; } +void BackendDB::updateGroup(const Group &group) { + { + QSqlDatabase database(this->openDB()); + QSqlQuery query; + + qDebug() << group.name; + + query.prepare("UPDATE groups SET " + "name = :name, " + "column = :column, " + "link = :link, " + "hidden = :hidden " + "WHERE id = :id"); + query.bindValue(":name", group.name); + query.bindValue(":column", group.column); + query.bindValue(":link", group.link); + query.bindValue(":hidden", group.hidden); + query.bindValue(":id", group.id); + query.exec(); + } + + QSqlDatabase::removeDatabase("qt_sql_default_connection"); +} + QString BackendDB::getDBPath() { QSettings settings; settings.beginGroup("paths"); diff --git a/src/backend/db_sqlite.h b/src/backend/db_sqlite.h index afaac8d..b138dc6 100644 --- a/src/backend/db_sqlite.h +++ b/src/backend/db_sqlite.h @@ -19,7 +19,7 @@ class BackendDB : QSqlDatabase { int insertGroup(const Group &new_group); int insertEntry(const Entry &new_entry); int insertRule(int new_rule); // param datatype TBD - void updateGroup(int group); // param datatype TBD + void updateGroup(const Group &group); void updateEntry(int entry); // param datatype TBD void updateRule(int rule); // param datatype TBD void removeGroup(int group); // param datatype TBD -- cgit