Commit f523fbaf authored by Dirk Wilden's avatar Dirk Wilden

drag n drop for multiple objects

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4363 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f1dd751c
......@@ -683,29 +683,43 @@ bool TreeModel::dropMimeData(const QMimeData *data,
ids.push_back( id );
}
if (ids.count() != 1)
if (ids.count() == 0)
return false;
//get new parent
BaseObject *newParent = getItem(parent);
//get new parent
if ( newParent == 0 || !newParent->isGroup() )
return false;
BaseObject* item = 0;
if (PluginFunctions::get_object(ids[0], item)){
item->parent()->removeChild(item);
item->setParent( newParent );
newParent->appendChild( item );
BaseObject *newParent = getItem(parent);
if ( newParent == 0 || !newParent->isGroup() )
return false;
//and move all objects
for (int i = 0; i < ids.count(); i++){
BaseObject* item = 0;
if (PluginFunctions::get_object(ids[i], item)){
item->parent()->removeChild(item);
//if parent was group and is empty now ->delete it
if ( !isRoot( item->parent() ) &&
item->parent()->isGroup() && item->parent()->childCount() == 0){
// remove the parent itself from the parent
item->parent()->parent()->removeChild(item->parent());
// delete it
delete item->parent();
}
item->setParent( newParent );
newParent->appendChild( item );
}
}
// emit dataChanged(QModelIndex(),QModelIndex());
//TODO do something better than reset
reset();
return true;
}
return false;
//TODO do something better than reset
reset();
return true;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment