diff --git a/src/core/defs.h.in b/src/core/defs.h.in index fdaeb3c41..b39ddb2fa 100755 --- a/src/core/defs.h.in +++ b/src/core/defs.h.in @@ -30,6 +30,7 @@ #define TRAY_ICON_BUBBLE_TIMEOUT 15000 #define KEY_MESSAGES_VIEW "messages_view_column_" #define CLOSE_LOCK_TIMEOUT 3000 +#define MESSAGES_VIEW_DEFAULT_COL 170 #define APP_DB_INIT_FILE "db_init.sql" #define APP_DB_INIT_SPLIT "-- !\n" diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index d5be4a976..821f133d3 100644 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -105,6 +105,19 @@ void FeedMessageViewer::updateSelectedFeeds() { } } +void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed, + int current, + int total) { + // Some feed got updated. + // Now we should change some widgets (reload counts + // of messages for the feed, update status bar and so on). + + + // TODO: Don't update counts of all feeds here, + // it is enough to update counts of update feed. + m_feedsView->updateCountsOfAllFeeds(true); +} + void FeedMessageViewer::onFeedUpdatesFinished() { // Updates of some feeds finished, unlock the lock. SystemFactory::getInstance()->applicationCloseLock()->unlock(); @@ -127,6 +140,16 @@ void FeedMessageViewer::createConnections() { connect(m_messagesView, SIGNAL(feedCountsChanged()), m_feedsView, SLOT(updateCountsOfSelectedFeeds())); + // Downloader connections. + connect(m_feedDownloaderThread, SIGNAL(finished()), + m_feedDownloaderThread, SLOT(deleteLater())); + connect(this, SIGNAL(feedsUpdateRequested(QList)), + m_feedDownloader, SLOT(updateFeeds(QList))); + connect(m_feedDownloader, SIGNAL(finished()), + this, SLOT(onFeedUpdatesFinished())); + connect(m_feedDownloader, SIGNAL(progress(FeedsModelFeed*,int,int)), + this, SLOT(onFeedUpdatesProgress(FeedsModelFeed*,int,int))); + // Toolbar forwardings. connect(FormMain::getInstance()->m_ui->m_actionSwitchImportanceOfSelectedMessages, SIGNAL(triggered()), m_messagesView, SLOT(switchSelectedMessagesImportance())); @@ -150,15 +173,6 @@ void FeedMessageViewer::createConnections() { SIGNAL(triggered()), m_messagesView, SLOT(setAllMessagesDeleted())); connect(FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeeds, SIGNAL(triggered()), this, SLOT(updateSelectedFeeds())); - - // Downloader connections. - // TODO: Připravit spojení pro progress a finished. - connect(m_feedDownloaderThread, SIGNAL(finished()), - m_feedDownloaderThread, SLOT(deleteLater())); - connect(this, SIGNAL(feedsUpdateRequested(QList)), - m_feedDownloader, SLOT(updateFeeds(QList))); - connect(m_feedDownloader, SIGNAL(finished()), - this, SLOT(onFeedUpdatesFinished())); } void FeedMessageViewer::initialize() { diff --git a/src/gui/feedmessageviewer.h b/src/gui/feedmessageviewer.h index 75f80443c..fc4b11bd2 100644 --- a/src/gui/feedmessageviewer.h +++ b/src/gui/feedmessageviewer.h @@ -34,6 +34,9 @@ class FeedMessageViewer : public TabContent { public slots: void updateSelectedFeeds(); + + protected slots: + void onFeedUpdatesProgress(FeedsModelFeed *feed, int current, int total); void onFeedUpdatesFinished(); protected: diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index f45dc0255..f99ee1663 100644 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -38,17 +38,28 @@ QList FeedsView::allFeeds() const { return m_sourceModel->getAllFeeds(); } -void FeedsView::updateCountsOfSelectedFeeds() { +void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) { QList feeds = selectedFeeds(); foreach (FeedsModelFeed *feed, feeds) { - feed->updateCounts(); + feed->updateCounts(update_total_too); } // Make sure that selected view reloads changed indexes. m_sourceModel->reloadChangedLayout(m_proxyModel->mapListToSource(selectionModel()->selectedRows())); } +void FeedsView::updateCountsOfAllFeeds(bool update_total_too) { + QList feeds = allFeeds(); + + foreach (FeedsModelFeed *feed, feeds) { + feed->updateCounts(update_total_too); + } + + // Make sure that all views reloads its data. + m_sourceModel->reloadWholeLayout(); +} + void FeedsView::setupAppearance() { #if QT_VERSION >= 0x050000 // Setup column resize strategies. diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index e3ed87a61..785b63a1e 100644 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -24,8 +24,11 @@ class FeedsView : public QTreeView { QList allFeeds() const; public slots: - // Reloads count for selected feeds. - void updateCountsOfSelectedFeeds(); + // Reloads counts for selected feeds. + void updateCountsOfSelectedFeeds(bool update_total_too = true); + + // Reloads counts for all feeds. + void updateCountsOfAllFeeds(bool update_total_too = true); protected: // Sets up appearance of this widget. diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp index 82f40c1b2..3bfa777c1 100644 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -100,6 +100,7 @@ void MessagesView::setupAppearance() { hideColumn(MSG_DB_CONTENTS_INDEX); } + header()->setDefaultSectionSize(MESSAGES_VIEW_DEFAULT_COL); header()->setStretchLastSection(false); setUniformRowHeights(true); setAcceptDrops(false); @@ -115,7 +116,7 @@ void MessagesView::setupAppearance() { // Make sure that initial sorting is that unread messages are visible // first. // NOTE: This can be rewritten so that it's changeable. - sortByColumn(MSG_DB_READ_INDEX, Qt::AscendingOrder); + sortByColumn(MSG_DB_DUPDATED_INDEX, Qt::AscendingOrder); } void MessagesView::keyPressEvent(QKeyEvent *event) { diff --git a/src/gui/messagesview.h b/src/gui/messagesview.h index 76fbb4571..6e567cf93 100755 --- a/src/gui/messagesview.h +++ b/src/gui/messagesview.h @@ -23,6 +23,7 @@ class MessagesView : public QTreeView { MessagesModel *sourceModel(); void createConnections(); + public slots: // Loads un-deleted messages from selected feeds. void loadFeeds(const QList &feed_ids);