make deleting of feeds work with sort order

This commit is contained in:
Martin Rotter 2022-03-14 16:10:35 +01:00
parent f7b36f0fd6
commit 5f14f2cc82
6 changed files with 11 additions and 7 deletions

View File

@ -2112,11 +2112,13 @@ void DatabaseQueries::createOverwriteAccount(const QSqlDatabase& db, ServiceRoot
}
}
bool DatabaseQueries::deleteFeed(const QSqlDatabase& db, int feed_custom_id, int account_id) {
bool DatabaseQueries::deleteFeed(const QSqlDatabase& db, Feed* feed, int account_id) {
moveItem(feed, false, true, {}, db);
QSqlQuery q(db);
q.prepare(QSL("DELETE FROM Messages WHERE feed = :feed AND account_id = :account_id;"));
q.bindValue(QSL(":feed"), feed_custom_id);
q.bindValue(QSL(":feed"), feed->customId());
q.bindValue(QSL(":account_id"), account_id);
if (!q.exec()) {
@ -2125,7 +2127,7 @@ bool DatabaseQueries::deleteFeed(const QSqlDatabase& db, int feed_custom_id, int
// Remove feed itself.
q.prepare(QSL("DELETE FROM Feeds WHERE custom_id = :feed AND account_id = :account_id;"));
q.bindValue(QSL(":feed"), feed_custom_id);
q.bindValue(QSL(":feed"), feed->customId());
q.bindValue(QSL(":account_id"), account_id);
return q.exec() &&

View File

@ -124,7 +124,7 @@ class DatabaseQueries {
static void storeAccountTree(const QSqlDatabase& db, RootItem* tree_root, int account_id);
static void createOverwriteFeed(const QSqlDatabase& db, Feed* feed, int account_id, int parent_id);
static void createOverwriteCategory(const QSqlDatabase& db, Category* category, int account_id, int parent_id);
static bool deleteFeed(const QSqlDatabase& db, int feed_custom_id, int account_id);
static bool deleteFeed(const QSqlDatabase& db, Feed* feed, int account_id);
static bool deleteCategory(const QSqlDatabase& db, int id);
template<typename T>

View File

@ -270,6 +270,8 @@ void FeedsView::deleteSelectedItem() {
// We have deleteable item selected, remove it via GUI.
if (!selected_item->deleteViaGui()) {
m_proxyModel->invalidate();
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
tr("Cannot delete \"%1\"").arg(selected_item->title()),
tr("This item cannot be deleted because something critically failed. Submit bug report."),

View File

@ -29,7 +29,7 @@ bool OwnCloudFeed::deleteViaGui() {
bool OwnCloudFeed::removeItself() {
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
return DatabaseQueries::deleteFeed(database, customId().toInt(), serviceRoot()->accountId());
return DatabaseQueries::deleteFeed(database, this, serviceRoot()->accountId());
}
OwnCloudServiceRoot* OwnCloudFeed::serviceRoot() const {

View File

@ -492,7 +492,7 @@ bool StandardFeed::performDragDropChange(RootItem* target_item) {
bool StandardFeed::removeItself() {
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
return DatabaseQueries::deleteFeed(database, customId().toInt(), getParentServiceRoot()->accountId());
return DatabaseQueries::deleteFeed(database, this, getParentServiceRoot()->accountId());
}
StandardFeed::Type StandardFeed::type() const {

View File

@ -60,5 +60,5 @@ QList<QAction*> TtRssFeed::contextMenuFeedsList() {
bool TtRssFeed::removeItself() {
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
return DatabaseQueries::deleteFeed(database, customId().toInt(), serviceRoot()->accountId());
return DatabaseQueries::deleteFeed(database, this, serviceRoot()->accountId());
}