fix export/import
This commit is contained in:
parent
6fa7c1bd03
commit
5cb6e9e791
@ -30,7 +30,7 @@
|
||||
<url type="donation">https://martinrotter.github.io/donate/</url>
|
||||
<content_rating type="oars-1.1" />
|
||||
<releases>
|
||||
<release version="3.9.0" date="2021-03-08"/>
|
||||
<release version="3.9.0" date="2021-03-09"/>
|
||||
</releases>
|
||||
<content_rating type="oars-1.0">
|
||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||
|
File diff suppressed because one or more lines are too long
@ -158,7 +158,7 @@ class RSSGUARD_DLLSPEC FeedsModel : public QAbstractItemModel {
|
||||
|
||||
inline QVariant FeedsModel::data(const QModelIndex& index, int role) const {
|
||||
switch (role) {
|
||||
case Qt::FontRole:
|
||||
case Qt::ItemDataRole::FontRole:
|
||||
return itemForIndex(index)->countOfUnreadMessages() > 0 ? m_boldFont : m_normalFont;
|
||||
|
||||
default:
|
||||
|
@ -150,7 +150,8 @@ QSqlDatabase MariaDbDriver::initializeDatabase(const QString& connection_name) {
|
||||
database.setPassword(qApp->settings()->password(GROUP(Database), SETTING(Database::MySQLPassword)).toString());
|
||||
|
||||
if (!database.open()) {
|
||||
qFatal("Cannot open MySQL database: %s.", qPrintable(database.lastError().text()));
|
||||
qFatal("Cannot open MySQL database: %s. Make sure your DB server is running and "
|
||||
"start application again.", qPrintable(database.lastError().text()));
|
||||
}
|
||||
else {
|
||||
QSqlQuery query_db(database);
|
||||
@ -187,11 +188,11 @@ QSqlDatabase MariaDbDriver::initializeDatabase(const QString& connection_name) {
|
||||
if (installed_db_schema.toInt() < QString(APP_DB_SCHEMA_VERSION).toInt()) {
|
||||
if (updateDatabaseSchema(database, installed_db_schema, database_name)) {
|
||||
qDebugNN << LOGSEC_DB
|
||||
<< "Database schema was updated from '"
|
||||
<< installed_db_schema
|
||||
<< "' to '"
|
||||
<< APP_DB_SCHEMA_VERSION
|
||||
<< "' successully or it is already up to date.";
|
||||
<< "Database schema was updated from"
|
||||
<< QUOTE_W_SPACE(installed_db_schema)
|
||||
<< "to"
|
||||
<< QUOTE_W_SPACE(APP_DB_SCHEMA_VERSION)
|
||||
<< "successully or it is already up to date.";
|
||||
}
|
||||
else {
|
||||
qFatal("Database schema was not updated from '%s' to '%s' successully.",
|
||||
@ -204,7 +205,6 @@ QSqlDatabase MariaDbDriver::initializeDatabase(const QString& connection_name) {
|
||||
query_db.finish();
|
||||
}
|
||||
|
||||
// Everything is initialized now.
|
||||
m_databaseInitialized = true;
|
||||
return database;
|
||||
}
|
||||
@ -237,12 +237,10 @@ bool MariaDbDriver::updateDatabaseSchema(const QSqlDatabase& database,
|
||||
|
||||
// Increment the version.
|
||||
qDebugNN << LOGSEC_DB
|
||||
<< "Updating database schema: '"
|
||||
<< working_version
|
||||
<< "' -> '"
|
||||
<< working_version + 1
|
||||
<< "'.";
|
||||
|
||||
<< "Updating database schema "
|
||||
<< QUOTE_W_SPACE(working_version)
|
||||
<< "->"
|
||||
<< QUOTE_W_SPACE_DOT(working_version + 1);
|
||||
working_version++;
|
||||
}
|
||||
|
||||
|
@ -22,10 +22,10 @@ QIcon IconFactory::fromByteArray(QByteArray array) {
|
||||
QIcon icon;
|
||||
QBuffer buffer(&array);
|
||||
|
||||
buffer.open(QIODevice::ReadOnly);
|
||||
buffer.open(QIODevice::OpenModeFlag::ReadOnly);
|
||||
QDataStream in(&buffer);
|
||||
|
||||
in.setVersion(QDataStream::Qt_4_7);
|
||||
in.setVersion(QDataStream::Version::Qt_4_7);
|
||||
in >> icon;
|
||||
buffer.close();
|
||||
return icon;
|
||||
@ -35,10 +35,10 @@ QByteArray IconFactory::toByteArray(const QIcon& icon) {
|
||||
QByteArray array;
|
||||
QBuffer buffer(&array);
|
||||
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
buffer.open(QIODevice::OpenModeFlag::WriteOnly);
|
||||
QDataStream out(&buffer);
|
||||
|
||||
out.setVersion(QDataStream::Qt_4_7);
|
||||
out.setVersion(QDataStream::Version::Qt_4_7);
|
||||
out << icon;
|
||||
buffer.close();
|
||||
return array.toBase64();
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
#include "services/abstract/feed.h"
|
||||
|
||||
#include "database/databasequeries.h"
|
||||
#include "definitions/definitions.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "database/databasequeries.h"
|
||||
#include "miscellaneous/feedreader.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "miscellaneous/mutex.h"
|
||||
@ -52,7 +52,7 @@ QList<Message> Feed::undeletedMessages() const {
|
||||
|
||||
QVariant Feed::data(int column, int role) const {
|
||||
switch (role) {
|
||||
case Qt::ForegroundRole:
|
||||
case Qt::ItemDataRole::ForegroundRole:
|
||||
switch (status()) {
|
||||
case Status::NewMessages:
|
||||
return qApp->skins()->currentSkin().m_colorPalette[Skin::PaletteColors::Highlight];
|
||||
|
@ -122,11 +122,8 @@ int RootItem::row() const {
|
||||
}
|
||||
|
||||
QVariant RootItem::data(int column, int role) const {
|
||||
Q_UNUSED(column)
|
||||
Q_UNUSED(role)
|
||||
|
||||
switch (role) {
|
||||
case Qt::ToolTipRole:
|
||||
case Qt::ItemDataRole::ToolTipRole:
|
||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||
QString tool_tip = m_title;
|
||||
|
||||
@ -150,7 +147,7 @@ QVariant RootItem::data(int column, int role) const {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
case Qt::EditRole:
|
||||
case Qt::ItemDataRole::EditRole:
|
||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||
return m_title;
|
||||
}
|
||||
@ -161,7 +158,7 @@ QVariant RootItem::data(int column, int role) const {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
case Qt::DisplayRole:
|
||||
case Qt::ItemDataRole::DisplayRole:
|
||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||
return m_title;
|
||||
}
|
||||
@ -177,7 +174,7 @@ QVariant RootItem::data(int column, int role) const {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
case Qt::DecorationRole:
|
||||
case Qt::ItemDataRole::DecorationRole:
|
||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||
return fullIcon();
|
||||
}
|
||||
@ -185,7 +182,7 @@ QVariant RootItem::data(int column, int role) const {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
case Qt::TextAlignmentRole:
|
||||
case Qt::ItemDataRole::TextAlignmentRole:
|
||||
if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||
return Qt::AlignmentFlag::AlignCenter;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray& result) {
|
||||
outline_category.setAttribute(QSL("description"), child_item->description());
|
||||
|
||||
if (!child_item->icon().isNull()) {
|
||||
outline_category.setAttributeNS(APP_URL, QSL("rssguard:icon"), QString(qApp->icons()->toByteArray(child_item->icon())));
|
||||
outline_category.setAttribute(QSL("rssguard:icon"), QString(qApp->icons()->toByteArray(child_item->icon())));
|
||||
}
|
||||
|
||||
active_element.appendChild(outline_category);
|
||||
@ -98,11 +98,11 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray& result) {
|
||||
outline_feed.setAttribute(QSL("encoding"), child_feed->encoding());
|
||||
outline_feed.setAttribute(QSL("title"), child_feed->title());
|
||||
|
||||
outline_feed.setAttributeNS(APP_URL, QSL("rssguard:xmlUrlType"), QString::number(int(child_feed->sourceType())));
|
||||
outline_feed.setAttributeNS(APP_URL, QSL("rssguard:postProcess"), child_feed->postProcessScript());
|
||||
outline_feed.setAttribute(QSL("rssguard:xmlUrlType"), QString::number(int(child_feed->sourceType())));
|
||||
outline_feed.setAttribute(QSL("rssguard:postProcess"), child_feed->postProcessScript());
|
||||
|
||||
if (!child_feed->icon().isNull()) {
|
||||
outline_feed.setAttributeNS(APP_URL, QSL("rssguard:icon"), QString(qApp->icons()->toByteArray(child_feed->icon())));
|
||||
outline_feed.setAttribute(QSL("rssguard:icon"), QString(qApp->icons()->toByteArray(child_feed->icon())));
|
||||
}
|
||||
|
||||
switch (child_feed->type()) {
|
||||
@ -215,9 +215,9 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||
QString feed_encoding = child_element.attribute(QSL("encoding"), DEFAULT_FEED_ENCODING);
|
||||
QString feed_type = child_element.attribute(QSL("version"), DEFAULT_FEED_TYPE).toUpper();
|
||||
QString feed_description = child_element.attribute(QSL("description"));
|
||||
QIcon feed_icon = qApp->icons()->fromByteArray(child_element.attributeNS(APP_URL, QSL("icon")).toLocal8Bit());
|
||||
QString source_type = child_element.attributeNS(APP_URL, QSL("xmlUrlType"));
|
||||
QString post_process = child_element.attributeNS(APP_URL, QSL("postProcess"));
|
||||
QIcon feed_icon = qApp->icons()->fromByteArray(child_element.attribute(QSL("rssguard:icon")).toLocal8Bit());
|
||||
QString source_type = child_element.attribute(QSL("rssguard:xmlUrlType"));
|
||||
QString post_process = child_element.attribute(QSL("rssguard:postProcess"));
|
||||
auto* new_feed = new StandardFeed(active_model_item);
|
||||
|
||||
new_feed->setTitle(feed_title);
|
||||
@ -259,7 +259,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||
// Add category and continue.
|
||||
QString category_title = child_element.attribute(QSL("text"));
|
||||
QString category_description = child_element.attribute(QSL("description"));
|
||||
QIcon category_icon = qApp->icons()->fromByteArray(child_element.attributeNS(APP_URL, QSL("icon")).toLocal8Bit());
|
||||
QIcon category_icon = qApp->icons()->fromByteArray(child_element.attribute(QSL("rssguard:icon")).toLocal8Bit());
|
||||
|
||||
if (category_title.isEmpty()) {
|
||||
qWarningNN << LOGSEC_CORE
|
||||
|
@ -3,12 +3,12 @@
|
||||
#include "services/standard/standardserviceroot.h"
|
||||
|
||||
#include "core/feedsmodel.h"
|
||||
#include "database/databasequeries.h"
|
||||
#include "definitions/definitions.h"
|
||||
#include "exceptions/applicationexception.h"
|
||||
#include "exceptions/scriptexception.h"
|
||||
#include "gui/messagebox.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "database/databasequeries.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "miscellaneous/mutex.h"
|
||||
#include "miscellaneous/settings.h"
|
||||
@ -82,6 +82,9 @@ void StandardServiceRoot::start(bool freshly_activated) {
|
||||
MessageBox::show(qApp->mainFormWidget(), QMessageBox::Critical, tr("Error when loading initial feeds"), ex.message());
|
||||
}
|
||||
}
|
||||
else {
|
||||
requestItemExpand({ this }, true);
|
||||
}
|
||||
}
|
||||
|
||||
checkArgumentsForFeedAdding();
|
||||
|
Loading…
x
Reference in New Issue
Block a user