diff --git a/resources/scripts/7za b/resources/scripts/7za index 9c10723bf..47f412575 160000 --- a/resources/scripts/7za +++ b/resources/scripts/7za @@ -1 +1 @@ -Subproject commit 9c10723bfbaf6cb85107d6ee16e0324e9e487749 +Subproject commit 47f4125753452eff8800dbd6600c5a05540b15d9 diff --git a/resources/sql/db_init_sqlite.sql b/resources/sql/db_init_sqlite.sql index 5d929012d..34eebd655 100644 --- a/resources/sql/db_init_sqlite.sql +++ b/resources/sql/db_init_sqlite.sql @@ -36,7 +36,7 @@ CREATE TABLE Feeds ( description TEXT, date_created BIGINT, icon °°, - category INTEGER NOT NULL CHECK (category >= -1), /* Root feeds contain -1 here. */ + category INTEGER NOT NULL CHECK (category >= -1), /* Physical category ID, also root feeds contain -1 here. */ source TEXT, update_type INTEGER NOT NULL CHECK (update_type >= 0), update_interval INTEGER NOT NULL DEFAULT 15 CHECK (update_interval >= 1), diff --git a/src/librssguard/services/abstract/gui/formfeeddetails.cpp b/src/librssguard/services/abstract/gui/formfeeddetails.cpp index d926dca80..a46696b02 100644 --- a/src/librssguard/services/abstract/gui/formfeeddetails.cpp +++ b/src/librssguard/services/abstract/gui/formfeeddetails.cpp @@ -3,12 +3,13 @@ #include "services/abstract/gui/formfeeddetails.h" #include "core/feedsmodel.h" +#include "database/databasequeries.h" #include "definitions/definitions.h" +#include "exceptions/applicationexception.h" #include "gui/baselineedit.h" #include "gui/guiutilities.h" #include "gui/messagebox.h" #include "gui/systemtrayicon.h" -#include "database/databasequeries.h" #include "miscellaneous/iconfactory.h" #include "miscellaneous/textfactory.h" #include "network-web/networkfactory.h" @@ -46,6 +47,13 @@ void FormFeedDetails::apply() { m_feed->setAutoUpdateType(static_cast(m_ui->m_cmbAutoUpdateType->itemData( m_ui->m_cmbAutoUpdateType->currentIndex()).toInt())); m_feed->setAutoUpdateInitialInterval(int(m_ui->m_spinAutoUpdateInterval->value())); + + if (!m_creatingNew) { + // We need to make sure that common data are saved. + QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className()); + + DatabaseQueries::createOverwriteFeed(database, m_feed, m_serviceRoot->accountId(), m_feed->parent()->id()); + } } void FormFeedDetails::onAutoUpdateTypeChanged(int new_index) { @@ -63,7 +71,7 @@ void FormFeedDetails::onAutoUpdateTypeChanged(int new_index) { } void FormFeedDetails::createConnections() { - connect(m_ui->m_buttonBox, &QDialogButtonBox::accepted, this, &FormFeedDetails::apply); + connect(m_ui->m_buttonBox, &QDialogButtonBox::accepted, this, &FormFeedDetails::acceptIfPossible); connect(m_ui->m_cmbAutoUpdateType, static_cast(&QComboBox::currentIndexChanged), this, &FormFeedDetails::onAutoUpdateTypeChanged); } @@ -80,6 +88,20 @@ void FormFeedDetails::loadFeedData() { m_ui->m_spinAutoUpdateInterval->setValue(m_feed->autoUpdateInitialInterval()); } +void FormFeedDetails::acceptIfPossible() { + try { + apply(); + accept(); + } + catch (const ApplicationException& ex) { + qApp->showGuiMessage(tr("Error"), + tr("Cannot save changes: %1").arg(ex.message()), + QSystemTrayIcon::MessageIcon::Critical, + this, + true); + } +} + void FormFeedDetails::initialize() { m_ui.reset(new Ui::FormFeedDetails()); m_ui->setupUi(this); diff --git a/src/librssguard/services/abstract/gui/formfeeddetails.h b/src/librssguard/services/abstract/gui/formfeeddetails.h index 9f4da0bb1..cf60f4267 100644 --- a/src/librssguard/services/abstract/gui/formfeeddetails.h +++ b/src/librssguard/services/abstract/gui/formfeeddetails.h @@ -47,6 +47,7 @@ class FormFeedDetails : public QDialog { virtual void loadFeedData(); private slots: + void acceptIfPossible(); void onAutoUpdateTypeChanged(int new_index); private: diff --git a/src/librssguard/services/owncloud/owncloudserviceroot.cpp b/src/librssguard/services/owncloud/owncloudserviceroot.cpp index 424285470..8bd436e45 100644 --- a/src/librssguard/services/owncloud/owncloudserviceroot.cpp +++ b/src/librssguard/services/owncloud/owncloudserviceroot.cpp @@ -2,9 +2,9 @@ #include "services/owncloud/owncloudserviceroot.h" +#include "database/databasequeries.h" #include "definitions/definitions.h" #include "miscellaneous/application.h" -#include "database/databasequeries.h" #include "miscellaneous/iconfactory.h" #include "miscellaneous/mutex.h" #include "miscellaneous/textfactory.h" @@ -153,7 +153,7 @@ QList OwnCloudServiceRoot::obtainNewMessages(const QList& feeds, QList msgs; for (Feed* feed : feeds) { - OwnCloudGetMessagesResponse messages = network()->getMessages(customNumericId(), networkProxy()); + OwnCloudGetMessagesResponse messages = network()->getMessages(feed->customNumericId(), networkProxy()); if (messages.networkError() != QNetworkReply::NetworkError::NoError) { feed->setStatus(Feed::Status::NetworkError); diff --git a/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp b/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp index f4aa83869..3b84fb006 100644 --- a/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp +++ b/src/librssguard/services/standard/gui/formstandardfeeddetails.cpp @@ -110,7 +110,6 @@ void FormStandardFeedDetails::apply() { m_serviceRoot->requestItemReassignment(m_feed, parent); m_serviceRoot->itemChanged({ m_feed }); - accept(); } void FormStandardFeedDetails::loadFeedData() { diff --git a/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp b/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp index a287f04eb..d636d0dd5 100755 --- a/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp +++ b/src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp @@ -2,6 +2,7 @@ #include "services/tt-rss/gui/formttrssfeeddetails.h" +#include "exceptions/applicationexception.h" #include "miscellaneous/application.h" #include "services/abstract/feed.h" #include "services/abstract/gui/authenticationdetails.h" @@ -43,18 +44,13 @@ void FormTtRssFeedDetails::apply() { if (response.code() == STF_INSERTED) { // Feed was added online. - accept(); qApp->showGuiMessage(tr("Feed added"), tr("Feed was added, obtaining new tree of feeds now."), QSystemTrayIcon::MessageIcon::Information); QTimer::singleShot(300, root, &TtRssServiceRoot::syncIn); } else { - qApp->showGuiMessage(tr("Cannot add feed"), - tr("Feed was not added due to error."), - QSystemTrayIcon::MessageIcon::Critical, - qApp->mainFormWidget(), - true); + throw ApplicationException(tr("API returned error code %1").arg(QString::number(response.code()))); } } }