Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
43 changes: 11 additions & 32 deletions src/gui/geonode/qgsgeonodesourceselect.cpp
Expand Up @@ -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();
}
}

Expand All @@ -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()
Expand Down Expand Up @@ -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 );
}
2 changes: 2 additions & 0 deletions src/gui/geonode/qgsgeonodesourceselect.h
Expand Up @@ -58,6 +58,8 @@ class GUI_EXPORT QgsGeoNodeSourceSelect: public QgsAbstractDataSourceWidget, pri
QPushButton *mBuildQueryButton = nullptr;
QModelIndex mSQLIndex;

void updateButtonStateForAvailableConnections();

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

0 comments on commit ea4b2dd

Please sign in to comment.