Commit a0a70377 authored by Dirk Wilden's avatar Dirk Wilden

adjusted DataControl to new visibility/selection handling

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7820 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ef285960
...@@ -162,6 +162,9 @@ void DataControlPlugin::initializePlugin() ...@@ -162,6 +162,9 @@ void DataControlPlugin::initializePlugin()
this, SLOT(slotHeaderCustomContextMenuRequested ( const QPoint & ) )); this, SLOT(slotHeaderCustomContextMenuRequested ( const QPoint & ) ));
emit addToolbox("Data Control", tool_); emit addToolbox("Data Control", tool_);
onlyDown_ = 0;
onlyUp_ = 0;
} }
...@@ -178,19 +181,38 @@ void DataControlPlugin::slotObjectSelectionChanged( int _identifier ) ...@@ -178,19 +181,38 @@ void DataControlPlugin::slotObjectSelectionChanged( int _identifier )
if ( PluginFunctions::getObject( _identifier, obj) ) if ( PluginFunctions::getObject( _identifier, obj) )
updateBoundingBox (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 //check for changes in the tree
BaseObject* object = 0; BaseObject* object = 0;
if ( PluginFunctions::getObject( _identifier, object) ){ if ( PluginFunctions::getObject( _identifier, object) ){
// if we are allowed to propagate up
if ( onlyDown_ == 0 ){
onlyUp_++;
propagateUpwards(object->parent(), 2); // 2 = source-target propagateUpwards(object->parent(), 2); // 2 = source-target
onlyUp_--;
}
// if we are allowed to propagate down
if ( onlyUp_ == 0 ){
onlyDown_++;
if ( object->isGroup() ) if ( object->isGroup() )
propagateDownwards(object, 2); // 2 = source-target propagateDownwards(object, 2); // 2 = source-target
}
emit updateView(); onlyDown_--;
}
}
} }
...@@ -201,17 +223,40 @@ void DataControlPlugin::slotObjectSelectionChanged( int _identifier ) ...@@ -201,17 +223,40 @@ void DataControlPlugin::slotObjectSelectionChanged( int _identifier )
* @param _identifier id of an object * @param _identifier id of an object
*/ */
void DataControlPlugin::slotVisibilityChanged( int _identifier ){ void DataControlPlugin::slotVisibilityChanged( int _identifier ){
// if onlyUp_ > 0 --> _identifier is a group and the selection
// does not have to be applied
if (onlyUp_ == 0){
//inform the model //inform the model
model_->objectChanged( _identifier ); model_->objectChanged( _identifier );
}
//check for changes in the tree //check for changes in the tree
BaseObject* obj = 0; BaseObject* obj = 0;
if ( PluginFunctions::getObject( _identifier, obj) ){ if ( PluginFunctions::getObject( _identifier, obj) ){
// if we are allowed to propagate up
if ( onlyDown_ == 0 ){
onlyUp_++;
propagateUpwards(obj->parent(), 1); // 1 = visibilty propagateUpwards(obj->parent(), 1); // 1 = visibilty
onlyUp_--;
}
// if we are allowed to propagate down
if ( onlyUp_ == 0 ){
onlyDown_++;
if ( obj->isGroup() ) if ( obj->isGroup() )
propagateDownwards(obj, 1); // 1 = visibilty propagateDownwards(obj, 1); // 1 = visibilty
onlyDown_--;
}
} }
BaseObjectData* object = 0; BaseObjectData* object = 0;
...@@ -457,9 +502,6 @@ void DataControlPlugin::loadIniFileOptionsLast( INIFile& _ini ) { ...@@ -457,9 +502,6 @@ void DataControlPlugin::loadIniFileOptionsLast( INIFile& _ini ) {
group = dynamic_cast< BaseObject* >( new GroupObject( current, dynamic_cast< GroupObject* >(parentItem ) ) ); group = dynamic_cast< BaseObject* >( new GroupObject( current, dynamic_cast< GroupObject* >(parentItem ) ) );
parentItem->appendChild(group);
group->setParent(parentItem);
emit emptyObjectAdded( group->id() ); emit emptyObjectAdded( group->id() );
// in the groups vector we only need the lowest groups // in the groups vector we only need the lowest groups
...@@ -579,6 +621,7 @@ void DataControlPlugin::saveIniFileOptions( INIFile& _ini ) { ...@@ -579,6 +621,7 @@ void DataControlPlugin::saveIniFileOptions( INIFile& _ini ) {
*/ */
void DataControlPlugin::propagateUpwards(BaseObject* _obj, int _column ){ void DataControlPlugin::propagateUpwards(BaseObject* _obj, int _column ){
if ( _obj == PluginFunctions::objectRoot() || (!_obj->isGroup()) ) if ( _obj == PluginFunctions::objectRoot() || (!_obj->isGroup()) )
return; return;
......
...@@ -176,6 +176,10 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn ...@@ -176,6 +176,10 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
void propagateDownwards(BaseObject* _obj, int _column ); void propagateDownwards(BaseObject* _obj, int _column );
void propagateUpwards(BaseObject* _obj, int _column ); void propagateUpwards(BaseObject* _obj, int _column );
//variables to restrict propagation direction
int onlyDown_;
int onlyUp_;
/** @} */ /** @} */
//=========================================================================== //===========================================================================
......
...@@ -379,9 +379,12 @@ void TreeModel::objectChanged(int _id) { ...@@ -379,9 +379,12 @@ void TreeModel::objectChanged(int _id) {
item->name( obj->name() ); item->name( obj->name() );
QModelIndex index = getModelIndex(item,0); //TODO actually we do not need to update the whole row but single column somehow doesn't work
if ( index.isValid() ) QModelIndex index0 = getModelIndex(item,0);
emit dataChanged( index, index); QModelIndex index1 = getModelIndex(item,3);
if ( index0.isValid() && index1.isValid() )
emit dataChanged( index0, index1);
} }
//update visibility //update visibility
...@@ -407,9 +410,13 @@ void TreeModel::objectChanged(int _id) { ...@@ -407,9 +410,13 @@ void TreeModel::objectChanged(int _id) {
item->source( obj->source() ); item->source( obj->source() );
QModelIndex index = getModelIndex(item,2); //TODO actually we do not need to update the whole row but single column somehow doesn't work
if ( index.isValid() ){ QModelIndex index0 = getModelIndex(item,0);
emit dataChanged( index, index); 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 ); propagateUpwards(item->parent(), 2, false );
} }
...@@ -422,9 +429,13 @@ void TreeModel::objectChanged(int _id) { ...@@ -422,9 +429,13 @@ void TreeModel::objectChanged(int _id) {
item->target( obj->target() ); item->target( obj->target() );
QModelIndex index = getModelIndex(item,3); //TODO actually we do not need to update the whole row but single column somehow doesn't work
if ( index.isValid() ){ QModelIndex index0 = getModelIndex(item,0);
emit dataChanged( index, index); 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 ); propagateUpwards(item->parent(), 3, false );
} }
...@@ -709,6 +720,7 @@ bool TreeModel::setData(const QModelIndex &index, const QVariant &value, int /*r ...@@ -709,6 +720,7 @@ bool TreeModel::setData(const QModelIndex &index, const QVariant &value, int /*r
emit dataChangedInside( itemId(index), index.column(), value ); emit dataChangedInside( itemId(index), index.column(), value );
return true; 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