make deleting of feeds work with sort order
This commit is contained in:
parent
f7b36f0fd6
commit
5f14f2cc82
@ -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);
|
QSqlQuery q(db);
|
||||||
|
|
||||||
q.prepare(QSL("DELETE FROM Messages WHERE feed = :feed AND account_id = :account_id;"));
|
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);
|
q.bindValue(QSL(":account_id"), account_id);
|
||||||
|
|
||||||
if (!q.exec()) {
|
if (!q.exec()) {
|
||||||
@ -2125,7 +2127,7 @@ bool DatabaseQueries::deleteFeed(const QSqlDatabase& db, int feed_custom_id, int
|
|||||||
|
|
||||||
// Remove feed itself.
|
// Remove feed itself.
|
||||||
q.prepare(QSL("DELETE FROM Feeds WHERE custom_id = :feed AND account_id = :account_id;"));
|
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);
|
q.bindValue(QSL(":account_id"), account_id);
|
||||||
|
|
||||||
return q.exec() &&
|
return q.exec() &&
|
||||||
|
@ -124,7 +124,7 @@ class DatabaseQueries {
|
|||||||
static void storeAccountTree(const QSqlDatabase& db, RootItem* tree_root, int account_id);
|
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 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 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);
|
static bool deleteCategory(const QSqlDatabase& db, int id);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -270,6 +270,8 @@ void FeedsView::deleteSelectedItem() {
|
|||||||
|
|
||||||
// We have deleteable item selected, remove it via GUI.
|
// We have deleteable item selected, remove it via GUI.
|
||||||
if (!selected_item->deleteViaGui()) {
|
if (!selected_item->deleteViaGui()) {
|
||||||
|
m_proxyModel->invalidate();
|
||||||
|
|
||||||
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
qApp->showGuiMessage(Notification::Event::GeneralEvent, {
|
||||||
tr("Cannot delete \"%1\"").arg(selected_item->title()),
|
tr("Cannot delete \"%1\"").arg(selected_item->title()),
|
||||||
tr("This item cannot be deleted because something critically failed. Submit bug report."),
|
tr("This item cannot be deleted because something critically failed. Submit bug report."),
|
||||||
|
@ -29,7 +29,7 @@ bool OwnCloudFeed::deleteViaGui() {
|
|||||||
bool OwnCloudFeed::removeItself() {
|
bool OwnCloudFeed::removeItself() {
|
||||||
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
|
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 {
|
OwnCloudServiceRoot* OwnCloudFeed::serviceRoot() const {
|
||||||
|
@ -492,7 +492,7 @@ bool StandardFeed::performDragDropChange(RootItem* target_item) {
|
|||||||
bool StandardFeed::removeItself() {
|
bool StandardFeed::removeItself() {
|
||||||
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
|
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 {
|
StandardFeed::Type StandardFeed::type() const {
|
||||||
|
@ -60,5 +60,5 @@ QList<QAction*> TtRssFeed::contextMenuFeedsList() {
|
|||||||
bool TtRssFeed::removeItself() {
|
bool TtRssFeed::removeItself() {
|
||||||
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
|
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
|
||||||
|
|
||||||
return DatabaseQueries::deleteFeed(database, customId().toInt(), serviceRoot()->accountId());
|
return DatabaseQueries::deleteFeed(database, this, serviceRoot()->accountId());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user