diff --git a/DataControlPlugin.cc b/DataControlPlugin.cc index 609ce57f88b5c1a0a53ed8037386035a5821b3d6..cc244c457c8e35eeb5dc3140a7aa8dada013e648 100644 --- a/DataControlPlugin.cc +++ b/DataControlPlugin.cc @@ -162,6 +162,9 @@ void DataControlPlugin::initializePlugin() this, SLOT(slotHeaderCustomContextMenuRequested ( const QPoint & ) )); emit addToolbox("Data Control", tool_); + + onlyDown_ = 0; + onlyUp_ = 0; } @@ -172,25 +175,44 @@ void DataControlPlugin::initializePlugin() */ void DataControlPlugin::slotObjectSelectionChanged( int _identifier ) { - + BaseObjectData* obj = 0; if ( PluginFunctions::getObject( _identifier, obj) ) updateBoundingBox (obj); - model_->objectChanged( _identifier ); + // if onlyUp_ > 0 --> _identifier is a group and the selection + // does not have to be applied + if (onlyUp_ == 0) + model_->objectChanged( _identifier ); + //check for changes in the tree BaseObject* object = 0; if ( PluginFunctions::getObject( _identifier, object) ){ - propagateUpwards(object->parent(), 2); // 2 = source-target + + // if we are allowed to propagate up + if ( onlyDown_ == 0 ){ + + onlyUp_++; + + propagateUpwards(object->parent(), 2); // 2 = source-target + + onlyUp_--; + } + + // if we are allowed to propagate down + if ( onlyUp_ == 0 ){ - if ( object->isGroup() ) - propagateDownwards(object, 2); // 2 = source-target - } + onlyDown_++; - emit updateView(); + if ( object->isGroup() ) + propagateDownwards(object, 2); // 2 = source-target + + onlyDown_--; + } + } } @@ -201,17 +223,40 @@ void DataControlPlugin::slotObjectSelectionChanged( int _identifier ) * @param _identifier id of an object */ void DataControlPlugin::slotVisibilityChanged( int _identifier ){ - //inform the model - model_->objectChanged( _identifier ); + + // if onlyUp_ > 0 --> _identifier is a group and the selection + // does not have to be applied + if (onlyUp_ == 0){ + //inform the model + model_->objectChanged( _identifier ); + } //check for changes in the tree BaseObject* obj = 0; if ( PluginFunctions::getObject( _identifier, obj) ){ - propagateUpwards(obj->parent(), 1); // 1 = visibilty - if ( obj->isGroup() ) - propagateDownwards(obj, 1); // 1 = visibilty + // if we are allowed to propagate up + if ( onlyDown_ == 0 ){ + + onlyUp_++; + + propagateUpwards(obj->parent(), 1); // 1 = visibilty + + onlyUp_--; + + } + + // if we are allowed to propagate down + if ( onlyUp_ == 0 ){ + + onlyDown_++; + + if ( obj->isGroup() ) + propagateDownwards(obj, 1); // 1 = visibilty + + onlyDown_--; + } } BaseObjectData* object = 0; @@ -323,7 +368,7 @@ void DataControlPlugin::slotDataChanged ( int _id, int _column, const QVariant& BaseObject* obj = 0; if ( !PluginFunctions::getObject( _id, obj) ) return; - + switch ( _column ) { // Name case 0: @@ -457,9 +502,6 @@ void DataControlPlugin::loadIniFileOptionsLast( INIFile& _ini ) { group = dynamic_cast< BaseObject* >( new GroupObject( current, dynamic_cast< GroupObject* >(parentItem ) ) ); - parentItem->appendChild(group); - group->setParent(parentItem); - emit emptyObjectAdded( group->id() ); // in the groups vector we only need the lowest groups @@ -579,6 +621,7 @@ void DataControlPlugin::saveIniFileOptions( INIFile& _ini ) { */ void DataControlPlugin::propagateUpwards(BaseObject* _obj, int _column ){ + if ( _obj == PluginFunctions::objectRoot() || (!_obj->isGroup()) ) return; diff --git a/DataControlPlugin.hh b/DataControlPlugin.hh index 7d272a845c9f4ab96195ab44fb116b1ddf06b6ec..5fe129d20146cc4355d715e4a8a039d08d608541 100644 --- a/DataControlPlugin.hh +++ b/DataControlPlugin.hh @@ -176,6 +176,10 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn void propagateDownwards(BaseObject* _obj, int _column ); void propagateUpwards(BaseObject* _obj, int _column ); + //variables to restrict propagation direction + int onlyDown_; + int onlyUp_; + /** @} */ //=========================================================================== diff --git a/TreeModel.cc b/TreeModel.cc index a15451bd30dddd48d1e31064a21d48e4ca5a7862..ace3877868d8d2e7010308b4453af6e9e2b37f08 100644 --- a/TreeModel.cc +++ b/TreeModel.cc @@ -379,9 +379,12 @@ void TreeModel::objectChanged(int _id) { item->name( obj->name() ); - QModelIndex index = getModelIndex(item,0); - if ( index.isValid() ) - emit dataChanged( index, index); + //TODO actually we do not need to update the whole row but single column somehow doesn't work + QModelIndex index0 = getModelIndex(item,0); + QModelIndex index1 = getModelIndex(item,3); + + if ( index0.isValid() && index1.isValid() ) + emit dataChanged( index0, index1); } //update visibility @@ -407,9 +410,13 @@ void TreeModel::objectChanged(int _id) { item->source( obj->source() ); - QModelIndex index = getModelIndex(item,2); - if ( index.isValid() ){ - emit dataChanged( index, index); + //TODO actually we do not need to update the whole row but single column somehow doesn't work + QModelIndex index0 = getModelIndex(item,0); + QModelIndex index1 = getModelIndex(item,3); + + if ( index0.isValid() && index1.isValid() ){ + //the whole row has to be updated because of the grey background-color + emit dataChanged( index0, index1); propagateUpwards(item->parent(), 2, false ); } @@ -422,9 +429,13 @@ void TreeModel::objectChanged(int _id) { item->target( obj->target() ); - QModelIndex index = getModelIndex(item,3); - if ( index.isValid() ){ - emit dataChanged( index, index); + //TODO actually we do not need to update the whole row but single column somehow doesn't work + QModelIndex index0 = getModelIndex(item,0); + QModelIndex index1 = getModelIndex(item,3); + + if ( index0.isValid() && index1.isValid() ){ + //the whole row has to be updated because of the grey background-color + emit dataChanged( index0, index1); propagateUpwards(item->parent(), 3, false ); } @@ -709,6 +720,7 @@ bool TreeModel::setData(const QModelIndex &index, const QVariant &value, int /*r emit dataChangedInside( itemId(index), index.column(), value ); + return true; }