Skip to content
Permalink
Browse files

Condense code

  • Loading branch information
nyalldawson committed Sep 5, 2017
1 parent e6c0ba9 commit ea4b2dd5b8f1e91a701db1ed1b8325b678f7eb21
Showing with 13 additions and 32 deletions.
  1. +11 −32 src/gui/geonode/qgsgeonodesourceselect.cpp
  2. +2 −0 src/gui/geonode/qgsgeonodesourceselect.h
@@ -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.
You can’t perform that action at this time.