Skip to content
Permalink
Browse files

Flip some messagebox errors to message bars

  • Loading branch information
nyalldawson committed Jan 21, 2016
1 parent fdeff63 commit 49b5a2b6b77eb50530a8bfe47ae0e782e22aea8e
Showing with 51 additions and 12 deletions.
  1. +51 −12 src/app/qgisapp.cpp
@@ -6298,21 +6298,31 @@ void QgisApp::mergeAttributesOfSelectedFeatures()
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( activeMapLayer );
if ( !vl )
{
QMessageBox::information( nullptr, tr( "Active layer is not vector" ), tr( "The merge features tool only works on vector layers. Please select a vector layer from the layer list" ) );
messageBar()->pushMessage(
tr( "Layer not editable" ),
tr( "The merge features tool only works on vector layers." ),
QgsMessageBar::WARNING );
return;
}

if ( !vl->isEditable() )
{
QMessageBox::information( nullptr, tr( "Layer not editable" ), tr( "Merging features can only be done for layers in editing mode. To use the merge tool, go to Layer->Toggle editing" ) );
messageBar()->pushMessage(
tr( "Layer not editable" ),
tr( "Merging features can only be done for layers in editing mode." ),
QgsMessageBar::WARNING );

return;
}

//get selected feature ids (as a QSet<int> )
const QgsFeatureIds& featureIdSet = vl->selectedFeaturesIds();
if ( featureIdSet.size() < 2 )
{
QMessageBox::information( nullptr, tr( "Not enough features selected" ), tr( "The merge tool requires at least two selected features" ) );
messageBar()->pushMessage(
tr( "Not enough features selected" ),
tr( "The merge tool requires at least two selected features" ),
QgsMessageBar::WARNING );
return;
}

@@ -6381,18 +6391,28 @@ void QgisApp::mergeSelectedFeatures()
QgsMapLayer* activeMapLayer = activeLayer();
if ( !activeMapLayer )
{
QMessageBox::information( nullptr, tr( "No active layer" ), tr( "No active layer found. Please select a layer in the layer list" ) );
messageBar()->pushMessage(
tr( "No active layer" ),
tr( "Please select a layer in the layer list" ),
QgsMessageBar::WARNING );
return;
}
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( activeMapLayer );
if ( !vl )
{
QMessageBox::information( nullptr, tr( "Active layer is not vector" ), tr( "The merge features tool only works on vector layers. Please select a vector layer from the layer list" ) );
messageBar()->pushMessage(
tr( "Invalid layer" ),
tr( "The merge features tool only works on vector layers." ),
QgsMessageBar::WARNING );
return;
}
if ( !vl->isEditable() )
{
QMessageBox::information( nullptr, tr( "Layer not editable" ), tr( "Merging features can only be done for layers in editing mode. To use the merge tool, go to Layer->Toggle editing" ) );
messageBar()->pushMessage(
tr( "Layer not editable" ),
tr( "Merging features can only be done for layers in editing mode." ),
QgsMessageBar::WARNING );

return;
}

@@ -6407,7 +6427,10 @@ void QgisApp::mergeSelectedFeatures()
const QgsFeatureIds& featureIdSet = vl->selectedFeaturesIds();
if ( featureIdSet.size() < 2 )
{
QMessageBox::information( nullptr, tr( "Not enough features selected" ), tr( "The merge tool requires at least two selected features" ) );
messageBar()->pushMessage(
tr( "Not enough features selected" ),
tr( "The merge tool requires at least two selected features" ),
QgsMessageBar::WARNING );
return;
}

@@ -6420,15 +6443,22 @@ void QgisApp::mergeSelectedFeatures()
{
if ( !canceled )
{
QMessageBox::critical( nullptr, tr( "Merge failed" ), tr( "An error occurred during the merge operation" ) );
messageBar()->pushMessage(
tr( "Merge failed" ),
tr( "An error occurred during the merge operation" ),
QgsMessageBar::CRITICAL );
}
return;
}

//make a first geometry union and notify the user straight away if the union geometry type does not match the layer one
if ( providerChecksTypeStrictly && unionGeom->wkbType() != vl->wkbType() )
{
QMessageBox::critical( nullptr, tr( "Union operation canceled" ), tr( "The union operation would result in a geometry type that is not compatible with the current layer and therefore is canceled" ) );
messageBar()->pushMessage(
tr( "Merge cancelled" ),
tr( "The union operation would result in a geometry type that is not compatible with the current layer." ),
QgsMessageBar::CRITICAL );

delete unionGeom;
return;
}
@@ -6445,7 +6475,10 @@ void QgisApp::mergeSelectedFeatures()

if ( featureIdsAfter.size() < 2 )
{
QMessageBox::information( nullptr, tr( "Not enough features selected" ), tr( "The merge tool requires at least two selected features" ) );
messageBar()->pushMessage(
tr( "Not enough features selected" ),
tr( "The merge tool requires at least two selected features" ),
QgsMessageBar::WARNING );
delete unionGeom;
return;
}
@@ -6461,14 +6494,20 @@ void QgisApp::mergeSelectedFeatures()
{
if ( !canceled )
{
QMessageBox::critical( nullptr, tr( "Merge failed" ), tr( "An error occurred during the merge operation" ) );
messageBar()->pushMessage(
tr( "Merge failed" ),
tr( "An error occurred during the merge operation" ),
QgsMessageBar::CRITICAL );
}
return;
}

if ( providerChecksTypeStrictly && unionGeom->wkbType() != vl->wkbType() )
{
QMessageBox::critical( nullptr, "Union operation canceled", tr( "The union operation would result in a geometry type that is not compatible with the current layer and therefore is canceled" ) );
messageBar()->pushMessage(
tr( "Merge cancelled" ),
tr( "The union operation would result in a geometry type that is not compatible with the current layer." ),
QgsMessageBar::CRITICAL );
delete unionGeom;
return;
}

0 comments on commit 49b5a2b

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