diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/db_sqlite.cpp | 20 | ||||
-rw-r--r-- | src/backend/db_sqlite.h | 4 | ||||
-rw-r--r-- | src/entryLayout.cpp | 5 |
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(); } |