Skip to content

Commit

Permalink
Group add db layer actions together in toolbar
Browse files Browse the repository at this point in the history
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 7b64feb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
48 changes: 41 additions & 7 deletions src/app/qgisapp.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 );
}
Expand Down
4 changes: 0 additions & 4 deletions src/ui/qgisapp.ui
Expand Up @@ -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"/>
Expand Down

1 comment on commit 7b64feb

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 7b64feb May 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.