From c6a59392e032ee0570c2f5182ae1b53c9ddecae8 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Wed, 3 Jun 2020 00:20:29 +0200 Subject: [PATCH] Add option to never delete entries --- src/alligatorsettings.kcfg | 2 +- src/database.cpp | 12 ++++++++---- src/qml/SettingsPage.qml | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/alligatorsettings.kcfg b/src/alligatorsettings.kcfg index 9069c74b..5d2dcb41 100644 --- a/src/alligatorsettings.kcfg +++ b/src/alligatorsettings.kcfg @@ -11,7 +11,7 @@ - 2 + 3 diff --git a/src/database.cpp b/src/database.cpp index 3d25140c..3cef5241 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -106,15 +106,19 @@ void Database::cleanup() int count = settings.deleteAfterCount(); int type = settings.deleteAfterType(); - if (type == 0) { // Delete after posts per feed + if(type == 0) { //Never delete Entries + return; + } + + if (type == 1) { // Delete after posts per feed // TODO } else { QDateTime dateTime = QDateTime::currentDateTime(); - if (type == 1) + if (type == 2) dateTime = dateTime.addDays(-count); - else if (type == 2) - dateTime = dateTime.addDays(-7 * count); else if (type == 3) + dateTime = dateTime.addDays(-7 * count); + else if (type == 4) dateTime = dateTime.addMonths(-count); qint64 sinceEpoch = dateTime.toSecsSinceEpoch(); diff --git a/src/qml/SettingsPage.qml b/src/qml/SettingsPage.qml index 7ef7968d..413d093e 100644 --- a/src/qml/SettingsPage.qml +++ b/src/qml/SettingsPage.qml @@ -34,11 +34,12 @@ Kirigami.ScrollablePage { id: deleteAfterCount text: settings.deleteAfterCount Kirigami.FormData.label: i18n("Delete posts after:") + enabled: deleteAfterType.currentIndex !== 0 } Controls.ComboBox { id: deleteAfterType currentIndex: settings.deleteAfterType - model: [i18n("Posts"), i18n("Days"), i18n("Weeks"), i18n("Months")] + model: [i18n("Never"), i18n("Posts"), i18n("Days"), i18n("Weeks"), i18n("Months")] } Controls.Button { text: i18n("Save")