From 7c5ff7cec9d85d10e1702ec4552a6202571dfa78 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 6 May 2013 15:34:56 +0200 Subject: [PATCH] Do not allow to drag and drop child items of non-group objects in tree view --- src/Gui/Tree.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index c2b3284455..a10cf015b3 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -340,6 +340,15 @@ QMimeData * TreeWidget::mimeData (const QList items) const doc = obj->getDocument(); else if (doc != obj->getDocument()) return 0; + // Now check for object with a parent that is an ObjectType, too. + // If this object is *not* a group we are not allowed to remove + // its child (e.g. the sketch of a pad). + QTreeWidgetItem* parent = (*it)->parent(); + if (parent && parent->type() == TreeWidget::ObjectType) { + App::DocumentObject* par = static_cast(parent)->object()->getObject(); + if (!par->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) + return 0; + } } return QTreeWidget::mimeData(items); }