mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-03 02:37:46 +01:00
Added drag&drop support for feeds/categories.
This commit is contained in:
parent
b685f1fc86
commit
81cc30878b
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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<FormStandardCategoryDetails> form_pointer = new FormStandardCategoryDetails(serviceRoot(), qApp->mainForm());
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user