mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-04 03:08:04 +01:00
fixed #388
This commit is contained in:
parent
502e4d88e0
commit
eac63ff867
@ -235,12 +235,16 @@ void FormStandardImportExport::selectImportFile() {
|
||||
m_conversionType = ConversionType::TxtUrlPerLine;
|
||||
}
|
||||
|
||||
m_ui->m_cbDoNotFetchTitles->setEnabled(m_conversionType == ConversionType::OPML20);
|
||||
m_ui->m_lblSelectFile->setStatus(WidgetWithStatus::StatusType::Ok,
|
||||
QDir::toNativeSeparators(selected_file),
|
||||
tr("File is selected."));
|
||||
|
||||
try {
|
||||
parseImportFile(selected_file, m_ui->m_groupFetchMetadata->isChecked());
|
||||
parseImportFile(selected_file,
|
||||
m_ui->m_groupFetchMetadata->isChecked(),
|
||||
m_ui->m_cbDoNotFetchTitles->isChecked(),
|
||||
m_ui->m_txtPostProcessScript->textEdit()->toPlainText());
|
||||
}
|
||||
catch (const ApplicationException& ex) {
|
||||
m_ui->m_btnSelectFile->setEnabled(true);
|
||||
@ -254,7 +258,10 @@ void FormStandardImportExport::selectImportFile() {
|
||||
}
|
||||
}
|
||||
|
||||
void FormStandardImportExport::parseImportFile(const QString& file_name, bool fetch_metadata_online) {
|
||||
void FormStandardImportExport::parseImportFile(const QString& file_name,
|
||||
bool fetch_metadata_online,
|
||||
bool do_not_fetch_titles,
|
||||
const QString& post_process_script) {
|
||||
QByteArray input_data;
|
||||
QFile input_file(file_name);
|
||||
|
||||
@ -269,9 +276,7 @@ void FormStandardImportExport::parseImportFile(const QString& file_name, bool fe
|
||||
|
||||
switch (m_conversionType) {
|
||||
case ConversionType::OPML20:
|
||||
m_model->importAsOPML20(input_data,
|
||||
fetch_metadata_online,
|
||||
m_ui->m_txtPostProcessScript->textEdit()->toPlainText());
|
||||
m_model->importAsOPML20(input_data, fetch_metadata_online, do_not_fetch_titles, post_process_script);
|
||||
break;
|
||||
|
||||
case ConversionType::TxtUrlPerLine:
|
||||
|
@ -39,7 +39,10 @@ class FormStandardImportExport : public QDialog {
|
||||
private:
|
||||
void selectExportFile(bool without_dialog);
|
||||
void selectImportFile();
|
||||
void parseImportFile(const QString& file_name, bool fetch_metadata_online);
|
||||
void parseImportFile(const QString& file_name,
|
||||
bool fetch_metadata_online,
|
||||
bool do_not_fetch_titles,
|
||||
const QString& post_process_script);
|
||||
|
||||
void exportFeeds();
|
||||
void importFeeds();
|
||||
|
@ -58,6 +58,13 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_cbDoNotFetchTitles">
|
||||
<property name="text">
|
||||
<string>Do not fetch titles</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
@ -277,6 +284,7 @@
|
||||
<tabstops>
|
||||
<tabstop>m_btnSelectFile</tabstop>
|
||||
<tabstop>m_groupFetchMetadata</tabstop>
|
||||
<tabstop>m_cbDoNotFetchTitles</tabstop>
|
||||
<tabstop>m_cmbRootNode</tabstop>
|
||||
<tabstop>m_cbExportIcons</tabstop>
|
||||
<tabstop>m_btnCheckAllItems</tabstop>
|
||||
|
@ -191,6 +191,14 @@ bool FeedsImportExportModel::produceFeed(const FeedLookup& feed_lookup) {
|
||||
|
||||
new_feed->setSource(feed_lookup.url);
|
||||
new_feed->setPostProcessScript(feed_lookup.post_process_script);
|
||||
|
||||
if (feed_lookup.do_not_fetch_titles) {
|
||||
QString old_title = feed_lookup.custom_data[QSL("title")].toString();
|
||||
|
||||
if (!old_title.simplified().isEmpty()) {
|
||||
new_feed->setTitle(old_title);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
new_feed = new StandardFeed();
|
||||
@ -258,6 +266,7 @@ bool FeedsImportExportModel::produceFeed(const FeedLookup& feed_lookup) {
|
||||
|
||||
void FeedsImportExportModel::importAsOPML20(const QByteArray& data,
|
||||
bool fetch_metadata_online,
|
||||
bool do_not_fetch_titles,
|
||||
const QString& post_process_script) {
|
||||
emit parsingStarted();
|
||||
emit layoutAboutToBeChanged();
|
||||
@ -327,6 +336,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data,
|
||||
|
||||
f.custom_proxy = custom_proxy;
|
||||
f.fetch_metadata_online = fetch_metadata_online;
|
||||
f.do_not_fetch_titles = do_not_fetch_titles;
|
||||
f.custom_data = feed_data;
|
||||
f.parent = active_model_item;
|
||||
f.post_process_script = post_process_script;
|
||||
|
@ -17,6 +17,7 @@ struct FeedLookup {
|
||||
QVariantMap custom_data;
|
||||
QString url;
|
||||
bool fetch_metadata_online;
|
||||
bool do_not_fetch_titles;
|
||||
QNetworkProxy custom_proxy;
|
||||
QString post_process_script;
|
||||
};
|
||||
@ -33,7 +34,10 @@ class FeedsImportExportModel : public AccountCheckSortedModel {
|
||||
// Exports to OPML 2.0
|
||||
// NOTE: http://dev.opml.org/spec2.html
|
||||
bool exportToOMPL20(QByteArray& result, bool export_icons);
|
||||
void importAsOPML20(const QByteArray& data, bool fetch_metadata_online, const QString& post_process_script = {});
|
||||
void importAsOPML20(const QByteArray& data,
|
||||
bool fetch_metadata_online,
|
||||
bool do_not_fetch_titles,
|
||||
const QString& post_process_script = {});
|
||||
|
||||
// Exports to plain text format
|
||||
// where there is one feed URL per line.
|
||||
|
@ -75,7 +75,7 @@ void StandardServiceRoot::start(bool freshly_activated) {
|
||||
QString output_msg;
|
||||
|
||||
try {
|
||||
model.importAsOPML20(IOFactory::readFile(file_to_load), false);
|
||||
model.importAsOPML20(IOFactory::readFile(file_to_load), false, false);
|
||||
model.checkAllItems();
|
||||
|
||||
if (mergeImportExportModel(&model, this, output_msg)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user