diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 4e8a3a183..cec8e3ed9 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -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() { m_rootItem->updateCounts(true); reloadWholeLayout(); @@ -464,6 +472,10 @@ bool FeedsModel::hasAnyFeedNewMessages() const { return false; } +RootItem *FeedsModel::rootItem() const { + return m_rootItem; +} + void FeedsModel::reloadChangedLayout(QModelIndexList list) { while (!list.isEmpty()) { QModelIndex indx = list.takeFirst(); @@ -486,6 +498,7 @@ void FeedsModel::reloadChangedItem(RootItem *item) { void FeedsModel::notifyWithCounts() { if (SystemTrayIcon::isSystemTrayActivated()) { + // TODO: Udělat přes signál, jádro by nemělo inkludovat GUI prvky. qApp->trayIcon()->setNumber(countOfUnreadMessages(), hasAnyFeedNewMessages()); } } diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index ca1a84a7e..8fb606d30 100755 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -24,13 +24,11 @@ #include "core/feeddownloader.h" #include "services/abstract/rootitem.h" -class DatabaseCleaner; class Category; class Feed; class ServiceRoot; class ServiceEntryPoint; class StandardServiceRoot; -class QTimer; class FeedsModel : public QAbstractItemModel { Q_OBJECT @@ -61,15 +59,8 @@ class FeedsModel : public QAbstractItemModel { int rowCount(const QModelIndex &parent) const; // Returns counts of ALL/UNREAD (non-deleted) messages for the model. - inline int countOfAllMessages() const { - return m_rootItem->countOfAllMessages(); - } - - inline int countOfUnreadMessages() const { - return m_rootItem->countOfUnreadMessages(); - } - - void reloadCountsOfWholeModel(); + int countOfAllMessages() const; + int countOfUnreadMessages() const; // Removes item with given index. // NOTE: Also deletes item from memory. @@ -117,20 +108,21 @@ class FeedsModel : public QAbstractItemModel { bool hasAnyFeedNewMessages() const; // Access to root item. - inline RootItem *rootItem() const { - return m_rootItem; - } - - // Does necessary job before quitting this component. - void quit(); + 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(); - 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. // If it is, then it reassigns original_node to new parent. void reassignNodeToNewParent(RootItem *original_node, RootItem *new_parent); diff --git a/src/core/feedsproxymodel.h b/src/core/feedsproxymodel.h index a2d7597bf..4da7ee09d 100755 --- a/src/core/feedsproxymodel.h +++ b/src/core/feedsproxymodel.h @@ -32,11 +32,6 @@ class FeedsProxyModel : public QSortFilterProxyModel { explicit FeedsProxyModel(FeedsModel *source_model, QObject *parent = 0); virtual ~FeedsProxyModel(); - // Access to the source model. - inline FeedsModel *sourceModel() const { - return m_sourceModel; - } - // Returns index list of items which "match" given value. // 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; diff --git a/src/core/messagesproxymodel.h b/src/core/messagesproxymodel.h index 8bde53751..ee1fde93c 100755 --- a/src/core/messagesproxymodel.h +++ b/src/core/messagesproxymodel.h @@ -31,11 +31,6 @@ class MessagesProxyModel : public QSortFilterProxyModel { explicit MessagesProxyModel(MessagesModel *source_model, QObject *parent = 0); virtual ~MessagesProxyModel(); - // Source model getter. - inline MessagesModel *sourceModel() { - return m_sourceModel; - } - QModelIndex getNextPreviousUnreadItemIndex(int default_row); // Maps list of indexes. @@ -45,6 +40,7 @@ class MessagesProxyModel : public QSortFilterProxyModel { // 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; + // Performs sort of items. void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); private: diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index d2f3492e6..b8aa4ab7a 100755 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -301,7 +301,7 @@ void FeedMessageViewer::createConnections() { connect(form_main->m_ui->m_actionUpdateSelectedItems, SIGNAL(triggered()), m_feedsView, SLOT(updateSelectedItems())); 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, SIGNAL(triggered()), m_feedsView->sourceModel(), SLOT(stopRunningFeedUpdate())); connect(form_main->m_ui->m_actionEditSelectedItem, diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index c789088d2..75ab00282 100755 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -202,10 +202,6 @@ void FeedsView::expandCollapseCurrentItem() { } } -void FeedsView::updateAllItems() { - qApp->feedReader()->updateAllFeeds(); -} - void FeedsView::updateSelectedItems() { qApp->feedReader()->updateFeeds(selectedFeeds()); } diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index 5ef406b10..753c5bc30 100755 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -68,7 +68,6 @@ class FeedsView : public QTreeView { void expandCollapseCurrentItem(); // Feed updating. - void updateAllItems(); void updateSelectedItems(); // Feed read/unread manipulators. diff --git a/src/main.cpp b/src/main.cpp index 8cfc8ad09..56a118827 100755 --- a/src/main.cpp +++ b/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 // and skin. - qApp->icons()->setupSearchPaths(); - qApp->icons()->loadCurrentIconTheme(); - qApp->skins()->loadCurrentSkin(); + if (!run_minimal_without_gui) { + qApp->icons()->setupSearchPaths(); + qApp->icons()->loadCurrentIconTheme(); + qApp->skins()->loadCurrentSkin(); - // Load localization and setup locale before any widget is constructed. - qApp->localization()->loadActiveLanguage(); + // Load localization and setup locale before any widget is constructed. + qApp->localization()->loadActiveLanguage(); + } // These settings needs to be set before any QSettings object. Application::setApplicationName(APP_NAME); @@ -110,8 +112,6 @@ int main(int argc, char *argv[]) { Application::setOrganizationDomain(APP_URL); Application::setWindowIcon(QIcon(APP_ICON_PATH)); - qDebug().nospace() << "Creating main application form in thread: \'" << QThread::currentThreadId() << "\'."; - // Load activated accounts. qApp->feedReader()->feedsModel()->loadActivatedServiceAccounts(); @@ -119,6 +119,8 @@ int main(int argc, char *argv[]) { QObject::connect(&application, &Application::messageReceived, &application, &Application::processExecutionMessage); if (!run_minimal_without_gui) { + qDebug().nospace() << "Creating main application form in thread: \'" << QThread::currentThreadId() << "\'."; + // Instantiate main application window. FormMain main_window;