diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index 647262e02..5546108c1 100755 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -4,6 +4,7 @@ Added: ▪ Added generic "Add new feed" action, which can be accessed via "Feeds & messages" menu. (issue #146) +▪ User can now specify destination root node when importing feeds. (issue #147) ▪ Added support for import/export to/from plain TXT file (one feed URL per line). (issue #142) ▪ Optimized menu items in "Add new item" submenu. Added two new bindable actions for adding feeds & categories. (issues #146 and #148) diff --git a/src/services/standard/gui/formstandardfeeddetails.cpp b/src/services/standard/gui/formstandardfeeddetails.cpp index c6b7e5a77..58b671489 100755 --- a/src/services/standard/gui/formstandardfeeddetails.cpp +++ b/src/services/standard/gui/formstandardfeeddetails.cpp @@ -482,8 +482,7 @@ void FormStandardFeedDetails::initialize() { m_ui->m_txtUrl->lineEdit()->setFocus(Qt::TabFocusReason); } -void FormStandardFeedDetails::loadCategories(const QList categories, - RootItem *root_item) { +void FormStandardFeedDetails::loadCategories(const QList categories, RootItem *root_item) { m_ui->m_cmbParentCategory->addItem(root_item->icon(), root_item->title(), QVariant::fromValue((void*) root_item)); diff --git a/src/services/standard/gui/formstandardimportexport.cpp b/src/services/standard/gui/formstandardimportexport.cpp index 77c5375da..a69b1b822 100755 --- a/src/services/standard/gui/formstandardimportexport.cpp +++ b/src/services/standard/gui/formstandardimportexport.cpp @@ -17,6 +17,7 @@ #include "services/standard/gui/formstandardimportexport.h" +#include "services/abstract/category.h" #include "services/standard/standardfeedsimportexportmodel.h" #include "services/standard/standardserviceroot.h" #include "core/feedsmodel.h" @@ -65,6 +66,8 @@ void FormStandardImportExport::setMode(const FeedsImportExportModel::Mode &mode) m_model->checkAllItems(); m_ui->m_treeFeeds->setModel(m_model); m_ui->m_treeFeeds->expandAll(); + m_ui->m_cmbRootNode->setVisible(false); + m_ui->m_lblRootNode->setVisible(false); m_ui->m_groupFile->setTitle(tr("Destination file")); m_ui->m_groupFeeds->setTitle(tr("Source feeds && categories")); setWindowTitle(tr("Export feeds")); @@ -76,6 +79,9 @@ void FormStandardImportExport::setMode(const FeedsImportExportModel::Mode &mode) m_ui->m_groupFile->setTitle(tr("Source file")); m_ui->m_groupFeeds->setTitle(tr("Target feeds && categories")); m_ui->m_groupFeeds->setDisabled(true); + + // Load categories. + loadCategories(m_serviceRoot->getSubTreeCategories(), m_serviceRoot); setWindowTitle(tr("Import feeds")); setWindowIcon(qApp->icons()->fromTheme(QSL("document-import"))); break; @@ -127,6 +133,7 @@ void FormStandardImportExport::onParsingFinished(int count_failed, int count_suc m_ui->m_treeFeeds->expandAll(); } else { + m_ui->m_groupFeeds->setEnabled(false); m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, tr("Error, file is not well-formed. Select another file."), tr("Error occurred. File is not well-formed. Select another file.")); } @@ -141,7 +148,7 @@ void FormStandardImportExport::onParsingProgress(int completed, int total) { void FormStandardImportExport::selectExportFile() { const QString filter_opml20 = tr("OPML 2.0 files (*.opml)"); - const QString filter_txt_url_per_line = tr("TXT files (one URL per line) (*.txt)"); + const QString filter_txt_url_per_line = tr("TXT files [one URL per line] (*.txt)"); QString filter; QString selected_filter; @@ -178,7 +185,7 @@ void FormStandardImportExport::selectExportFile() { void FormStandardImportExport::selectImportFile() { const QString filter_opml20 = tr("OPML 2.0 files (*.opml)"); - const QString filter_txt_url_per_line = tr("TXT files (one URL per line) (*.txt)"); + const QString filter_txt_url_per_line = tr("TXT files [one URL per line] (*.txt)"); QString filter; QString selected_filter; @@ -284,12 +291,21 @@ void FormStandardImportExport::exportFeeds() { void FormStandardImportExport::importFeeds() { QString output_message; + RootItem *parent = static_cast(m_ui->m_cmbRootNode->itemData(m_ui->m_cmbRootNode->currentIndex()).value()); - if (m_serviceRoot->mergeImportExportModel(m_model, output_message)) { - m_serviceRoot->requestItemExpand(m_serviceRoot->getSubTree(), true); + if (m_serviceRoot->mergeImportExportModel(m_model, parent, output_message)) { + m_serviceRoot->requestItemExpand(parent->getSubTree(), true); m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, output_message, output_message); } else { m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, output_message, output_message); } } + +void FormStandardImportExport::loadCategories(const QList categories, RootItem *root_item) { + m_ui->m_cmbRootNode->addItem(root_item->icon(), root_item->title(), QVariant::fromValue((void*) root_item)); + + foreach (Category *category, categories) { + m_ui->m_cmbRootNode->addItem(category->icon(), category->title(), QVariant::fromValue((void*) category)); + } +} diff --git a/src/services/standard/gui/formstandardimportexport.h b/src/services/standard/gui/formstandardimportexport.h index 9a7c18fe3..80657edbc 100755 --- a/src/services/standard/gui/formstandardimportexport.h +++ b/src/services/standard/gui/formstandardimportexport.h @@ -27,6 +27,7 @@ namespace Ui { class FormStandardImportExport; } +class Category; class StandardServiceRoot; class FormStandardImportExport : public QDialog { @@ -60,6 +61,8 @@ class FormStandardImportExport : public QDialog { void exportFeeds(); void importFeeds(); + void loadCategories(const QList categories, RootItem *root_item); + QScopedPointer m_ui; ConversionType m_conversionType; FeedsImportExportModel *m_model; diff --git a/src/services/standard/gui/formstandardimportexport.ui b/src/services/standard/gui/formstandardimportexport.ui index b1107d194..b438067af 100755 --- a/src/services/standard/gui/formstandardimportexport.ui +++ b/src/services/standard/gui/formstandardimportexport.ui @@ -37,27 +37,57 @@ + + + + + + Root node + + + m_cmbRootNode + + + + + + + Select parent item for your feed. + + + + 12 + 12 + + + + true + + + + + - + &Check all items - + &Uncheck all items - + Qt::Horizontal @@ -70,7 +100,7 @@ - + diff --git a/src/services/standard/standardserviceroot.cpp b/src/services/standard/standardserviceroot.cpp index 6bb9a11b9..ef8d996e7 100755 --- a/src/services/standard/standardserviceroot.cpp +++ b/src/services/standard/standardserviceroot.cpp @@ -87,7 +87,7 @@ void StandardServiceRoot::start(bool freshly_activated) { model.importAsOPML20(IOFactory::readTextFile(file_to_load)); model.checkAllItems(); - if (mergeImportExportModel(&model, output_msg)) { + if (mergeImportExportModel(&model, this, output_msg)) { requestItemExpand(getSubTree(), true); } } @@ -332,8 +332,8 @@ QList StandardServiceRoot::getContextMenuForFeed(StandardFeed *feed) { return m_feedContextMenu; } -bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel *model, QString &output_message) { - QStack original_parents; original_parents.push(this); +bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel *model, RootItem *target_root_node, QString &output_message) { + QStack original_parents; original_parents.push(target_root_node); QStack new_parents; new_parents.push(model->rootItem()); bool some_feed_category_error = false; diff --git a/src/services/standard/standardserviceroot.h b/src/services/standard/standardserviceroot.h index 2e485dd2c..632a8f82c 100755 --- a/src/services/standard/standardserviceroot.h +++ b/src/services/standard/standardserviceroot.h @@ -92,7 +92,7 @@ class StandardServiceRoot : public ServiceRoot { // Takes structure residing under given root item and adds feeds/categories from // it to active structure. // NOTE: This is used for import/export of the model. - bool mergeImportExportModel(FeedsImportExportModel *model, QString &output_message); + bool mergeImportExportModel(FeedsImportExportModel *model, RootItem *target_root_node, QString &output_message); bool markFeedsReadUnread(QList items, ReadStatus read); bool cleanFeeds(QList items, bool clean_read_only);