mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-04 03:08:04 +01:00
support very fast auto-fetch intervals
This commit is contained in:
parent
1b48f289d1
commit
4ed6f9c2da
@ -244,6 +244,7 @@ QList<ServiceRoot*> FeedsModel::serviceRoots() const {
|
||||
QList<Feed*> FeedsModel::feedsForScheduledUpdate(bool auto_update_now) {
|
||||
QList<Feed*> feeds_for_update;
|
||||
auto stf = m_rootItem->getSubTreeFeeds();
|
||||
auto cur_date = QDateTime::currentDateTimeUtc();
|
||||
|
||||
for (Feed* feed : qAsConst(stf)) {
|
||||
switch (feed->autoUpdateType()) {
|
||||
@ -260,7 +261,7 @@ QList<Feed*> FeedsModel::feedsForScheduledUpdate(bool auto_update_now) {
|
||||
|
||||
case Feed::AutoUpdateType::SpecificAutoUpdate:
|
||||
default:
|
||||
if (feed->lastUpdated().addSecs(feed->autoUpdateInterval()) < QDateTime::currentDateTimeUtc()) {
|
||||
if (feed->lastUpdated().addSecs(feed->autoUpdateInterval()) < cur_date) {
|
||||
feeds_for_update.append(feed);
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,7 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
||||
&QComboBox::setEnabled);
|
||||
|
||||
connect(m_ui->m_checkMessagesTimeFormat, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_cmbFastAutoUpdate, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_checkMessagesTimeFormat, &QCheckBox::toggled, m_ui->m_cmbMessagesTimeFormat, &QComboBox::setEnabled);
|
||||
|
||||
connect(m_ui->m_checkRemoveReadMessagesOnExit, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
@ -241,6 +242,7 @@ void SettingsFeedsMessages::loadSettings() {
|
||||
->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateOnlyUnfocused)).toBool());
|
||||
m_ui->m_spinAutoUpdateInterval->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateInterval)).toInt());
|
||||
m_ui->m_spinFeedUpdateTimeout->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt());
|
||||
m_ui->m_cmbFastAutoUpdate->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::FastAutoUpdate)).toBool());
|
||||
m_ui->m_checkUpdateAllFeedsOnStartup
|
||||
->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool());
|
||||
m_ui->m_spinStartupUpdateDelay
|
||||
@ -326,6 +328,7 @@ void SettingsFeedsMessages::saveSettings() {
|
||||
settings()->setValue(GROUP(Feeds), Feeds::AutoUpdateOnlyUnfocused, m_ui->m_checkAutoUpdateOnlyUnfocused->isChecked());
|
||||
settings()->setValue(GROUP(Feeds), Feeds::AutoUpdateInterval, m_ui->m_spinAutoUpdateInterval->value());
|
||||
settings()->setValue(GROUP(Feeds), Feeds::UpdateTimeout, m_ui->m_spinFeedUpdateTimeout->value());
|
||||
settings()->setValue(GROUP(Feeds), Feeds::FastAutoUpdate, m_ui->m_cmbFastAutoUpdate->isChecked());
|
||||
settings()->setValue(GROUP(Feeds), Feeds::FeedsUpdateOnStartup, m_ui->m_checkUpdateAllFeedsOnStartup->isChecked());
|
||||
settings()->setValue(GROUP(Feeds), Feeds::FeedsUpdateStartupDelay, m_ui->m_spinStartupUpdateDelay->value());
|
||||
settings()->setValue(GROUP(Feeds), Feeds::CountFormat, m_ui->m_cmbCountsFeedList->currentText());
|
||||
|
@ -80,7 +80,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Feed connection timeout</string>
|
||||
@ -90,7 +90,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="m_spinFeedUpdateTimeout">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@ -115,6 +115,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_cmbFastAutoUpdate">
|
||||
<property name="text">
|
||||
<string>Support very fast auto-fetching intervals (under 10 seconds)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="m_tabFeedsList">
|
||||
@ -619,6 +626,7 @@
|
||||
<tabstop>m_checkAutoUpdate</tabstop>
|
||||
<tabstop>m_spinAutoUpdateInterval</tabstop>
|
||||
<tabstop>m_checkAutoUpdateOnlyUnfocused</tabstop>
|
||||
<tabstop>m_cmbFastAutoUpdate</tabstop>
|
||||
<tabstop>m_spinFeedUpdateTimeout</tabstop>
|
||||
<tabstop>m_spinHeightRowsFeeds</tabstop>
|
||||
<tabstop>m_btnChangeFeedListFont</tabstop>
|
||||
|
@ -153,6 +153,7 @@ void FeedReader::updateAutoUpdateStatus() {
|
||||
// Restore global intervals.
|
||||
// NOTE: Specific per-feed interval are left intact.
|
||||
m_globalAutoUpdateInterval = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateInterval)).toInt();
|
||||
m_globalAutoUpdateFast = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::FastAutoUpdate)).toBool();
|
||||
|
||||
if (m_lastAutoUpdate.isNull()) {
|
||||
m_lastAutoUpdate = QDateTime::currentDateTimeUtc();
|
||||
@ -162,12 +163,22 @@ void FeedReader::updateAutoUpdateStatus() {
|
||||
m_globalAutoUpdateOnlyUnfocused =
|
||||
qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateOnlyUnfocused)).toBool();
|
||||
|
||||
if (m_globalAutoUpdateFast) {
|
||||
// NOTE: In "fast" mode, we set interval to 1 second.
|
||||
// This might have some performance consequences.
|
||||
m_autoUpdateTimer->setInterval(1000);
|
||||
qDebugNN << LOGSEC_CORE
|
||||
<< "Enabling support for very small auto-fetching intervals. This might have performance consequences.";
|
||||
}
|
||||
else {
|
||||
m_autoUpdateTimer->setInterval(AUTO_UPDATE_INTERVAL * 1000);
|
||||
}
|
||||
|
||||
// Start global auto-update timer if it is not running yet.
|
||||
// NOTE: The timer must run even if global auto-update
|
||||
// is not enabled because user can still enable auto-update
|
||||
// for individual feeds.
|
||||
if (!m_autoUpdateTimer->isActive()) {
|
||||
m_autoUpdateTimer->setInterval(AUTO_UPDATE_INTERVAL * 1000);
|
||||
m_autoUpdateTimer->start();
|
||||
qDebugNN << LOGSEC_CORE << "Auto-download timer started with interval " << m_autoUpdateTimer->interval() << " ms.";
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ class RSSGUARD_DLLSPEC FeedReader : public QObject {
|
||||
// Auto-update stuff.
|
||||
QTimer* m_autoUpdateTimer;
|
||||
bool m_globalAutoUpdateEnabled{};
|
||||
bool m_globalAutoUpdateFast{};
|
||||
bool m_globalAutoUpdateOnlyUnfocused{};
|
||||
int m_globalAutoUpdateInterval{}; // In seconds.
|
||||
QDateTime m_lastAutoUpdate;
|
||||
|
@ -86,6 +86,9 @@ DVALUE(int) Feeds::AutoUpdateIntervalDef = DEFAULT_AUTO_UPDATE_INTERVAL;
|
||||
DKEY Feeds::AutoUpdateEnabled = "auto_update_enabled";
|
||||
DVALUE(bool) Feeds::AutoUpdateEnabledDef = false;
|
||||
|
||||
DKEY Feeds::FastAutoUpdate = "auto_update_fast";
|
||||
DVALUE(bool) Feeds::FastAutoUpdateDef = false;
|
||||
|
||||
DKEY Feeds::AutoUpdateOnlyUnfocused = "auto_update_only_unfocused";
|
||||
DVALUE(bool) Feeds::AutoUpdateOnlyUnfocusedDef = false;
|
||||
|
||||
|
@ -83,6 +83,9 @@ namespace Feeds {
|
||||
KEY AutoUpdateEnabled;
|
||||
VALUE(bool) AutoUpdateEnabledDef;
|
||||
|
||||
KEY FastAutoUpdate;
|
||||
VALUE(bool) FastAutoUpdateDef;
|
||||
|
||||
KEY AutoUpdateOnlyUnfocused;
|
||||
VALUE(bool) AutoUpdateOnlyUnfocusedDef;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user