Work on auto-updates.
This commit is contained in:
parent
43b2d82e2b
commit
13c5c629df
@ -27,6 +27,7 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QProgressBar>
|
#include <QProgressBar>
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
|
||||||
FeedMessageViewer::FeedMessageViewer(QWidget *parent)
|
FeedMessageViewer::FeedMessageViewer(QWidget *parent)
|
||||||
@ -36,13 +37,23 @@ FeedMessageViewer::FeedMessageViewer(QWidget *parent)
|
|||||||
m_feedsView(new FeedsView(this)),
|
m_feedsView(new FeedsView(this)),
|
||||||
m_messagesBrowser(new WebBrowser(this)),
|
m_messagesBrowser(new WebBrowser(this)),
|
||||||
m_feedDownloaderThread(new QThread()),
|
m_feedDownloaderThread(new QThread()),
|
||||||
m_feedDownloader(new FeedDownloader()) {
|
m_feedDownloader(new FeedDownloader()),
|
||||||
|
m_autoUpdateTimer(new QTimer(this)) {
|
||||||
initialize();
|
initialize();
|
||||||
initializeViews();
|
initializeViews();
|
||||||
createConnections();
|
createConnections();
|
||||||
|
|
||||||
// Start the feed downloader thread.
|
// Start the feed downloader thread.
|
||||||
m_feedDownloaderThread->start();
|
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() {
|
FeedMessageViewer::~FeedMessageViewer() {
|
||||||
@ -130,6 +141,10 @@ void FeedMessageViewer::onFeedUpdatesFinished() {
|
|||||||
void FeedMessageViewer::createConnections() {
|
void FeedMessageViewer::createConnections() {
|
||||||
FormMain *form_main = FormMain::instance();
|
FormMain *form_main = FormMain::instance();
|
||||||
|
|
||||||
|
// Timed actions.
|
||||||
|
connect(m_autoUpdateTimer, SIGNAL(timeout()),
|
||||||
|
m_feedsView, SLOT(updateScheduledFeeds()));
|
||||||
|
|
||||||
// Message changers.
|
// Message changers.
|
||||||
connect(m_messagesView, SIGNAL(currentMessagesRemoved()),
|
connect(m_messagesView, SIGNAL(currentMessagesRemoved()),
|
||||||
m_messagesBrowser, SLOT(clear()));
|
m_messagesBrowser, SLOT(clear()));
|
||||||
|
@ -14,6 +14,7 @@ class FeedsModelFeed;
|
|||||||
class QToolBar;
|
class QToolBar;
|
||||||
class QSplitter;
|
class QSplitter;
|
||||||
class QProgressBar;
|
class QProgressBar;
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
class FeedMessageViewer : public TabContent {
|
class FeedMessageViewer : public TabContent {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -73,6 +74,8 @@ class FeedMessageViewer : public TabContent {
|
|||||||
|
|
||||||
QThread *m_feedDownloaderThread;
|
QThread *m_feedDownloaderThread;
|
||||||
FeedDownloader *m_feedDownloader;
|
FeedDownloader *m_feedDownloader;
|
||||||
|
|
||||||
|
QTimer *m_autoUpdateTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FEEDMESSAGEVIEWER_H
|
#endif // FEEDMESSAGEVIEWER_H
|
||||||
|
@ -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) {
|
void FeedsView::setSelectedFeedsClearStatus(int clear) {
|
||||||
m_sourceModel->markFeedsDeleted(selectedFeeds(), clear, 0);
|
m_sourceModel->markFeedsDeleted(selectedFeeds(), clear, 0);
|
||||||
updateCountsOfSelectedFeeds();
|
updateCountsOfSelectedFeeds();
|
||||||
|
@ -44,6 +44,7 @@ class FeedsView : public QTreeView {
|
|||||||
// Feed updating.
|
// Feed updating.
|
||||||
void updateAllFeeds();
|
void updateAllFeeds();
|
||||||
void updateSelectedFeeds();
|
void updateSelectedFeeds();
|
||||||
|
void updateScheduledFeeds();
|
||||||
|
|
||||||
// Feed read/unread manipulators.
|
// Feed read/unread manipulators.
|
||||||
void markSelectedFeedsReadStatus(int read);
|
void markSelectedFeedsReadStatus(int read);
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QStackedWidget" name="m_stackedSettings">
|
<widget class="QStackedWidget" name="m_stackedSettings">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>5</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="m_pageGeneral">
|
<widget class="QWidget" name="m_pageGeneral">
|
||||||
<layout class="QFormLayout" name="formLayout_5">
|
<layout class="QFormLayout" name="formLayout_5">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user