Commit a3bfaef1 authored by Antoine Regimbeau's avatar Antoine Regimbeau

BUG: signal propagiation try

parent 2d822ba7
......@@ -212,6 +212,7 @@ public:
// Public SLOTS.
public slots:
void Clear();
void Deleting( SizeType index )
inline void Delete( const KeyType & );
inline void DeleteCurrent();
inline void LowerCurrent();
......
......@@ -218,11 +218,104 @@ StackedLayerModel
}
/*****************************************************************************/
void
StackedLayerModel
::Deleting( SizeType index )
{
// qDebug() << this << "::Delete(" << index << ")";
//
// Check content.
if( IsEmpty() )
return;
if( index>=GetCount() )
return;
assert( !m_Keys[ index ].empty() );
//
// Find item.
LayerModelMap::iterator it(
m_LayerModels.find( m_Keys[ index ] )
);
assert( it!=m_LayerModels.end() );
//
// Check if signals have to be emitted.
bool emitCurrentChanged = m_Current<GetCount() && index<=m_Current;
bool emitReferenceChanged = m_Reference<GetCount() && index<=m_Reference;
//
// Remember new current index.
SizeType current =
index>m_Current
? m_Current
: ( m_Current>0
? m_Current - 1
: GetCount()>1 ? 0 : StackedLayerModel::NIL_INDEX );
//
// Emit signals.
emit ContentAboutToBeChanged();
emit LayerAboutToBeDeleted( index );
//
// Clear satellite date.
ClearPixelInfos();
//
// Remove layer-model.
AbstractLayerModel * layer = it->second;
// Disconnect the renaming signals
QObject::disconnect(
layer,
SIGNAL( NameChanged() ),
// from:
this,
SIGNAL( LayerRenamed() )
);
m_LayerModels.erase( it );
m_Keys.erase( m_Keys.begin() + index );
it = m_LayerModels.end();
//
// Update pointer to current.
if( emitCurrentChanged )
SetCurrent( current, true );
//
// Update reference pointer.
if( emitReferenceChanged )
SetReference(
index>m_Reference
? m_Reference
: ( m_Reference > 0
? m_Reference - 1
: GetCount() > 0 ? 0 : StackedLayerModel::NIL_INDEX ),
true
);
//
// Eventually delete layer.
if( layer->parent()==this )
{
delete layer;
layer = NULL;
}
}
void
StackedLayerModel
::Delete( SizeType index )
{
// qDebug() << this << "::Delete(" << index << ")";
/*// qDebug() << this << "::Delete(" << index << ")";
//
......@@ -310,7 +403,7 @@ StackedLayerModel
layer = NULL;
}
//
//*/
// Emit signals.
emit LayerDeleted( index );
emit ContentChanged();
......
......@@ -255,6 +255,7 @@ public slots:
//
// Signals.
signals:
void LayerDeleting(unsigned int index);
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
......
......@@ -159,6 +159,8 @@ public slots:
//
// Signals.
signals:
//bugFix
void LayerDeletingWidget( unsigned int index );
/**
*/
void CurrentChanged( int );
......
......@@ -150,6 +150,14 @@ LayerStackController
SLOT( OnProjectionButtonClicked() )
);
//bugfix
QObject::connect(
widget,
SIGNAL( LayerDeletingWidget( unsigned int index ) ),
// to:
model,
SLOT( Deleting( int ) )
);
QObject::connect(
widget,
......
......@@ -788,15 +788,34 @@ LayerStackItemModel
if( p.isValid() || count!=1 )
return false;
LayerStackWidget * widget = GetWidget< LayerStackWidget >();
assert( widget!=NULL );
QObject::disconnect(
widget,
SIGNAL( SelectionChanged( int ) ),
// from:
this,
SLOT( OnSelectionChanged( int ) )
);
beginRemoveRows( p, row, row + count - 1 );
{
// StackedLayerModel has already been shortened.
emit LayerDeleting(row);
// TODO: Release additional row data here.
}
endRemoveRows();
QObject::connect(
widget,
SIGNAL( SelectionChanged( int ) ),
// from:
this,
SLOT( OnSelectionChanged( int ) )
);
return true;
}
......
......@@ -120,6 +120,16 @@ LayerStackWidget
this,
SLOT( OnSelectionChanged( const QItemSelection &, const QItemSelection & ) )
);
/////// Bugfix
QObject::connect(
m_UI->treeView->selectionModel(),
SIGNAL( LayerDeleting(unsigned int index) ),
// to:
this,
SIGNAL( LayerDeletingWidget(unsigned int index) )
);
///////////////
QObject::connect(
m_UI->topButton,
......
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