Commit 358caedd authored by Dirk Wilden's avatar Dirk Wilden

grouping via scripting

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6065 383ad7c9-94d9-4d36-a494-682f7c89f535
parent b52b2330
...@@ -166,6 +166,8 @@ void DataControlPlugin::hideObject( int objectId ) { ...@@ -166,6 +166,8 @@ void DataControlPlugin::hideObject( int objectId ) {
emit visibilityChanged( object->id() ); emit visibilityChanged( object->id() );
} }
emit updateView();
} }
...@@ -257,6 +259,8 @@ void DataControlPlugin::showObject( int objectId ) { ...@@ -257,6 +259,8 @@ void DataControlPlugin::showObject( int objectId ) {
emit visibilityChanged( object->id() ); emit visibilityChanged( object->id() );
} }
emit updateView();
} }
...@@ -283,8 +287,9 @@ void DataControlPlugin::groupObjects(idList _objectIDs, QString _groupName) { ...@@ -283,8 +287,9 @@ void DataControlPlugin::groupObjects(idList _objectIDs, QString _groupName) {
//check if all objects have the same parent //check if all objects have the same parent
//abort if the parents differ //abort if the parents differ
bool target = (objs[0])->target(); bool visible = (objs[0])->visible();
bool source = (objs[0])->source(); bool target = (objs[0])->target();
bool source = (objs[0])->source();
BaseObject* parent = (objs[0])->parent(); BaseObject* parent = (objs[0])->parent();
for ( int i = 1 ; i < objs.size() ; ++i){ for ( int i = 1 ; i < objs.size() ; ++i){
...@@ -293,14 +298,17 @@ void DataControlPlugin::groupObjects(idList _objectIDs, QString _groupName) { ...@@ -293,14 +298,17 @@ void DataControlPlugin::groupObjects(idList _objectIDs, QString _groupName) {
return; return;
} }
target |= (objs[i])->target(); visible |= (objs[i])->visible();
source |= (objs[i])->source(); target |= (objs[i])->target();
source |= (objs[i])->source();
} }
//create new group //create new group
if (parent == 0) if (parent == 0)
parent = PluginFunctions::objectRoot(); parent = PluginFunctions::objectRoot();
GroupObject* groupItem = new GroupObject( "newGroup", dynamic_cast< GroupObject* >(parent)); GroupObject* groupItem = new GroupObject( "newGroup", dynamic_cast< GroupObject* >(parent));
//set groupName //set groupName
if (_groupName == "") if (_groupName == "")
groupItem->setName("newGroup " + QString::number(groupItem->id())); groupItem->setName("newGroup " + QString::number(groupItem->id()));
...@@ -309,22 +317,26 @@ void DataControlPlugin::groupObjects(idList _objectIDs, QString _groupName) { ...@@ -309,22 +317,26 @@ void DataControlPlugin::groupObjects(idList _objectIDs, QString _groupName) {
parent->appendChild( dynamic_cast< BaseObject* >( groupItem ) ); parent->appendChild( dynamic_cast< BaseObject* >( groupItem ) );
groupItem->setParent( parent ); groupItem->setParent( parent );
emit emptyObjectAdded( groupItem->id() );
//append new children to group //append new children to group
for ( int i = 0 ; i < objs.size() ; ++i) { for ( int i = 0 ; i < objs.size() ; ++i) {
(objs[i])->parent()->removeChild( objs[i] ); (objs[i])->parent()->removeChild( objs[i] );
(objs[i])->setParent( dynamic_cast< BaseObject* >( groupItem ) ); (objs[i])->setParent( dynamic_cast< BaseObject* >( groupItem ) );
groupItem->appendChild( objs[i] ); groupItem->appendChild( objs[i] );
//inform everyone that the parent changed
emit objectPropertiesChanged( (objs[i])->id() );
} }
//update target/source state //update target/source state
groupItem->visible(visible);
groupItem->target(target); groupItem->target(target);
groupItem->source(source); groupItem->source(source);
emit objectPropertiesChanged( groupItem->id() ); emit objectPropertiesChanged( groupItem->id() );
emit visibilityChanged ( groupItem->id() );
emit objectSelectionChanged ( groupItem->id() ); emit objectSelectionChanged ( groupItem->id() );
//because the parent of all items in the group changed
emit objectPropertiesChanged( -1 );
} }
......
...@@ -514,6 +514,8 @@ void TreeModel::moveItem(TreeItem* _item, TreeItem* _parent ){ ...@@ -514,6 +514,8 @@ void TreeModel::moveItem(TreeItem* _item, TreeItem* _parent ){
endInsertRows(); endInsertRows();
if ( newParentIndex.isValid() )
dataChanged(newParentIndex, newParentIndex);
} }
//****************************************************************************** //******************************************************************************
......
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