Skip to content
Permalink
Browse files
Condense code
  • Loading branch information
nyalldawson committed Sep 12, 2017
1 parent e6c0ba9 commit ea4b2dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 32 deletions.
@@ -110,22 +110,7 @@ void QgsGeoNodeSourceSelect::deleteConnectionsEntryList()
}
emit connectionsChanged();

if ( cmbConnections->count() > 0 )
{
// Connections available - enable various buttons
btnConnect->setEnabled( true );
btnEdit->setEnabled( true );
btnDelete->setEnabled( true );
btnSave->setEnabled( true );
}
else
{
// No connections available - disable various buttons
btnConnect->setEnabled( false );
btnEdit->setEnabled( false );
btnDelete->setEnabled( false );
btnSave->setEnabled( false );
}
updateButtonStateForAvailableConnections();
}
}

@@ -151,22 +136,7 @@ void QgsGeoNodeSourceSelect::setConnectionListPosition()
cmbConnections->setCurrentIndex( cmbConnections->count() - 1 );
}

if ( cmbConnections->count() == 0 )
{
// No connections - disable various buttons
btnConnect->setEnabled( false );
btnEdit->setEnabled( false );
btnDelete->setEnabled( false );
btnSave->setEnabled( false );
}
else
{
// Connections - enable various buttons
btnConnect->setEnabled( true );
btnEdit->setEnabled( true );
btnDelete->setEnabled( true );
btnSave->setEnabled( true );
}
updateButtonStateForAvailableConnections();
}

void QgsGeoNodeSourceSelect::showHelp()
@@ -487,3 +457,12 @@ void QgsGeoNodeSourceSelect::addButtonClicked()

QApplication::restoreOverrideCursor();
}

void QgsGeoNodeSourceSelect::updateButtonStateForAvailableConnections()
{
bool connectionsAvailable = cmbConnections->count() > 0;
btnConnect->setEnabled( connectionsAvailable );
btnEdit->setEnabled( connectionsAvailable );
btnDelete->setEnabled( connectionsAvailable );
btnSave->setEnabled( connectionsAvailable );
}
@@ -58,6 +58,8 @@ class GUI_EXPORT QgsGeoNodeSourceSelect: public QgsAbstractDataSourceWidget, pri
QPushButton *mBuildQueryButton = nullptr;
QModelIndex mSQLIndex;

void updateButtonStateForAvailableConnections();

private slots:
void addConnectionsEntryList();
void modifyConnectionsEntryList();

0 comments on commit ea4b2dd

Please sign in to comment.