Navigation Menu

Skip to content

Commit

Permalink
[topology checker] Improve test deletion UI by allowing deletion of m…
Browse files Browse the repository at this point in the history
…ultiple rows
  • Loading branch information
nirvn committed Jan 26, 2023
1 parent 0baf3c9 commit dcd4afc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
25 changes: 20 additions & 5 deletions src/plugins/topology/rulesDialog.cpp
Expand Up @@ -15,6 +15,8 @@
* *
***************************************************************************/

#include <set>

#include <QDebug>
#include <QTableWidgetItem>

Expand Down Expand Up @@ -50,9 +52,15 @@ rulesDialog::rulesDialog( const QMap<QString, TopologyRule> &testMap, QgisInterf

connect( mAddTestButton, &QAbstractButton::clicked, this, &rulesDialog::addRule );
connect( mAddTestButton, &QAbstractButton::clicked, mRulesTable, &QTableView::resizeColumnsToContents );
// attempt to add new test when OK clicked
//connect( buttonBox, SIGNAL( accepted() ), this, SLOT( addTest() ) );

connect( mRulesTable->selectionModel(), &QItemSelectionModel::selectionChanged, this, [ = ]()
{
bool enabled = !mRulesTable->selectionModel()->selectedIndexes().isEmpty();
mDeleteTestButton->setEnabled( enabled );
} );
mDeleteTestButton->setEnabled( !mRulesTable->selectionModel()->selectedIndexes().isEmpty() );
connect( mDeleteTestButton, &QAbstractButton::clicked, this, &rulesDialog::deleteTest );

connect( buttonBox, &QDialogButtonBox::helpRequested, this, &rulesDialog::showHelp );

connect( mLayer1Box, &QComboBox::currentTextChanged, this, &rulesDialog::updateRuleItems );
Expand Down Expand Up @@ -258,9 +266,17 @@ void rulesDialog::addRule()

void rulesDialog::deleteTest()
{
const int row = mRulesTable->currentRow();
if ( 0 <= row && row < mRulesTable->rowCount() )
std::set<int, std::greater<int>> selectedRows;
QModelIndexList selectedIndexes = mRulesTable->selectionModel()->selectedRows();
for ( QModelIndex index : selectedIndexes )
{
selectedRows.insert( index.row() );
}

for ( int row : selectedRows )
{
mRulesTable->removeRow( row );
}
}

void rulesDialog::updateRuleItems( const QString &layerName )
Expand Down Expand Up @@ -312,7 +328,6 @@ void rulesDialog::initGui()
for ( int i = 0; i < layerList.size(); ++i )
{
QgsVectorLayer *v1 = ( QgsVectorLayer * )QgsProject::instance()->mapLayer( layerList[i] );
qDebug() << "layerid = " + layerList[i];

// add layer name to the layer combo boxes
if ( v1->type() == QgsMapLayerType::VectorLayer )
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/topology/rulesDialog.ui
Expand Up @@ -127,8 +127,8 @@
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="mDeleteTestButton">
<property name="text">
<string>Delete Selected Rule</string>
<property name="toolTip">
<string>Delete selected rules</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit dcd4afc

Please sign in to comment.