fixed #388
This commit is contained in:
parent
502e4d88e0
commit
eac63ff867
@ -235,12 +235,16 @@ void FormStandardImportExport::selectImportFile() {
|
|||||||
m_conversionType = ConversionType::TxtUrlPerLine;
|
m_conversionType = ConversionType::TxtUrlPerLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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),
|
||||||
tr("File is selected."));
|
tr("File is selected."));
|
||||||
|
|
||||||
try {
|
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) {
|
catch (const ApplicationException& ex) {
|
||||||
m_ui->m_btnSelectFile->setEnabled(true);
|
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;
|
QByteArray input_data;
|
||||||
QFile input_file(file_name);
|
QFile input_file(file_name);
|
||||||
|
|
||||||
@ -269,9 +276,7 @@ void FormStandardImportExport::parseImportFile(const QString& file_name, bool fe
|
|||||||
|
|
||||||
switch (m_conversionType) {
|
switch (m_conversionType) {
|
||||||
case ConversionType::OPML20:
|
case ConversionType::OPML20:
|
||||||
m_model->importAsOPML20(input_data,
|
m_model->importAsOPML20(input_data, fetch_metadata_online, do_not_fetch_titles, post_process_script);
|
||||||
fetch_metadata_online,
|
|
||||||
m_ui->m_txtPostProcessScript->textEdit()->toPlainText());
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ConversionType::TxtUrlPerLine:
|
case ConversionType::TxtUrlPerLine:
|
||||||
|
@ -39,7 +39,10 @@ class FormStandardImportExport : public QDialog {
|
|||||||
private:
|
private:
|
||||||
void selectExportFile(bool without_dialog);
|
void selectExportFile(bool without_dialog);
|
||||||
void selectImportFile();
|
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 exportFeeds();
|
||||||
void importFeeds();
|
void importFeeds();
|
||||||
|
@ -58,6 +58,13 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<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>
|
<item>
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -277,6 +284,7 @@
|
|||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>m_btnSelectFile</tabstop>
|
<tabstop>m_btnSelectFile</tabstop>
|
||||||
<tabstop>m_groupFetchMetadata</tabstop>
|
<tabstop>m_groupFetchMetadata</tabstop>
|
||||||
|
<tabstop>m_cbDoNotFetchTitles</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>
|
||||||
|
@ -191,6 +191,14 @@ bool FeedsImportExportModel::produceFeed(const FeedLookup& feed_lookup) {
|
|||||||
|
|
||||||
new_feed->setSource(feed_lookup.url);
|
new_feed->setSource(feed_lookup.url);
|
||||||
new_feed->setPostProcessScript(feed_lookup.post_process_script);
|
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 {
|
else {
|
||||||
new_feed = new StandardFeed();
|
new_feed = new StandardFeed();
|
||||||
@ -258,6 +266,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,
|
||||||
const QString& post_process_script) {
|
const QString& post_process_script) {
|
||||||
emit parsingStarted();
|
emit parsingStarted();
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
@ -327,6 +336,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.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;
|
||||||
|
@ -17,6 +17,7 @@ struct FeedLookup {
|
|||||||
QVariantMap custom_data;
|
QVariantMap custom_data;
|
||||||
QString url;
|
QString url;
|
||||||
bool fetch_metadata_online;
|
bool fetch_metadata_online;
|
||||||
|
bool do_not_fetch_titles;
|
||||||
QNetworkProxy custom_proxy;
|
QNetworkProxy custom_proxy;
|
||||||
QString post_process_script;
|
QString post_process_script;
|
||||||
};
|
};
|
||||||
@ -33,7 +34,10 @@ class FeedsImportExportModel : public AccountCheckSortedModel {
|
|||||||
// 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 export_icons);
|
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
|
// Exports to plain text format
|
||||||
// where there is one feed URL per line.
|
// where there is one feed URL per line.
|
||||||
|
@ -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);
|
model.importAsOPML20(IOFactory::readFile(file_to_load), false, false);
|
||||||
model.checkAllItems();
|
model.checkAllItems();
|
||||||
|
|
||||||
if (mergeImportExportModel(&model, this, output_msg)) {
|
if (mergeImportExportModel(&model, this, output_msg)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user