Skip to content

Commit

Permalink
Merge pull request #1028 from ahuarte47/Issue_9191
Browse files Browse the repository at this point in the history
Bug #9191-#9190: fix enable/disable issues of buttons
  • Loading branch information
jef-n committed Dec 17, 2013
2 parents accd06d + 32d4af2 commit bf45669
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 33 deletions.
11 changes: 11 additions & 0 deletions src/gui/qgsmanageconnectionsdialog.cpp
Expand Up @@ -46,11 +46,13 @@ QgsManageConnectionsDialog::QgsManageConnectionsDialog( QWidget *parent, Mode mo
{
label->setText( tr( "Select connections to import" ) );
buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Import" ) );
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
}
else
{
//label->setText( tr( "Select connections to export" ) );
buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Export" ) );
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
}

if ( !populateConnections() )
Expand All @@ -61,6 +63,13 @@ QgsManageConnectionsDialog::QgsManageConnectionsDialog( QWidget *parent, Mode mo
// use Ok button for starting import and export operations
disconnect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( doExportImport() ) );

connect( listConnections, SIGNAL( itemSelectionChanged() ), this, SLOT( selectionChanged() ) );
}

void QgsManageConnectionsDialog::selectionChanged()
{
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !listConnections->selectedItems().isEmpty() );
}

void QgsManageConnectionsDialog::doExportImport()
Expand Down Expand Up @@ -945,9 +954,11 @@ void QgsManageConnectionsDialog::loadOracleConnections( const QDomDocument &doc,
void QgsManageConnectionsDialog::selectAll()
{
listConnections->selectAll();
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !listConnections->selectedItems().isEmpty() );
}

void QgsManageConnectionsDialog::clearSelection()
{
listConnections->clearSelection();
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
}
1 change: 1 addition & 0 deletions src/gui/qgsmanageconnectionsdialog.h
Expand Up @@ -52,6 +52,7 @@ class GUI_EXPORT QgsManageConnectionsDialog : public QDialog, private Ui::QgsMan
void doExportImport();
void selectAll();
void clearSelection();
void selectionChanged();

private:
bool populateConnections();
Expand Down
7 changes: 6 additions & 1 deletion src/gui/qgsnewhttpconnection.cpp
Expand Up @@ -141,7 +141,12 @@ QgsNewHttpConnection::~QgsNewHttpConnection()

void QgsNewHttpConnection::on_txtName_textChanged( const QString &text )
{
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( text.isEmpty() );
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
}

void QgsNewHttpConnection::on_txtUrl_textChanged( const QString &text )
{
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
}

void QgsNewHttpConnection::accept()
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsnewhttpconnection.h
Expand Up @@ -38,6 +38,8 @@ class GUI_EXPORT QgsNewHttpConnection : public QDialog, private Ui::QgsNewHttpCo

void on_txtName_textChanged( const QString & );

void on_txtUrl_textChanged( const QString & );

void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }

private:
Expand Down
33 changes: 18 additions & 15 deletions src/gui/qgsowssourceselect.cpp
Expand Up @@ -239,21 +239,6 @@ void QgsOWSSourceSelect::populateConnectionList()
mConnectionsComboBox->addItems( QgsOWSConnection::connectionList( mService ) );

setConnectionListPosition();

if ( mConnectionsComboBox->count() == 0 )
{
// No connections - disable various buttons
mConnectButton->setEnabled( false );
mEditButton->setEnabled( false );
mDeleteButton->setEnabled( false );
}
else
{
// Connections - enable various buttons
mConnectButton->setEnabled( true );
mEditButton->setEnabled( true );
mDeleteButton->setEnabled( true );
}
}
void QgsOWSSourceSelect::on_mNewButton_clicked()
{
Expand Down Expand Up @@ -546,6 +531,24 @@ void QgsOWSSourceSelect::setConnectionListPosition()
else
mConnectionsComboBox->setCurrentIndex( mConnectionsComboBox->count() - 1 );
}

if ( mConnectionsComboBox->count() == 0 )
{
// No connections - disable various buttons
mConnectButton->setEnabled( false );
mEditButton->setEnabled( false );
mDeleteButton->setEnabled( false );
mSaveButton->setEnabled( false );
}
else
{
// Connections - enable various buttons
mConnectButton->setEnabled( true );
mEditButton->setEnabled( true );
mDeleteButton->setEnabled( true );
mSaveButton->setEnabled( true );
}

QgsOWSConnection::setSelectedConnection( mService, mConnectionsComboBox->currentText() );
}

Expand Down
20 changes: 19 additions & 1 deletion src/providers/wfs/qgswfssourceselect.cpp
Expand Up @@ -132,14 +132,15 @@ void QgsWFSSourceSelect::populateConnectionList()
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 );
}

//set last used connection
Expand Down Expand Up @@ -303,6 +304,23 @@ void QgsWFSSourceSelect::deleteEntryOfServerList()
QgsOWSConnection::deleteConnection( "WFS", cmbConnections->currentText() );
cmbConnections->removeItem( cmbConnections->currentIndex() );
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 );
}
}
}

Expand Down
34 changes: 18 additions & 16 deletions src/providers/wms/qgswmssourceselect.cpp
Expand Up @@ -164,21 +164,6 @@ void QgsWMSSourceSelect::populateConnectionList()
cmbConnections->addItems( QgsWMSConnection::connectionList() );

setConnectionListPosition();

if ( cmbConnections->count() == 0 )
{
// No connections - disable various buttons
btnConnect->setEnabled( false );
btnEdit->setEnabled( false );
btnDelete->setEnabled( false );
}
else
{
// Connections - enable various buttons
btnConnect->setEnabled( true );
btnEdit->setEnabled( true );
btnDelete->setEnabled( true );
}
}
void QgsWMSSourceSelect::on_btnNew_clicked()
{
Expand Down Expand Up @@ -214,7 +199,7 @@ void QgsWMSSourceSelect::on_btnDelete_clicked()
if ( result == QMessageBox::Ok )
{
QgsWMSConnection::deleteConnection( cmbConnections->currentText() );
cmbConnections->removeItem( cmbConnections->currentIndex() ); // populateConnectionList();
cmbConnections->removeItem( cmbConnections->currentIndex() );
setConnectionListPosition();
emit connectionsChanged();
}
Expand Down Expand Up @@ -1024,6 +1009,23 @@ void QgsWMSSourceSelect::setConnectionListPosition()
else
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 );
}
}

void QgsWMSSourceSelect::showStatusMessage( QString const &theMessage )
Expand Down

0 comments on commit bf45669

Please sign in to comment.