Skip to content
Permalink
Browse files

Fix legend nodes

  • Loading branch information
elpaso committed Nov 9, 2020
1 parent f48cd39 commit 093b0a1d11c464a1fd605a728fce2c6ffde6ee61
Showing with 10 additions and 2 deletions.
  1. +8 −0 src/core/layertree/qgslayertreemodel.cpp
  2. +2 −2 tests/qt_modeltest/modeltest.cpp
@@ -1349,6 +1349,14 @@ void QgsLayerTreeModel::addLegendToLayer( QgsLayerTreeLayer *nodeL )

if ( !filteredLstNew.isEmpty() )
{
// Make sure it's clear
const QModelIndex nodeIndex { node2index( nodeL ) };
if ( rowCount( nodeIndex ) > 0 )
{
beginRemoveRows( node2index( nodeL ), 0, rowCount( nodeIndex ) - 1 );
mLegend[nodeL] = LayerLegendData();
endRemoveRows();
}
beginInsertRows( node2index( nodeL ), 0, count - 1 );
}

@@ -504,7 +504,7 @@ void ModelTest::rowsInserted( const QModelIndex &parent, int start, int end )
}
//*/
Q_ASSERT( c.parent == parent );
Q_ASSERT( c.oldSize + ( end - start + 1 ) == model->rowCount( parent ) );
Q_ASSERT_X( c.oldSize + ( end - start + 1 ) == model->rowCount( parent ), "Rows inserted", QStringLiteral( "%1 != %2" ).arg( c.oldSize + ( end - start + 1 ) ).arg( model->rowCount( parent ) ).toStdString().c_str() );
Q_ASSERT( c.last == model->data( model->index( start - 1, 0, c.parent ) ) );
Q_ASSERT( c.next == model->data( model->index( end + 1, 0, c.parent ) ) );
}
@@ -549,7 +549,7 @@ void ModelTest::rowsRemoved( const QModelIndex &parent, int start, int end )
{
Changing c = remove.pop();
Q_ASSERT( c.parent == parent );
Q_ASSERT( c.oldSize - ( end - start + 1 ) == model->rowCount( parent ) );
Q_ASSERT_X( c.oldSize - ( end - start + 1 ) == model->rowCount( parent ), "Rows removed", QStringLiteral( "%1 != %2" ).arg( c.oldSize + ( end - start + 1 ) ).arg( model->rowCount( parent ) ).toStdString().c_str() );
Q_ASSERT( c.last == model->data( model->index( start - 1, 0, c.parent ) ) );
Q_ASSERT( c.next == model->data( model->index( start, 0, c.parent ) ) );
}

0 comments on commit 093b0a1

Please sign in to comment.
You can’t perform that action at this time.