diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 4e478513f..2f2cc28ae 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -265,7 +265,7 @@ bool FeedsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int if (dragged_item_root != target_item_root) { // Transferring of items between different accounts is not possible. - qApp->showGuiMessage(tr("Cannot perform drag \& drop operation."), + qApp->showGuiMessage(tr("Cannot perform drag & drop operation."), tr("You can't transfer dragged item into different account, this is not supported."), QSystemTrayIcon::Warning, qApp->mainForm(), @@ -275,31 +275,11 @@ bool FeedsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int return false; } - /* - if (dragged_item->kind() == RootItem::Feeed) { - qDebug("Drag-drop action for feed '%s' detected, editing the feed.", qPrintable(dragged_item->title())); - - Feed *actual_feed = dragged_item->toFeed(); - Feed *feed_new = new Feed(*actual_feed); - - feed_new->setParent(target_item); - editFeed(actual_feed, feed_new); - - emit requireItemValidationAfterDragDrop(indexForItem(actual_feed)); + if (dragged_item->performDragDropChange(target_item)) { + // Drag & drop is supported by the dragged item and was + // completed on data level and in item hierarchy. + emit requireItemValidationAfterDragDrop(indexForItem(dragged_item)); } - else if (dragged_item->kind() == RootItem::Cattegory) { - qDebug("Drag-drop action for category '%s' detected, editing the feed.", qPrintable(dragged_item->title())); - - Category *actual_category = dragged_item->toCategory(); - Category *category_new = new Category(*actual_category); - - category_new->clearChildren(); - category_new->setParent(target_item); - editCategory(actual_category, category_new); - - emit requireItemValidationAfterDragDrop(indexForItem(actual_category)); - } - */ } return true; diff --git a/src/core/rootitem.cpp b/src/core/rootitem.cpp index 42738133f..d2c78a5e3 100755 --- a/src/core/rootitem.cpp +++ b/src/core/rootitem.cpp @@ -170,6 +170,10 @@ Qt::ItemFlags RootItem::additionalFlags() const { return Qt::NoItemFlags; } +bool RootItem::performDragDropChange(RootItem *target_item) { + return false; +} + int RootItem::countOfAllMessages() const { int total_count = 0; diff --git a/src/core/rootitem.h b/src/core/rootitem.h index 1b0b6646e..ed6dbc370 100755 --- a/src/core/rootitem.h +++ b/src/core/rootitem.h @@ -113,6 +113,7 @@ class RootItem : public QObject { virtual int row() const; virtual QVariant data(int column, int role) const; virtual Qt::ItemFlags additionalFlags() const; + virtual bool performDragDropChange(RootItem *target_item); // Each item offers "counts" of messages. // Returns counts of messages of all child items summed up. diff --git a/src/services/standard/standardcategory.cpp b/src/services/standard/standardcategory.cpp index 578016dd5..ceca4f418 100755 --- a/src/services/standard/standardcategory.cpp +++ b/src/services/standard/standardcategory.cpp @@ -94,6 +94,22 @@ Qt::ItemFlags StandardCategory::additionalFlags() const { return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled; } +bool StandardCategory::performDragDropChange(RootItem *target_item) { + StandardCategory *category_new = new StandardCategory(*this); + category_new->clearChildren(); + category_new->setParent(target_item); + + if (editItself(category_new)) { + serviceRoot()->feedsModel()->reassignNodeToNewParent(this, target_item); + delete category_new; + return true; + } + else { + delete category_new; + return false; + } +} + bool StandardCategory::editViaGui() { QPointer form_pointer = new FormStandardCategoryDetails(serviceRoot(), qApp->mainForm()); diff --git a/src/services/standard/standardcategory.h b/src/services/standard/standardcategory.h index 38a8d513f..36ac62f9a 100755 --- a/src/services/standard/standardcategory.h +++ b/src/services/standard/standardcategory.h @@ -45,6 +45,7 @@ class StandardCategory : public Category { // Returns the actual data representation of standard category. QVariant data(int column, int role) const; Qt::ItemFlags additionalFlags() const; + bool performDragDropChange(RootItem *target_item); bool canBeEdited() { return true; diff --git a/src/services/standard/standardfeed.cpp b/src/services/standard/standardfeed.cpp index 8902b6fe6..36e2ad098 100755 --- a/src/services/standard/standardfeed.cpp +++ b/src/services/standard/standardfeed.cpp @@ -440,6 +440,21 @@ Qt::ItemFlags StandardFeed::additionalFlags() const { return Qt::ItemIsDragEnabled; } +bool StandardFeed::performDragDropChange(RootItem *target_item) { + StandardFeed *feed_new = new StandardFeed(*this); + feed_new->setParent(target_item); + + if (editItself(feed_new)) { + serviceRoot()->feedsModel()->reassignNodeToNewParent(this, target_item); + delete feed_new; + return true; + } + else { + delete feed_new; + return false; + } +} + int StandardFeed::update() { QByteArray feed_contents; int download_timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt(); diff --git a/src/services/standard/standardfeed.h b/src/services/standard/standardfeed.h index f97714ba8..4e5f234fc 100755 --- a/src/services/standard/standardfeed.h +++ b/src/services/standard/standardfeed.h @@ -82,6 +82,7 @@ class StandardFeed : public Feed { // Obtains data related to this feed. QVariant data(int column, int role) const; Qt::ItemFlags additionalFlags() const; + bool performDragDropChange(RootItem *target_item); // Perform fetching of new messages. Returns number of newly updated messages. int update();