Skip to content

Commit 4984c1c

Browse files
author
jef
committed
optionally allow adding postgis table addition with double click and extended selection of tables (fixes #1801)
git-svn-id: http://svn.osgeo.org/qgis/trunk@11140 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 8a803aa commit 4984c1c

File tree

5 files changed

+568
-515
lines changed

5 files changed

+568
-515
lines changed

src/app/qgsdbsourceselect.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ QgsDbSourceSelect::QgsDbSourceSelect( QWidget *parent, Qt::WFlags fl )
6767
mTablesTreeView->setModel( &mProxyModel );
6868
mTablesTreeView->setSortingEnabled( true );
6969

70+
QSettings settings;
71+
mTablesTreeView->setSelectionMode( settings.value( "/qgis/addPostgisDC", false ).toBool() ?
72+
QAbstractItemView::ExtendedSelection :
73+
QAbstractItemView::MultiSelection );
74+
7075
mSearchGroupBox->hide();
71-
connect( mTablesTreeView, SIGNAL( doubleClicked( const QModelIndex& ) ), this, SLOT( setSql( const QModelIndex& ) ) );
7276

7377
//for Qt < 4.3.2, passing -1 to include all model columns
7478
//in search does not seem to work
@@ -110,6 +114,29 @@ void QgsDbSourceSelect::on_cmbConnections_activated( int )
110114
dbChanged();
111115
}
112116

117+
void QgsDbSourceSelect::on_btnBuildQuery_clicked()
118+
{
119+
setSql( mTablesTreeView->currentIndex() );
120+
}
121+
122+
void QgsDbSourceSelect::on_mTablesTreeView_clicked( const QModelIndex &index )
123+
{
124+
btnBuildQuery->setEnabled( index.parent().isValid() );
125+
}
126+
127+
void QgsDbSourceSelect::on_mTablesTreeView_doubleClicked( const QModelIndex &index )
128+
{
129+
QSettings settings;
130+
if ( settings.value( "/qgis/addPostgisDC", false ).toBool() )
131+
{
132+
addTables();
133+
}
134+
else
135+
{
136+
setSql( index );
137+
}
138+
}
139+
113140
void QgsDbSourceSelect::on_mSearchOptionsButton_clicked()
114141
{
115142
if ( mSearchGroupBox->isVisible() )

src/app/qgsdbsourceselect.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class QgsDbSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
8585
void on_btnAdd_clicked();
8686
void on_btnNew_clicked();
8787
void on_btnEdit_clicked();
88+
void on_btnBuildQuery_clicked();
8889
void on_btnDelete_clicked();
8990
void on_mSearchOptionsButton_clicked();
9091
void on_mSearchTableEdit_textChanged( const QString & text );
@@ -95,6 +96,8 @@ class QgsDbSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
9596
void on_cmbConnections_activated( int );
9697
void setLayerType( QString schema, QString table, QString column,
9798
QString type );
99+
void on_mTablesTreeView_clicked( const QModelIndex &index );
100+
void on_mTablesTreeView_doubleClicked( const QModelIndex &index );
98101
//!Sets a new regular expression to the model
99102
void setSearchExpression( const QString& regexp );
100103

src/app/qgsoptions.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
139139
cbxLegendClassifiers->setChecked( settings.value( "/qgis/showLegendClassifiers", false ).toBool() );
140140
cbxHideSplash->setChecked( settings.value( "/qgis/hideSplash", false ).toBool() );
141141
cbxAttributeTableDocked->setChecked( settings.value( "/qgis/dockAttributeTable", false ).toBool() );
142+
cbxAddPostgisDC->setChecked( settings.value( "/qgis/addPostgisDC", false ).toBool() );
142143

143144
//set the colour for selections
144145
int myRed = settings.value( "/qgis/default_selection_color_red", 255 ).toInt();
@@ -218,7 +219,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
218219
mSearchRadiusVertexEditComboBox->setCurrentIndex( settings.value( "/qgis/digitizing/search_radius_vertex_edit_unit", 0 ).toInt() );
219220

220221
//vertex marker
221-
mMarkersOnlyForSelectedCheckBox->setChecked(settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool());
222+
mMarkersOnlyForSelectedCheckBox->setChecked( settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool() );
222223

223224
mMarkerStyleComboBox->addItem( tr( "Semi transparent circle" ) );
224225
mMarkerStyleComboBox->addItem( tr( "Cross" ) );
@@ -339,6 +340,7 @@ void QgsOptions::saveOptions()
339340
settings.setValue( "/qgis/showLegendClassifiers", cbxLegendClassifiers->isChecked() );
340341
settings.setValue( "/qgis/hideSplash", cbxHideSplash->isChecked() );
341342
settings.setValue( "/qgis/dockAttributeTable", cbxAttributeTableDocked->isChecked() );
343+
settings.setValue( "/qgis/addPostgisDC", cbxAddPostgisDC->isChecked() );
342344
settings.setValue( "/qgis/new_layers_visible", chkAddedVisibility->isChecked() );
343345
settings.setValue( "/qgis/enable_anti_aliasing", chkAntiAliasing->isChecked() );
344346
settings.setValue( "/qgis/use_qimage_to_render", !( chkUseQPixmap->isChecked() ) );

0 commit comments

Comments
 (0)