From ff801dd9a5db31e957c169b6cb4a90837d8b2a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20M=C3=B6ller?= Date: Fri, 18 Jan 2013 11:19:30 +0000 Subject: [PATCH] removed additional recursion checking the status of objects. refs #1375 git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@16165 383ad7c9-94d9-4d36-a494-682f7c89f535 --- Plugin-Datacontrol/DataControlPlugin.cc | 41 +++++----- Plugin-Datacontrol/TreeModel.cc | 104 +----------------------- Plugin-Datacontrol/TreeModel.hh | 4 - 3 files changed, 22 insertions(+), 127 deletions(-) diff --git a/Plugin-Datacontrol/DataControlPlugin.cc b/Plugin-Datacontrol/DataControlPlugin.cc index 02825c5ff..296b2497f 100644 --- a/Plugin-Datacontrol/DataControlPlugin.cc +++ b/Plugin-Datacontrol/DataControlPlugin.cc @@ -239,37 +239,36 @@ void DataControlPlugin::slotObjectSelectionChanged( int _identifier ) if ( PluginFunctions::getObject( _identifier, obj) ) updateBoundingBox (obj); - // if onlyUp_ > 0 --> _identifier is a group and the selection - // does not have to be applied - if (onlyUp_ == 0) - model_->objectChanged( _identifier ); + model_->objectChanged( _identifier ); //check for changes in the tree BaseObject* object = 0; if ( PluginFunctions::getObject( _identifier, object) ){ - - // 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 we are allowed to propagate down + if ( onlyUp_ == 0 ){ + + onlyDown_++; - onlyDown_++; + if ( object->isGroup() ) + propagateDownwards(object, 2); // 2 = source-target + + onlyDown_--; + } + + // if we are allowed to propagate up + if ( onlyDown_ == 0 ){ + + onlyUp_++; + + propagateUpwards(object->parent(), 2); // 2 = source-target + + onlyUp_--; + } - if ( object->isGroup() ) - propagateDownwards(object, 2); // 2 = source-target - onlyDown_--; - } } } diff --git a/Plugin-Datacontrol/TreeModel.cc b/Plugin-Datacontrol/TreeModel.cc index 93142515b..ec4664def 100644 --- a/Plugin-Datacontrol/TreeModel.cc +++ b/Plugin-Datacontrol/TreeModel.cc @@ -406,11 +406,7 @@ void TreeModel::objectChanged(int _id) { 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(), 1, obj->visible() ); } - - if ( obj->isGroup() ) - propagateDownwards(item, 1 ); } //update source flag @@ -425,11 +421,7 @@ void TreeModel::objectChanged(int _id) { 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 ); } - - if ( obj->isGroup() ) - propagateDownwards(item, 2 ); } //update target flag @@ -444,11 +436,7 @@ void TreeModel::objectChanged(int _id) { 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 ); } - - if ( obj->isGroup() ) - propagateDownwards(item, 3 ); } //update parent @@ -462,8 +450,10 @@ void TreeModel::objectChanged(int _id) { if (parent != 0) moveItem(item, parent ); } + } } + } @@ -627,96 +617,6 @@ QModelIndex TreeModel::getModelIndex(TreeItem* _object, int _column ){ return index; } - -//****************************************************************************** - -/** \brief Recursively update a column up to the root of the tree - * - * @param _item item to start with - * @param _column Column that should be propagated - * @param _value New value - */ -void TreeModel::propagateUpwards(TreeItem* _item, int _column, bool _value ){ - - if ( isRoot(_item) || (!_item->isGroup()) ) - return; - - if (_column == 1){ //visibility - _item->visible( _value ); - - //the whole row has to be updated because of the grey background-color - QModelIndex index0 = getModelIndex(_item,0); - QModelIndex index1 = getModelIndex(_item,3); - - emit dataChanged( index0, index1); - - } else { - - QModelIndex index = getModelIndex(_item,_column); - emit dataChanged(index, index); - } - - propagateUpwards( _item->parent(), _column, _value ); -} - -//****************************************************************************** - -/** \brief Recursively update a column up to the root of the tree - * - * @param _item Item to start with - * @param _column Column that should be propagated - */ -void TreeModel::propagateDownwards(TreeItem* _item, int _column ){ - - for (int i=0; i < _item->childCount(); i++){ - - TreeItem* current = _item->child(i); - - bool changed = false; - - switch ( _column ){ - - case 1: //VISIBILTY - - if ( current->visible() != _item->visible() ){ - - current->visible( _item->visible() ); - changed = true; - } - break; - - case 2: //SOURCE - - if ( current->source() != _item->source() ){ - - current->source( _item->source() ); - changed = true; - } - break; - - case 3: //TARGET - - if ( current->target() != _item->target() ){ - - current->target( _item->target() ); - changed = true; - } - break; - - default: - break; - } - - if (changed){ - QModelIndex index = getModelIndex(current,_column); - emit dataChanged(index, index); - } - - if ( current->isGroup() ) - propagateDownwards(current, _column); - } -} - //****************************************************************************** bool TreeModel::setData(const QModelIndex &index, const QVariant &value, int /*role*/) diff --git a/Plugin-Datacontrol/TreeModel.hh b/Plugin-Datacontrol/TreeModel.hh index be574e878..d3d1ec9c8 100644 --- a/Plugin-Datacontrol/TreeModel.hh +++ b/Plugin-Datacontrol/TreeModel.hh @@ -155,10 +155,6 @@ private: /// Root item of the tree TreeItem* rootItem_; - - void propagateUpwards(TreeItem* _obj, int _column, bool _value ); - void propagateDownwards(TreeItem* _obj, int _column ); - /** @} */ //=========================================================================== -- GitLab