diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 136ab535a..04fc11dd6 100644 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -27,6 +27,7 @@ #include #include #include +#include FeedMessageViewer::FeedMessageViewer(QWidget *parent) @@ -36,13 +37,23 @@ FeedMessageViewer::FeedMessageViewer(QWidget *parent) m_feedsView(new FeedsView(this)), m_messagesBrowser(new WebBrowser(this)), m_feedDownloaderThread(new QThread()), - m_feedDownloader(new FeedDownloader()) { + m_feedDownloader(new FeedDownloader()), + m_autoUpdateTimer(new QTimer(this)) { initialize(); initializeViews(); createConnections(); // Start the feed downloader thread. m_feedDownloaderThread->start(); + + // Start the auto-update timer. + // TODO: co kdyz update bude trvat dele nez minutu? + // asi udelat metodu pro update v teto tride + // ta obali update v m_feedsView + // a nastavit jako single shot -> true nejak nevim + m_autoUpdateTimer->setInterval(1000); + m_autoUpdateTimer->setSingleShot(false); + m_autoUpdateTimer->start(); } FeedMessageViewer::~FeedMessageViewer() { @@ -130,6 +141,10 @@ void FeedMessageViewer::onFeedUpdatesFinished() { void FeedMessageViewer::createConnections() { FormMain *form_main = FormMain::instance(); + // Timed actions. + connect(m_autoUpdateTimer, SIGNAL(timeout()), + m_feedsView, SLOT(updateScheduledFeeds())); + // Message changers. connect(m_messagesView, SIGNAL(currentMessagesRemoved()), m_messagesBrowser, SLOT(clear())); diff --git a/src/gui/feedmessageviewer.h b/src/gui/feedmessageviewer.h index 7d24c27f3..954eedb5c 100644 --- a/src/gui/feedmessageviewer.h +++ b/src/gui/feedmessageviewer.h @@ -14,6 +14,7 @@ class FeedsModelFeed; class QToolBar; class QSplitter; class QProgressBar; +class QTimer; class FeedMessageViewer : public TabContent { Q_OBJECT @@ -73,6 +74,8 @@ class FeedMessageViewer : public TabContent { QThread *m_feedDownloaderThread; FeedDownloader *m_feedDownloader; + + QTimer *m_autoUpdateTimer; }; #endif // FEEDMESSAGEVIEWER_H diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index f2974b61c..189ea2d74 100644 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -102,6 +102,22 @@ void FeedsView::updateSelectedFeeds() { } } +void FeedsView::updateScheduledFeeds() { + if (SystemFactory::instance()->applicationCloseLock()->tryLock()) { + // Update master lock obtained, select + // feeds which should be updated and + // request their update. + // TODO: emit feedsUpdateRequested(selectedFeeds()); + } + else { + if (SystemTrayIcon::isSystemTrayActivated()) { + SystemTrayIcon::instance()->showMessage(tr("Cannot update scheduled items"), + tr("You cannot update scheduled items because another feed update is ongoing."), + QSystemTrayIcon::Warning); + } + } +} + void FeedsView::setSelectedFeedsClearStatus(int clear) { m_sourceModel->markFeedsDeleted(selectedFeeds(), clear, 0); updateCountsOfSelectedFeeds(); diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index 83b96ce34..571821a5b 100644 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -44,6 +44,7 @@ class FeedsView : public QTreeView { // Feed updating. void updateAllFeeds(); void updateSelectedFeeds(); + void updateScheduledFeeds(); // Feed read/unread manipulators. void markSelectedFeedsReadStatus(int read); diff --git a/src/gui/formsettings.ui b/src/gui/formsettings.ui index 728a2c9fd..b7019663a 100644 --- a/src/gui/formsettings.ui +++ b/src/gui/formsettings.ui @@ -17,7 +17,7 @@ - 5 + 0