Fixing selections.
This commit is contained in:
parent
48a8763606
commit
1df7ce45e3
@ -23,7 +23,7 @@
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
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<FeedsModelFeed*> &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<FeedsModelFeed*> &feeds) {
|
||||
// can eventually quit.
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void FeedDownloader::abortOngoingUpdate() {
|
||||
m_updateAbortionRequested = true;
|
||||
}
|
||||
|
@ -41,6 +41,9 @@ class FeedDownloader : public QObject {
|
||||
// Appropriate signals are emitted.
|
||||
void updateFeeds(const QList<FeedsModelFeed*> &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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#define FEEDSSELECTION_H
|
||||
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
#include <QMetaType>
|
||||
|
||||
|
||||
class FeedsModelRootItem;
|
||||
|
@ -123,6 +123,7 @@ void FeedMessageViewer::quit() {
|
||||
m_feedsView->quit();
|
||||
|
||||
qDebug("Quitting feed downloader thread.");
|
||||
m_feedDownloader->abortOngoingUpdate();
|
||||
m_feedDownloaderThread->quit();
|
||||
m_feedDownloaderThread->wait();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user