Refactoring.

This commit is contained in:
Martin Rotter 2016-08-16 11:35:02 +02:00
parent d78cc3b1a1
commit 9b167f13e2
12 changed files with 49 additions and 62 deletions

View File

@ -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 <QThread>
#include <QSqlError>
#include <QSqlRecord>
#include <QPair>
#include <QStack>
#include <QMimeData>
#include <QTimer>
#include <algorithm>
@ -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<Feed*> FeedsModel::feedsForIndex(const QModelIndex &index) const {

View File

@ -21,7 +21,6 @@
#include <QAbstractItemModel>
#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);

View File

@ -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 <QTimer>

View File

@ -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)

View File

@ -18,12 +18,12 @@
#ifndef MESSAGESMODEL_H
#define MESSAGESMODEL_H
#include "definitions/definitions.h"
#include <QSqlTableModel>
#include "definitions/definitions.h"
#include "core/message.h"
#include "services/abstract/rootitem.h"
#include <QSqlTableModel>
#include <QFont>
#include <QIcon>

View File

@ -27,7 +27,7 @@
DynamicShortcuts::DynamicShortcuts() {
}
void DynamicShortcuts::save(const QList<QAction*> actions) {
void DynamicShortcuts::save(const QList<QAction*> &actions) {
Settings *settings = qApp->settings();
foreach (const QAction *action, actions) {
@ -35,7 +35,7 @@ void DynamicShortcuts::save(const QList<QAction*> actions) {
}
}
void DynamicShortcuts::load(const QList<QAction*> actions) {
void DynamicShortcuts::load(const QList<QAction *> &actions) {
Settings *settings = qApp->settings();
foreach (QAction *action, actions) {

View File

@ -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<QAction*> actions);
static void load(const QList<QAction*> &actions);
// Stores shortcut of each action from actions into the application
// settings.
static void save(const QList<QAction*> actions);
static void save(const QList<QAction*> &actions);
private:
// Constructor.

View File

@ -24,8 +24,6 @@
#include <QGridLayout>
#include <QAction>
#include <QLabel>
#include <QSpacerItem>
#include <QPalette>
DynamicShortcutsWidget::DynamicShortcutsWidget(QWidget *parent) : QWidget(parent) {

View File

@ -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());
}

View File

@ -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();

View File

@ -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.");

View File

@ -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: