Skip to content
Permalink
Browse files

allow removing multiple parameters at once

  • Loading branch information
3nids committed Jan 8, 2021
1 parent 30a3e34 commit 1562a49e0fd912159dc5f17725c706809296e57e
Showing with 10 additions and 7 deletions.
  1. +9 −6 src/gui/symbology/qgssvgselectorwidget.cpp
  2. +1 −1 src/gui/symbology/qgssvgselectorwidget.h
@@ -407,7 +407,7 @@ QgsSvgSelectorWidget::QgsSvgSelectorWidget( QWidget *parent )
mParametersTreeView->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
mParametersTreeView->header()->setStretchLastSection( true );
mParametersTreeView->setSelectionBehavior( QAbstractItemView::SelectRows );
mParametersTreeView->setSelectionMode( QAbstractItemView::SingleSelection );
mParametersTreeView->setSelectionMode( QAbstractItemView::MultiSelection );
mParametersTreeView->setEditTriggers( QAbstractItemView::DoubleClicked );

connect( mParametersModel, &QgsSvgParametersModel::parametersChanged, this, &QgsSvgSelectorWidget::svgParametersChanged );
@@ -418,7 +418,7 @@ QgsSvgSelectorWidget::QgsSvgSelectorWidget( QWidget *parent )
{
const QModelIndexList selectedRows = mParametersTreeView->selectionModel()->selectedRows();
if ( selectedRows.count() > 0 )
mParametersModel->removeParameter( selectedRows.at( 0 ) );
mParametersModel->removeParameters( selectedRows );
} );
}

@@ -583,13 +583,16 @@ QMap<QString, QgsProperty> QgsSvgParametersModel::parameters() const
return params;
}

void QgsSvgParametersModel::removeParameter( const QModelIndex &index )
void QgsSvgParametersModel::removeParameters( const QModelIndexList &indexList )
{
if ( !index.isValid() )
if ( !indexList.count() )
return;

beginRemoveRows( QModelIndex(), index.row(), index.row() );
mParameters.removeAt( index.row() );
auto mm = std::minmax_element( indexList.constBegin(), indexList.constEnd(), []( const QModelIndex & i1, const QModelIndex & i2 ) {return i1.row() < i2.row();} );

beginRemoveRows( QModelIndex(), ( *mm.first ).row(), ( *mm.second ).row() );
for ( const QModelIndex &index : indexList )
mParameters.removeAt( index.row() );
endRemoveRows();
}

@@ -73,7 +73,7 @@ class GUI_EXPORT QgsSvgParametersModel : public QAbstractTableModel
QMap<QString, QgsProperty> parameters() const;

//! Remove the parameter at given index
void removeParameter( const QModelIndex &index );
void removeParameters( const QModelIndexList &indexList );

//! Sets the vector layer
void setLayer( QgsVectorLayer *layer );

0 comments on commit 1562a49

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