From 41c239ff03ff0acacb07f265c088a82258ab8494 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 14 Jul 2015 08:45:16 +0200 Subject: [PATCH] Some cosmetic fixes. --- src/core/feeddownloader.h | 7 +++---- src/core/feedsmodelcategory.cpp | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/core/feeddownloader.h b/src/core/feeddownloader.h index e720ef603..f2233c515 100644 --- a/src/core/feeddownloader.h +++ b/src/core/feeddownloader.h @@ -25,6 +25,7 @@ class FeedsModelFeed; +// Represents results of batch feed updates. struct FeedDownloadResults { explicit FeedDownloadResults() : m_updatedFeeds(QList >()) { } @@ -35,13 +36,11 @@ struct FeedDownloadResults { return lhs.second > rhs.second; } - // QString represents title if the feed, int represents - // count of newly downloaded messages. + // QString represents title if the feed, int represents count of newly downloaded messages. QList > m_updatedFeeds; }; -// This class offers means to "update" feeds -// and "special" categories. +// This class offers means to "update" feeds and "special" categories. // NOTE: This class is used within separate thread. class FeedDownloader : public QObject { Q_OBJECT diff --git a/src/core/feedsmodelcategory.cpp b/src/core/feedsmodelcategory.cpp index dbb437e30..40c17040d 100755 --- a/src/core/feedsmodelcategory.cpp +++ b/src/core/feedsmodelcategory.cpp @@ -121,28 +121,28 @@ QVariant FeedsModelCategory::data(int column, int role) const { } bool FeedsModelCategory::removeItself() { - bool result = true; + bool children_removed = true; // Remove all child items (feeds, categories.) foreach (FeedsModelRootItem *child, m_childItems) { - result &= child->removeItself(); + children_removed &= child->removeItself(); } - if (!result) { - return result; + if (children_removed) { + // Children are removed, remove this standard category too. + QSqlDatabase database = qApp->database()->connection(QSL("FeedsModelCategory"), DatabaseFactory::FromSettings); + QSqlQuery query_remove(database); + + // Remove this category from database. + query_remove.setForwardOnly(true); + query_remove.prepare(QSL("DELETE FROM Categories WHERE id = :category;")); + query_remove.bindValue(QSL(":category"), id()); + + return query_remove.exec(); + } + else { + return false; } - - // Children are removed, remove this standard category too. - QSqlDatabase database = qApp->database()->connection(QSL("FeedsModelCategory"), DatabaseFactory::FromSettings); - QSqlQuery query_remove(database); - - query_remove.setForwardOnly(true); - - // Remove all messages from this standard feed. - query_remove.prepare(QSL("DELETE FROM Categories WHERE id = :category;")); - query_remove.bindValue(QSL(":category"), id()); - - return query_remove.exec(); } FeedsModelCategory::FeedsModelCategory(const QSqlRecord &record) : FeedsModelRootItem(NULL) {