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>
<entry name="deleteAfterType" type="Int"> <entry name="deleteAfterType" type="Int">
<label>Delete after type</label> <label>Delete after type</label>
<default>2</default> <default>3</default>
</entry> </entry>
</group> </group>
</kcfg> </kcfg>

View File

@ -106,15 +106,19 @@ void Database::cleanup()
int count = settings.deleteAfterCount(); int count = settings.deleteAfterCount();
int type = settings.deleteAfterType(); 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 // TODO
} else { } else {
QDateTime dateTime = QDateTime::currentDateTime(); QDateTime dateTime = QDateTime::currentDateTime();
if (type == 1) if (type == 2)
dateTime = dateTime.addDays(-count); dateTime = dateTime.addDays(-count);
else if (type == 2)
dateTime = dateTime.addDays(-7 * count);
else if (type == 3) else if (type == 3)
dateTime = dateTime.addDays(-7 * count);
else if (type == 4)
dateTime = dateTime.addMonths(-count); dateTime = dateTime.addMonths(-count);
qint64 sinceEpoch = dateTime.toSecsSinceEpoch(); qint64 sinceEpoch = dateTime.toSecsSinceEpoch();

View File

@ -34,11 +34,12 @@ Kirigami.ScrollablePage {
id: deleteAfterCount id: deleteAfterCount
text: settings.deleteAfterCount text: settings.deleteAfterCount
Kirigami.FormData.label: i18n("Delete posts after:") Kirigami.FormData.label: i18n("Delete posts after:")
enabled: deleteAfterType.currentIndex !== 0
} }
Controls.ComboBox { Controls.ComboBox {
id: deleteAfterType id: deleteAfterType
currentIndex: settings.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 { Controls.Button {
text: i18n("Save") text: i18n("Save")