Refactoring.
This commit is contained in:
parent
d8ecbcac04
commit
b62dcd2926
8 changed files with 34 additions and 41 deletions
|
@ -277,6 +277,14 @@ int FeedsModel::rowCount(const QModelIndex &parent) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int FeedsModel::countOfAllMessages() const {
|
||||||
|
return m_rootItem->countOfAllMessages();
|
||||||
|
}
|
||||||
|
|
||||||
|
int FeedsModel::countOfUnreadMessages() const {
|
||||||
|
return m_rootItem->countOfUnreadMessages();
|
||||||
|
}
|
||||||
|
|
||||||
void FeedsModel::reloadCountsOfWholeModel() {
|
void FeedsModel::reloadCountsOfWholeModel() {
|
||||||
m_rootItem->updateCounts(true);
|
m_rootItem->updateCounts(true);
|
||||||
reloadWholeLayout();
|
reloadWholeLayout();
|
||||||
|
@ -464,6 +472,10 @@ bool FeedsModel::hasAnyFeedNewMessages() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RootItem *FeedsModel::rootItem() const {
|
||||||
|
return m_rootItem;
|
||||||
|
}
|
||||||
|
|
||||||
void FeedsModel::reloadChangedLayout(QModelIndexList list) {
|
void FeedsModel::reloadChangedLayout(QModelIndexList list) {
|
||||||
while (!list.isEmpty()) {
|
while (!list.isEmpty()) {
|
||||||
QModelIndex indx = list.takeFirst();
|
QModelIndex indx = list.takeFirst();
|
||||||
|
@ -486,6 +498,7 @@ void FeedsModel::reloadChangedItem(RootItem *item) {
|
||||||
|
|
||||||
void FeedsModel::notifyWithCounts() {
|
void FeedsModel::notifyWithCounts() {
|
||||||
if (SystemTrayIcon::isSystemTrayActivated()) {
|
if (SystemTrayIcon::isSystemTrayActivated()) {
|
||||||
|
// TODO: Udělat přes signál, jádro by nemělo inkludovat GUI prvky.
|
||||||
qApp->trayIcon()->setNumber(countOfUnreadMessages(), hasAnyFeedNewMessages());
|
qApp->trayIcon()->setNumber(countOfUnreadMessages(), hasAnyFeedNewMessages());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,11 @@
|
||||||
#include "core/feeddownloader.h"
|
#include "core/feeddownloader.h"
|
||||||
#include "services/abstract/rootitem.h"
|
#include "services/abstract/rootitem.h"
|
||||||
|
|
||||||
class DatabaseCleaner;
|
|
||||||
class Category;
|
class Category;
|
||||||
class Feed;
|
class Feed;
|
||||||
class ServiceRoot;
|
class ServiceRoot;
|
||||||
class ServiceEntryPoint;
|
class ServiceEntryPoint;
|
||||||
class StandardServiceRoot;
|
class StandardServiceRoot;
|
||||||
class QTimer;
|
|
||||||
|
|
||||||
class FeedsModel : public QAbstractItemModel {
|
class FeedsModel : public QAbstractItemModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -61,15 +59,8 @@ class FeedsModel : public QAbstractItemModel {
|
||||||
int rowCount(const QModelIndex &parent) const;
|
int rowCount(const QModelIndex &parent) const;
|
||||||
|
|
||||||
// Returns counts of ALL/UNREAD (non-deleted) messages for the model.
|
// Returns counts of ALL/UNREAD (non-deleted) messages for the model.
|
||||||
inline int countOfAllMessages() const {
|
int countOfAllMessages() const;
|
||||||
return m_rootItem->countOfAllMessages();
|
int countOfUnreadMessages() const;
|
||||||
}
|
|
||||||
|
|
||||||
inline int countOfUnreadMessages() const {
|
|
||||||
return m_rootItem->countOfUnreadMessages();
|
|
||||||
}
|
|
||||||
|
|
||||||
void reloadCountsOfWholeModel();
|
|
||||||
|
|
||||||
// Removes item with given index.
|
// Removes item with given index.
|
||||||
// NOTE: Also deletes item from memory.
|
// NOTE: Also deletes item from memory.
|
||||||
|
@ -117,20 +108,21 @@ class FeedsModel : public QAbstractItemModel {
|
||||||
bool hasAnyFeedNewMessages() const;
|
bool hasAnyFeedNewMessages() const;
|
||||||
|
|
||||||
// Access to root item.
|
// Access to root item.
|
||||||
inline RootItem *rootItem() const {
|
RootItem *rootItem() const;
|
||||||
return m_rootItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Does necessary job before quitting this component.
|
|
||||||
void quit();
|
|
||||||
|
|
||||||
// Adds given service root account.
|
// Adds given service root account.
|
||||||
bool addServiceAccount(ServiceRoot *root, bool freshly_activated);
|
bool addServiceAccount(ServiceRoot *root, bool freshly_activated);
|
||||||
|
|
||||||
|
public slots:
|
||||||
// Loads feed/categories from the database.
|
// Loads feed/categories from the database.
|
||||||
void loadActivatedServiceAccounts();
|
void loadActivatedServiceAccounts();
|
||||||
|
|
||||||
public slots:
|
// Does necessary job before quitting this component.
|
||||||
|
void quit();
|
||||||
|
|
||||||
|
// Reloads counts of all feeds/categories/whatever in the model.
|
||||||
|
void reloadCountsOfWholeModel();
|
||||||
|
|
||||||
// Checks if new parent node is different from one used by original node.
|
// Checks if new parent node is different from one used by original node.
|
||||||
// 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);
|
||||||
|
|
|
@ -32,11 +32,6 @@ class FeedsProxyModel : public QSortFilterProxyModel {
|
||||||
explicit FeedsProxyModel(FeedsModel *source_model, QObject *parent = 0);
|
explicit FeedsProxyModel(FeedsModel *source_model, QObject *parent = 0);
|
||||||
virtual ~FeedsProxyModel();
|
virtual ~FeedsProxyModel();
|
||||||
|
|
||||||
// Access to the source model.
|
|
||||||
inline FeedsModel *sourceModel() const {
|
|
||||||
return m_sourceModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns index list of items which "match" given value.
|
// Returns index list of items which "match" given value.
|
||||||
// Used for finding items according to entered title text.
|
// Used for finding items according to entered title text.
|
||||||
QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const;
|
QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const;
|
||||||
|
|
|
@ -31,11 +31,6 @@ class MessagesProxyModel : public QSortFilterProxyModel {
|
||||||
explicit MessagesProxyModel(MessagesModel *source_model, QObject *parent = 0);
|
explicit MessagesProxyModel(MessagesModel *source_model, QObject *parent = 0);
|
||||||
virtual ~MessagesProxyModel();
|
virtual ~MessagesProxyModel();
|
||||||
|
|
||||||
// Source model getter.
|
|
||||||
inline MessagesModel *sourceModel() {
|
|
||||||
return m_sourceModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
QModelIndex getNextPreviousUnreadItemIndex(int default_row);
|
QModelIndex getNextPreviousUnreadItemIndex(int default_row);
|
||||||
|
|
||||||
// Maps list of indexes.
|
// Maps list of indexes.
|
||||||
|
@ -45,6 +40,7 @@ class MessagesProxyModel : public QSortFilterProxyModel {
|
||||||
// Fix for matching indexes with respect to specifics of the message model.
|
// Fix for matching indexes with respect to specifics of the message model.
|
||||||
QModelIndexList match(const QModelIndex &start, int role, const QVariant &entered_value, int hits, Qt::MatchFlags flags) const;
|
QModelIndexList match(const QModelIndex &start, int role, const QVariant &entered_value, int hits, Qt::MatchFlags flags) const;
|
||||||
|
|
||||||
|
// Performs sort of items.
|
||||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -301,7 +301,7 @@ void FeedMessageViewer::createConnections() {
|
||||||
connect(form_main->m_ui->m_actionUpdateSelectedItems,
|
connect(form_main->m_ui->m_actionUpdateSelectedItems,
|
||||||
SIGNAL(triggered()), m_feedsView, SLOT(updateSelectedItems()));
|
SIGNAL(triggered()), m_feedsView, SLOT(updateSelectedItems()));
|
||||||
connect(form_main->m_ui->m_actionUpdateAllItems,
|
connect(form_main->m_ui->m_actionUpdateAllItems,
|
||||||
SIGNAL(triggered()), m_feedsView, SLOT(updateAllItems()));
|
SIGNAL(triggered()), qApp->feedReader(), SLOT(updateAllFeeds()));
|
||||||
connect(form_main->m_ui->m_actionStopRunningItemsUpdate,
|
connect(form_main->m_ui->m_actionStopRunningItemsUpdate,
|
||||||
SIGNAL(triggered()), m_feedsView->sourceModel(), SLOT(stopRunningFeedUpdate()));
|
SIGNAL(triggered()), m_feedsView->sourceModel(), SLOT(stopRunningFeedUpdate()));
|
||||||
connect(form_main->m_ui->m_actionEditSelectedItem,
|
connect(form_main->m_ui->m_actionEditSelectedItem,
|
||||||
|
|
|
@ -202,10 +202,6 @@ void FeedsView::expandCollapseCurrentItem() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::updateAllItems() {
|
|
||||||
qApp->feedReader()->updateAllFeeds();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FeedsView::updateSelectedItems() {
|
void FeedsView::updateSelectedItems() {
|
||||||
qApp->feedReader()->updateFeeds(selectedFeeds());
|
qApp->feedReader()->updateFeeds(selectedFeeds());
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,6 @@ class FeedsView : public QTreeView {
|
||||||
void expandCollapseCurrentItem();
|
void expandCollapseCurrentItem();
|
||||||
|
|
||||||
// Feed updating.
|
// Feed updating.
|
||||||
void updateAllItems();
|
|
||||||
void updateSelectedItems();
|
void updateSelectedItems();
|
||||||
|
|
||||||
// Feed read/unread manipulators.
|
// Feed read/unread manipulators.
|
||||||
|
|
16
src/main.cpp
16
src/main.cpp
|
@ -96,12 +96,14 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// Add an extra path for non-system icon themes and set current icon theme
|
// Add an extra path for non-system icon themes and set current icon theme
|
||||||
// and skin.
|
// and skin.
|
||||||
qApp->icons()->setupSearchPaths();
|
if (!run_minimal_without_gui) {
|
||||||
qApp->icons()->loadCurrentIconTheme();
|
qApp->icons()->setupSearchPaths();
|
||||||
qApp->skins()->loadCurrentSkin();
|
qApp->icons()->loadCurrentIconTheme();
|
||||||
|
qApp->skins()->loadCurrentSkin();
|
||||||
|
|
||||||
// Load localization and setup locale before any widget is constructed.
|
// Load localization and setup locale before any widget is constructed.
|
||||||
qApp->localization()->loadActiveLanguage();
|
qApp->localization()->loadActiveLanguage();
|
||||||
|
}
|
||||||
|
|
||||||
// These settings needs to be set before any QSettings object.
|
// These settings needs to be set before any QSettings object.
|
||||||
Application::setApplicationName(APP_NAME);
|
Application::setApplicationName(APP_NAME);
|
||||||
|
@ -110,8 +112,6 @@ int main(int argc, char *argv[]) {
|
||||||
Application::setOrganizationDomain(APP_URL);
|
Application::setOrganizationDomain(APP_URL);
|
||||||
Application::setWindowIcon(QIcon(APP_ICON_PATH));
|
Application::setWindowIcon(QIcon(APP_ICON_PATH));
|
||||||
|
|
||||||
qDebug().nospace() << "Creating main application form in thread: \'" << QThread::currentThreadId() << "\'.";
|
|
||||||
|
|
||||||
// Load activated accounts.
|
// Load activated accounts.
|
||||||
qApp->feedReader()->feedsModel()->loadActivatedServiceAccounts();
|
qApp->feedReader()->feedsModel()->loadActivatedServiceAccounts();
|
||||||
|
|
||||||
|
@ -119,6 +119,8 @@ int main(int argc, char *argv[]) {
|
||||||
QObject::connect(&application, &Application::messageReceived, &application, &Application::processExecutionMessage);
|
QObject::connect(&application, &Application::messageReceived, &application, &Application::processExecutionMessage);
|
||||||
|
|
||||||
if (!run_minimal_without_gui) {
|
if (!run_minimal_without_gui) {
|
||||||
|
qDebug().nospace() << "Creating main application form in thread: \'" << QThread::currentThreadId() << "\'.";
|
||||||
|
|
||||||
// Instantiate main application window.
|
// Instantiate main application window.
|
||||||
FormMain main_window;
|
FormMain main_window;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue