Commit 7280cbb8 authored by Dirk Wilden's avatar Dirk Wilden

fixed last version

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5347 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ce55b9ef
......@@ -129,8 +129,8 @@ bool DataControlPlugin::initializeToolbox(QWidget*& _widget)
view_->setSelectionMode(QAbstractItemView::ExtendedSelection);
connect( model_,SIGNAL(dataChangedInside( const QModelIndex&) ),
this, SLOT( slotDataChanged( const QModelIndex& )) );
connect( model_,SIGNAL(dataChangedInside(BaseObject*,int) ),
this, SLOT( slotDataChanged(BaseObject*,int)) );
connect( model_ , SIGNAL( modelAboutToBeReset() ),
this , SLOT(slotModelAboutToReset() ) );
......@@ -228,18 +228,33 @@ void DataControlPlugin::slotObjectPropertiesChanged( int _identifier ){
*/
void DataControlPlugin::slotObjectUpdated( int _identifier ){
if (_identifier != -1){
//abort if the object is already in the model
BaseObject* obj;
if (_identifier == -1)
model_->objectChanged( _identifier );
}
if ( PluginFunctions::getObject( _identifier, obj) )
if ( (model_->getModelIndex(obj, 0)).isValid() )
return;
}
model_->objectChanged( -1 );
//******************************************************************************
/** \brief Update the model if a file has been opened
*
* @param _id id of an object
*/
void DataControlPlugin::fileOpened(int){
model_->objectChanged(-1);
}
//******************************************************************************
/** \brief Update the model if an empty object has been added
*
* @param _id id of an object
*/
void DataControlPlugin::addedEmptyObject(int){
model_->objectChanged(-1);
}
//******************************************************************************
/** \brief a key event occurred
......@@ -277,36 +292,37 @@ void DataControlPlugin::slotKeyEvent( QKeyEvent* _event )
* @param topLeft index in the model
* @param
*/
void DataControlPlugin::slotDataChanged ( const QModelIndex& _index)
void DataControlPlugin::slotDataChanged ( BaseObject* _obj, int _column)
{
BaseObject* obj = model_->getItem(_index);
switch (_index.column()) {
// Name
case 0:
emit objectPropertiesChanged( obj->id() );
view_->expandToDepth(0);
break;
// show/hide
case 1:
emit visibilityChanged( obj->id() );
emit updateView();
break;
if (_obj != 0){
// std::cerr << "slotDataChanged obj " << _obj->id() << " column " << _column << std::endl;
switch ( _column ) {
// Name
case 0:
emit objectPropertiesChanged( _obj->id() );
view_->expandToDepth(0);
break;
// show/hide
case 1:
emit visibilityChanged( _obj->id() );
emit updateView();
break;
// source
case 2:
emit objectSelectionChanged( _obj->id() );
break;
// target
case 3:
emit objectSelectionChanged( _obj->id() );
break;
// source
case 2:
emit objectSelectionChanged( obj->id() );
break;
// target
case 3:
emit objectSelectionChanged( obj->id() );
break;
default:
break;
default:
break;
}
}
}
......
......@@ -43,6 +43,7 @@
#include <OpenFlipper/BasePlugin/ContextMenuInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/INIInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <OpenFlipper/common/Types.hh>
#include "Toolbox.hh"
......@@ -51,7 +52,7 @@
/** Plugin for controlling the Object data structures (Show,hide Object, Target, Source selection
*/
class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyInterface , LoggingInterface, INIInterface, ContextMenuInterface, ScriptInterface
class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyInterface , LoggingInterface, INIInterface, ContextMenuInterface, ScriptInterface, LoadSaveInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
......@@ -61,6 +62,7 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
Q_INTERFACES(INIInterface)
Q_INTERFACES(ContextMenuInterface)
Q_INTERFACES(ScriptInterface)
Q_INTERFACES(LoadSaveInterface)
signals:
// BaseInterface
......@@ -95,6 +97,10 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
void loadIniFileOptionsLast( INIFile& _ini );
void saveIniFileOptions( INIFile& _ini );
// LoadSaveInterface
void fileOpened(int _id);
void addedEmptyObject(int _id);
public :
/// Destructor
~DataControlPlugin() {};
......@@ -139,7 +145,7 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
private slots:
/// Gets called when the data in the table has changed
void slotDataChanged ( const QModelIndex & _index );
void slotDataChanged ( BaseObject* _obj, int _column );
void slotModelAboutToReset();
......
......@@ -359,14 +359,15 @@ void TreeModel::objectChanged(int _id) {
if (obj != 0 ){
if ( name.isValid() )
emit dataChanged( name, name);
if ( visible.isValid() )
emit dataChanged( visible, visible);
if ( source.isValid() )
emit dataChanged( source, source);
if ( target.isValid() )
emit dataChanged( target, target);
// if ( name.isValid() )
// emit dataChanged( name, name);
// if ( visible.isValid() )
// emit dataChanged( visible, visible);
// if ( source.isValid() )
// emit dataChanged( source, source);
// if ( target.isValid() )
// emit dataChanged( target, target);
emit dataChanged( QModelIndex(), QModelIndex() );
}
return;
......@@ -397,7 +398,9 @@ BaseObject* TreeModel::getItem(const QModelIndex &index) const
//******************************************************************************
/** \brief Return index of given item
*
*
* Warning: Only use this function if you know that all ModelIndices are created
*
* @param _object an object
* @param _column a column
* @return index of object and column
......@@ -436,10 +439,9 @@ void TreeModel::propagateUpwards(BaseObject* _obj, int _column ){
for (int i=0; i < children.size(); i++)
value |= children[i]->visible();
if ( true /*_obj->visible() != value*/){
_obj->visible( value );
changed = true;
}
_obj->visible( value );
changed = true;
break;
case 2: //SOURCE
......@@ -470,12 +472,8 @@ void TreeModel::propagateUpwards(BaseObject* _obj, int _column ){
break;
}
//if (changed){
QModelIndex index = getModelIndex(_obj, _column);
emit dataChanged(index, index);
emit dataChangedInside(index);
//}
if (changed && (!_obj->isGroup()) )
emit dataChangedInside(_obj, _column );
propagateUpwards( _obj->parent(), _column );
}
......@@ -499,6 +497,7 @@ void TreeModel::propagateDownwards(BaseObject* _obj, int _column ){
case 1: //VISIBILTY
if ( current->visible() != _obj->visible() ){
current->visible( _obj->visible() );
changed = true;
}
......@@ -526,15 +525,11 @@ void TreeModel::propagateDownwards(BaseObject* _obj, int _column ){
break;
}
if ( current->isGroup() )
if ( current->isGroup() ){
propagateDownwards(current, _column);
//if (changed){
QModelIndex index = getModelIndex(current, _column);
emit dataChanged(index, index);
emit dataChangedInside(index);
//}
} else if (changed)
emit dataChangedInside(current, _column );
}
}
......@@ -555,7 +550,6 @@ bool TreeModel::setData(const QModelIndex &index, const QVariant &value, int /*r
bool newValue;
if ( item->isGroup() ) {
int childCount = 0;
// Decide on column what to do with the value
switch ( index.column() ) {
......@@ -572,79 +566,31 @@ bool TreeModel::setData(const QModelIndex &index, const QVariant &value, int /*r
// visible
case 1 :
newValue = value.toBool();
std::cerr << "change visibilty :" << item->visible() << " to " << newValue << std::endl;
if ( true /*item->visible() != newValue*/){
item->visible(newValue);
changed = true;
std::cerr << "changed visibilty :" << item->visible() << " to " << newValue << std::endl;
propagateDownwards(item, index.row());
}
item->visible( value.toBool() );
changed = true;
propagateDownwards( item, index.column() );
break;
// source
case 2 :
newValue = value.toBool();
if (item->source() != newValue){
item->source( newValue );
changed = true;
QList< BaseObject* > children = item->getLeafs();
childCount = children.size();
for (int i=0; i < children.size(); i++){
if (children[i] && children[i]->source() != newValue){
children[i]->source( newValue );
QModelIndex childIndex = createIndex((children[i])->row(), index.column(), children[i]);
emit dataChanged( childIndex, childIndex );
emit dataChangedInside(childIndex);
}
}
}
item->source( value.toBool() );
changed = true;
propagateDownwards(item, index.column());
break;
//target
case 3 :
newValue = value.toBool();
if (item->target() != newValue){
item->target( newValue );
changed = true;
QList< BaseObject* > children = item->getLeafs();
childCount = children.size();
for (int i=0; i < children.size(); i++){
if (children[i] && children[i]->target() != newValue){
children[i]->target( newValue );
QModelIndex childIndex = createIndex((children[i])->row(), index.column(), children[i]);
emit dataChanged( childIndex, childIndex );
emit dataChangedInside(childIndex);
}
}
}
item->target( value.toBool() );
changed = true;
propagateDownwards(item, index.column());
break;
}
if (changed){
emit dataChanged( index, index );
emit dataChangedInside(index);
}
if (changed)
emit dataChangedInside(item, index.column() );
return true;
}
......@@ -717,10 +663,8 @@ std::cerr << "changed visibilty :" << item->visible() << " to " << newValue << s
break;
}
if (changed){
emit dataChanged(index,index);
emit dataChangedInside(index);
}
if (changed)
emit dataChangedInside(item, index.column() );
return true;
}
......
......@@ -48,7 +48,7 @@ class TreeModel : public QAbstractItemModel
Q_OBJECT
signals:
void dataChangedInside(const QModelIndex& _index);
void dataChangedInside(BaseObject* _obj, int _column);
public:
......
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