Skip to content
Permalink
Browse files

Added buttons to select-deselect all layers in check geometries

  • Loading branch information
uclaros authored and nyalldawson committed Mar 2, 2020
1 parent 7d0b476 commit 0bfff34af533736159aca88968a0c19c67005be8
@@ -69,6 +69,8 @@ QgsGeometryCheckerSetupTab::QgsGeometryCheckerSetupTab( QgisInterface *iface, QD
connect( ui.listWidgetInputLayers, &QListWidget::itemChanged, this, &QgsGeometryCheckerSetupTab::validateInput );
connect( QgsProject::instance(), &QgsProject::layersAdded, this, &QgsGeometryCheckerSetupTab::updateLayers );
connect( QgsProject::instance(), static_cast<void ( QgsProject::* )( const QStringList & )>( &QgsProject::layersRemoved ), this, &QgsGeometryCheckerSetupTab::updateLayers );
connect( ui.pushButtonSelectAllLayers, &QAbstractButton::clicked, this, &QgsGeometryCheckerSetupTab::selectAllLayers );
connect( ui.pushButtonDeselectAllLayers, &QAbstractButton::clicked, this, &QgsGeometryCheckerSetupTab::deselectAllLayers );
connect( ui.radioButtonOutputNew, &QAbstractButton::toggled, ui.frameOutput, &QWidget::setEnabled );
connect( ui.buttonGroupOutput, static_cast<void ( QButtonGroup::* )( int )>( &QButtonGroup::buttonClicked ), this, &QgsGeometryCheckerSetupTab::validateInput );
connect( ui.pushButtonOutputDirectory, &QAbstractButton::clicked, this, &QgsGeometryCheckerSetupTab::selectOutputDirectory );
@@ -133,16 +135,8 @@ void QgsGeometryCheckerSetupTab::updateLayers()
item->setData( LayerIdRole, layer->id() );
if ( supportedGeometryType )
{
if ( mCheckerDialog->isVisible() )
{
// If dialog is visible, only set item to checked if it previously was
item->setCheckState( prevCheckedLayers.contains( layer->id() ) ? Qt::Checked : Qt::Unchecked );
}
else
{
// Otherwise, set item to checked
item->setCheckState( Qt::Checked );
}
// Only set item to checked if it previously was
item->setCheckState( prevCheckedLayers.contains( layer->id() ) ? Qt::Checked : Qt::Unchecked );
}
else
{
@@ -154,6 +148,30 @@ void QgsGeometryCheckerSetupTab::updateLayers()
validateInput();
}

void QgsGeometryCheckerSetupTab::selectAllLayers()
{
for ( int row = 0, nRows = ui.listWidgetInputLayers->count(); row < nRows; ++row )
{
QListWidgetItem *item = ui.listWidgetInputLayers->item( row );
if ( item->flags().testFlag( Qt::ItemIsEnabled ) )
{
item->setCheckState( Qt::Checked );
}
}
}

void QgsGeometryCheckerSetupTab::deselectAllLayers()
{
for ( int row = 0, nRows = ui.listWidgetInputLayers->count(); row < nRows; ++row )
{
QListWidgetItem *item = ui.listWidgetInputLayers->item( row );
if ( item->flags().testFlag( Qt::ItemIsEnabled ) )
{
item->setCheckState( Qt::Unchecked );
}
}
}

QList<QgsVectorLayer *> QgsGeometryCheckerSetupTab::getSelectedLayers()
{
QList<QgsVectorLayer *> layers;
@@ -57,6 +57,8 @@ class QgsGeometryCheckerSetupTab : public QWidget
private slots:
void runChecks();
void updateLayers();
void selectAllLayers();
void deselectAllLayers();
void validateInput();
void selectOutputDirectory();
void showCancelFeedback();
@@ -90,15 +90,53 @@
<number>2</number>
</property>
<item>
<widget class="QListWidget" name="listWidgetInputLayers"/>
</item>
<item>
<widget class="QCheckBox" name="checkBoxInputSelectedOnly">
<property name="text">
<string>Only selected features</string>
<widget class="QListWidget" name="listWidgetInputLayers">
<property name="minimumSize">
<size>
<width>0</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="checkBoxInputSelectedOnly">
<property name="text">
<string>Only selected features</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButtonSelectAllLayers">
<property name="text">
<string>Select All</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonDeselectAllLayers">
<property name="text">
<string>Deselect All</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>

0 comments on commit 0bfff34

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