From 418511bdc812482efd1271133e85be1b3e016fd6 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Thu, 4 Sep 2014 15:52:42 +0200 Subject: [PATCH] Now, impor feature merges existing content. --- resources/text/CHANGELOG | 2 +- resources/text/UPDATES | 16 +++++++++++++--- src/core/feedsmodel.cpp | 13 ++++++++++++- src/core/feedsmodelrootitem.cpp | 15 +++++++++++++++ src/core/feedsmodelrootitem.h | 2 ++ src/gui/formcategorydetails.cpp | 6 ++---- 6 files changed, 45 insertions(+), 9 deletions(-) diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index e4bd7b567..376a23d1e 100644 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -16,7 +16,7 @@ Fixed: Added: diff --git a/resources/text/UPDATES b/resources/text/UPDATES index 513b8c317..54dad8fd4 100644 --- a/resources/text/UPDATES +++ b/resources/text/UPDATES @@ -1,21 +1,31 @@ - - https://bitbucket.org/skunkos/rssguard/downloads/rssguard-2.0.0.0-win32-test.exe + + https://bitbucket.org/skunkos/rssguard/downloads/rssguard-2.0.0.0-win32.exe Fixed:
    -
  • Improved behavior of updater.
  • +
  • Improved behavior of updater. Switched to NSIS installers.
  • +
  • Adjusted OS/2 icon handling.
  • +
  • Toolbars tweaked.
  • +
  • Source code huge refactorings.
  • +
  • Flag icons are now separated into their own directory.
  • +
  • File downloaders are now thinner.
  • +
  • GUI tweaked.
  • +
  • Database connections are only used when really needed.
Added:
  • Added NSIS-based "portable" installer for Windows and restructured update process.
  • +
  • Added experimental support for exporting and importing feeds to/from OPML 2.0.
  • +
  • Feeds now change their color to red if their network status reports error - feed is not reachable or was moved or is unavailable due to other errors.
Changed:
    +
  • Added newly-compiled SQL libraries - MariaDB, Postgre SQL.
  • Updated bundled OpenSSL libraries for Windows portable version.
]]> diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index fa06fc2f2..85d12de9e 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -565,7 +565,18 @@ bool FeedsModel::mergeModel(FeedsImportExportModel *model, QString &output_messa new_parents.push(source_category); } else { - some_feed_category_error = true; + // Add category failed, but this can mean that the same category (with same title) + // already exists. If such a category exists in current parent, then find it and + // add descendants to it. + FeedsModelRootItem *existing_category = target_parent->child(FeedsModelRootItem::Category, new_category->title()); + + if (existing_category != NULL) { + original_parents.push(existing_category); + new_parents.push(source_category); + } + else { + some_feed_category_error = true; + } } } else if (source_item->kind() == FeedsModelRootItem::Feed) { diff --git a/src/core/feedsmodelrootitem.cpp b/src/core/feedsmodelrootitem.cpp index 3ab022520..a41ee819c 100755 --- a/src/core/feedsmodelrootitem.cpp +++ b/src/core/feedsmodelrootitem.cpp @@ -18,6 +18,8 @@ #include "core/feedsmodelrootitem.h" #include "miscellaneous/application.h" +#include "core/feedsmodelcategory.h" +#include "core/feedsmodelfeed.h" #include @@ -78,6 +80,19 @@ bool FeedsModelRootItem::removeChild(FeedsModelRootItem *child) { return m_childItems.removeOne(child); } +FeedsModelRootItem *FeedsModelRootItem::child(FeedsModelRootItem::Kind kind_of_child, const QString &identifier) { + foreach (FeedsModelRootItem *child, childItems()) { + if (child->kind() == kind_of_child) { + if (kind_of_child == Category && static_cast(child)->title() == identifier || + kind_of_child == Feed && static_cast(child)->url() == identifier) { + return child; + } + } + } + + return NULL; +} + int FeedsModelRootItem::countOfUnreadMessages() const { int total_count = 0; diff --git a/src/core/feedsmodelrootitem.h b/src/core/feedsmodelrootitem.h index 53bf2ecea..266b8b04f 100755 --- a/src/core/feedsmodelrootitem.h +++ b/src/core/feedsmodelrootitem.h @@ -53,6 +53,8 @@ class FeedsModelRootItem { return m_childItems.value(row); } + virtual FeedsModelRootItem *child(FeedsModelRootItem::Kind kind_of_child, const QString &identifier); + inline virtual int childCount() const { return m_childItems.size(); } diff --git a/src/gui/formcategorydetails.cpp b/src/gui/formcategorydetails.cpp index b920a1cb4..bc772b15a 100755 --- a/src/gui/formcategorydetails.cpp +++ b/src/gui/formcategorydetails.cpp @@ -240,16 +240,14 @@ void FormCategoryDetails::loadCategories(const QList catego QVariant::fromValue((void*) root_item)); foreach (FeedsModelCategory *category, categories) { - if (input_category != NULL && (category == input_category || - category->isChildOf(input_category))) { + if (input_category != NULL && (category == input_category || category->isChildOf(input_category))) { // This category cannot be selected as the new // parent for currently edited category, so // don't add it. continue; } - m_ui->m_cmbParentCategory->addItem(category->data(FDS_MODEL_TITLE_INDEX, - Qt::DecorationRole).value(), + m_ui->m_cmbParentCategory->addItem(category->data(FDS_MODEL_TITLE_INDEX, Qt::DecorationRole).value(), category->title(), QVariant::fromValue((void*) category)); }