Skip to content

Commit

Permalink
optionally allow adding postgis table addition with double click and …
Browse files Browse the repository at this point in the history
…extended selection of tables (fixes #1801)

git-svn-id: http://svn.osgeo.org/qgis/trunk@11140 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jul 21, 2009
1 parent 8a803aa commit 4984c1c
Show file tree
Hide file tree
Showing 5 changed files with 568 additions and 515 deletions.
29 changes: 28 additions & 1 deletion src/app/qgsdbsourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ QgsDbSourceSelect::QgsDbSourceSelect( QWidget *parent, Qt::WFlags fl )
mTablesTreeView->setModel( &mProxyModel );
mTablesTreeView->setSortingEnabled( true );

QSettings settings;
mTablesTreeView->setSelectionMode( settings.value( "/qgis/addPostgisDC", false ).toBool() ?
QAbstractItemView::ExtendedSelection :
QAbstractItemView::MultiSelection );

mSearchGroupBox->hide();
connect( mTablesTreeView, SIGNAL( doubleClicked( const QModelIndex& ) ), this, SLOT( setSql( const QModelIndex& ) ) );

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

void QgsDbSourceSelect::on_btnBuildQuery_clicked()
{
setSql( mTablesTreeView->currentIndex() );
}

void QgsDbSourceSelect::on_mTablesTreeView_clicked( const QModelIndex &index )
{
btnBuildQuery->setEnabled( index.parent().isValid() );
}

void QgsDbSourceSelect::on_mTablesTreeView_doubleClicked( const QModelIndex &index )
{
QSettings settings;
if ( settings.value( "/qgis/addPostgisDC", false ).toBool() )
{
addTables();
}
else
{
setSql( index );
}
}

void QgsDbSourceSelect::on_mSearchOptionsButton_clicked()
{
if ( mSearchGroupBox->isVisible() )
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgsdbsourceselect.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class QgsDbSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
void on_btnAdd_clicked();
void on_btnNew_clicked();
void on_btnEdit_clicked();
void on_btnBuildQuery_clicked();
void on_btnDelete_clicked();
void on_mSearchOptionsButton_clicked();
void on_mSearchTableEdit_textChanged( const QString & text );
Expand All @@ -95,6 +96,8 @@ class QgsDbSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
void on_cmbConnections_activated( int );
void setLayerType( QString schema, QString table, QString column,
QString type );
void on_mTablesTreeView_clicked( const QModelIndex &index );
void on_mTablesTreeView_doubleClicked( const QModelIndex &index );
//!Sets a new regular expression to the model
void setSearchExpression( const QString& regexp );

Expand Down
4 changes: 3 additions & 1 deletion src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
cbxLegendClassifiers->setChecked( settings.value( "/qgis/showLegendClassifiers", false ).toBool() );
cbxHideSplash->setChecked( settings.value( "/qgis/hideSplash", false ).toBool() );
cbxAttributeTableDocked->setChecked( settings.value( "/qgis/dockAttributeTable", false ).toBool() );
cbxAddPostgisDC->setChecked( settings.value( "/qgis/addPostgisDC", false ).toBool() );

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

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

mMarkerStyleComboBox->addItem( tr( "Semi transparent circle" ) );
mMarkerStyleComboBox->addItem( tr( "Cross" ) );
Expand Down Expand Up @@ -339,6 +340,7 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/showLegendClassifiers", cbxLegendClassifiers->isChecked() );
settings.setValue( "/qgis/hideSplash", cbxHideSplash->isChecked() );
settings.setValue( "/qgis/dockAttributeTable", cbxAttributeTableDocked->isChecked() );
settings.setValue( "/qgis/addPostgisDC", cbxAddPostgisDC->isChecked() );
settings.setValue( "/qgis/new_layers_visible", chkAddedVisibility->isChecked() );
settings.setValue( "/qgis/enable_anti_aliasing", chkAntiAliasing->isChecked() );
settings.setValue( "/qgis/use_qimage_to_render", !( chkUseQPixmap->isChecked() ) );
Expand Down
Loading

0 comments on commit 4984c1c

Please sign in to comment.