Skip to content
Permalink
Browse files

Merge pull request #3100 from alexbruy/add-db-table

enable Add button in DB dialogs only when at least one table is selected (fix #5616)
  • Loading branch information
alexbruy committed May 28, 2016
2 parents 27c5f78 + 7132209 commit 427559c872280618c9cc632f36e5f7b04c62faf5
@@ -176,6 +176,8 @@ QgsDb2SourceSelect::QgsDb2SourceSelect( QWidget *parent, Qt::WindowFlags fl, boo
mTablesTreeView->setEditTriggers( QAbstractItemView::CurrentChanged );
mTablesTreeView->setItemDelegate( new QgsDb2SourceSelectDelegate( this ) );

connect( mTablesTreeView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( treeWidgetSelectionChanged( const QItemSelection&, const QItemSelection& ) ) );

QSettings settings;
mTablesTreeView->setSelectionMode( settings.value( "/qgis/addDb2DC", false ).toBool() ?
QAbstractItemView::ExtendedSelection :
@@ -558,9 +560,6 @@ void QgsDb2SourceSelect::finishList()
{
QApplication::restoreOverrideCursor();

if ( cmbConnections->count() > 0 )
mAddButton->setEnabled( true );

mTablesTreeView->sortByColumn( QgsDb2TableModel::dbtmTable, Qt::AscendingOrder );
mTablesTreeView->sortByColumn( QgsDb2TableModel::dbtmSchema, Qt::AscendingOrder );
}
@@ -663,6 +662,12 @@ void QgsDb2SourceSelect::setSearchExpression( const QString& regexp )
Q_UNUSED( regexp );
}

void QgsDb2SourceSelect::treeWidgetSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
{
Q_UNUSED( deselected )
mAddButton->setEnabled( !selected.isEmpty() );
}


QgsDb2GeomColumnTypeThread::QgsDb2GeomColumnTypeThread( QString connectionName, bool useEstimatedMetadata )
: QThread()
@@ -142,6 +142,7 @@ class QgsDb2SourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
void setLayerType( QgsDb2LayerProperty layerProperty );
void on_mTablesTreeView_clicked( const QModelIndex &index );
void on_mTablesTreeView_doubleClicked( const QModelIndex &index );
void treeWidgetSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
//!Sets a new regular expression to the model
void setSearchExpression( const QString& regexp );

@@ -173,6 +173,8 @@ QgsMssqlSourceSelect::QgsMssqlSourceSelect( QWidget *parent, Qt::WindowFlags fl,
mTablesTreeView->setEditTriggers( QAbstractItemView::CurrentChanged );
mTablesTreeView->setItemDelegate( new QgsMssqlSourceSelectDelegate( this ) );

connect( mTablesTreeView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( treeWidgetSelectionChanged( const QItemSelection&, const QItemSelection& ) ) );

QSettings settings;
mTablesTreeView->setSelectionMode( settings.value( "/qgis/addMSSQLDC", false ).toBool() ?
QAbstractItemView::ExtendedSelection :
@@ -632,9 +634,6 @@ void QgsMssqlSourceSelect::finishList()
{
QApplication::restoreOverrideCursor();

if ( cmbConnections->count() > 0 )
mAddButton->setEnabled( true );

mTablesTreeView->sortByColumn( QgsMssqlTableModel::dbtmTable, Qt::AscendingOrder );
mTablesTreeView->sortByColumn( QgsMssqlTableModel::dbtmSchema, Qt::AscendingOrder );
}
@@ -737,6 +736,11 @@ void QgsMssqlSourceSelect::setSearchExpression( const QString& regexp )
Q_UNUSED( regexp );
}

void QgsMssqlSourceSelect::treeWidgetSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
{
Q_UNUSED( deselected )
mAddButton->setEnabled( !selected.isEmpty() );
}

QgsMssqlGeomColumnTypeThread::QgsMssqlGeomColumnTypeThread( QString connectionName, bool useEstimatedMetadata )
: QThread()
@@ -140,6 +140,7 @@ class QgsMssqlSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
void setLayerType( const QgsMssqlLayerProperty& layerProperty );
void on_mTablesTreeView_clicked( const QModelIndex &index );
void on_mTablesTreeView_doubleClicked( const QModelIndex &index );
void treeWidgetSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
//!Sets a new regular expression to the model
void setSearchExpression( const QString& regexp );

@@ -224,6 +224,8 @@ QgsOracleSourceSelect::QgsOracleSourceSelect( QWidget *parent, Qt::WindowFlags f
mTablesTreeView->setEditTriggers( QAbstractItemView::CurrentChanged );
mTablesTreeView->setItemDelegate( mTablesTreeDelegate );

connect( mTablesTreeView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( treeWidgetSelectionChanged( const QItemSelection&, const QItemSelection& ) ) );

QSettings settings;
mTablesTreeView->setSelectionMode( settings.value( "/qgis/addOracleDC", false ).toBool() ?
QAbstractItemView::ExtendedSelection :
@@ -541,9 +543,6 @@ void QgsOracleSourceSelect::finishList()
{
QApplication::restoreOverrideCursor();

if ( cmbConnections->count() > 0 )
mAddButton->setEnabled( true );

#if 0
for ( int i = 0; i < QgsOracleTableModel::dbtmColumns; i++ )
mTablesTreeView->resizeColumnToContents( i );
@@ -678,3 +677,9 @@ void QgsOracleSourceSelect::loadTableFromCache()

finishList();
}

void QgsOracleSourceSelect::treeWidgetSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
{
Q_UNUSED( deselected )
mAddButton->setEnabled( !selected.isEmpty() );
}
@@ -130,6 +130,7 @@ class QgsOracleSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
void setLayerType( QgsOracleLayerProperty layerProperty );
void on_mTablesTreeView_clicked( const QModelIndex &index );
void on_mTablesTreeView_doubleClicked( const QModelIndex &index );
void treeWidgetSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
//!Sets a new regular expression to the model
void setSearchExpression( const QString& regexp );

@@ -252,6 +252,8 @@ QgsPgSourceSelect::QgsPgSourceSelect( QWidget *parent, Qt::WindowFlags fl, bool
mTablesTreeView->setEditTriggers( QAbstractItemView::CurrentChanged );
mTablesTreeView->setItemDelegate( new QgsPgSourceSelectDelegate( this ) );

connect( mTablesTreeView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( treeWidgetSelectionChanged( const QItemSelection&, const QItemSelection& ) ) );

QSettings settings;
mTablesTreeView->setSelectionMode( settings.value( "/qgis/addPostgisDC", false ).toBool() ?
QAbstractItemView::ExtendedSelection :
@@ -557,9 +559,6 @@ void QgsPgSourceSelect::finishList()
{
QApplication::restoreOverrideCursor();

if ( cmbConnections->count() > 0 )
mAddButton->setEnabled( true );

#if 0
for ( int i = 0; i < QgsPgTableModel::dbtmColumns; i++ )
mTablesTreeView->resizeColumnToContents( i );
@@ -658,3 +657,9 @@ void QgsPgSourceSelect::setSearchExpression( const QString& regexp )
{
Q_UNUSED( regexp );
}

void QgsPgSourceSelect::treeWidgetSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
{
Q_UNUSED( deselected )
mAddButton->setEnabled( !selected.isEmpty() );
}
@@ -112,6 +112,7 @@ class QgsPgSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
void setLayerType( const QgsPostgresLayerProperty& layerProperty );
void on_mTablesTreeView_clicked( const QModelIndex &index );
void on_mTablesTreeView_doubleClicked( const QModelIndex &index );
void treeWidgetSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
//!Sets a new regular expression to the model
void setSearchExpression( const QString& regexp );

@@ -96,6 +96,8 @@ QgsSpatiaLiteSourceSelect::QgsSpatiaLiteSourceSelect( QWidget * parent, Qt::Wind
mTablesTreeView->setModel( &mProxyModel );
mTablesTreeView->setSortingEnabled( true );

connect( mTablesTreeView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( treeWidgetSelectionChanged( const QItemSelection&, const QItemSelection& ) ) );

//for Qt < 4.3.2, passing -1 to include all model columns
//in search does not seem to work
mSearchColumnComboBox->setCurrentIndex( 1 );
@@ -484,7 +486,6 @@ void QgsSpatiaLiteSourceSelect::on_btnConnect_clicked()

if ( cmbConnections->count() > 0 )
{
mAddButton->setEnabled( true );
mStatsButton->setEnabled( true );
}

@@ -573,3 +574,9 @@ void QgsSpatiaLiteSourceSelect::setSearchExpression( const QString & regexp )
{
Q_UNUSED( regexp );
}

void QgsSpatiaLiteSourceSelect::treeWidgetSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
{
Q_UNUSED( deselected )
mAddButton->setEnabled( !selected.isEmpty() );
}
@@ -86,6 +86,7 @@ class QgsSpatiaLiteSourceSelect: public QDialog, private Ui::QgsDbSourceSelectBa
void setLayerType( const QString& table, const QString& column, const QString& type );
void on_mTablesTreeView_clicked( const QModelIndex &index );
void on_mTablesTreeView_doubleClicked( const QModelIndex &index );
void treeWidgetSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
//!Sets a new regular expression to the model
void setSearchExpression( const QString & regexp );

@@ -101,6 +101,12 @@
</item>
<item row="1" column="0">
<widget class="QTreeView" name="mTablesTreeView">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>

0 comments on commit 427559c

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