big refactoring of PR #588
This commit is contained in:
parent
547754e83d
commit
f5856679d4
@ -26,7 +26,7 @@
|
|||||||
<url type="donation">https://github.com/sponsors/martinrotter</url>
|
<url type="donation">https://github.com/sponsors/martinrotter</url>
|
||||||
<content_rating type="oars-1.1" />
|
<content_rating type="oars-1.1" />
|
||||||
<releases>
|
<releases>
|
||||||
<release version="4.1.2" date="2022-01-17"/>
|
<release version="4.1.2" date="2022-01-18"/>
|
||||||
</releases>
|
</releases>
|
||||||
<content_rating type="oars-1.0">
|
<content_rating type="oars-1.0">
|
||||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>sql/db_init_mysql.sql</file>
|
<file>sql/db_init_mysql.sql</file>
|
||||||
|
<file>sql/db_update_mysql_1_2.sql</file>
|
||||||
|
|
||||||
<file>sql/db_init_sqlite.sql</file>
|
<file>sql/db_init_sqlite.sql</file>
|
||||||
|
<file>sql/db_update_sqlite_1_2.sql</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
@ -3,7 +3,7 @@ CREATE TABLE Information (
|
|||||||
inf_value TEXT
|
inf_value TEXT
|
||||||
);
|
);
|
||||||
-- !
|
-- !
|
||||||
INSERT INTO Information VALUES ('schema_version', '1');
|
INSERT INTO Information VALUES ('schema_version', '2');
|
||||||
-- !
|
-- !
|
||||||
CREATE TABLE Accounts (
|
CREATE TABLE Accounts (
|
||||||
id $$,
|
id $$,
|
||||||
@ -40,11 +40,12 @@ CREATE TABLE Feeds (
|
|||||||
source TEXT,
|
source TEXT,
|
||||||
update_type INTEGER NOT NULL CHECK (update_type >= 0),
|
update_type INTEGER NOT NULL CHECK (update_type >= 0),
|
||||||
update_interval INTEGER NOT NULL DEFAULT 15 CHECK (update_interval >= 1),
|
update_interval INTEGER NOT NULL DEFAULT 15 CHECK (update_interval >= 1),
|
||||||
|
is_off INTEGER NOT NULL DEFAULT 0 CHECK (is_off >= 0 AND is_off <= 1),
|
||||||
|
open_articles INTEGER NOT NULL DEFAULT 0 CHECK (open_articles >= 0 AND open_articles <= 1),
|
||||||
account_id INTEGER NOT NULL,
|
account_id INTEGER NOT NULL,
|
||||||
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
|
||||||
);
|
);
|
||||||
|
3
resources/sql/db_update_mysql_1_2.sql
Executable file
3
resources/sql/db_update_mysql_1_2.sql
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
USE ##;
|
||||||
|
-- !
|
||||||
|
!! db_update_sqlite_1_2.sql
|
31
resources/sql/db_update_sqlite_1_2.sql
Executable file
31
resources/sql/db_update_sqlite_1_2.sql
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
CREATE TABLE backup_Feeds AS SELECT * FROM Feeds;
|
||||||
|
-- !
|
||||||
|
DROP TABLE Feeds;
|
||||||
|
-- !
|
||||||
|
CREATE TABLE Feeds (
|
||||||
|
id $$,
|
||||||
|
title TEXT NOT NULL CHECK (title != ''),
|
||||||
|
description TEXT,
|
||||||
|
date_created BIGINT,
|
||||||
|
icon ^^,
|
||||||
|
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),
|
||||||
|
is_off INTEGER NOT NULL DEFAULT 0 CHECK (is_off >= 0 AND is_off <= 1),
|
||||||
|
open_articles INTEGER NOT NULL DEFAULT 0 CHECK (open_articles >= 0 AND open_articles <= 1),
|
||||||
|
account_id INTEGER NOT NULL,
|
||||||
|
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,
|
||||||
|
|
||||||
|
FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
-- !
|
||||||
|
INSERT INTO Feeds (id, title, description, date_created, icon, category, source, update_type, update_interval, account_id, custom_id, custom_data)
|
||||||
|
SELECT id, title, description, date_created, icon, category, source, update_type, update_interval, account_id, custom_id, custom_data
|
||||||
|
FROM backup_Feeds;
|
||||||
|
-- !
|
||||||
|
DROP TABLE backup_Feeds;
|
||||||
|
-- !
|
||||||
|
UPDATE Information SET inf_value = '2' WHERE inf_key = 'schema_version';
|
@ -48,16 +48,16 @@ void DatabaseFactory::determineDriver() {
|
|||||||
qFatal("DB driver for '%s' was not found.", qPrintable(db_driver));
|
qFatal("DB driver for '%s' was not found.", qPrintable(db_driver));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_dbDriver->driverType() != DatabaseDriver::DriverType::SQLite) {
|
|
||||||
// Try to setup connection and fallback to SQLite.
|
// Try to setup connection and fallback to SQLite.
|
||||||
try {
|
try {
|
||||||
m_dbDriver->connection(QSL("DatabaseFactory"));
|
m_dbDriver->connection(QSL("DatabaseFactory"));
|
||||||
}
|
}
|
||||||
catch (const ApplicationException& ex) {
|
catch (const ApplicationException& ex) {
|
||||||
qCriticalNN << LOGSEC_DB
|
qCriticalNN << LOGSEC_DB
|
||||||
<< "Failed to reach connection to DB source, let's fallback to SQLite:"
|
<< "Failed to reach connection to DB source:"
|
||||||
<< QUOTE_W_SPACE_DOT(ex.message());
|
<< QUOTE_W_SPACE_DOT(ex.message());
|
||||||
|
|
||||||
|
if (m_dbDriver->driverType() != DatabaseDriver::DriverType::SQLite) {
|
||||||
MessageBox::show(nullptr,
|
MessageBox::show(nullptr,
|
||||||
QMessageBox::Icon::Critical,
|
QMessageBox::Icon::Critical,
|
||||||
tr("Cannot connect to database"),
|
tr("Cannot connect to database"),
|
||||||
|
@ -1989,8 +1989,8 @@ void DatabaseQueries::createOverwriteFeed(const QSqlDatabase& db, Feed* feed, in
|
|||||||
q.prepare("UPDATE Feeds "
|
q.prepare("UPDATE Feeds "
|
||||||
"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, is_off = :is_off, open_articles = :open_articles, "
|
||||||
" custom_id = :custom_id, custom_data = :custom_data, display_url = :display_url "
|
" account_id = :account_id, custom_id = :custom_id, custom_data = :custom_data "
|
||||||
"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,7 +2003,8 @@ 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());
|
q.bindValue(QSL(":is_off"), feed->isSwitchedOff());
|
||||||
|
q.bindValue(QSL(":open_articles"), feed->openArticlesDirectly());
|
||||||
|
|
||||||
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,14 +299,15 @@ 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());
|
feed->setIsSwitchedOff(query.value(FDS_DB_IS_OFF_INDEX).toBool());
|
||||||
|
feed->setOpenArticlesDirectly(query.value(FDS_DB_OPEN_ARTICLES_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"
|
||||||
<< QUOTE_W_SPACE_DOT(feed->customId());
|
<< QUOTE_W_SPACE_DOT(feed->customId());
|
||||||
|
|
||||||
// Load custom data.
|
// Load custom data.
|
||||||
feed->setCustomDatabaseData(deserializeCustomData(query.value(QSL("custom_data")).toString()));
|
feed->setCustomDatabaseData(deserializeCustomData(query.value(FDS_DB_CUSTOM_DATA_INDEX).toString()));
|
||||||
|
|
||||||
if (filters_in_feeds.contains(feed->customId())) {
|
if (filters_in_feeds.contains(feed->customId())) {
|
||||||
auto all_filters_for_this_feed = filters_in_feeds.values(feed->customId());
|
auto all_filters_for_this_feed = filters_in_feeds.values(feed->customId());
|
||||||
|
@ -191,7 +191,7 @@ QSqlDatabase MariaDbDriver::initializeDatabase(const QString& connection_name) {
|
|||||||
const QString installed_db_schema = query_db.value(0).toString();
|
const QString installed_db_schema = query_db.value(0).toString();
|
||||||
|
|
||||||
if (installed_db_schema.toInt() < QSL(APP_DB_SCHEMA_VERSION).toInt()) {
|
if (installed_db_schema.toInt() < QSL(APP_DB_SCHEMA_VERSION).toInt()) {
|
||||||
if (updateDatabaseSchema(database, installed_db_schema, database_name)) {
|
if (updateDatabaseSchema(query_db, installed_db_schema, database_name)) {
|
||||||
qDebugNN << LOGSEC_DB
|
qDebugNN << LOGSEC_DB
|
||||||
<< "Database schema was updated from"
|
<< "Database schema was updated from"
|
||||||
<< QUOTE_W_SPACE(installed_db_schema)
|
<< QUOTE_W_SPACE(installed_db_schema)
|
||||||
@ -214,7 +214,7 @@ QSqlDatabase MariaDbDriver::initializeDatabase(const QString& connection_name) {
|
|||||||
return database;
|
return database;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MariaDbDriver::updateDatabaseSchema(const QSqlDatabase& database,
|
bool MariaDbDriver::updateDatabaseSchema(QSqlQuery& query,
|
||||||
const QString& source_db_schema_version,
|
const QString& source_db_schema_version,
|
||||||
const QString& database_name) {
|
const QString& database_name) {
|
||||||
int working_version = QString(source_db_schema_version).remove('.').toInt();
|
int working_version = QString(source_db_schema_version).remove('.').toInt();
|
||||||
@ -229,8 +229,6 @@ bool MariaDbDriver::updateDatabaseSchema(const QSqlDatabase& database,
|
|||||||
database_name);
|
database_name);
|
||||||
|
|
||||||
for (const QString& statement : statements) {
|
for (const QString& statement : statements) {
|
||||||
QSqlQuery query = database.exec(statement);
|
|
||||||
|
|
||||||
if (!query.exec(statement) && query.lastError().isValid()) {
|
if (!query.exec(statement) && query.lastError().isValid()) {
|
||||||
throw ApplicationException(query.lastError().text());
|
throw ApplicationException(query.lastError().text());
|
||||||
}
|
}
|
||||||
@ -246,6 +244,7 @@ bool MariaDbDriver::updateDatabaseSchema(const QSqlDatabase& database,
|
|||||||
<< QUOTE_W_SPACE(working_version)
|
<< QUOTE_W_SPACE(working_version)
|
||||||
<< "->"
|
<< "->"
|
||||||
<< QUOTE_W_SPACE_DOT(working_version + 1);
|
<< QUOTE_W_SPACE_DOT(working_version + 1);
|
||||||
|
|
||||||
working_version++;
|
working_version++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class MariaDbDriver : public DatabaseDriver {
|
|||||||
QString interpretErrorCode(MariaDbError error_code) const;
|
QString interpretErrorCode(MariaDbError error_code) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool updateDatabaseSchema(const QSqlDatabase& database,
|
bool updateDatabaseSchema(QSqlQuery &query,
|
||||||
const QString& source_db_schema_version,
|
const QString& source_db_schema_version,
|
||||||
const QString& database_name);
|
const QString& database_name);
|
||||||
QSqlDatabase initializeDatabase(const QString& connection_name);
|
QSqlDatabase initializeDatabase(const QString& connection_name);
|
||||||
|
@ -262,7 +262,7 @@ QSqlDatabase SqliteDriver::initializeDatabase(const QString& connection_name, bo
|
|||||||
const QString installed_db_schema = query_db.value(0).toString();
|
const QString installed_db_schema = query_db.value(0).toString();
|
||||||
|
|
||||||
if (installed_db_schema.toInt() < QSL(APP_DB_SCHEMA_VERSION).toInt()) {
|
if (installed_db_schema.toInt() < QSL(APP_DB_SCHEMA_VERSION).toInt()) {
|
||||||
if (updateDatabaseSchema(database, installed_db_schema)) {
|
if (updateDatabaseSchema(query_db, installed_db_schema)) {
|
||||||
qDebugNN << LOGSEC_DB
|
qDebugNN << LOGSEC_DB
|
||||||
<< "Database schema was updated from '"
|
<< "Database schema was updated from '"
|
||||||
<< installed_db_schema
|
<< installed_db_schema
|
||||||
@ -342,7 +342,7 @@ QString SqliteDriver::databaseFilePath() const {
|
|||||||
return m_databaseFilePath + QDir::separator() + APP_DB_SQLITE_FILE;
|
return m_databaseFilePath + QDir::separator() + APP_DB_SQLITE_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SqliteDriver::updateDatabaseSchema(const QSqlDatabase& database, const QString& source_db_schema_version) {
|
bool SqliteDriver::updateDatabaseSchema(QSqlQuery& query, const QString& source_db_schema_version) {
|
||||||
int working_version = QString(source_db_schema_version).remove('.').toInt();
|
int working_version = QString(source_db_schema_version).remove('.').toInt();
|
||||||
const int current_version = QSL(APP_DB_SCHEMA_VERSION).remove('.').toInt();
|
const int current_version = QSL(APP_DB_SCHEMA_VERSION).remove('.').toInt();
|
||||||
|
|
||||||
@ -362,8 +362,6 @@ bool SqliteDriver::updateDatabaseSchema(const QSqlDatabase& database, const QStr
|
|||||||
QString::number(working_version + 1)));
|
QString::number(working_version + 1)));
|
||||||
|
|
||||||
for (const QString& statement : statements) {
|
for (const QString& statement : statements) {
|
||||||
QSqlQuery query = database.exec(statement);
|
|
||||||
|
|
||||||
if (!query.exec(statement) && query.lastError().isValid()) {
|
if (!query.exec(statement) && query.lastError().isValid()) {
|
||||||
throw ApplicationException(query.lastError().text());
|
throw ApplicationException(query.lastError().text());
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class SqliteDriver : public DatabaseDriver {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QSqlDatabase initializeDatabase(const QString& connection_name, bool in_memory);
|
QSqlDatabase initializeDatabase(const QString& connection_name, bool in_memory);
|
||||||
bool updateDatabaseSchema(const QSqlDatabase& database, const QString& source_db_schema_version);
|
bool updateDatabaseSchema(QSqlQuery &query, const QString& source_db_schema_version);
|
||||||
void setPragmas(QSqlQuery& query);
|
void setPragmas(QSqlQuery& query);
|
||||||
QString databaseFilePath() const;
|
QString databaseFilePath() const;
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@
|
|||||||
#define APP_DB_SQLITE_FILE "database.db"
|
#define APP_DB_SQLITE_FILE "database.db"
|
||||||
|
|
||||||
// Keep this in sync with schema versions declared in SQL initialization code.
|
// Keep this in sync with schema versions declared in SQL initialization code.
|
||||||
#define APP_DB_SCHEMA_VERSION "1"
|
#define APP_DB_SCHEMA_VERSION "2"
|
||||||
#define APP_DB_UPDATE_FILE_PATTERN "db_update_%1_%2_%3.sql"
|
#define APP_DB_UPDATE_FILE_PATTERN "db_update_%1_%2_%3.sql"
|
||||||
#define APP_DB_COMMENT_SPLIT "-- !\n"
|
#define APP_DB_COMMENT_SPLIT "-- !\n"
|
||||||
#define APP_DB_INCLUDE_PLACEHOLDER "!!"
|
#define APP_DB_INCLUDE_PLACEHOLDER "!!"
|
||||||
@ -246,10 +246,11 @@
|
|||||||
#define FDS_DB_SOURCE_INDEX 6
|
#define FDS_DB_SOURCE_INDEX 6
|
||||||
#define FDS_DB_UPDATE_TYPE_INDEX 7
|
#define FDS_DB_UPDATE_TYPE_INDEX 7
|
||||||
#define FDS_DB_UPDATE_INTERVAL_INDEX 8
|
#define FDS_DB_UPDATE_INTERVAL_INDEX 8
|
||||||
#define FDS_DB_ACCOUNT_ID_INDEX 9
|
#define FDS_DB_IS_OFF_INDEX 9
|
||||||
#define FDS_DB_CUSTOM_ID_INDEX 10
|
#define FDS_DB_OPEN_ARTICLES_INDEX 10
|
||||||
#define FDS_DB_CUSTOM_DATA_INDEX 11
|
#define FDS_DB_ACCOUNT_ID_INDEX 11
|
||||||
#define FDS_DB_DISPLAY_URL_INDEX 12
|
#define FDS_DB_CUSTOM_ID_INDEX 12
|
||||||
|
#define FDS_DB_CUSTOM_DATA_INDEX 13
|
||||||
|
|
||||||
// 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,15 +121,23 @@ void MessagePreviewer::loadMessage(const Message& message, RootItem* root) {
|
|||||||
|
|
||||||
if (!same_message) {
|
if (!same_message) {
|
||||||
m_txtMessage->setVerticalScrollBarPosition(0.0);
|
m_txtMessage->setVerticalScrollBarPosition(0.0);
|
||||||
|
|
||||||
|
#if defined(USE_WEBENGINE)
|
||||||
|
const auto msg_feed_id = message.m_feedId;
|
||||||
const auto* feed = root->getParentServiceRoot()->getItemFromSubTree(
|
const auto* feed = root->getParentServiceRoot()->getItemFromSubTree(
|
||||||
[feedId = message.m_feedId](const RootItem * it) {
|
[msg_feed_id](const RootItem* it) {
|
||||||
return it->kind() == RootItem::Kind::Feed && it->customId() == feedId;
|
return it->kind() == RootItem::Kind::Feed && it->customId() == msg_feed_id;
|
||||||
})->toFeed();
|
})->toFeed();
|
||||||
if (feed && feed->displayUrl()) {
|
|
||||||
|
if (feed != nullptr && feed->openArticlesDirectly()) {
|
||||||
m_txtMessage->loadUrl(m_message.m_url);
|
m_txtMessage->loadUrl(m_message.m_url);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
m_txtMessage->loadMessage(message, m_root);
|
m_txtMessage->loadMessage(message, m_root);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
m_txtMessage->loadMessage(message, m_root);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
Feed::Feed(RootItem* parent)
|
Feed::Feed(RootItem* parent)
|
||||||
: RootItem(parent), m_source(QString()), m_status(Status::Normal), m_statusString(QString()), m_autoUpdateType(AutoUpdateType::DefaultAutoUpdate),
|
: RootItem(parent), m_source(QString()), m_status(Status::Normal), m_statusString(QString()), m_autoUpdateType(AutoUpdateType::DefaultAutoUpdate),
|
||||||
m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL),
|
m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL),
|
||||||
m_messageFilters(QList<QPointer<MessageFilter>>()) {
|
m_isSwitchedOff(false), m_openArticlesDirectly(false), m_messageFilters(QList<QPointer<MessageFilter>>()) {
|
||||||
setKind(RootItem::Kind::Feed);
|
setKind(RootItem::Kind::Feed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,8 @@ 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());
|
setOpenArticlesDirectly(other.openArticlesDirectly());
|
||||||
|
setIsSwitchedOff(other.isSwitchedOff());
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Message> Feed::undeletedMessages() const {
|
QList<Message> Feed::undeletedMessages() const {
|
||||||
@ -172,12 +173,12 @@ void Feed::setSource(const QString& source) {
|
|||||||
m_source = source;
|
m_source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Feed::displayUrl() const {
|
bool Feed::openArticlesDirectly() const {
|
||||||
return m_displayUrl;
|
return m_openArticlesDirectly;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Feed::setDisplayUrl(bool flag) {
|
void Feed::setOpenArticlesDirectly(bool opn) {
|
||||||
m_displayUrl = flag;
|
m_openArticlesDirectly = opn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Feed::appendMessageFilter(MessageFilter* filter) {
|
void Feed::appendMessageFilter(MessageFilter* filter) {
|
||||||
@ -266,6 +267,14 @@ QString Feed::getStatusDescription() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Feed::isSwitchedOff() const {
|
||||||
|
return m_isSwitchedOff;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Feed::setIsSwitchedOff(bool switched_off) {
|
||||||
|
m_isSwitchedOff = switched_off;
|
||||||
|
}
|
||||||
|
|
||||||
QString Feed::statusString() const {
|
QString Feed::statusString() const {
|
||||||
return m_statusString;
|
return m_statusString;
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,11 @@ class Feed : public RootItem {
|
|||||||
QString source() const;
|
QString source() const;
|
||||||
void setSource(const QString& source);
|
void setSource(const QString& source);
|
||||||
|
|
||||||
bool displayUrl() const;
|
bool openArticlesDirectly() const;
|
||||||
void setDisplayUrl(bool flag);
|
void setOpenArticlesDirectly(bool opn);
|
||||||
|
|
||||||
|
bool isSwitchedOff() const;
|
||||||
|
void setIsSwitchedOff(bool switched_off);
|
||||||
|
|
||||||
void appendMessageFilter(MessageFilter* filter);
|
void appendMessageFilter(MessageFilter* filter);
|
||||||
QList<QPointer<MessageFilter>> messageFilters() const;
|
QList<QPointer<MessageFilter>> messageFilters() const;
|
||||||
@ -95,7 +98,8 @@ 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};
|
bool m_isSwitchedOff;
|
||||||
|
bool m_openArticlesDirectly;
|
||||||
int m_totalCount{};
|
int m_totalCount{};
|
||||||
int m_unreadCount{};
|
int m_unreadCount{};
|
||||||
QList<QPointer<MessageFilter>> m_messageFilters;
|
QList<QPointer<MessageFilter>> m_messageFilters;
|
||||||
|
@ -47,8 +47,7 @@ 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);
|
m_feed->setOpenArticlesDirectly(m_ui->m_cbOpenArticlesAutomatically->isChecked());
|
||||||
|
|
||||||
|
|
||||||
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.
|
||||||
@ -92,7 +91,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);
|
m_ui->m_cbOpenArticlesAutomatically->setChecked(m_feed->openArticlesDirectly());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormFeedDetails::acceptIfPossible() {
|
void FormFeedDetails::acceptIfPossible() {
|
||||||
|
@ -52,20 +52,10 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_7">
|
<widget class="QCheckBox" name="m_cbOpenArticlesAutomatically">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Display URL in preview</string>
|
<string>Open articles via their URL automatically</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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -373,6 +373,9 @@ QMap<QString, QVariantMap> ServiceRoot::storeCustomFeedsData() {
|
|||||||
feed_custom_data.insert(QSL("auto_update_interval"), feed->autoUpdateInitialInterval());
|
feed_custom_data.insert(QSL("auto_update_interval"), feed->autoUpdateInitialInterval());
|
||||||
feed_custom_data.insert(QSL("auto_update_type"), int(feed->autoUpdateType()));
|
feed_custom_data.insert(QSL("auto_update_type"), int(feed->autoUpdateType()));
|
||||||
feed_custom_data.insert(QSL("msg_filters"), QVariant::fromValue(feed->messageFilters()));
|
feed_custom_data.insert(QSL("msg_filters"), QVariant::fromValue(feed->messageFilters()));
|
||||||
|
feed_custom_data.insert(QSL("is_off"), feed->isSwitchedOff());
|
||||||
|
feed_custom_data.insert(QSL("open_articles_directly"), feed->openArticlesDirectly());
|
||||||
|
|
||||||
custom_data.insert(feed->customId(), feed_custom_data);
|
custom_data.insert(feed->customId(), feed_custom_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,6 +396,9 @@ void ServiceRoot::restoreCustomFeedsData(const QMap<QString, QVariantMap>& data,
|
|||||||
feed->setAutoUpdateInitialInterval(feed_custom_data.value(QSL("auto_update_interval")).toInt());
|
feed->setAutoUpdateInitialInterval(feed_custom_data.value(QSL("auto_update_interval")).toInt());
|
||||||
feed->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(feed_custom_data.value(QSL("auto_update_type")).toInt()));
|
feed->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(feed_custom_data.value(QSL("auto_update_type")).toInt()));
|
||||||
feed->setMessageFilters(feed_custom_data.value(QSL("msg_filters")).value<QList<QPointer<MessageFilter>>>());
|
feed->setMessageFilters(feed_custom_data.value(QSL("msg_filters")).value<QList<QPointer<MessageFilter>>>());
|
||||||
|
|
||||||
|
feed->setIsSwitchedOff(feed_custom_data.value(QSL("is_off")).toBool());
|
||||||
|
feed->setOpenArticlesDirectly(feed_custom_data.value(QSL("open_articles_directly")).toBool());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user