Refactoring.
This commit is contained in:
parent
d8ecbcac04
commit
b62dcd2926
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -202,10 +202,6 @@ void FeedsView::expandCollapseCurrentItem() {
|
|||
}
|
||||
}
|
||||
|
||||
void FeedsView::updateAllItems() {
|
||||
qApp->feedReader()->updateAllFeeds();
|
||||
}
|
||||
|
||||
void FeedsView::updateSelectedItems() {
|
||||
qApp->feedReader()->updateFeeds(selectedFeeds());
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ class FeedsView : public QTreeView {
|
|||
void expandCollapseCurrentItem();
|
||||
|
||||
// Feed updating.
|
||||
void updateAllItems();
|
||||
void updateSelectedItems();
|
||||
|
||||
// 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
|
||||
// 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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue