new sync algorithm now switchable, by default is off

This commit is contained in:
Martin Rotter 2021-08-04 14:58:53 +02:00
parent 7c7c991fab
commit fd91a2d738
6 changed files with 51 additions and 20 deletions

View File

@ -20,7 +20,7 @@
GreaderNetwork::GreaderNetwork(QObject* parent)
: QObject(parent), m_service(GreaderServiceRoot::Service::FreshRss), m_username(QString()), m_password(QString()),
m_baseUrl(QString()), m_batchSize(GREADER_DEFAULT_BATCH_SIZE), m_downloadOnlyUnreadMessages(false),
m_prefetchedMessages({}), m_performGlobalFetching(false) {
m_prefetchedMessages({}), m_performGlobalFetching(false), m_intelligentSynchronization(false) {
clearCredentials();
}
@ -1053,6 +1053,14 @@ QString GreaderNetwork::generateFullUrl(GreaderNetwork::Operations operation) co
}
}
bool GreaderNetwork::intelligentSynchronization() const {
return m_intelligentSynchronization;
}
void GreaderNetwork::setIntelligentSynchronization(bool intelligent_synchronization) {
m_intelligentSynchronization = intelligent_synchronization;
}
bool GreaderNetwork::downloadOnlyUnreadMessages() const {
return m_downloadOnlyUnreadMessages;
}

View File

@ -92,6 +92,9 @@ class GreaderNetwork : public QObject {
bool downloadOnlyUnreadMessages() const;
void setDownloadOnlyUnreadMessages(bool download_only_unread);
bool intelligentSynchronization() const;
void setIntelligentSynchronization(bool intelligent_synchronization);
private:
QPair<QByteArray, QByteArray> authHeader() const;
@ -120,6 +123,7 @@ class GreaderNetwork : public QObject {
QString m_authToken;
QList<Message> m_prefetchedMessages;
bool m_performGlobalFetching;
bool m_intelligentSynchronization;
};
#endif // GREADERNETWORK_H

View File

@ -44,6 +44,7 @@ QVariantHash GreaderServiceRoot::customDatabaseData() const {
data["url"] = m_network->baseUrl();
data["batch_size"] = m_network->batchSize();
data["download_only_unread"] = m_network->downloadOnlyUnreadMessages();
data["intelligent_synchronization"] = m_network->intelligentSynchronization();
return data;
}
@ -55,13 +56,13 @@ void GreaderServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
m_network->setBaseUrl(data["url"].toString());
m_network->setBatchSize(data["batch_size"].toInt());
m_network->setDownloadOnlyUnreadMessages(data["download_only_unread"].toBool());
m_network->setIntelligentSynchronization(data["intelligent_synchronization"].toBool());
}
void GreaderServiceRoot::aboutToBeginFeedFetching(const QList<Feed*>& feeds,
const QHash<QString, QHash<BagOfMessages, QStringList>>& stated_messages,
const QHash<QString, QStringList>& tagged_messages) {
// Prefetch starred messages.
if (true /* intelligent downloading */) {
if (m_network->intelligentSynchronization()) {
m_network->prepareFeedFetching(this, feeds, stated_messages, tagged_messages, networkProxy());
}
else {
@ -72,13 +73,10 @@ void GreaderServiceRoot::aboutToBeginFeedFetching(const QList<Feed*>& feeds,
QList<Message> GreaderServiceRoot::obtainNewMessages(Feed* feed,
const QHash<ServiceRoot::BagOfMessages, QStringList>& stated_messages,
const QHash<QString, QStringList>& tagged_messages) {
Q_UNUSED(stated_messages)
Q_UNUSED(tagged_messages)
Feed::Status error = Feed::Status::Normal;
if (true /* intelligent downloading */ ) {
return network()->getMessagesIntelligently(this,
if (m_network->intelligentSynchronization()) {
return m_network->getMessagesIntelligently(this,
feed->customId(),
stated_messages,
tagged_messages,
@ -86,7 +84,7 @@ QList<Message> GreaderServiceRoot::obtainNewMessages(Feed* feed,
networkProxy());
}
else {
return network()->streamContents(this, feed->customId(), error, networkProxy());
return m_network->streamContents(this, feed->customId(), error, networkProxy());
}
if (error != Feed::Status::NewMessages && error != Feed::Status::Normal) {

View File

@ -29,6 +29,7 @@ void FormEditGreaderAccount::apply() {
account<GreaderServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
account<GreaderServiceRoot>()->network()->setDownloadOnlyUnreadMessages(m_details->m_ui.m_cbDownloadOnlyUnreadMessages->isChecked());
account<GreaderServiceRoot>()->network()->setService(m_details->service());
account<GreaderServiceRoot>()->network()->setIntelligentSynchronization(m_details->m_ui.m_cbNewAlgorithm->isChecked());
account<GreaderServiceRoot>()->saveAccountDataToDatabase();
accept();
@ -50,6 +51,7 @@ void FormEditGreaderAccount::loadAccountData() {
m_details->m_ui.m_txtUrl->lineEdit()->setText(existing_root->network()->baseUrl());
m_details->m_ui.m_spinLimitMessages->setValue(existing_root->network()->batchSize());
m_details->m_ui.m_cbDownloadOnlyUnreadMessages->setChecked(existing_root->network()->downloadOnlyUnreadMessages());
m_details->m_ui.m_cbNewAlgorithm->setChecked(existing_root->network()->intelligentSynchronization());
}
void FormEditGreaderAccount::performTest() {

View File

@ -29,22 +29,29 @@ GreaderAccountDetails::GreaderAccountDetails(QWidget* parent) : QWidget(parent)
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Information,
tr("No test done yet."),
tr("Here, results of connection test are shown."));
m_ui.m_lblLimitMessages->setText(tr("Limiting the number of fetched articles per feed makes fetching of "
"articles faster, but if your feed contains more articles "
"than specified limit, then some older articles might not be "
"fetched at all."));
GuiUtilities::setLabelAsNotice(*m_ui.m_lblLimitMessages, true);
m_ui.m_lblNewAlgorithm->setText(tr("If you select intelligent synchronization, then only not-yet-fetched "
"or updated articles are downloaded. Network usage is greatly reduced and "
"overall synchronization speed is greatly improved."));
GuiUtilities::setLabelAsNotice(*m_ui.m_lblNewAlgorithm, false);
connect(m_ui.m_checkShowPassword, &QCheckBox::toggled, this, &GreaderAccountDetails::displayPassword);
connect(m_ui.m_txtPassword->lineEdit(), &BaseLineEdit::textChanged, this, &GreaderAccountDetails::onPasswordChanged);
connect(m_ui.m_txtUsername->lineEdit(), &BaseLineEdit::textChanged, this, &GreaderAccountDetails::onUsernameChanged);
connect(m_ui.m_txtUrl->lineEdit(), &BaseLineEdit::textChanged, this, &GreaderAccountDetails::onUrlChanged);
connect(m_ui.m_cmbService, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &GreaderAccountDetails::fillPredefinedUrl);
connect(m_ui.m_cbNewAlgorithm, &QCheckBox::toggled, m_ui.m_spinLimitMessages, &MessageCountSpinBox::setDisabled);
setTabOrder(m_ui.m_cmbService, m_ui.m_txtUrl->lineEdit());
setTabOrder(m_ui.m_txtUrl->lineEdit(), m_ui.m_cbDownloadOnlyUnreadMessages);
setTabOrder(m_ui.m_cbDownloadOnlyUnreadMessages, m_ui.m_spinLimitMessages);
setTabOrder(m_ui.m_cbDownloadOnlyUnreadMessages, m_ui.m_cbNewAlgorithm);
setTabOrder(m_ui.m_cbNewAlgorithm, m_ui.m_spinLimitMessages);
setTabOrder(m_ui.m_spinLimitMessages, m_ui.m_txtUsername->lineEdit());
setTabOrder(m_ui.m_txtUsername->lineEdit(), m_ui.m_txtPassword->lineEdit());
setTabOrder(m_ui.m_txtPassword->lineEdit(), m_ui.m_checkShowPassword);

View File

@ -34,7 +34,7 @@
<item row="2" column="1">
<widget class="LineEditWithStatus" name="m_txtUrl" native="true"/>
</item>
<item row="5" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
@ -51,17 +51,14 @@
</item>
</layout>
</item>
<item row="7" column="0" colspan="2">
<item row="9" column="0" colspan="2">
<widget class="QLabel" name="m_lblLimitMessages">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<item row="10" column="0" colspan="2">
<widget class="QGroupBox" name="m_gbAuthentication">
<property name="toolTip">
<string>Some feeds require authentication, including GMail feeds. BASIC, NTLM-2 and DIGEST-MD5 authentication schemes are supported.</string>
@ -112,7 +109,7 @@
</layout>
</widget>
</item>
<item row="9" column="0" colspan="2">
<item row="11" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="m_btnTestSetup">
@ -136,7 +133,7 @@
</item>
</layout>
</item>
<item row="10" column="0" colspan="2">
<item row="12" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -156,6 +153,20 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="m_cbNewAlgorithm">
<property name="text">
<string>Intelligent synchronization algorithm</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="m_lblNewAlgorithm">
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
@ -178,11 +189,12 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>m_cmbService</tabstop>
<tabstop>m_cbDownloadOnlyUnreadMessages</tabstop>
<tabstop>m_cbNewAlgorithm</tabstop>
<tabstop>m_spinLimitMessages</tabstop>
<tabstop>m_checkShowPassword</tabstop>
<tabstop>m_btnTestSetup</tabstop>
<tabstop>m_cmbService</tabstop>
</tabstops>
<resources/>
<connections/>