From 1df7ce45e37dbcd5486db0839b8f88730216600b Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 4 May 2015 18:25:00 +0200 Subject: [PATCH] Fixing selections. --- src/core/feeddownloader.cpp | 16 +++++++++++++++- src/core/feeddownloader.h | 6 ++++++ src/core/feedsselection.cpp | 8 ++++---- src/core/feedsselection.h | 2 +- src/gui/feedmessageviewer.cpp | 1 + 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/core/feeddownloader.cpp b/src/core/feeddownloader.cpp index 208bd8b02..761295f8f 100644 --- a/src/core/feeddownloader.cpp +++ b/src/core/feeddownloader.cpp @@ -23,7 +23,7 @@ #include -FeedDownloader::FeedDownloader(QObject *parent) : QObject(parent) { +FeedDownloader::FeedDownloader(QObject *parent) : QObject(parent), m_updateAbortionRequested(false) { } FeedDownloader::~FeedDownloader() { @@ -33,10 +33,20 @@ FeedDownloader::~FeedDownloader() { void FeedDownloader::updateFeeds(const QList &feeds) { qDebug().nospace() << "Performing feed updates in thread: \'" << QThread::currentThreadId() << "\'."; + if (m_updateAbortionRequested) { + m_updateAbortionRequested = false; + } + // Job starts now. emit started(); for (int i = 0, total = feeds.size(); i < total; i++) { + if (m_updateAbortionRequested) { + m_updateAbortionRequested = false; + qWarning("Interruption of feeds update process was requested. Interrupting it now."); + break; + } + feeds.at(i)->update(); qDebug("Made progress in feed updates: %d/%d (id of feed is %d).", i + 1, total, feeds.at(i)->id()); emit progress(feeds.at(i), i + 1, total); @@ -50,3 +60,7 @@ void FeedDownloader::updateFeeds(const QList &feeds) { // can eventually quit. emit finished(); } + +void FeedDownloader::abortOngoingUpdate() { + m_updateAbortionRequested = true; +} diff --git a/src/core/feeddownloader.h b/src/core/feeddownloader.h index 365cb4012..78ef9058d 100644 --- a/src/core/feeddownloader.h +++ b/src/core/feeddownloader.h @@ -41,6 +41,9 @@ class FeedDownloader : public QObject { // Appropriate signals are emitted. void updateFeeds(const QList &feeds); + // Aborts ongoing message if there is any. + void abortOngoingUpdate(); + signals: // Emitted if feed updates started. void started(); @@ -54,6 +57,9 @@ class FeedDownloader : public QObject { // and "total" number indicates total number of feeds // which were in the initial queue. void progress(FeedsModelFeed *feed, int current, int total); + + private: + bool m_updateAbortionRequested; }; #endif // FEEDDOWNLOADER_H diff --git a/src/core/feedsselection.cpp b/src/core/feedsselection.cpp index 5ca545f59..dfbbb50e5 100644 --- a/src/core/feedsselection.cpp +++ b/src/core/feedsselection.cpp @@ -34,19 +34,19 @@ FeedsSelection::~FeedsSelection() { FeedsSelection::SelectionMode FeedsSelection::mode() { if (m_selectedItem == NULL) { - return SelectionMode::NoMode; + return FeedsSelection::NoMode; } switch (m_selectedItem->kind()) { case FeedsModelRootItem::RecycleBin: - return SelectionMode::MessagesFromRecycleBin; + return FeedsSelection::MessagesFromRecycleBin; case FeedsModelRootItem::Category: case FeedsModelRootItem::Feed: - return SelectionMode::MessagesFromFeeds; + return FeedsSelection::MessagesFromFeeds; default: - return SelectionMode::NoMode; + return FeedsSelection::NoMode; } } diff --git a/src/core/feedsselection.h b/src/core/feedsselection.h index 9ff8d4d0d..3caebc6f4 100644 --- a/src/core/feedsselection.h +++ b/src/core/feedsselection.h @@ -19,7 +19,7 @@ #define FEEDSSELECTION_H #include -#include +#include class FeedsModelRootItem; diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index b8c3c96ce..ca85d669d 100755 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -123,6 +123,7 @@ void FeedMessageViewer::quit() { m_feedsView->quit(); qDebug("Quitting feed downloader thread."); + m_feedDownloader->abortOngoingUpdate(); m_feedDownloaderThread->quit(); m_feedDownloaderThread->wait();