diff --git a/resources/sql/db_init_sqlite.sql b/resources/sql/db_init_sqlite.sql index 8fca6d468..6326f28b0 100644 --- a/resources/sql/db_init_sqlite.sql +++ b/resources/sql/db_init_sqlite.sql @@ -44,6 +44,7 @@ CREATE TABLE Feeds ( custom_id TEXT NOT NULL CHECK (custom_id != ''), /* Custom ID cannot be empty, it must contain either service-specific ID, or Feeds/id. */ /* Custom column for (serialized) custom account-specific data. */ custom_data TEXT, + display_url BOOLEAN NOT NULL DEFAULT FALSE, FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE ); @@ -100,4 +101,4 @@ CREATE TABLE LabelsInMessages ( account_id INTEGER NOT NULL, FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE -); \ No newline at end of file +); diff --git a/src/librssguard/database/databasequeries.cpp b/src/librssguard/database/databasequeries.cpp index 725a40c08..f3d2c2db7 100644 --- a/src/librssguard/database/databasequeries.cpp +++ b/src/librssguard/database/databasequeries.cpp @@ -1990,7 +1990,7 @@ void DatabaseQueries::createOverwriteFeed(const QSqlDatabase& db, Feed* feed, in "SET title = :title, description = :description, date_created = :date_created, " " icon = :icon, category = :category, source = :source, update_type = :update_type, " " update_interval = :update_interval, account_id = :account_id, " - " custom_id = :custom_id, custom_data = :custom_data " + " custom_id = :custom_id, custom_data = :custom_data, display_url = :display_url " "WHERE id = :id;"); q.bindValue(QSL(":title"), feed->title()); q.bindValue(QSL(":description"), feed->description()); @@ -2003,6 +2003,7 @@ void DatabaseQueries::createOverwriteFeed(const QSqlDatabase& db, Feed* feed, in q.bindValue(QSL(":account_id"), account_id); q.bindValue(QSL(":custom_id"), feed->customId()); q.bindValue(QSL(":id"), feed->id()); + q.bindValue(QSL(":display_url"), feed->displayUrl()); auto custom_data = feed->customDatabaseData(); QString serialized_custom_data = serializeCustomData(custom_data); diff --git a/src/librssguard/database/databasequeries.h b/src/librssguard/database/databasequeries.h index 708c97099..4f34e6bba 100644 --- a/src/librssguard/database/databasequeries.h +++ b/src/librssguard/database/databasequeries.h @@ -299,6 +299,7 @@ Assignment DatabaseQueries::getFeeds(const QSqlDatabase& db, feed->setIcon(qApp->icons()->fromByteArray(query.value(FDS_DB_ICON_INDEX).toByteArray())); feed->setAutoUpdateType(static_cast(query.value(FDS_DB_UPDATE_TYPE_INDEX).toInt())); feed->setAutoUpdateInitialInterval(query.value(FDS_DB_UPDATE_INTERVAL_INDEX).toInt()); + feed->setDisplayUrl(query.value(FDS_DB_DISPLAY_URL_INDEX).toBool()); qDebugNN << LOGSEC_CORE << "Custom ID of feed when loading from DB is" diff --git a/src/librssguard/definitions/definitions.h b/src/librssguard/definitions/definitions.h index 6ddfbc37c..541558361 100644 --- a/src/librssguard/definitions/definitions.h +++ b/src/librssguard/definitions/definitions.h @@ -249,6 +249,7 @@ #define FDS_DB_ACCOUNT_ID_INDEX 9 #define FDS_DB_CUSTOM_ID_INDEX 10 #define FDS_DB_CUSTOM_DATA_INDEX 11 +#define FDS_DB_DISPLAY_URL_INDEX 12 // Indexes of columns for feed models. #define FDS_MODEL_TITLE_INDEX 0 diff --git a/src/librssguard/gui/messagepreviewer.cpp b/src/librssguard/gui/messagepreviewer.cpp index 30e60982f..56fe05383 100644 --- a/src/librssguard/gui/messagepreviewer.cpp +++ b/src/librssguard/gui/messagepreviewer.cpp @@ -121,7 +121,15 @@ void MessagePreviewer::loadMessage(const Message& message, RootItem* root) { if (!same_message) { m_txtMessage->setVerticalScrollBarPosition(0.0); - m_txtMessage->loadMessage(message, m_root); + const auto * feed = root->getParentServiceRoot()->getItemFromSubTree( + [feedId = message.m_feedId](const RootItem * it) { + return it->kind() == RootItem::Kind::Feed && it->customId() == feedId; + })->toFeed(); + if (feed && feed->displayUrl()) { + m_txtMessage->loadUrl(m_message.m_url); + } else { + m_txtMessage->loadMessage(message, m_root); + } } } } diff --git a/src/librssguard/services/abstract/feed.cpp b/src/librssguard/services/abstract/feed.cpp index 1ec655171..0be63ed0d 100644 --- a/src/librssguard/services/abstract/feed.cpp +++ b/src/librssguard/services/abstract/feed.cpp @@ -43,6 +43,7 @@ Feed::Feed(const Feed& other) : RootItem(other) { setAutoUpdateInitialInterval(other.autoUpdateInitialInterval()); setAutoUpdateRemainingInterval(other.autoUpdateRemainingInterval()); setMessageFilters(other.messageFilters()); + setDisplayUrl(other.displayUrl()); } QList Feed::undeletedMessages() const { @@ -171,6 +172,14 @@ void Feed::setSource(const QString& source) { m_source = source; } +bool Feed::displayUrl() const { + return m_displayUrl; +} + +void Feed::setDisplayUrl(bool flag) { + m_displayUrl = flag; +} + void Feed::appendMessageFilter(MessageFilter* filter) { m_messageFilters.append(QPointer(filter)); } diff --git a/src/librssguard/services/abstract/feed.h b/src/librssguard/services/abstract/feed.h index 9baf93252..7e2c8d8a7 100644 --- a/src/librssguard/services/abstract/feed.h +++ b/src/librssguard/services/abstract/feed.h @@ -73,6 +73,9 @@ class Feed : public RootItem { QString source() const; void setSource(const QString& source); + bool displayUrl() const; + void setDisplayUrl(bool flag); + void appendMessageFilter(MessageFilter* filter); QList> messageFilters() const; void setMessageFilters(const QList>& messageFilters); @@ -92,6 +95,7 @@ class Feed : public RootItem { AutoUpdateType m_autoUpdateType; int m_autoUpdateInitialInterval{}; int m_autoUpdateRemainingInterval{}; + bool m_displayUrl{false}; int m_totalCount{}; int m_unreadCount{}; QList> m_messageFilters; diff --git a/src/librssguard/services/abstract/gui/formfeeddetails.cpp b/src/librssguard/services/abstract/gui/formfeeddetails.cpp index 731adf219..64bdbcaad 100644 --- a/src/librssguard/services/abstract/gui/formfeeddetails.cpp +++ b/src/librssguard/services/abstract/gui/formfeeddetails.cpp @@ -47,6 +47,8 @@ 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())); + m_feed->setDisplayUrl(m_ui->m_cbLoadUrl->checkState() == Qt::CheckState::Checked); + if (!m_creatingNew) { // We need to make sure that common data are saved. @@ -90,6 +92,7 @@ void FormFeedDetails::loadFeedData() { m_ui->m_cmbAutoUpdateType->setCurrentIndex(m_ui->m_cmbAutoUpdateType->findData(QVariant::fromValue(int(m_feed->autoUpdateType())))); m_ui->m_spinAutoUpdateInterval->setValue(m_feed->autoUpdateInitialInterval()); + m_ui->m_cbLoadUrl->setCheckState(m_feed->displayUrl() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); } void FormFeedDetails::acceptIfPossible() { diff --git a/src/librssguard/services/abstract/gui/formfeeddetails.ui b/src/librssguard/services/abstract/gui/formfeeddetails.ui index a3ab7202e..f6674748f 100644 --- a/src/librssguard/services/abstract/gui/formfeeddetails.ui +++ b/src/librssguard/services/abstract/gui/formfeeddetails.ui @@ -21,7 +21,7 @@ - Auto-downloading of articles + Articles @@ -52,6 +52,23 @@ + + + + Display URL in preview + + + m_cmbAutoUpdateType + + + + + + + + + + @@ -87,8 +104,8 @@ reject() - 325 - 342 + 331 + 556 286