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()
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;
......
......@@ -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_;
/** @} */
//===========================================================================
......
......@@ -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;
}
......
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