fix #685
This commit is contained in:
parent
9fb922f785
commit
52798f9ed2
6 changed files with 111 additions and 100 deletions
|
@ -39,7 +39,7 @@ BraceWrapping:
|
||||||
AfterStruct: false
|
AfterStruct: false
|
||||||
AfterUnion: false
|
AfterUnion: false
|
||||||
AfterExternBlock: false
|
AfterExternBlock: false
|
||||||
BeforeCatch: false
|
BeforeCatch: true
|
||||||
BeforeElse: true
|
BeforeElse: true
|
||||||
BeforeLambdaBody: false
|
BeforeLambdaBody: false
|
||||||
BeforeWhile: true
|
BeforeWhile: true
|
||||||
|
|
|
@ -60,18 +60,13 @@ bool WebEnginePage::acceptNavigationRequest(const QUrl& url, NavigationType type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (url.host() == INTERNAL_URL_MESSAGE_HOST) {
|
|
||||||
setHtml(view()->messageContents(), QUrl(INTERNAL_URL_MESSAGE));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {*/
|
|
||||||
return QWebEnginePage::acceptNavigationRequest(url, type, is_main_frame);
|
return QWebEnginePage::acceptNavigationRequest(url, type, is_main_frame);
|
||||||
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebEnginePage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message,
|
void WebEnginePage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level,
|
||||||
int line_number, const QString& source_id) {
|
const QString& message,
|
||||||
|
int line_number,
|
||||||
|
const QString& source_id) {
|
||||||
Q_UNUSED(level)
|
Q_UNUSED(level)
|
||||||
|
|
||||||
qWarningNN << LOGSEC_JS << message << QSL(" (source: %1:%2)").arg(source_id, QString::number(line_number));
|
qWarningNN << LOGSEC_JS << message << QSL(" (source: %1:%2)").arg(source_id, QString::number(line_number));
|
||||||
|
|
|
@ -27,11 +27,18 @@ FormStandardImportExport::FormStandardImportExport(StandardServiceRoot* service_
|
||||||
|
|
||||||
GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("document-export")));
|
GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("document-export")));
|
||||||
|
|
||||||
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::StatusType::Error, tr("No file is selected."), tr("No file is selected."));
|
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::StatusType::Error,
|
||||||
|
tr("No file is selected."),
|
||||||
|
tr("No file is selected."));
|
||||||
m_ui->m_buttonBox->button(QDialogButtonBox::StandardButton::Ok)->disconnect();
|
m_ui->m_buttonBox->button(QDialogButtonBox::StandardButton::Ok)->disconnect();
|
||||||
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Warning, tr("No operation executed yet."), tr("No operation executed yet."));
|
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Warning,
|
||||||
|
tr("No operation executed yet."),
|
||||||
|
tr("No operation executed yet."));
|
||||||
|
|
||||||
connect(m_ui->m_buttonBox->button(QDialogButtonBox::StandardButton::Ok), &QPushButton::clicked, this, &FormStandardImportExport::performAction);
|
connect(m_ui->m_buttonBox->button(QDialogButtonBox::StandardButton::Ok),
|
||||||
|
&QPushButton::clicked,
|
||||||
|
this,
|
||||||
|
&FormStandardImportExport::performAction);
|
||||||
connect(m_ui->m_btnSelectFile, &QPushButton::clicked, this, &FormStandardImportExport::selectFile);
|
connect(m_ui->m_btnSelectFile, &QPushButton::clicked, this, &FormStandardImportExport::selectFile);
|
||||||
connect(m_ui->m_btnCheckAllItems, &QPushButton::clicked, m_model, &FeedsImportExportModel::checkAllItems);
|
connect(m_ui->m_btnCheckAllItems, &QPushButton::clicked, m_model, &FeedsImportExportModel::checkAllItems);
|
||||||
connect(m_ui->m_btnUncheckAllItems, &QPushButton::clicked, m_model, &FeedsImportExportModel::uncheckAllItems);
|
connect(m_ui->m_btnUncheckAllItems, &QPushButton::clicked, m_model, &FeedsImportExportModel::uncheckAllItems);
|
||||||
|
@ -61,10 +68,12 @@ void FormStandardImportExport::setMode(FeedsImportExportModel::Mode mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case FeedsImportExportModel::Mode::Import: {
|
case FeedsImportExportModel::Mode::Import: {
|
||||||
|
m_ui->m_cbExportIcons->setVisible(false);
|
||||||
m_ui->m_groupFile->setTitle(tr("Source file"));
|
m_ui->m_groupFile->setTitle(tr("Source file"));
|
||||||
m_ui->m_groupFeeds->setTitle(tr("Target feeds && categories"));
|
m_ui->m_groupFeeds->setTitle(tr("Target feeds && categories"));
|
||||||
m_ui->m_groupFeeds->setDisabled(true);
|
m_ui->m_groupFeeds->setDisabled(true);
|
||||||
m_ui->m_buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setText(tr("&Import from file"));
|
m_ui->m_buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setText(tr("&Import from file"));
|
||||||
|
m_ui->m_buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setEnabled(false);
|
||||||
|
|
||||||
// Load categories.
|
// Load categories.
|
||||||
loadCategories(m_serviceRoot->getSubTreeCategories(), m_serviceRoot);
|
loadCategories(m_serviceRoot->getSubTreeCategories(), m_serviceRoot);
|
||||||
|
@ -76,8 +85,6 @@ void FormStandardImportExport::setMode(FeedsImportExportModel::Mode mode) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui->m_buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormStandardImportExport::selectFile() {
|
void FormStandardImportExport::selectFile() {
|
||||||
|
@ -122,7 +129,8 @@ void FormStandardImportExport::onParsingFinished(int count_failed, int count_suc
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ui->m_groupFeeds->setEnabled(false);
|
m_ui->m_groupFeeds->setEnabled(false);
|
||||||
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error, tr("Error, file is not well-formed. Select another file."),
|
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error,
|
||||||
|
tr("Error, file is not well-formed. Select another file."),
|
||||||
tr("Error occurred. File is not well-formed. Select another file."));
|
tr("Error occurred. File is not well-formed. Select another file."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,8 +143,7 @@ void FormStandardImportExport::onParsingProgress(int completed, int total) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormStandardImportExport::selectExportFile(bool without_dialog) {
|
void FormStandardImportExport::selectExportFile(bool without_dialog) {
|
||||||
const QString the_file = qApp->homeFolder() +
|
const QString the_file = qApp->homeFolder() + QDir::separator() +
|
||||||
QDir::separator() +
|
|
||||||
QSL("rssguard_feeds_%1.opml").arg(QDate::currentDate().toString(Qt::DateFormat::ISODate));
|
QSL("rssguard_feeds_%1.opml").arg(QDate::currentDate().toString(Qt::DateFormat::ISODate));
|
||||||
QString selected_file;
|
QString selected_file;
|
||||||
QString selected_filter;
|
QString selected_filter;
|
||||||
|
@ -150,10 +157,8 @@ void FormStandardImportExport::selectExportFile(bool without_dialog) {
|
||||||
filter += filter_opml20;
|
filter += filter_opml20;
|
||||||
filter += QSL(";;");
|
filter += QSL(";;");
|
||||||
filter += filter_txt_url_per_line;
|
filter += filter_txt_url_per_line;
|
||||||
selected_file = QFileDialog::getSaveFileName(this, tr("Select file for feeds export"),
|
selected_file =
|
||||||
the_file,
|
QFileDialog::getSaveFileName(this, tr("Select file for feeds export"), the_file, filter, &selected_filter);
|
||||||
filter,
|
|
||||||
&selected_filter);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
selected_file = the_file;
|
selected_file = the_file;
|
||||||
|
@ -176,10 +181,14 @@ void FormStandardImportExport::selectExportFile(bool without_dialog) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::StatusType::Ok, QDir::toNativeSeparators(selected_file), tr("File is selected."));
|
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::StatusType::Ok,
|
||||||
|
QDir::toNativeSeparators(selected_file),
|
||||||
|
tr("File is selected."));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui->m_buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setEnabled(m_ui->m_lblSelectFile->status() == WidgetWithStatus::StatusType::Ok);
|
const auto is_ok = m_ui->m_lblSelectFile->status() == WidgetWithStatus::StatusType::Ok;
|
||||||
|
|
||||||
|
m_ui->m_buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setEnabled(is_ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormStandardImportExport::selectImportFile() {
|
void FormStandardImportExport::selectImportFile() {
|
||||||
|
@ -192,8 +201,11 @@ void FormStandardImportExport::selectImportFile() {
|
||||||
filter += filter_opml20;
|
filter += filter_opml20;
|
||||||
filter += QSL(";;");
|
filter += QSL(";;");
|
||||||
filter += filter_txt_url_per_line;
|
filter += filter_txt_url_per_line;
|
||||||
const QString selected_file = QFileDialog::getOpenFileName(this, tr("Select file for feeds import"), qApp->homeFolder(),
|
const QString selected_file = QFileDialog::getOpenFileName(this,
|
||||||
filter, &selected_filter);
|
tr("Select file for feeds import"),
|
||||||
|
qApp->homeFolder(),
|
||||||
|
filter,
|
||||||
|
&selected_filter);
|
||||||
|
|
||||||
if (!selected_file.isEmpty()) {
|
if (!selected_file.isEmpty()) {
|
||||||
if (selected_filter == filter_opml20) {
|
if (selected_filter == filter_opml20) {
|
||||||
|
@ -203,16 +215,18 @@ void FormStandardImportExport::selectImportFile() {
|
||||||
m_conversionType = ConversionType::TxtUrlPerLine;
|
m_conversionType = ConversionType::TxtUrlPerLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::StatusType::Ok, QDir::toNativeSeparators(selected_file), tr("File is selected."));
|
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::StatusType::Ok,
|
||||||
QMessageBox::StandardButton answer = MsgBox::show(this,
|
QDir::toNativeSeparators(selected_file),
|
||||||
|
tr("File is selected."));
|
||||||
|
QMessageBox::StandardButton answer =
|
||||||
|
MsgBox::show(this,
|
||||||
QMessageBox::Icon::Warning,
|
QMessageBox::Icon::Warning,
|
||||||
tr("Get online metadata"),
|
tr("Get online metadata"),
|
||||||
tr("Metadata for your feeds can be fetched online. Note that the action "
|
tr("Metadata for your feeds can be fetched online. Note that the action "
|
||||||
"could take several minutes, depending on number of feeds."),
|
"could take several minutes, depending on number of feeds."),
|
||||||
tr("Do you want to fetch feed metadata online?"),
|
tr("Do you want to fetch feed metadata online?"),
|
||||||
QString(),
|
QString(),
|
||||||
QMessageBox::StandardButton::Yes |
|
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No,
|
||||||
QMessageBox::StandardButton::No,
|
|
||||||
QMessageBox::StandardButton::Yes);
|
QMessageBox::StandardButton::Yes);
|
||||||
|
|
||||||
parseImportFile(selected_file, answer == QMessageBox::StandardButton::Yes);
|
parseImportFile(selected_file, answer == QMessageBox::StandardButton::Yes);
|
||||||
|
@ -228,7 +242,9 @@ void FormStandardImportExport::parseImportFile(const QString& file_name, bool fe
|
||||||
input_file.close();
|
input_file.close();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error, tr("Cannot open source file."), tr("Cannot open source file."));
|
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error,
|
||||||
|
tr("Cannot open source file."),
|
||||||
|
tr("Cannot open source file."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +283,7 @@ void FormStandardImportExport::exportFeeds() {
|
||||||
|
|
||||||
switch (m_conversionType) {
|
switch (m_conversionType) {
|
||||||
case ConversionType::OPML20:
|
case ConversionType::OPML20:
|
||||||
result_export = m_model->exportToOMPL20(result_data);
|
result_export = m_model->exportToOMPL20(result_data, m_ui->m_cbExportIcons->isChecked());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ConversionType::TxtUrlPerLine:
|
case ConversionType::TxtUrlPerLine:
|
||||||
|
@ -281,21 +297,27 @@ void FormStandardImportExport::exportFeeds() {
|
||||||
if (result_export) {
|
if (result_export) {
|
||||||
try {
|
try {
|
||||||
IOFactory::writeFile(m_ui->m_lblSelectFile->label()->text(), result_data);
|
IOFactory::writeFile(m_ui->m_lblSelectFile->label()->text(), result_data);
|
||||||
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Ok, tr("Feeds were exported successfully."),
|
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Ok,
|
||||||
|
tr("Feeds were exported successfully."),
|
||||||
tr("Feeds were exported successfully."));
|
tr("Feeds were exported successfully."));
|
||||||
}
|
}
|
||||||
catch (IOException& ex) {
|
catch (IOException& ex) {
|
||||||
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error, tr("Cannot write into destination file: '%1'."), ex.message());
|
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error,
|
||||||
|
tr("Cannot write into destination file: '%1'."),
|
||||||
|
ex.message());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error, tr("Critical error occurred."), tr("Critical error occurred."));
|
m_ui->m_lblResult->setStatus(WidgetWithStatus::StatusType::Error,
|
||||||
|
tr("Critical error occurred."),
|
||||||
|
tr("Critical error occurred."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormStandardImportExport::importFeeds() {
|
void FormStandardImportExport::importFeeds() {
|
||||||
QString output_message;
|
QString output_message;
|
||||||
RootItem* parent = static_cast<RootItem*>(m_ui->m_cmbRootNode->itemData(m_ui->m_cmbRootNode->currentIndex()).value<void*>());
|
RootItem* parent =
|
||||||
|
static_cast<RootItem*>(m_ui->m_cmbRootNode->itemData(m_ui->m_cmbRootNode->currentIndex()).value<void*>());
|
||||||
|
|
||||||
if (m_serviceRoot->mergeImportExportModel(m_model, parent, output_message)) {
|
if (m_serviceRoot->mergeImportExportModel(m_model, parent, output_message)) {
|
||||||
m_serviceRoot->requestItemExpand(parent->getSubTree(), true);
|
m_serviceRoot->requestItemExpand(parent->getSubTree(), true);
|
||||||
|
|
|
@ -79,6 +79,13 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="m_cbExportIcons">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export icons</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="m_groupFeeds">
|
<widget class="QGroupBox" name="m_groupFeeds">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -97,20 +104,6 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QPushButton" name="m_btnCheckAllItems">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Check all feeds</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2">
|
|
||||||
<widget class="QPushButton" name="m_btnUncheckAllItems">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Uncheck all feeds</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="3">
|
<item row="1" column="3">
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -152,6 +145,20 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="m_btnCheckAllItems">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Check all feeds</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QPushButton" name="m_btnUncheckAllItems">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Uncheck all feeds</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -226,6 +233,7 @@
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>m_btnSelectFile</tabstop>
|
<tabstop>m_btnSelectFile</tabstop>
|
||||||
<tabstop>m_cmbRootNode</tabstop>
|
<tabstop>m_cmbRootNode</tabstop>
|
||||||
|
<tabstop>m_cbExportIcons</tabstop>
|
||||||
<tabstop>m_btnCheckAllItems</tabstop>
|
<tabstop>m_btnCheckAllItems</tabstop>
|
||||||
<tabstop>m_btnUncheckAllItems</tabstop>
|
<tabstop>m_btnUncheckAllItems</tabstop>
|
||||||
<tabstop>m_treeFeeds</tabstop>
|
<tabstop>m_treeFeeds</tabstop>
|
||||||
|
|
|
@ -28,11 +28,10 @@ FeedsImportExportModel::~FeedsImportExportModel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FeedsImportExportModel::exportToOMPL20(QByteArray& result) {
|
bool FeedsImportExportModel::exportToOMPL20(QByteArray& result, bool export_icons) {
|
||||||
QDomDocument opml_document;
|
QDomDocument opml_document;
|
||||||
QDomProcessingInstruction xml_declaration = opml_document.createProcessingInstruction(QSL("xml"),
|
QDomProcessingInstruction xml_declaration =
|
||||||
QSL(
|
opml_document.createProcessingInstruction(QSL("xml"), QSL("version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\""));
|
||||||
"version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\""));
|
|
||||||
|
|
||||||
opml_document.appendChild(xml_declaration);
|
opml_document.appendChild(xml_declaration);
|
||||||
|
|
||||||
|
@ -80,8 +79,9 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray& result) {
|
||||||
outline_category.setAttribute(QSL("text"), child_item->title());
|
outline_category.setAttribute(QSL("text"), child_item->title());
|
||||||
outline_category.setAttribute(QSL("description"), child_item->description());
|
outline_category.setAttribute(QSL("description"), child_item->description());
|
||||||
|
|
||||||
if (!child_item->icon().isNull()) {
|
if (export_icons && !child_item->icon().isNull()) {
|
||||||
outline_category.setAttribute(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);
|
active_element.appendChild(outline_category);
|
||||||
|
@ -104,7 +104,7 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray& result) {
|
||||||
outline_feed.setAttribute(QSL("rssguard:xmlUrlType"), QString::number(int(child_feed->sourceType())));
|
outline_feed.setAttribute(QSL("rssguard:xmlUrlType"), QString::number(int(child_feed->sourceType())));
|
||||||
outline_feed.setAttribute(QSL("rssguard:postProcess"), child_feed->postProcessScript());
|
outline_feed.setAttribute(QSL("rssguard:postProcess"), child_feed->postProcessScript());
|
||||||
|
|
||||||
if (!child_feed->icon().isNull()) {
|
if (export_icons && !child_feed->icon().isNull()) {
|
||||||
outline_feed.setAttribute(QSL("rssguard:icon"), QString(qApp->icons()->toByteArray(child_feed->icon())));
|
outline_feed.setAttribute(QSL("rssguard:icon"), QString(qApp->icons()->toByteArray(child_feed->icon())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,8 +168,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||||
QStack<RootItem*> model_items;
|
QStack<RootItem*> model_items;
|
||||||
QNetworkProxy custom_proxy;
|
QNetworkProxy custom_proxy;
|
||||||
|
|
||||||
if (sourceModel()->rootItem() != nullptr &&
|
if (sourceModel()->rootItem() != nullptr && sourceModel()->rootItem()->getParentServiceRoot() != nullptr) {
|
||||||
sourceModel()->rootItem()->getParentServiceRoot() != nullptr) {
|
|
||||||
custom_proxy = sourceModel()->rootItem()->getParentServiceRoot()->networkProxy();
|
custom_proxy = sourceModel()->rootItem()->getParentServiceRoot()->networkProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,23 +200,17 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||||
if (!feed_url.isEmpty()) {
|
if (!feed_url.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
if (fetch_metadata_online) {
|
if (fetch_metadata_online) {
|
||||||
StandardFeed* guessed = StandardFeed::guessFeed(StandardFeed::SourceType::Url,
|
StandardFeed* guessed =
|
||||||
feed_url,
|
StandardFeed::guessFeed(StandardFeed::SourceType::Url, feed_url, {}, {}, {}, custom_proxy);
|
||||||
{}, {}, {},
|
|
||||||
custom_proxy);
|
|
||||||
|
|
||||||
guessed->setSource(feed_url);
|
guessed->setSource(feed_url);
|
||||||
active_model_item->appendChild(guessed);
|
active_model_item->appendChild(guessed);
|
||||||
succeded++;
|
succeded++;
|
||||||
add_offline_anyway = false;
|
add_offline_anyway = false;
|
||||||
}
|
}
|
||||||
}
|
} catch (const ApplicationException& ex) {
|
||||||
catch (const ApplicationException& ex) {
|
qCriticalNN << LOGSEC_CORE << "Cannot fetch medatada for feed:" << QUOTE_W_SPACE(feed_url)
|
||||||
qCriticalNN << LOGSEC_CORE
|
<< "with error:" << QUOTE_W_SPACE_DOT(ex.message());
|
||||||
<< "Cannot fetch medatada for feed:"
|
|
||||||
<< QUOTE_W_SPACE(feed_url)
|
|
||||||
<< "with error:"
|
|
||||||
<< QUOTE_W_SPACE_DOT(ex.message());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add_offline_anyway) {
|
if (add_offline_anyway) {
|
||||||
|
@ -225,8 +218,10 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||||
QString feed_encoding = child_element.attribute(QSL("encoding"), QSL(DEFAULT_FEED_ENCODING));
|
QString feed_encoding = child_element.attribute(QSL("encoding"), QSL(DEFAULT_FEED_ENCODING));
|
||||||
QString feed_type = child_element.attribute(QSL("version"), QSL(DEFAULT_FEED_TYPE)).toUpper();
|
QString feed_type = child_element.attribute(QSL("version"), QSL(DEFAULT_FEED_TYPE)).toUpper();
|
||||||
QString feed_description = child_element.attribute(QSL("description"));
|
QString feed_description = child_element.attribute(QSL("description"));
|
||||||
QIcon feed_icon = qApp->icons()->fromByteArray(child_element.attribute(QSL("rssguard:icon")).toLocal8Bit());
|
QIcon feed_icon =
|
||||||
StandardFeed::SourceType source_type = StandardFeed::SourceType(child_element.attribute(QSL("rssguard:xmlUrlType")).toInt());
|
qApp->icons()->fromByteArray(child_element.attribute(QSL("rssguard:icon")).toLocal8Bit());
|
||||||
|
StandardFeed::SourceType source_type =
|
||||||
|
StandardFeed::SourceType(child_element.attribute(QSL("rssguard:xmlUrlType")).toInt());
|
||||||
QString post_process = child_element.attribute(QSL("rssguard:postProcess"));
|
QString post_process = child_element.attribute(QSL("rssguard:postProcess"));
|
||||||
auto* new_feed = new StandardFeed(active_model_item);
|
auto* new_feed = new StandardFeed(active_model_item);
|
||||||
|
|
||||||
|
@ -270,7 +265,8 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||||
// Add category and continue.
|
// Add category and continue.
|
||||||
QString category_title = child_element.attribute(QSL("text"));
|
QString category_title = child_element.attribute(QSL("text"));
|
||||||
QString category_description = child_element.attribute(QSL("description"));
|
QString category_description = child_element.attribute(QSL("description"));
|
||||||
QIcon category_icon = qApp->icons()->fromByteArray(child_element.attribute(QSL("rssguard:icon")).toLocal8Bit());
|
QIcon category_icon =
|
||||||
|
qApp->icons()->fromByteArray(child_element.attribute(QSL("rssguard:icon")).toLocal8Bit());
|
||||||
|
|
||||||
if (category_title.isEmpty()) {
|
if (category_title.isEmpty()) {
|
||||||
qWarningNN << LOGSEC_CORE
|
qWarningNN << LOGSEC_CORE
|
||||||
|
@ -332,8 +328,7 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, bool
|
||||||
auto* root_item = new StandardServiceRoot();
|
auto* root_item = new StandardServiceRoot();
|
||||||
QNetworkProxy custom_proxy;
|
QNetworkProxy custom_proxy;
|
||||||
|
|
||||||
if (sourceModel()->rootItem() != nullptr &&
|
if (sourceModel()->rootItem() != nullptr && sourceModel()->rootItem()->getParentServiceRoot() != nullptr) {
|
||||||
sourceModel()->rootItem()->getParentServiceRoot() != nullptr) {
|
|
||||||
custom_proxy = sourceModel()->rootItem()->getParentServiceRoot()->networkProxy();
|
custom_proxy = sourceModel()->rootItem()->getParentServiceRoot()->networkProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,22 +340,16 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, bool
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (fetch_metadata_online) {
|
if (fetch_metadata_online) {
|
||||||
StandardFeed* guessed = StandardFeed::guessFeed(StandardFeed::SourceType::Url,
|
StandardFeed* guessed = StandardFeed::guessFeed(StandardFeed::SourceType::Url, url, {}, {}, {}, custom_proxy);
|
||||||
url, {}, {}, {},
|
|
||||||
custom_proxy);
|
|
||||||
|
|
||||||
guessed->setSource(url);
|
guessed->setSource(url);
|
||||||
root_item->appendChild(guessed);
|
root_item->appendChild(guessed);
|
||||||
succeded++;
|
succeded++;
|
||||||
add_offline_anyway = false;
|
add_offline_anyway = false;
|
||||||
}
|
}
|
||||||
}
|
} catch (const ApplicationException& ex) {
|
||||||
catch (const ApplicationException& ex) {
|
qCriticalNN << LOGSEC_CORE << "Cannot fetch medatada for feed:" << QUOTE_W_SPACE(url)
|
||||||
qCriticalNN << LOGSEC_CORE
|
<< "with error:" << QUOTE_W_SPACE_DOT(ex.message());
|
||||||
<< "Cannot fetch medatada for feed:"
|
|
||||||
<< QUOTE_W_SPACE(url)
|
|
||||||
<< "with error:"
|
|
||||||
<< QUOTE_W_SPACE_DOT(ex.message());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add_offline_anyway) {
|
if (add_offline_anyway) {
|
||||||
|
|
|
@ -9,17 +9,14 @@ class FeedsImportExportModel : public AccountCheckSortedModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class Mode {
|
enum class Mode { Import, Export };
|
||||||
Import,
|
|
||||||
Export
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit FeedsImportExportModel(QObject* parent = nullptr);
|
explicit FeedsImportExportModel(QObject* parent = nullptr);
|
||||||
virtual ~FeedsImportExportModel();
|
virtual ~FeedsImportExportModel();
|
||||||
|
|
||||||
// Exports to OPML 2.0
|
// Exports to OPML 2.0
|
||||||
// NOTE: http://dev.opml.org/spec2.html
|
// NOTE: http://dev.opml.org/spec2.html
|
||||||
bool exportToOMPL20(QByteArray& result);
|
bool exportToOMPL20(QByteArray& result, bool export_icons);
|
||||||
void importAsOPML20(const QByteArray& data, bool fetch_metadata_online);
|
void importAsOPML20(const QByteArray& data, bool fetch_metadata_online);
|
||||||
|
|
||||||
// Exports to plain text format
|
// Exports to plain text format
|
||||||
|
|
Loading…
Add table
Reference in a new issue