Commit cde229ff authored by Dirk Wilden's avatar Dirk Wilden
Browse files

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 4f888edf
......@@ -282,8 +282,8 @@ void Core::newObject(int _objectId) {
PluginFunctions::getObject(_objectId,baseObject);
if ( baseObject ) {
connect( baseObject, SIGNAL(visibilityChanged(int)), this, SLOT(slotVisibilityChanged(int))) ;
connect( baseObject, SIGNAL(objectSelectionChanged(int)),this, SLOT(slotObjectSelectionChanged(int)) );
connect( baseObject, SIGNAL(visibilityChanged(int)), this, SLOT(slotVisibilityChanged(int)), Qt::DirectConnection) ;
connect( baseObject, SIGNAL(objectSelectionChanged(int)),this, SLOT(slotObjectSelectionChanged(int)), Qt::DirectConnection );
} else {
emit log(LOGERR,tr("newObject received from objectManager with invalid id! This should not happen. The new Object will not work correctly!"));
}
......
......@@ -530,7 +530,7 @@ void Core::loadPlugin(QString filename, bool silent){
}
if ( checkSlot( plugin , "slotObjectSelectionChanged(int)" ) )
connect(this,SIGNAL(objectSelectionChanged(int)),plugin,SLOT(slotObjectSelectionChanged(int) ));
connect(this,SIGNAL(objectSelectionChanged(int)),plugin,SLOT(slotObjectSelectionChanged(int) ), Qt::DirectConnection);
if ( checkSlot( plugin , "pluginsInitialized()" ) )
......
......@@ -249,11 +249,14 @@ bool BaseObject::flag(QString _flag)
void BaseObject::setFlag(QString _flag, bool _set)
{
bool emitted = false;
if (flags_.contains(_flag))
{
if (!_set) {
flags_.removeAll(_flag);
emit objectSelectionChanged(id());
emitted = true;
}
}
else
......@@ -261,9 +264,13 @@ void BaseObject::setFlag(QString _flag, bool _set)
if (_set) {
flags_ << _flag;
emit objectSelectionChanged(id());
emitted = true;
}
}
//always emit if its a group
if ( !emitted && isGroup() )
emit objectSelectionChanged(id());
}
QStringList BaseObject::flags()
......@@ -283,8 +290,15 @@ void BaseObject::visible(bool _visible) {
// Only do something if this is really a change
if ( visible_ != _visible ) {
visible_ = _visible;
emit visibilityChanged( id() );
} else {
//always emit if its a group
if ( isGroup() )
emit visibilityChanged( id() );
}
emit visibilityChanged( id() );
}
// ===============================================================================
......
......@@ -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