From 9b167f13e22838d39ec5b1e16b14b544d00ed80b Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 16 Aug 2016 11:35:02 +0200 Subject: [PATCH] Refactoring. --- src/core/feedsmodel.cpp | 17 ++--------- src/core/feedsmodel.h | 15 +++++----- src/core/feedsproxymodel.cpp | 2 -- src/core/messagesmodel.cpp | 2 +- src/core/messagesmodel.h | 4 +-- src/dynamic-shortcuts/dynamicshortcuts.cpp | 4 +-- src/dynamic-shortcuts/dynamicshortcuts.h | 4 +-- .../dynamicshortcutswidget.cpp | 2 -- src/dynamic-shortcuts/shortcutcatcher.cpp | 22 +++++++++++++++ src/dynamic-shortcuts/shortcutcatcher.h | 28 ++++--------------- src/miscellaneous/feedreader.cpp | 8 ++++-- src/miscellaneous/feedreader.h | 3 -- 12 files changed, 49 insertions(+), 62 deletions(-) diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index b7688fc46..723fab65d 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -22,26 +22,18 @@ #include "services/abstract/category.h" #include "services/abstract/serviceroot.h" #include "services/abstract/recyclebin.h" +#include "services/abstract/serviceentrypoint.h" #include "services/standard/standardserviceroot.h" #include "miscellaneous/textfactory.h" #include "miscellaneous/databasefactory.h" -#include "miscellaneous/databasecleaner.h" #include "miscellaneous/iconfactory.h" -#include "miscellaneous/mutex.h" #include "miscellaneous/feedreader.h" -#include "gui/messagebox.h" -#include "gui/statusbar.h" -#include "gui/dialogs/formmain.h" -#include "core/feeddownloader.h" -#include "services/abstract/serviceentrypoint.h" -#include #include #include #include #include #include -#include #include @@ -141,7 +133,7 @@ bool FeedsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int qApp->showGuiMessage(tr("Cannot perform drag & drop operation"), tr("You can't transfer dragged item into different account, this is not supported."), QSystemTrayIcon::Warning, - qApp->mainForm(), + qApp->mainFormWidget(), true); qDebug("Dragged item cannot be dragged into different account. Cancelling drag-drop action."); @@ -548,11 +540,6 @@ void FeedsModel::loadActivatedServiceAccounts() { addServiceAccount(root, false); } } - - if (qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool()) { - qDebug("Requesting update for all feeds on application startup."); - QTimer::singleShot(STARTUP_UPDATE_DELAY, this, SLOT(updateAllFeeds())); - } } QList FeedsModel::feedsForIndex(const QModelIndex &index) const { diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index f61ea338d..9b129c693 100755 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -21,7 +21,6 @@ #include #include "core/message.h" -#include "core/feeddownloader.h" #include "services/abstract/rootitem.h" class Category; @@ -62,10 +61,6 @@ class FeedsModel : public QAbstractItemModel { int countOfAllMessages() const; int countOfUnreadMessages() const; - // Removes item with given index. - // NOTE: Also deletes item from memory. - void removeItem(const QModelIndex &index); - // Returns all activated service roots. // NOTE: Service root nodes are lying directly UNDER // the model root item. @@ -110,9 +105,6 @@ class FeedsModel : public QAbstractItemModel { // Access to root item. RootItem *rootItem() const; - // Adds given service root account. - bool addServiceAccount(ServiceRoot *root, bool freshly_activated); - public slots: // Loads feed/categories from the database. void loadActivatedServiceAccounts(); @@ -124,6 +116,13 @@ class FeedsModel : public QAbstractItemModel { // If it is, then it reassigns original_node to new parent. void reassignNodeToNewParent(RootItem *original_node, RootItem *new_parent); + // Adds given service root account. + bool addServiceAccount(ServiceRoot *root, bool freshly_activated); + + // Removes item with given index. + // NOTE: Also deletes item from memory. + void removeItem(const QModelIndex &index); + // Removes given item from the model/memory. void removeItem(RootItem *deleting_item); diff --git a/src/core/feedsproxymodel.cpp b/src/core/feedsproxymodel.cpp index 0c83937ba..1200a84c3 100755 --- a/src/core/feedsproxymodel.cpp +++ b/src/core/feedsproxymodel.cpp @@ -21,8 +21,6 @@ #include "miscellaneous/application.h" #include "core/feedsmodel.h" #include "services/abstract/rootitem.h" -#include "services/standard/standardcategory.h" -#include "services/standard/standardfeed.h" #include diff --git a/src/core/messagesmodel.cpp b/src/core/messagesmodel.cpp index d34975203..c0ca29790 100755 --- a/src/core/messagesmodel.cpp +++ b/src/core/messagesmodel.cpp @@ -22,8 +22,8 @@ #include "miscellaneous/textfactory.h" #include "miscellaneous/databasefactory.h" #include "miscellaneous/iconfactory.h" -#include "services/abstract/serviceroot.h" #include "miscellaneous/databasequeries.h" +#include "services/abstract/serviceroot.h" MessagesModel::MessagesModel(QObject *parent) diff --git a/src/core/messagesmodel.h b/src/core/messagesmodel.h index 985274f7f..b86c9022f 100755 --- a/src/core/messagesmodel.h +++ b/src/core/messagesmodel.h @@ -18,12 +18,12 @@ #ifndef MESSAGESMODEL_H #define MESSAGESMODEL_H -#include "definitions/definitions.h" +#include +#include "definitions/definitions.h" #include "core/message.h" #include "services/abstract/rootitem.h" -#include #include #include diff --git a/src/dynamic-shortcuts/dynamicshortcuts.cpp b/src/dynamic-shortcuts/dynamicshortcuts.cpp index 2f10bb794..28807329d 100755 --- a/src/dynamic-shortcuts/dynamicshortcuts.cpp +++ b/src/dynamic-shortcuts/dynamicshortcuts.cpp @@ -27,7 +27,7 @@ DynamicShortcuts::DynamicShortcuts() { } -void DynamicShortcuts::save(const QList actions) { +void DynamicShortcuts::save(const QList &actions) { Settings *settings = qApp->settings(); foreach (const QAction *action, actions) { @@ -35,7 +35,7 @@ void DynamicShortcuts::save(const QList actions) { } } -void DynamicShortcuts::load(const QList actions) { +void DynamicShortcuts::load(const QList &actions) { Settings *settings = qApp->settings(); foreach (QAction *action, actions) { diff --git a/src/dynamic-shortcuts/dynamicshortcuts.h b/src/dynamic-shortcuts/dynamicshortcuts.h index a68fae5d2..28eee6457 100755 --- a/src/dynamic-shortcuts/dynamicshortcuts.h +++ b/src/dynamic-shortcuts/dynamicshortcuts.h @@ -27,11 +27,11 @@ class DynamicShortcuts { public: // Checks the application settings and then initializes shortcut of // each action from actions from the settings. - static void load(const QList actions); + static void load(const QList &actions); // Stores shortcut of each action from actions into the application // settings. - static void save(const QList actions); + static void save(const QList &actions); private: // Constructor. diff --git a/src/dynamic-shortcuts/dynamicshortcutswidget.cpp b/src/dynamic-shortcuts/dynamicshortcutswidget.cpp index 7a9f9c0e4..082b38ec8 100755 --- a/src/dynamic-shortcuts/dynamicshortcutswidget.cpp +++ b/src/dynamic-shortcuts/dynamicshortcutswidget.cpp @@ -24,8 +24,6 @@ #include #include #include -#include -#include DynamicShortcutsWidget::DynamicShortcutsWidget(QWidget *parent) : QWidget(parent) { diff --git a/src/dynamic-shortcuts/shortcutcatcher.cpp b/src/dynamic-shortcuts/shortcutcatcher.cpp index 74ad2ddf4..52cae0341 100755 --- a/src/dynamic-shortcuts/shortcutcatcher.cpp +++ b/src/dynamic-shortcuts/shortcutcatcher.cpp @@ -150,3 +150,25 @@ void ShortcutCatcher::updateDisplayShortcut() { m_btnChange->setText(str); } + +QKeySequence ShortcutCatcher::shortcut() const { + return m_currentSequence; +} + +void ShortcutCatcher::setDefaultShortcut(const QKeySequence &key) { + m_defaultSequence = key; + setShortcut(key); +} + +void ShortcutCatcher::setShortcut(const QKeySequence &key) { + m_currentSequence = key; + doneRecording(); +} + +void ShortcutCatcher::resetShortcut() { + setShortcut(m_defaultSequence); +} + +void ShortcutCatcher::clearShortcut() { + setShortcut(QKeySequence()); +} diff --git a/src/dynamic-shortcuts/shortcutcatcher.h b/src/dynamic-shortcuts/shortcutcatcher.h index 9968f8533..119e26a16 100755 --- a/src/dynamic-shortcuts/shortcutcatcher.h +++ b/src/dynamic-shortcuts/shortcutcatcher.h @@ -57,7 +57,6 @@ class ShortcutCatcher : public QWidget { Q_OBJECT friend class ShortcutButton; - friend class DynamicShortcutsWidget; public: // Constructors and destructors. @@ -67,30 +66,15 @@ class ShortcutCatcher : public QWidget { void controlModifierlessTimout(); void updateDisplayShortcut(); - inline QKeySequence shortcut() const { - return m_currentSequence; - } - - inline void setDefaultShortcut(const QKeySequence &key) { - m_defaultSequence = key; - setShortcut(key); - } - - inline void setShortcut(const QKeySequence &key) { - m_currentSequence = key; - doneRecording(); - } + QKeySequence shortcut() const; + void setDefaultShortcut(const QKeySequence &key); + void setShortcut(const QKeySequence &key); public slots: - inline void resetShortcut() { - setShortcut(m_defaultSequence); - } + void resetShortcut(); + void clearShortcut(); - inline void clearShortcut() { - setShortcut(QKeySequence()); - } - - protected slots: + private slots: void startRecording(); void doneRecording(); diff --git a/src/miscellaneous/feedreader.cpp b/src/miscellaneous/feedreader.cpp index 630f60687..021a2ed37 100755 --- a/src/miscellaneous/feedreader.cpp +++ b/src/miscellaneous/feedreader.cpp @@ -45,6 +45,11 @@ FeedReader::FeedReader(QObject *parent) connect(m_autoUpdateTimer, &QTimer::timeout, this, &FeedReader::executeNextAutoUpdate); updateAutoUpdateStatus(); + + if (qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool()) { + qDebug("Requesting update for all feeds on application startup."); + QTimer::singleShot(STARTUP_UPDATE_DELAY, this, SLOT(updateAllFeeds())); + } } FeedReader::~FeedReader() { @@ -158,9 +163,6 @@ MessagesModel *FeedReader::messagesModel() const { return m_messagesModel; } -void FeedReader::start() { -} - void FeedReader::executeNextAutoUpdate() { if (!qApp->feedUpdateLock()->tryLock()) { qDebug("Delaying scheduled feed auto-updates for one minute due to another running update."); diff --git a/src/miscellaneous/feedreader.h b/src/miscellaneous/feedreader.h index afdb22a0e..a1a994bc4 100755 --- a/src/miscellaneous/feedreader.h +++ b/src/miscellaneous/feedreader.h @@ -64,10 +64,7 @@ class FeedReader : public QObject { public slots: // Schedules all feeds from all accounts for update. void updateAllFeeds(); - void stopRunningFeedUpdate(); - - void start(); void stop(); private slots: