Skip to content

Commit

Permalink
[Geometry checker] Tweak logic for choosing which layers are selected…
Browse files Browse the repository at this point in the history
… in the setup tab
  • Loading branch information
manisandro committed Oct 23, 2017
1 parent f0f66d7 commit c1b06ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ QgsGeometryCheckerDialog::QgsGeometryCheckerDialog( QgisInterface *iface, QWidge
layout->addWidget( mTabWidget );
layout->addWidget( mButtonBox );

mTabWidget->addTab( new QgsGeometryCheckerSetupTab( iface ), tr( "Settings" ) );
mTabWidget->addTab( new QgsGeometryCheckerSetupTab( iface, this ), tr( "Settings" ) );
mTabWidget->addTab( new QWidget(), tr( "Result" ) );
mTabWidget->setTabEnabled( 1, false );

Expand Down
18 changes: 14 additions & 4 deletions src/plugins/geometry_checker/ui/qgsgeometrycheckersetuptab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@

static const int LayerIdRole = Qt::UserRole + 1;

QgsGeometryCheckerSetupTab::QgsGeometryCheckerSetupTab( QgisInterface *iface, QWidget *parent )
QgsGeometryCheckerSetupTab::QgsGeometryCheckerSetupTab( QgisInterface *iface, QDialog *checkerDialog, QWidget *parent )
: QWidget( parent )
, mIface( iface )
, mCheckerDialog( checkerDialog )

{
ui.setupUi( this );
Expand Down Expand Up @@ -90,13 +91,13 @@ QgsGeometryCheckerSetupTab::~QgsGeometryCheckerSetupTab()

void QgsGeometryCheckerSetupTab::updateLayers()
{
QStringList prevLayers;
QStringList prevCheckedLayers;
for ( int row = 0, nRows = ui.listWidgetInputLayers->count(); row < nRows; ++row )
{
QListWidgetItem *item = ui.listWidgetInputLayers->item( row );
if ( item->checkState() == Qt::Checked )
{
prevLayers.append( item->data( LayerIdRole ).toString() );
prevCheckedLayers.append( item->data( LayerIdRole ).toString() );
}
}
ui.listWidgetInputLayers->clear();
Expand Down Expand Up @@ -125,7 +126,16 @@ void QgsGeometryCheckerSetupTab::updateLayers()
item->setData( LayerIdRole, layer->id() );
if ( supportedGeometryType )
{
item->setCheckState( prevLayers.contains( layer->id() ) ? Qt::Checked : Qt::Unchecked );
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 );
}
}
else
{
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/geometry_checker/ui/qgsgeometrycheckersetuptab.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class QgsGeometryCheckerSetupTab : public QWidget
{
Q_OBJECT
public:
QgsGeometryCheckerSetupTab( QgisInterface *iface, QWidget *parent = nullptr );
QgsGeometryCheckerSetupTab( QgisInterface *iface, QDialog *checkerDialog, QWidget *parent = nullptr );
~QgsGeometryCheckerSetupTab();

signals:
Expand All @@ -40,6 +40,7 @@ class QgsGeometryCheckerSetupTab : public QWidget

private:
QgisInterface *mIface = nullptr;
QDialog *mCheckerDialog;
Ui::QgsGeometryCheckerSetupTab ui;
QPushButton *mRunButton = nullptr;
QPushButton *mAbortButton = nullptr;
Expand Down

0 comments on commit c1b06ce

Please sign in to comment.