Skip to content
Permalink
Browse files

[Geometry checker] Tweak logic for choosing which layers are selected…

… in the setup tab
  • Loading branch information
manisandro committed Jun 28, 2017
1 parent f0f66d7 commit c1b06cef79d021e2eb7c302cab7d0a9c08197764
@@ -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 );

@@ -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 );
@@ -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();
@@ -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
{
@@ -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:
@@ -40,6 +40,7 @@ class QgsGeometryCheckerSetupTab : public QWidget

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

0 comments on commit c1b06ce

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