fix #1009
This commit is contained in:
parent
c76320fbcd
commit
aa372361ee
9 changed files with 61 additions and 12 deletions
|
@ -235,6 +235,7 @@ void FormStandardImportExport::selectImportFile() {
|
||||||
m_conversionType = ConversionType::TxtUrlPerLine;
|
m_conversionType = ConversionType::TxtUrlPerLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_ui->m_cbDoNotFetchIcons->setEnabled(m_conversionType == ConversionType::OPML20);
|
||||||
m_ui->m_cbDoNotFetchTitles->setEnabled(m_conversionType == ConversionType::OPML20);
|
m_ui->m_cbDoNotFetchTitles->setEnabled(m_conversionType == ConversionType::OPML20);
|
||||||
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::StatusType::Ok,
|
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::StatusType::Ok,
|
||||||
QDir::toNativeSeparators(selected_file),
|
QDir::toNativeSeparators(selected_file),
|
||||||
|
@ -244,6 +245,7 @@ void FormStandardImportExport::selectImportFile() {
|
||||||
parseImportFile(selected_file,
|
parseImportFile(selected_file,
|
||||||
m_ui->m_groupFetchMetadata->isChecked(),
|
m_ui->m_groupFetchMetadata->isChecked(),
|
||||||
m_ui->m_cbDoNotFetchTitles->isChecked(),
|
m_ui->m_cbDoNotFetchTitles->isChecked(),
|
||||||
|
m_ui->m_cbDoNotFetchIcons->isChecked(),
|
||||||
m_ui->m_txtPostProcessScript->textEdit()->toPlainText());
|
m_ui->m_txtPostProcessScript->textEdit()->toPlainText());
|
||||||
}
|
}
|
||||||
catch (const ApplicationException& ex) {
|
catch (const ApplicationException& ex) {
|
||||||
|
@ -261,6 +263,7 @@ void FormStandardImportExport::selectImportFile() {
|
||||||
void FormStandardImportExport::parseImportFile(const QString& file_name,
|
void FormStandardImportExport::parseImportFile(const QString& file_name,
|
||||||
bool fetch_metadata_online,
|
bool fetch_metadata_online,
|
||||||
bool do_not_fetch_titles,
|
bool do_not_fetch_titles,
|
||||||
|
bool do_not_fetch_icons,
|
||||||
const QString& post_process_script) {
|
const QString& post_process_script) {
|
||||||
QByteArray input_data;
|
QByteArray input_data;
|
||||||
QFile input_file(file_name);
|
QFile input_file(file_name);
|
||||||
|
@ -276,7 +279,11 @@ void FormStandardImportExport::parseImportFile(const QString& file_name,
|
||||||
|
|
||||||
switch (m_conversionType) {
|
switch (m_conversionType) {
|
||||||
case ConversionType::OPML20:
|
case ConversionType::OPML20:
|
||||||
m_model->importAsOPML20(input_data, fetch_metadata_online, do_not_fetch_titles, post_process_script);
|
m_model->importAsOPML20(input_data,
|
||||||
|
fetch_metadata_online,
|
||||||
|
do_not_fetch_titles,
|
||||||
|
do_not_fetch_icons,
|
||||||
|
post_process_script);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ConversionType::TxtUrlPerLine:
|
case ConversionType::TxtUrlPerLine:
|
||||||
|
|
|
@ -42,6 +42,7 @@ class FormStandardImportExport : public QDialog {
|
||||||
void parseImportFile(const QString& file_name,
|
void parseImportFile(const QString& file_name,
|
||||||
bool fetch_metadata_online,
|
bool fetch_metadata_online,
|
||||||
bool do_not_fetch_titles,
|
bool do_not_fetch_titles,
|
||||||
|
bool do_not_fetch_icons,
|
||||||
const QString& post_process_script);
|
const QString& post_process_script);
|
||||||
|
|
||||||
void exportFeeds();
|
void exportFeeds();
|
||||||
|
|
|
@ -65,6 +65,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="m_cbDoNotFetchIcons">
|
||||||
|
<property name="text">
|
||||||
|
<string>Do not fetch icons</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -291,6 +298,7 @@
|
||||||
<tabstop>m_btnSelectFile</tabstop>
|
<tabstop>m_btnSelectFile</tabstop>
|
||||||
<tabstop>m_groupFetchMetadata</tabstop>
|
<tabstop>m_groupFetchMetadata</tabstop>
|
||||||
<tabstop>m_cbDoNotFetchTitles</tabstop>
|
<tabstop>m_cbDoNotFetchTitles</tabstop>
|
||||||
|
<tabstop>m_cbDoNotFetchIcons</tabstop>
|
||||||
<tabstop>m_cmbRootNode</tabstop>
|
<tabstop>m_cmbRootNode</tabstop>
|
||||||
<tabstop>m_cbExportIcons</tabstop>
|
<tabstop>m_cbExportIcons</tabstop>
|
||||||
<tabstop>m_btnCheckAllItems</tabstop>
|
<tabstop>m_btnCheckAllItems</tabstop>
|
||||||
|
|
|
@ -137,8 +137,14 @@ void StandardFeedDetails::guessIconOnly(StandardFeed::SourceType source_type,
|
||||||
const QString& password,
|
const QString& password,
|
||||||
const QNetworkProxy& custom_proxy) {
|
const QNetworkProxy& custom_proxy) {
|
||||||
try {
|
try {
|
||||||
StandardFeed* metadata =
|
StandardFeed* metadata = StandardFeed::guessFeed(source_type,
|
||||||
StandardFeed::guessFeed(source_type, source, post_process_script, protection, username, password, custom_proxy);
|
source,
|
||||||
|
post_process_script,
|
||||||
|
protection,
|
||||||
|
true,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
custom_proxy);
|
||||||
|
|
||||||
// Icon or whole feed was guessed.
|
// Icon or whole feed was guessed.
|
||||||
m_ui.m_btnIcon->setIcon(metadata->icon());
|
m_ui.m_btnIcon->setIcon(metadata->icon());
|
||||||
|
@ -174,8 +180,14 @@ void StandardFeedDetails::guessFeed(StandardFeed::SourceType source_type,
|
||||||
const QString& password,
|
const QString& password,
|
||||||
const QNetworkProxy& custom_proxy) {
|
const QNetworkProxy& custom_proxy) {
|
||||||
try {
|
try {
|
||||||
StandardFeed* metadata =
|
StandardFeed* metadata = StandardFeed::guessFeed(source_type,
|
||||||
StandardFeed::guessFeed(source_type, source, post_process_script, protection, username, password, custom_proxy);
|
source,
|
||||||
|
post_process_script,
|
||||||
|
protection,
|
||||||
|
true,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
custom_proxy);
|
||||||
|
|
||||||
// Icon or whole feed was guessed.
|
// Icon or whole feed was guessed.
|
||||||
m_ui.m_btnIcon->setIcon(metadata->icon());
|
m_ui.m_btnIcon->setIcon(metadata->icon());
|
||||||
|
|
|
@ -184,6 +184,7 @@ void StandardFeed::fetchMetadataForItself() {
|
||||||
source(),
|
source(),
|
||||||
postProcessScript(),
|
postProcessScript(),
|
||||||
protection(),
|
protection(),
|
||||||
|
true,
|
||||||
username(),
|
username(),
|
||||||
password(),
|
password(),
|
||||||
getParentServiceRoot()->networkProxy());
|
getParentServiceRoot()->networkProxy());
|
||||||
|
@ -231,6 +232,7 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
|
||||||
const QString& source,
|
const QString& source,
|
||||||
const QString& post_process_script,
|
const QString& post_process_script,
|
||||||
NetworkFactory::NetworkFactory::NetworkAuthentication protection,
|
NetworkFactory::NetworkFactory::NetworkAuthentication protection,
|
||||||
|
bool fetch_icons,
|
||||||
const QString& username,
|
const QString& username,
|
||||||
const QString& password,
|
const QString& password,
|
||||||
const QNetworkProxy& custom_proxy) {
|
const QNetworkProxy& custom_proxy) {
|
||||||
|
@ -446,13 +448,15 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
|
||||||
icon_possible_locations.append({source, false});
|
icon_possible_locations.append({source, false});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to obtain icon.
|
if (fetch_icons) {
|
||||||
QPixmap icon_data;
|
// Try to obtain icon.
|
||||||
|
QPixmap icon_data;
|
||||||
|
|
||||||
if (NetworkFactory::downloadIcon(icon_possible_locations, DOWNLOAD_TIMEOUT, icon_data, {}, custom_proxy) ==
|
if (NetworkFactory::downloadIcon(icon_possible_locations, DOWNLOAD_TIMEOUT, icon_data, {}, custom_proxy) ==
|
||||||
QNetworkReply::NetworkError::NoError) {
|
QNetworkReply::NetworkError::NoError) {
|
||||||
// Icon for feed was downloaded and is stored now in icon_data.
|
// Icon for feed was downloaded and is stored now in icon_data.
|
||||||
feed->setIcon(icon_data);
|
feed->setIcon(icon_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return feed;
|
return feed;
|
||||||
|
|
|
@ -78,6 +78,7 @@ class StandardFeed : public Feed {
|
||||||
const QString& url,
|
const QString& url,
|
||||||
const QString& post_process_script,
|
const QString& post_process_script,
|
||||||
NetworkFactory::NetworkAuthentication protection,
|
NetworkFactory::NetworkAuthentication protection,
|
||||||
|
bool fetch_icons = true,
|
||||||
const QString& username = QString(),
|
const QString& username = QString(),
|
||||||
const QString& password = QString(),
|
const QString& password = QString(),
|
||||||
const QNetworkProxy& custom_proxy = QNetworkProxy::ProxyType::DefaultProxy);
|
const QNetworkProxy& custom_proxy = QNetworkProxy::ProxyType::DefaultProxy);
|
||||||
|
|
|
@ -185,6 +185,7 @@ bool FeedsImportExportModel::produceFeed(const FeedLookup& feed_lookup) {
|
||||||
feed_lookup.url,
|
feed_lookup.url,
|
||||||
feed_lookup.post_process_script,
|
feed_lookup.post_process_script,
|
||||||
NetworkFactory::NetworkAuthentication::NoAuthentication,
|
NetworkFactory::NetworkAuthentication::NoAuthentication,
|
||||||
|
!feed_lookup.do_not_fetch_icons,
|
||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
feed_lookup.custom_proxy);
|
feed_lookup.custom_proxy);
|
||||||
|
@ -199,6 +200,17 @@ bool FeedsImportExportModel::produceFeed(const FeedLookup& feed_lookup) {
|
||||||
new_feed->setTitle(old_title);
|
new_feed->setTitle(old_title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (feed_lookup.do_not_fetch_icons) {
|
||||||
|
QIcon old_icon = feed_lookup.custom_data[QSL("icon")].value<QIcon>();
|
||||||
|
|
||||||
|
if (old_icon.isNull()) {
|
||||||
|
new_feed->setIcon(qApp->icons()->fromTheme(QSL("application-rss+xml")));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
new_feed->setIcon(old_icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
new_feed = new StandardFeed();
|
new_feed = new StandardFeed();
|
||||||
|
@ -267,6 +279,7 @@ bool FeedsImportExportModel::produceFeed(const FeedLookup& feed_lookup) {
|
||||||
void FeedsImportExportModel::importAsOPML20(const QByteArray& data,
|
void FeedsImportExportModel::importAsOPML20(const QByteArray& data,
|
||||||
bool fetch_metadata_online,
|
bool fetch_metadata_online,
|
||||||
bool do_not_fetch_titles,
|
bool do_not_fetch_titles,
|
||||||
|
bool do_not_fetch_icons,
|
||||||
const QString& post_process_script) {
|
const QString& post_process_script) {
|
||||||
emit parsingStarted();
|
emit parsingStarted();
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
|
@ -337,6 +350,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data,
|
||||||
f.custom_proxy = custom_proxy;
|
f.custom_proxy = custom_proxy;
|
||||||
f.fetch_metadata_online = fetch_metadata_online;
|
f.fetch_metadata_online = fetch_metadata_online;
|
||||||
f.do_not_fetch_titles = do_not_fetch_titles;
|
f.do_not_fetch_titles = do_not_fetch_titles;
|
||||||
|
f.do_not_fetch_icons = do_not_fetch_icons;
|
||||||
f.custom_data = feed_data;
|
f.custom_data = feed_data;
|
||||||
f.parent = active_model_item;
|
f.parent = active_model_item;
|
||||||
f.post_process_script = post_process_script;
|
f.post_process_script = post_process_script;
|
||||||
|
|
|
@ -18,6 +18,7 @@ struct FeedLookup {
|
||||||
QString url;
|
QString url;
|
||||||
bool fetch_metadata_online;
|
bool fetch_metadata_online;
|
||||||
bool do_not_fetch_titles;
|
bool do_not_fetch_titles;
|
||||||
|
bool do_not_fetch_icons;
|
||||||
QNetworkProxy custom_proxy;
|
QNetworkProxy custom_proxy;
|
||||||
QString post_process_script;
|
QString post_process_script;
|
||||||
};
|
};
|
||||||
|
@ -37,6 +38,7 @@ class FeedsImportExportModel : public AccountCheckSortedModel {
|
||||||
void importAsOPML20(const QByteArray& data,
|
void importAsOPML20(const QByteArray& data,
|
||||||
bool fetch_metadata_online,
|
bool fetch_metadata_online,
|
||||||
bool do_not_fetch_titles,
|
bool do_not_fetch_titles,
|
||||||
|
bool do_not_fetch_icons,
|
||||||
const QString& post_process_script = {});
|
const QString& post_process_script = {});
|
||||||
|
|
||||||
// Exports to plain text format
|
// Exports to plain text format
|
||||||
|
|
|
@ -75,7 +75,7 @@ void StandardServiceRoot::start(bool freshly_activated) {
|
||||||
QString output_msg;
|
QString output_msg;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
model.importAsOPML20(IOFactory::readFile(file_to_load), false, false);
|
model.importAsOPML20(IOFactory::readFile(file_to_load), false, false, false);
|
||||||
model.checkAllItems();
|
model.checkAllItems();
|
||||||
|
|
||||||
if (mergeImportExportModel(&model, this, output_msg)) {
|
if (mergeImportExportModel(&model, this, output_msg)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue