Refactoring.
This commit is contained in:
parent
d78cc3b1a1
commit
9b167f13e2
@ -22,26 +22,18 @@
|
|||||||
#include "services/abstract/category.h"
|
#include "services/abstract/category.h"
|
||||||
#include "services/abstract/serviceroot.h"
|
#include "services/abstract/serviceroot.h"
|
||||||
#include "services/abstract/recyclebin.h"
|
#include "services/abstract/recyclebin.h"
|
||||||
|
#include "services/abstract/serviceentrypoint.h"
|
||||||
#include "services/standard/standardserviceroot.h"
|
#include "services/standard/standardserviceroot.h"
|
||||||
#include "miscellaneous/textfactory.h"
|
#include "miscellaneous/textfactory.h"
|
||||||
#include "miscellaneous/databasefactory.h"
|
#include "miscellaneous/databasefactory.h"
|
||||||
#include "miscellaneous/databasecleaner.h"
|
|
||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
#include "miscellaneous/mutex.h"
|
|
||||||
#include "miscellaneous/feedreader.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 <QSqlError>
|
||||||
#include <QSqlRecord>
|
#include <QSqlRecord>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QStack>
|
#include <QStack>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -141,7 +133,7 @@ bool FeedsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int
|
|||||||
qApp->showGuiMessage(tr("Cannot perform drag & drop operation"),
|
qApp->showGuiMessage(tr("Cannot perform drag & drop operation"),
|
||||||
tr("You can't transfer dragged item into different account, this is not supported."),
|
tr("You can't transfer dragged item into different account, this is not supported."),
|
||||||
QSystemTrayIcon::Warning,
|
QSystemTrayIcon::Warning,
|
||||||
qApp->mainForm(),
|
qApp->mainFormWidget(),
|
||||||
true);
|
true);
|
||||||
|
|
||||||
qDebug("Dragged item cannot be dragged into different account. Cancelling drag-drop action.");
|
qDebug("Dragged item cannot be dragged into different account. Cancelling drag-drop action.");
|
||||||
@ -548,11 +540,6 @@ void FeedsModel::loadActivatedServiceAccounts() {
|
|||||||
addServiceAccount(root, false);
|
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 {
|
QList<Feed*> FeedsModel::feedsForIndex(const QModelIndex &index) const {
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
#include "core/message.h"
|
#include "core/message.h"
|
||||||
#include "core/feeddownloader.h"
|
|
||||||
#include "services/abstract/rootitem.h"
|
#include "services/abstract/rootitem.h"
|
||||||
|
|
||||||
class Category;
|
class Category;
|
||||||
@ -62,10 +61,6 @@ class FeedsModel : public QAbstractItemModel {
|
|||||||
int countOfAllMessages() const;
|
int countOfAllMessages() const;
|
||||||
int countOfUnreadMessages() 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.
|
// Returns all activated service roots.
|
||||||
// NOTE: Service root nodes are lying directly UNDER
|
// NOTE: Service root nodes are lying directly UNDER
|
||||||
// the model root item.
|
// the model root item.
|
||||||
@ -110,9 +105,6 @@ class FeedsModel : public QAbstractItemModel {
|
|||||||
// Access to root item.
|
// Access to root item.
|
||||||
RootItem *rootItem() const;
|
RootItem *rootItem() const;
|
||||||
|
|
||||||
// Adds given service root account.
|
|
||||||
bool addServiceAccount(ServiceRoot *root, bool freshly_activated);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// Loads feed/categories from the database.
|
// Loads feed/categories from the database.
|
||||||
void loadActivatedServiceAccounts();
|
void loadActivatedServiceAccounts();
|
||||||
@ -124,6 +116,13 @@ class FeedsModel : public QAbstractItemModel {
|
|||||||
// If it is, then it reassigns original_node to new parent.
|
// If it is, then it reassigns original_node to new parent.
|
||||||
void reassignNodeToNewParent(RootItem *original_node, RootItem *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.
|
// Removes given item from the model/memory.
|
||||||
void removeItem(RootItem *deleting_item);
|
void removeItem(RootItem *deleting_item);
|
||||||
|
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
#include "miscellaneous/application.h"
|
#include "miscellaneous/application.h"
|
||||||
#include "core/feedsmodel.h"
|
#include "core/feedsmodel.h"
|
||||||
#include "services/abstract/rootitem.h"
|
#include "services/abstract/rootitem.h"
|
||||||
#include "services/standard/standardcategory.h"
|
|
||||||
#include "services/standard/standardfeed.h"
|
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
#include "miscellaneous/textfactory.h"
|
#include "miscellaneous/textfactory.h"
|
||||||
#include "miscellaneous/databasefactory.h"
|
#include "miscellaneous/databasefactory.h"
|
||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
#include "services/abstract/serviceroot.h"
|
|
||||||
#include "miscellaneous/databasequeries.h"
|
#include "miscellaneous/databasequeries.h"
|
||||||
|
#include "services/abstract/serviceroot.h"
|
||||||
|
|
||||||
|
|
||||||
MessagesModel::MessagesModel(QObject *parent)
|
MessagesModel::MessagesModel(QObject *parent)
|
||||||
|
@ -18,12 +18,12 @@
|
|||||||
#ifndef MESSAGESMODEL_H
|
#ifndef MESSAGESMODEL_H
|
||||||
#define MESSAGESMODEL_H
|
#define MESSAGESMODEL_H
|
||||||
|
|
||||||
#include "definitions/definitions.h"
|
#include <QSqlTableModel>
|
||||||
|
|
||||||
|
#include "definitions/definitions.h"
|
||||||
#include "core/message.h"
|
#include "core/message.h"
|
||||||
#include "services/abstract/rootitem.h"
|
#include "services/abstract/rootitem.h"
|
||||||
|
|
||||||
#include <QSqlTableModel>
|
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
DynamicShortcuts::DynamicShortcuts() {
|
DynamicShortcuts::DynamicShortcuts() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicShortcuts::save(const QList<QAction*> actions) {
|
void DynamicShortcuts::save(const QList<QAction*> &actions) {
|
||||||
Settings *settings = qApp->settings();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
foreach (const QAction *action, actions) {
|
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();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
foreach (QAction *action, actions) {
|
foreach (QAction *action, actions) {
|
||||||
|
@ -27,11 +27,11 @@ class DynamicShortcuts {
|
|||||||
public:
|
public:
|
||||||
// Checks the application settings and then initializes shortcut of
|
// Checks the application settings and then initializes shortcut of
|
||||||
// each action from actions from the settings.
|
// 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
|
// Stores shortcut of each action from actions into the application
|
||||||
// settings.
|
// settings.
|
||||||
static void save(const QList<QAction*> actions);
|
static void save(const QList<QAction*> &actions);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Constructor.
|
// Constructor.
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QSpacerItem>
|
|
||||||
#include <QPalette>
|
|
||||||
|
|
||||||
|
|
||||||
DynamicShortcutsWidget::DynamicShortcutsWidget(QWidget *parent) : QWidget(parent) {
|
DynamicShortcutsWidget::DynamicShortcutsWidget(QWidget *parent) : QWidget(parent) {
|
||||||
|
@ -150,3 +150,25 @@ void ShortcutCatcher::updateDisplayShortcut() {
|
|||||||
|
|
||||||
m_btnChange->setText(str);
|
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());
|
||||||
|
}
|
||||||
|
@ -57,7 +57,6 @@ class ShortcutCatcher : public QWidget {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
friend class ShortcutButton;
|
friend class ShortcutButton;
|
||||||
friend class DynamicShortcutsWidget;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructors and destructors.
|
// Constructors and destructors.
|
||||||
@ -67,30 +66,15 @@ class ShortcutCatcher : public QWidget {
|
|||||||
void controlModifierlessTimout();
|
void controlModifierlessTimout();
|
||||||
void updateDisplayShortcut();
|
void updateDisplayShortcut();
|
||||||
|
|
||||||
inline QKeySequence shortcut() const {
|
QKeySequence shortcut() const;
|
||||||
return m_currentSequence;
|
void setDefaultShortcut(const QKeySequence &key);
|
||||||
}
|
void setShortcut(const QKeySequence &key);
|
||||||
|
|
||||||
inline void setDefaultShortcut(const QKeySequence &key) {
|
|
||||||
m_defaultSequence = key;
|
|
||||||
setShortcut(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void setShortcut(const QKeySequence &key) {
|
|
||||||
m_currentSequence = key;
|
|
||||||
doneRecording();
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
inline void resetShortcut() {
|
void resetShortcut();
|
||||||
setShortcut(m_defaultSequence);
|
void clearShortcut();
|
||||||
}
|
|
||||||
|
|
||||||
inline void clearShortcut() {
|
private slots:
|
||||||
setShortcut(QKeySequence());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected slots:
|
|
||||||
void startRecording();
|
void startRecording();
|
||||||
void doneRecording();
|
void doneRecording();
|
||||||
|
|
||||||
|
@ -45,6 +45,11 @@ FeedReader::FeedReader(QObject *parent)
|
|||||||
|
|
||||||
connect(m_autoUpdateTimer, &QTimer::timeout, this, &FeedReader::executeNextAutoUpdate);
|
connect(m_autoUpdateTimer, &QTimer::timeout, this, &FeedReader::executeNextAutoUpdate);
|
||||||
updateAutoUpdateStatus();
|
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() {
|
FeedReader::~FeedReader() {
|
||||||
@ -158,9 +163,6 @@ MessagesModel *FeedReader::messagesModel() const {
|
|||||||
return m_messagesModel;
|
return m_messagesModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedReader::start() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void FeedReader::executeNextAutoUpdate() {
|
void FeedReader::executeNextAutoUpdate() {
|
||||||
if (!qApp->feedUpdateLock()->tryLock()) {
|
if (!qApp->feedUpdateLock()->tryLock()) {
|
||||||
qDebug("Delaying scheduled feed auto-updates for one minute due to another running update.");
|
qDebug("Delaying scheduled feed auto-updates for one minute due to another running update.");
|
||||||
|
@ -64,10 +64,7 @@ class FeedReader : public QObject {
|
|||||||
public slots:
|
public slots:
|
||||||
// Schedules all feeds from all accounts for update.
|
// Schedules all feeds from all accounts for update.
|
||||||
void updateAllFeeds();
|
void updateAllFeeds();
|
||||||
|
|
||||||
void stopRunningFeedUpdate();
|
void stopRunningFeedUpdate();
|
||||||
|
|
||||||
void start();
|
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user