diff options
author | Louie S <louie@example.com> | 2024-03-10 15:10:53 -0400 |
---|---|---|
committer | Louie S <louie@example.com> | 2024-03-10 15:10:53 -0400 |
commit | 7aadb8987a6e044c7922817ce797332c4f037476 (patch) | |
tree | 45bff872537b3b165e0643dda98ced774106ab0b /src | |
parent | 930dc4d918fef8c6325d5f69ac7c5f9aeada9f74 (diff) |
Implement cleanHidden
Diffstat (limited to 'src')
-rw-r--r-- | src/assignmentList.cpp | 3 | ||||
-rw-r--r-- | src/backend/db_sqlite.cpp | 20 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/assignmentList.cpp b/src/assignmentList.cpp index 5168914..09ef6e3 100644 --- a/src/assignmentList.cpp +++ b/src/assignmentList.cpp @@ -128,7 +128,8 @@ void AssignmentList::reload() { } void AssignmentList::cleanHidden() { - qDebug() << "WIP"; + BackendDB database; + database.cleanHidden(); } void AssignmentList::aboutDialog() { diff --git a/src/backend/db_sqlite.cpp b/src/backend/db_sqlite.cpp index 91bb3e5..763fba5 100644 --- a/src/backend/db_sqlite.cpp +++ b/src/backend/db_sqlite.cpp @@ -245,6 +245,26 @@ int BackendDB::removeGroup(const Group &group) { return output; } +// permanently delete removed/hidden groups and entries +void BackendDB::cleanHidden() { + { + QSqlDatabase database(this->openDB()); + QSqlQuery query; + + // remove rules associated with hidden entries + query.exec("DELETE FROM rules WHERE id IN (" + "SELECT rules.id FROM rules" + "INNER JOIN entries ON rules.entry_id = entries.id" + "WHERE entries.hidden = 1)"); + // remove hidden entries + query.exec("DELETE FROM entries WHERE hidden = 1"); + // remove hidden groups + query.exec("DELETE FROM groups WHERE hidden = 1"); + } + + QSqlDatabase::removeDatabase("qt_sql_default_connection"); +} + QString BackendDB::getDBPath() { QSettings settings; settings.beginGroup("paths"); |