Work on auto-updates.

This commit is contained in:
Martin Rotter 2014-02-03 18:49:06 +01:00
parent 43b2d82e2b
commit 13c5c629df
5 changed files with 37 additions and 2 deletions

View File

@ -27,6 +27,7 @@
#include <QThread>
#include <QProgressBar>
#include <QStatusBar>
#include <QTimer>
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()));

View File

@ -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

View File

@ -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();

View File

@ -44,6 +44,7 @@ class FeedsView : public QTreeView {
// Feed updating.
void updateAllFeeds();
void updateSelectedFeeds();
void updateScheduledFeeds();
// Feed read/unread manipulators.
void markSelectedFeedsReadStatus(int read);

View File

@ -17,7 +17,7 @@
<item row="0" column="1">
<widget class="QStackedWidget" name="m_stackedSettings">
<property name="currentIndex">
<number>5</number>
<number>0</number>
</property>
<widget class="QWidget" name="m_pageGeneral">
<layout class="QFormLayout" name="formLayout_5">