Refactoring.
This commit is contained in:
parent
b62dcd2926
commit
7a42e2d7a1
|
@ -61,7 +61,7 @@ void FeedDownloader::updateFeeds(const QList<Feed*> &feeds) {
|
|||
m_feedsTotalCount = m_feedsToUpdate;
|
||||
|
||||
// Job starts now.
|
||||
emit started();
|
||||
emit updateStarted();
|
||||
|
||||
for (int i = 0; i < m_feedsTotalCount; i++) {
|
||||
if (m_stopUpdate) {
|
||||
|
@ -101,9 +101,8 @@ void FeedDownloader::oneFeedUpdateFinished(const QList<Message> &messages) {
|
|||
m_feedsUpdating--;
|
||||
|
||||
// Now make sure, that messages are actually stored to SQL in a locked state.
|
||||
|
||||
qDebug().nospace() << "Saving messages of feed "
|
||||
<< feed->customId() << " in thread: \'"
|
||||
<< feed->id() << " in thread: \'"
|
||||
<< QThread::currentThreadId() << "\'.";
|
||||
|
||||
int updated_messages = messages.isEmpty() ? 0 : feed->updateMessages(messages);
|
||||
|
@ -113,7 +112,7 @@ void FeedDownloader::oneFeedUpdateFinished(const QList<Message> &messages) {
|
|||
}
|
||||
|
||||
qDebug("Made progress in feed updates, total feeds count %d/%d (id of feed is %d).", m_feedsUpdated, m_feedsTotalCount, feed->id());
|
||||
emit progress(feed, m_feedsUpdated, m_feedsTotalCount);
|
||||
emit updateProgress(feed, m_feedsUpdated, m_feedsTotalCount);
|
||||
|
||||
if (m_feedsToUpdate <= 0 && m_feedsUpdating <= 0) {
|
||||
finalizeUpdate();
|
||||
|
@ -132,7 +131,7 @@ void FeedDownloader::finalizeUpdate() {
|
|||
// NOTE: This means that now "update lock" can be unlocked
|
||||
// and feeds can be added/edited/deleted and application
|
||||
// can eventually quit.
|
||||
emit finished(m_results);
|
||||
emit updateFinished(m_results);
|
||||
}
|
||||
|
||||
FeedDownloadResults::FeedDownloadResults() : m_updatedFeeds(QList<QPair<QString,int> >()) {
|
||||
|
|
|
@ -76,17 +76,17 @@ class FeedDownloader : public QObject {
|
|||
|
||||
signals:
|
||||
// Emitted if feed updates started.
|
||||
void started();
|
||||
void updateStarted();
|
||||
|
||||
// Emitted if all items from update queue are
|
||||
// processed.
|
||||
void finished(FeedDownloadResults updated_feeds);
|
||||
void updateFinished(FeedDownloadResults updated_feeds);
|
||||
|
||||
// Emitted if any item is processed.
|
||||
// "Current" number indicates count of processed feeds
|
||||
// and "total" number indicates total number of feeds
|
||||
// which were in the initial queue.
|
||||
void progress(const Feed *feed, int current, int total);
|
||||
void updateProgress(const Feed *feed, int current, int total);
|
||||
|
||||
private:
|
||||
void finalizeUpdate();
|
||||
|
|
|
@ -76,12 +76,6 @@ FeedsModel::~FeedsModel() {
|
|||
delete m_rootItem;
|
||||
}
|
||||
|
||||
void FeedsModel::quit() {
|
||||
if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::ClearReadOnExit)).toBool()) {
|
||||
markItemCleared(m_rootItem, true);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void FeedsModel::onFeedUpdatesStarted() {
|
||||
//: Text display in status bar when feed update is started.
|
||||
|
|
|
@ -117,9 +117,6 @@ class FeedsModel : public QAbstractItemModel {
|
|||
// Loads feed/categories from the database.
|
||||
void loadActivatedServiceAccounts();
|
||||
|
||||
// Does necessary job before quitting this component.
|
||||
void quit();
|
||||
|
||||
// Reloads counts of all feeds/categories/whatever in the model.
|
||||
void reloadCountsOfWholeModel();
|
||||
|
||||
|
|
|
@ -31,11 +31,13 @@
|
|||
#include "gui/systemtrayicon.h"
|
||||
#include "gui/tabbar.h"
|
||||
#include "gui/statusbar.h"
|
||||
#include "gui/messagesview.h"
|
||||
#include "gui/feedmessageviewer.h"
|
||||
#include "gui/plaintoolbutton.h"
|
||||
#include "gui/dialogs/formabout.h"
|
||||
#include "gui/dialogs/formsettings.h"
|
||||
#include "gui/dialogs/formupdate.h"
|
||||
#include "gui/dialogs/formdatabasecleanup.h"
|
||||
#include "gui/dialogs/formbackupdatabasesettings.h"
|
||||
#include "gui/dialogs/formrestoredatabasesettings.h"
|
||||
#include "gui/dialogs/formaddaccount.h"
|
||||
|
@ -89,6 +91,24 @@ FormMain::~FormMain() {
|
|||
qDebug("Destroying FormMain instance.");
|
||||
}
|
||||
|
||||
void FormMain::showDbCleanupAssistant() {
|
||||
if (qApp->feedUpdateLock()->tryLock()) {
|
||||
QScopedPointer<FormDatabaseCleanup> form_pointer(new FormDatabaseCleanup(this));
|
||||
form_pointer.data()->setCleaner(qApp->feedReader()->databaseCleaner());
|
||||
form_pointer.data()->exec();
|
||||
|
||||
qApp->feedUpdateLock()->unlock();
|
||||
|
||||
tabWidget()->feedMessageViewer()->messagesView()->reloadSelections(false);
|
||||
qApp->feedReader()->feedsModel()->reloadCountsOfWholeModel();
|
||||
}
|
||||
else {
|
||||
qApp->showGuiMessage(tr("Cannot cleanup database"),
|
||||
tr("Cannot cleanup database, because another critical action is running."),
|
||||
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
|
||||
}
|
||||
}
|
||||
|
||||
QList<QAction*> FormMain::allActions() const {
|
||||
QList<QAction*> actions;
|
||||
|
||||
|
@ -495,6 +515,8 @@ void FormMain::createConnections() {
|
|||
connect(m_ui->m_actionSettings, SIGNAL(triggered()), this, SLOT(showSettings()));
|
||||
connect(m_ui->m_actionDownloadManager, SIGNAL(triggered()), m_ui->m_tabWidget, SLOT(showDownloadManager()));
|
||||
|
||||
connect(m_ui->m_actionCleanupDatabase, SIGNAL(triggered()), this, SLOT(showDbCleanupAssistant()));
|
||||
|
||||
// Menu "Help" connections.
|
||||
connect(m_ui->m_actionAboutGuard, SIGNAL(triggered()), this, SLOT(showAbout()));
|
||||
connect(m_ui->m_actionCheckForUpdates, SIGNAL(triggered()), this, SLOT(showUpdates()));
|
||||
|
|
|
@ -63,7 +63,7 @@ class FormMain : public QMainWindow {
|
|||
void loadSize();
|
||||
void saveSize();
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
// Displays window on top or switches its visibility.
|
||||
void display();
|
||||
|
||||
|
@ -86,6 +86,7 @@ class FormMain : public QMainWindow {
|
|||
void showUpdates();
|
||||
void showWiki();
|
||||
void showAddAccountDialog();
|
||||
void showDbCleanupAssistant();
|
||||
void reportABug();
|
||||
void donate();
|
||||
|
||||
|
|
|
@ -76,6 +76,26 @@ FeedMessageViewer::~FeedMessageViewer() {
|
|||
qDebug("Destroying FeedMessageViewer instance.");
|
||||
}
|
||||
|
||||
WebBrowser *FeedMessageViewer::webBrowser() const {
|
||||
return m_messagesBrowser;
|
||||
}
|
||||
|
||||
FeedsView *FeedMessageViewer::feedsView() const {
|
||||
return m_feedsView;
|
||||
}
|
||||
|
||||
MessagesView *FeedMessageViewer::messagesView() const {
|
||||
return m_messagesView;
|
||||
}
|
||||
|
||||
MessagesToolBar *FeedMessageViewer::messagesToolBar() const {
|
||||
return m_toolBarMessages;
|
||||
}
|
||||
|
||||
FeedsToolBar *FeedMessageViewer::feedsToolBar() const {
|
||||
return m_toolBarFeeds;
|
||||
}
|
||||
|
||||
void FeedMessageViewer::saveSize() {
|
||||
Settings *settings = qApp->settings();
|
||||
|
||||
|
@ -121,11 +141,6 @@ void FeedMessageViewer::loadMessageViewerFonts() {
|
|||
m_messagesBrowser->reloadFontSettings();
|
||||
}
|
||||
|
||||
void FeedMessageViewer::quit() {
|
||||
// Quit the feeds model (stops auto-update timer etc.).
|
||||
m_feedsView->sourceModel()->quit();
|
||||
}
|
||||
|
||||
bool FeedMessageViewer::areToolBarsEnabled() const {
|
||||
return m_toolBarsEnabled;
|
||||
}
|
||||
|
@ -270,8 +285,6 @@ void FeedMessageViewer::createConnections() {
|
|||
m_feedsView, SLOT(addFeedIntoSelectedAccount()));
|
||||
connect(form_main->m_ui->m_actionAddCategoryIntoSelectedAccount, SIGNAL(triggered()),
|
||||
m_feedsView, SLOT(addCategoryIntoSelectedAccount()));
|
||||
connect(form_main->m_ui->m_actionCleanupDatabase,
|
||||
SIGNAL(triggered()), this, SLOT(showDbCleanupAssistant()));
|
||||
connect(form_main->m_ui->m_actionSwitchImportanceOfSelectedMessages,
|
||||
SIGNAL(triggered()), m_messagesView, SLOT(switchSelectedMessagesImportance()));
|
||||
connect(form_main->m_ui->m_actionDeleteSelectedMessages,
|
||||
|
@ -414,24 +427,6 @@ void FeedMessageViewer::initializeViews() {
|
|||
updateFeedButtonsAvailability();
|
||||
}
|
||||
|
||||
void FeedMessageViewer::showDbCleanupAssistant() {
|
||||
if (qApp->feedUpdateLock()->tryLock()) {
|
||||
QScopedPointer<FormDatabaseCleanup> form_pointer(new FormDatabaseCleanup(this));
|
||||
form_pointer.data()->setCleaner(qApp->feedReader()->databaseCleaner());
|
||||
form_pointer.data()->exec();
|
||||
|
||||
qApp->feedUpdateLock()->unlock();
|
||||
|
||||
m_messagesView->reloadSelections(false);
|
||||
m_feedsView->sourceModel()->reloadCountsOfWholeModel();
|
||||
}
|
||||
else {
|
||||
qApp->showGuiMessage(tr("Cannot cleanup database"),
|
||||
tr("Cannot cleanup database, because another critical action is running."),
|
||||
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
|
||||
}
|
||||
}
|
||||
|
||||
void FeedMessageViewer::refreshVisualProperties() {
|
||||
const Qt::ToolButtonStyle button_style = static_cast<Qt::ToolButtonStyle>(qApp->settings()->value(GROUP(GUI),
|
||||
SETTING(GUI::ToolbarStyle)).toInt());
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "gui/tabcontent.h"
|
||||
|
||||
#include "core/messagesmodel.h"
|
||||
#include "core/feeddownloader.h"
|
||||
|
||||
#include <QTextBrowser>
|
||||
|
||||
|
@ -45,28 +44,16 @@ class FeedMessageViewer : public TabContent {
|
|||
explicit FeedMessageViewer(QWidget *parent = 0);
|
||||
virtual ~FeedMessageViewer();
|
||||
|
||||
// WebBrowser getter from TabContent interface.
|
||||
inline WebBrowser *webBrowser() const {
|
||||
return m_messagesBrowser;
|
||||
}
|
||||
WebBrowser *webBrowser() const;
|
||||
FeedsView *feedsView() const;
|
||||
MessagesView *messagesView() const;
|
||||
MessagesToolBar *messagesToolBar() const;
|
||||
FeedsToolBar *feedsToolBar() const;
|
||||
|
||||
// FeedsView getter.
|
||||
inline FeedsView *feedsView() const {
|
||||
return m_feedsView;
|
||||
}
|
||||
|
||||
inline MessagesView *messagesView() const {
|
||||
return m_messagesView;
|
||||
}
|
||||
|
||||
inline MessagesToolBar *messagesToolBar() const {
|
||||
return m_toolBarMessages;
|
||||
}
|
||||
|
||||
inline FeedsToolBar *feedsToolBar() const {
|
||||
return m_toolBarFeeds;
|
||||
}
|
||||
bool areToolBarsEnabled() const;
|
||||
bool areListHeadersEnabled() const;
|
||||
|
||||
public slots:
|
||||
// Loads/saves sizes and states of ALL
|
||||
// underlying widgets, this contains primarily
|
||||
// splitters, toolbar and views.
|
||||
|
@ -75,14 +62,6 @@ class FeedMessageViewer : public TabContent {
|
|||
|
||||
void loadMessageViewerFonts();
|
||||
|
||||
// Destroys worker/feed downloader thread and
|
||||
// stops any child widgets/workers.
|
||||
void quit();
|
||||
|
||||
bool areToolBarsEnabled() const;
|
||||
bool areListHeadersEnabled() const;
|
||||
|
||||
public slots:
|
||||
// Switches orientation horizontal/vertical.
|
||||
void switchMessageSplitterOrientation();
|
||||
|
||||
|
@ -90,9 +69,6 @@ class FeedMessageViewer : public TabContent {
|
|||
void setToolBarsEnabled(bool enable);
|
||||
void setListHeadersEnabled(bool enable);
|
||||
|
||||
// Runs "cleanup" of the database.
|
||||
void showDbCleanupAssistant();
|
||||
|
||||
// Reloads some changeable visual settings.
|
||||
void refreshVisualProperties();
|
||||
|
||||
|
|
|
@ -317,7 +317,8 @@ void Application::onAboutToQuit() {
|
|||
system()->removeTrolltechJunkRegistryKeys();
|
||||
#endif
|
||||
|
||||
mainForm()->tabWidget()->feedMessageViewer()->quit();
|
||||
qApp->feedReader()->stop();
|
||||
|
||||
database()->saveDatabase();
|
||||
mainForm()->saveSize();
|
||||
|
||||
|
|
|
@ -232,6 +232,10 @@ void FeedReader::stop() {
|
|||
qDebug("Database cleaner exists. Deleting it from memory.");
|
||||
m_dbCleaner->deleteLater();
|
||||
}
|
||||
|
||||
if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::ClearReadOnExit)).toBool()) {
|
||||
m_feedsModel->markItemCleared(m_feedsModel->rootItem(), true);
|
||||
}
|
||||
}
|
||||
|
||||
MessagesProxyModel *FeedReader::messagesProxyModel() const {
|
||||
|
|
|
@ -61,7 +61,7 @@ class FeedReader : public QObject {
|
|||
// and starts/stop the timer as needed.
|
||||
void updateAutoUpdateStatus();
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
// Schedules all feeds from all accounts for update.
|
||||
void updateAllFeeds();
|
||||
|
||||
|
|
Loading…
Reference in New Issue