add feed option to load article URL in message preview (#588)
* add feed option to load article URL in message preview Some RSS feeds (such as reddit.com) provide quite limited `content` section, thus it is desirable to load the URL into the message preview. * Support displayUrl for all feed types
This commit is contained in:
parent
9b3e41344f
commit
547754e83d
@ -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_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 column for (serialized) custom account-specific data. */
|
||||||
custom_data TEXT,
|
custom_data TEXT,
|
||||||
|
display_url BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
|
||||||
FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE
|
FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
@ -1990,7 +1990,7 @@ void DatabaseQueries::createOverwriteFeed(const QSqlDatabase& db, Feed* feed, in
|
|||||||
"SET title = :title, description = :description, date_created = :date_created, "
|
"SET title = :title, description = :description, date_created = :date_created, "
|
||||||
" icon = :icon, category = :category, source = :source, update_type = :update_type, "
|
" icon = :icon, category = :category, source = :source, update_type = :update_type, "
|
||||||
" update_interval = :update_interval, account_id = :account_id, "
|
" 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;");
|
"WHERE id = :id;");
|
||||||
q.bindValue(QSL(":title"), feed->title());
|
q.bindValue(QSL(":title"), feed->title());
|
||||||
q.bindValue(QSL(":description"), feed->description());
|
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(":account_id"), account_id);
|
||||||
q.bindValue(QSL(":custom_id"), feed->customId());
|
q.bindValue(QSL(":custom_id"), feed->customId());
|
||||||
q.bindValue(QSL(":id"), feed->id());
|
q.bindValue(QSL(":id"), feed->id());
|
||||||
|
q.bindValue(QSL(":display_url"), feed->displayUrl());
|
||||||
|
|
||||||
auto custom_data = feed->customDatabaseData();
|
auto custom_data = feed->customDatabaseData();
|
||||||
QString serialized_custom_data = serializeCustomData(custom_data);
|
QString serialized_custom_data = serializeCustomData(custom_data);
|
||||||
|
@ -299,6 +299,7 @@ Assignment DatabaseQueries::getFeeds(const QSqlDatabase& db,
|
|||||||
feed->setIcon(qApp->icons()->fromByteArray(query.value(FDS_DB_ICON_INDEX).toByteArray()));
|
feed->setIcon(qApp->icons()->fromByteArray(query.value(FDS_DB_ICON_INDEX).toByteArray()));
|
||||||
feed->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(query.value(FDS_DB_UPDATE_TYPE_INDEX).toInt()));
|
feed->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(query.value(FDS_DB_UPDATE_TYPE_INDEX).toInt()));
|
||||||
feed->setAutoUpdateInitialInterval(query.value(FDS_DB_UPDATE_INTERVAL_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
|
qDebugNN << LOGSEC_CORE
|
||||||
<< "Custom ID of feed when loading from DB is"
|
<< "Custom ID of feed when loading from DB is"
|
||||||
|
@ -249,6 +249,7 @@
|
|||||||
#define FDS_DB_ACCOUNT_ID_INDEX 9
|
#define FDS_DB_ACCOUNT_ID_INDEX 9
|
||||||
#define FDS_DB_CUSTOM_ID_INDEX 10
|
#define FDS_DB_CUSTOM_ID_INDEX 10
|
||||||
#define FDS_DB_CUSTOM_DATA_INDEX 11
|
#define FDS_DB_CUSTOM_DATA_INDEX 11
|
||||||
|
#define FDS_DB_DISPLAY_URL_INDEX 12
|
||||||
|
|
||||||
// Indexes of columns for feed models.
|
// Indexes of columns for feed models.
|
||||||
#define FDS_MODEL_TITLE_INDEX 0
|
#define FDS_MODEL_TITLE_INDEX 0
|
||||||
|
@ -121,7 +121,15 @@ void MessagePreviewer::loadMessage(const Message& message, RootItem* root) {
|
|||||||
|
|
||||||
if (!same_message) {
|
if (!same_message) {
|
||||||
m_txtMessage->setVerticalScrollBarPosition(0.0);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ Feed::Feed(const Feed& other) : RootItem(other) {
|
|||||||
setAutoUpdateInitialInterval(other.autoUpdateInitialInterval());
|
setAutoUpdateInitialInterval(other.autoUpdateInitialInterval());
|
||||||
setAutoUpdateRemainingInterval(other.autoUpdateRemainingInterval());
|
setAutoUpdateRemainingInterval(other.autoUpdateRemainingInterval());
|
||||||
setMessageFilters(other.messageFilters());
|
setMessageFilters(other.messageFilters());
|
||||||
|
setDisplayUrl(other.displayUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Message> Feed::undeletedMessages() const {
|
QList<Message> Feed::undeletedMessages() const {
|
||||||
@ -171,6 +172,14 @@ void Feed::setSource(const QString& source) {
|
|||||||
m_source = source;
|
m_source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Feed::displayUrl() const {
|
||||||
|
return m_displayUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Feed::setDisplayUrl(bool flag) {
|
||||||
|
m_displayUrl = flag;
|
||||||
|
}
|
||||||
|
|
||||||
void Feed::appendMessageFilter(MessageFilter* filter) {
|
void Feed::appendMessageFilter(MessageFilter* filter) {
|
||||||
m_messageFilters.append(QPointer<MessageFilter>(filter));
|
m_messageFilters.append(QPointer<MessageFilter>(filter));
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,9 @@ class Feed : public RootItem {
|
|||||||
QString source() const;
|
QString source() const;
|
||||||
void setSource(const QString& source);
|
void setSource(const QString& source);
|
||||||
|
|
||||||
|
bool displayUrl() const;
|
||||||
|
void setDisplayUrl(bool flag);
|
||||||
|
|
||||||
void appendMessageFilter(MessageFilter* filter);
|
void appendMessageFilter(MessageFilter* filter);
|
||||||
QList<QPointer<MessageFilter>> messageFilters() const;
|
QList<QPointer<MessageFilter>> messageFilters() const;
|
||||||
void setMessageFilters(const QList<QPointer<MessageFilter>>& messageFilters);
|
void setMessageFilters(const QList<QPointer<MessageFilter>>& messageFilters);
|
||||||
@ -92,6 +95,7 @@ class Feed : public RootItem {
|
|||||||
AutoUpdateType m_autoUpdateType;
|
AutoUpdateType m_autoUpdateType;
|
||||||
int m_autoUpdateInitialInterval{};
|
int m_autoUpdateInitialInterval{};
|
||||||
int m_autoUpdateRemainingInterval{};
|
int m_autoUpdateRemainingInterval{};
|
||||||
|
bool m_displayUrl{false};
|
||||||
int m_totalCount{};
|
int m_totalCount{};
|
||||||
int m_unreadCount{};
|
int m_unreadCount{};
|
||||||
QList<QPointer<MessageFilter>> m_messageFilters;
|
QList<QPointer<MessageFilter>> m_messageFilters;
|
||||||
|
@ -47,6 +47,8 @@ void FormFeedDetails::apply() {
|
|||||||
m_feed->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(
|
m_feed->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(
|
||||||
m_ui->m_cmbAutoUpdateType->currentIndex()).toInt()));
|
m_ui->m_cmbAutoUpdateType->currentIndex()).toInt()));
|
||||||
m_feed->setAutoUpdateInitialInterval(int(m_ui->m_spinAutoUpdateInterval->value()));
|
m_feed->setAutoUpdateInitialInterval(int(m_ui->m_spinAutoUpdateInterval->value()));
|
||||||
|
m_feed->setDisplayUrl(m_ui->m_cbLoadUrl->checkState() == Qt::CheckState::Checked);
|
||||||
|
|
||||||
|
|
||||||
if (!m_creatingNew) {
|
if (!m_creatingNew) {
|
||||||
// We need to make sure that common data are saved.
|
// 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_cmbAutoUpdateType->setCurrentIndex(m_ui->m_cmbAutoUpdateType->findData(QVariant::fromValue(int(m_feed->autoUpdateType()))));
|
||||||
m_ui->m_spinAutoUpdateInterval->setValue(m_feed->autoUpdateInitialInterval());
|
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() {
|
void FormFeedDetails::acceptIfPossible() {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tabUpdating">
|
<widget class="QWidget" name="tabUpdating">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Auto-downloading of articles</string>
|
<string>Articles</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
@ -52,6 +52,23 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="text">
|
||||||
|
<string>Display URL in preview</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>m_cmbAutoUpdateType</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QCheckBox" name="m_cbLoadUrl">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
@ -87,8 +104,8 @@
|
|||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>325</x>
|
<x>331</x>
|
||||||
<y>342</y>
|
<y>556</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>286</x>
|
<x>286</x>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user