Skip to content

Commit

Permalink
Fix incorrect rows are removed when removing vector tile renderer/lab…
Browse files Browse the repository at this point in the history
…eling rules
  • Loading branch information
nyalldawson committed Sep 14, 2020
1 parent d214e63 commit 91598c7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/gui/vectortile/qgsvectortilebasiclabelingwidget.cpp
Expand Up @@ -459,11 +459,19 @@ void QgsVectorTileBasicLabelingWidget::updateLabelingFromWidget()
void QgsVectorTileBasicLabelingWidget::removeStyle()
{
const QModelIndexList sel = viewStyles->selectionModel()->selectedIndexes();

QList<int > res;
for ( const QModelIndex &proxyIndex : sel )
{
const QModelIndex sourceIndex = mProxyModel->mapToSource( proxyIndex );
if ( sourceIndex.isValid() )
mModel->removeRow( sourceIndex.row() );
if ( !res.contains( sourceIndex.row() ) )
res << sourceIndex.row();
}
std::sort( res.begin(), res.end() );

for ( int i = res.size() - 1; i >= 0; --i )
{
mModel->removeRow( res[ i ] );
}
// make sure that the selection is gone
viewStyles->selectionModel()->clear();
Expand Down
12 changes: 10 additions & 2 deletions src/gui/vectortile/qgsvectortilebasicrendererwidget.cpp
Expand Up @@ -474,11 +474,19 @@ void QgsVectorTileBasicRendererWidget::cleanUpSymbolSelector( QgsPanelWidget *co
void QgsVectorTileBasicRendererWidget::removeStyle()
{
const QModelIndexList sel = viewStyles->selectionModel()->selectedIndexes();

QList<int > res;
for ( const QModelIndex &proxyIndex : sel )
{
const QModelIndex sourceIndex = mProxyModel->mapToSource( proxyIndex );
if ( sourceIndex.isValid() )
mModel->removeRow( sourceIndex.row() );
if ( !res.contains( sourceIndex.row() ) )
res << sourceIndex.row();
}
std::sort( res.begin(), res.end() );

for ( int i = res.size() - 1; i >= 0; --i )
{
mModel->removeRow( res[ i ] );
}
// make sure that the selection is gone
viewStyles->selectionModel()->clear();
Expand Down

0 comments on commit 91598c7

Please sign in to comment.