Skip to content
Permalink
Browse files

Group add db layer actions together in toolbar

The add layer toolbar is very full and users are unlikely to be
connecting to more than one db provider type frequently (eg
at a workplace they will likely have access to a Postgres db
OR a MSSQL db, not both concurrently)
  • Loading branch information
nyalldawson committed May 12, 2016
1 parent 1f59541 commit 7b64feb7e101ac7f205737dce241c9d8fa03c452
Showing with 41 additions and 11 deletions.
  1. +41 −7 src/app/qgisapp.cpp
  2. +0 −4 src/ui/qgisapp.ui
@@ -2030,6 +2030,39 @@ void QgisApp::createToolBars()
newLayerAction->setObjectName( "ActionNewLayer" );
connect( bt, SIGNAL( triggered( QAction * ) ), this, SLOT( toolButtonActionTriggered( QAction * ) ) );

// add db layer button
bt = new QToolButton();
bt->setPopupMode( QToolButton::MenuButtonPopup );
if ( mActionAddPgLayer )
bt->addAction( mActionAddPgLayer );
if ( mActionAddMssqlLayer )
bt->addAction( mActionAddMssqlLayer );
if ( mActionAddDb2Layer )
bt->addAction( mActionAddDb2Layer );
if ( mActionAddOracleLayer )
bt->addAction( mActionAddOracleLayer );
QAction* defAddDbLayerAction = mActionAddPgLayer;
switch ( settings.value( "/UI/defaultAddDbLayerAction", 0 ).toInt() )
{
case 0:
defAddDbLayerAction = mActionAddPgLayer;
break;
case 1:
defAddDbLayerAction = mActionAddMssqlLayer;
break;
case 2:
defAddDbLayerAction = mActionAddDb2Layer;
break;
case 3:
defAddDbLayerAction = mActionAddOracleLayer;
break;
}
if ( defAddDbLayerAction )
bt->setDefaultAction( defAddDbLayerAction );
QAction* addDbLayerAction = mLayerToolBar->insertWidget( mActionAddWmsLayer, bt );
addDbLayerAction->setObjectName( "ActionAddDbLayer" );
connect( bt, SIGNAL( triggered( QAction * ) ), this, SLOT( toolButtonActionTriggered( QAction * ) ) );

//circular string digitize tool button
QToolButton* tbAddCircularString = new QToolButton( mDigitizeToolBar );
tbAddCircularString->setPopupMode( QToolButton::MenuButtonPopup );
@@ -6653,13 +6686,6 @@ void QgisApp::mergeSelectedFeatures()
return;
}

QgsVectorDataProvider* dp = vl->dataProvider();
bool providerChecksTypeStrictly = true;
if ( dp )
{
providerChecksTypeStrictly = dp->doesStrictFeatureTypeCheck();
}

//get selected feature ids (as a QSet<int> )
const QgsFeatureIds& featureIdSet = vl->selectedFeaturesIds();
if ( featureIdSet.size() < 2 )
@@ -11324,6 +11350,14 @@ void QgisApp::toolButtonActionTriggered( QAction *action )
settings.setValue( "/UI/defaultPointSymbolAction", 0 );
else if ( action == mActionOffsetPointSymbol )
settings.setValue( "/UI/defaultPointSymbolAction", 1 );
else if ( mActionAddPgLayer && action == mActionAddPgLayer )
settings.setValue( "/UI/defaultAddDbLayerAction", 0 );
else if ( mActionAddMssqlLayer && action == mActionAddMssqlLayer )
settings.setValue( "/UI/defaultAddDbLayerAction", 1 );
else if ( mActionAddDb2Layer && action == mActionAddDb2Layer )
settings.setValue( "/UI/defaultAddDbLayerAction", 2 );
else if ( mActionAddOracleLayer && action == mActionAddOracleLayer )
settings.setValue( "/UI/defaultAddDbLayerAction", 3 );

bt->setDefaultAction( action );
}
@@ -340,11 +340,7 @@
</attribute>
<addaction name="mActionAddOgrLayer"/>
<addaction name="mActionAddRasterLayer"/>
<addaction name="mActionAddPgLayer"/>
<addaction name="mActionAddSpatiaLiteLayer"/>
<addaction name="mActionAddMssqlLayer"/>
<addaction name="mActionAddDb2Layer"/>
<addaction name="mActionAddOracleLayer"/>
<addaction name="mActionAddWmsLayer"/>
<addaction name="mActionAddWcsLayer"/>
<addaction name="mActionAddWfsLayer"/>

1 comment on commit 7b64feb

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn commented on 7b64feb May 12, 2016

Nice. Applying the same logic to server-based layers would be nice too.

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