Add option to never delete entries

This commit is contained in:
Tobias Fella 2020-06-03 00:20:29 +02:00
parent 196e6bb003
commit c6a59392e0
3 changed files with 11 additions and 6 deletions

View File

@ -11,7 +11,7 @@
</entry>
<entry name="deleteAfterType" type="Int">
<label>Delete after type</label>
<default>2</default>
<default>3</default>
</entry>
</group>
</kcfg>

View File

@ -106,15 +106,19 @@ void Database::cleanup()
int count = settings.deleteAfterCount();
int type = settings.deleteAfterType();
if (type == 0) { // Delete after <count> posts per feed
if(type == 0) { //Never delete Entries
return;
}
if (type == 1) { // Delete after <count> 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();

View File

@ -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")