Skip to content

Commit

Permalink
remove old message boxes from map tools
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Sep 26, 2014
1 parent a9c97ae commit b734e87
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 75 deletions.
29 changes: 11 additions & 18 deletions src/app/qgsmaptooladdfeature.cpp
Expand Up @@ -27,7 +27,6 @@
#include "qgslogger.h"
#include "qgsfeatureaction.h"

#include <QMessageBox>
#include <QMouseEvent>
#include <QSettings>

Expand Down Expand Up @@ -76,8 +75,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )

if ( !( provider->capabilities() & QgsVectorDataProvider::AddFeatures ) )
{
QMessageBox::information( 0, tr( "Layer cannot be added to" ),
tr( "The data provider for this layer does not support the addition of features." ) );
emit messageEmitted( tr( "The data provider for this layer does not support the addition of features." ), QgsMessageBar::WARNING );
return;
}

Expand All @@ -96,8 +94,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
//check we only use this tool for point/multipoint layers
if ( vlayer->geometryType() != QGis::Point )
{
QMessageBox::information( 0, tr( "Wrong editing tool" ),
tr( "Cannot apply the 'capture point' tool on this vector layer" ) );
emit messageEmitted( tr( "Wrong editing tool, cannot apply the 'capture point' tool on this vector layer" ), QgsMessageBar::WARNING );
return;
}

Expand All @@ -117,8 +114,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
catch ( QgsCsException &cse )
{
Q_UNUSED( cse );
QMessageBox::information( 0, tr( "Coordinate transform error" ),
tr( "Cannot transform the point to the layers coordinate system" ) );
emit messageEmitted( tr( "Cannot transform the point to the layers coordinate system" ), QgsMessageBar::WARNING );
return;
}
}
Expand Down Expand Up @@ -154,16 +150,14 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
//check we only use the line tool for line/multiline layers
if ( mode() == CaptureLine && vlayer->geometryType() != QGis::Line )
{
QMessageBox::information( 0, tr( "Wrong editing tool" ),
tr( "Cannot apply the 'capture line' tool on this vector layer" ) );
emit messageEmitted( tr( "Wrong editing tool, cannot apply the 'capture line' tool on this vector layer" ), QgsMessageBar::WARNING );
return;
}

//check we only use the polygon tool for polygon/multipolygon layers
if ( mode() == CapturePolygon && vlayer->geometryType() != QGis::Polygon )
{
QMessageBox::information( 0, tr( "Wrong editing tool" ),
tr( "Cannot apply the 'capture polygon' tool on this vector layer" ) );
emit messageEmitted( tr( "Wrong editing tool, cannot apply the 'capture polygon' tool on this vector layer" ), QgsMessageBar::WARNING );
return;
}

Expand All @@ -179,8 +173,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
else if ( error == 2 )
{
//problem with coordinate transformation
QMessageBox::information( 0, tr( "Coordinate transform error" ),
tr( "Cannot transform the point to the layers coordinate system" ) );
emit messageEmitted( tr( "Cannot transform the point to the layers coordinate system" ), QgsMessageBar::WARNING );
return;
}

Expand Down Expand Up @@ -222,7 +215,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
}
else
{
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot add feature. Unknown WKB type" ) );
emit messageEmitted( tr( "Cannot add feature. Unknown WKB type" ), QgsMessageBar::CRITICAL );
stopCapturing();
return; //unknown wkbtype
}
Expand All @@ -241,7 +234,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
}
else
{
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot add feature. Unknown WKB type" ) );
emit messageEmitted( tr( "Cannot add feature. Unknown WKB type" ), QgsMessageBar::CRITICAL );
stopCapturing();
return; //unknown wkbtype
}
Expand All @@ -263,15 +256,15 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
else if ( avoidIntersectionsReturn == 2 ) //MH120131: disable this error message until there is a better way to cope with the single type / multi type problem
{
//bail out...
QMessageBox::critical( 0, tr( "Error" ), tr( "The feature could not be added because removing the polygon intersections would change the geometry type" ) );
emit messageEmitted( tr( "The feature could not be added because removing the polygon intersections would change the geometry type" ), QgsMessageBar::CRITICAL );
delete f;
stopCapturing();
return;
}
#endif
else if ( avoidIntersectionsReturn == 3 )
{
QMessageBox::critical( 0, tr( "Error" ), tr( "An error was reported during intersection removal" ) );
emit messageEmitted( tr( "An error was reported during intersection removal" ), QgsMessageBar::CRITICAL );
}

if ( !f->geometry()->asWkb() ) //avoid intersection might have removed the whole geometry
Expand All @@ -285,7 +278,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
{
reason = tr( "The feature cannot be added because it's geometry collapsed due to intersection avoidance" );
}
QMessageBox::critical( 0, tr( "Error" ), reason );
emit messageEmitted( reason, QgsMessageBar::CRITICAL );
delete f;
stopCapturing();
return;
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsmaptooladdpart.cpp
Expand Up @@ -20,7 +20,6 @@
#include "qgsvectorlayer.h"
#include "qgslogger.h"

#include <QMessageBox>
#include <QMouseEvent>

QgsMapToolAddPart::QgsMapToolAddPart( QgsMapCanvas* canvas )
Expand Down
27 changes: 14 additions & 13 deletions src/app/qgsmaptooladdring.cpp
Expand Up @@ -13,26 +13,28 @@
* *
***************************************************************************/

#include <QMouseEvent>

#include "qgsmaptooladdring.h"
#include "qgsgeometry.h"
#include "qgsmapcanvas.h"
#include "qgsproject.h"
#include "qgsvectorlayer.h"
#include <QMessageBox>
#include <QMouseEvent>


QgsMapToolAddRing::QgsMapToolAddRing( QgsMapCanvas* canvas ): QgsMapToolCapture( canvas, QgsMapToolCapture::CapturePolygon )
{

}

QgsMapToolAddRing::~QgsMapToolAddRing()
{

}

void QgsMapToolAddRing::canvasReleaseEvent( QMouseEvent * e )
{

emit messageDiscarded();

//check if we operate on a vector layer
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );

Expand Down Expand Up @@ -60,8 +62,7 @@ void QgsMapToolAddRing::canvasReleaseEvent( QMouseEvent * e )
else if ( error == 2 )
{
//problem with coordinate transformation
QMessageBox::information( 0, tr( "Coordinate transform error" ),
tr( "Cannot transform the point to the layers coordinate system" ) );
emit messageEmitted( tr( "Cannot transform the point to the layers coordinate system" ), QgsMessageBar::WARNING );
return;
}

Expand All @@ -81,29 +82,29 @@ void QgsMapToolAddRing::canvasReleaseEvent( QMouseEvent * e )
//todo: open message box to communicate errors
if ( addRingReturnCode == 1 )
{
errorMessage = tr( "A problem with geometry type occured" );
errorMessage = tr( "a problem with geometry type occured" );
}
else if ( addRingReturnCode == 2 )
{
errorMessage = tr( "The inserted Ring is not closed" );
errorMessage = tr( "the inserted Ring is not closed" );
}
else if ( addRingReturnCode == 3 )
{
errorMessage = tr( "The inserted Ring is not a valid geometry" );
errorMessage = tr( "the inserted Ring is not a valid geometry" );
}
else if ( addRingReturnCode == 4 )
{
errorMessage = tr( "The inserted Ring crosses existing rings" );
errorMessage = tr( "the inserted Ring crosses existing rings" );
}
else if ( addRingReturnCode == 5 )
{
errorMessage = tr( "The inserted Ring is not contained in a feature" );
errorMessage = tr( "the inserted Ring is not contained in a feature" );
}
else
{
errorMessage = tr( "An unknown error occured" );
errorMessage = tr( "an unknown error occured" );
}
QMessageBox::critical( 0, tr( "Error, could not add ring" ), errorMessage );
emit messageEmitted( tr( "could not add ring since %1." ).arg( errorMessage ), QgsMessageBar::CRITICAL );
vlayer->destroyEditCommand();
}
else
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsmaptoolcapture.cpp
Expand Up @@ -28,7 +28,6 @@

#include <QCursor>
#include <QPixmap>
#include <QMessageBox>
#include <QMouseEvent>
#include <QStatusBar>

Expand Down
1 change: 0 additions & 1 deletion src/app/qgsmaptooldeletepart.cpp
Expand Up @@ -22,7 +22,6 @@
#include "qgstolerance.h"

#include <QMouseEvent>
#include <QMessageBox>

QgsMapToolDeletePart::QgsMapToolDeletePart( QgsMapCanvas* canvas )
: QgsMapToolEdit( canvas ), mRubberBand( 0 )
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsmaptooldeletering.cpp
Expand Up @@ -20,7 +20,6 @@
#include "qgsvectorlayer.h"

#include <QMouseEvent>
#include <QMessageBox>
#include <limits>

QgsMapToolDeleteRing::QgsMapToolDeleteRing( QgsMapCanvas* canvas )
Expand Down
9 changes: 2 additions & 7 deletions src/app/qgsmaptoolfeatureaction.cpp
Expand Up @@ -32,7 +32,6 @@
#include "qgisapp.h"

#include <QSettings>
#include <QMessageBox>
#include <QMouseEvent>
#include <QStatusBar>

Expand Down Expand Up @@ -61,9 +60,7 @@ void QgsMapToolFeatureAction::canvasReleaseEvent( QMouseEvent *e )

if ( !layer || layer->type() != QgsMapLayer::VectorLayer )
{
QMessageBox::warning( mCanvas,
tr( "No active vector layer" ),
tr( "To run an action, you must choose a vector layer by clicking on its name in the legend" ) );
emit messageEmitted( tr( "To run an action, you must choose an active vector layer." ), QgsMessageBar::INFO );
return;
}

Expand All @@ -76,9 +73,7 @@ void QgsMapToolFeatureAction::canvasReleaseEvent( QMouseEvent *e )
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
if ( vlayer->actions()->size() == 0 && QgsMapLayerActionRegistry::instance()->mapLayerActions( vlayer ).size() == 0 )
{
QMessageBox::warning( mCanvas,
tr( "No actions available" ),
tr( "The active vector layer has no defined actions" ) );
emit messageEmitted( tr( "The active vector layer has no defined actions" ), QgsMessageBar::INFO );
return;
}

Expand Down
18 changes: 8 additions & 10 deletions src/app/qgsmaptoolfillring.cpp
Expand Up @@ -21,7 +21,6 @@
#include "qgsattributedialog.h"
#include <qgsapplication.h>

#include <QMessageBox>
#include <QMouseEvent>

#include <limits>
Expand Down Expand Up @@ -65,8 +64,7 @@ void QgsMapToolFillRing::canvasReleaseEvent( QMouseEvent * e )
else if ( error == 2 )
{
//problem with coordinate transformation
QMessageBox::information( 0, tr( "Coordinate transform error" ),
tr( "Cannot transform the point to the layers coordinate system" ) );
emit messageEmitted( tr( "Cannot transform the point to the layers coordinate system" ), QgsMessageBar::WARNING );
return;
}

Expand All @@ -86,29 +84,29 @@ void QgsMapToolFillRing::canvasReleaseEvent( QMouseEvent * e )
//todo: open message box to communicate errors
if ( addRingReturnCode == 1 )
{
errorMessage = tr( "A problem with geometry type occured" );
errorMessage = tr( "a problem with geometry type occured" );
}
else if ( addRingReturnCode == 2 )
{
errorMessage = tr( "The inserted Ring is not closed" );
errorMessage = tr( "the inserted Ring is not closed" );
}
else if ( addRingReturnCode == 3 )
{
errorMessage = tr( "The inserted Ring is not a valid geometry" );
errorMessage = tr( "the inserted Ring is not a valid geometry" );
}
else if ( addRingReturnCode == 4 )
{
errorMessage = tr( "The inserted Ring crosses existing rings" );
errorMessage = tr( "the inserted Ring crosses existing rings" );
}
else if ( addRingReturnCode == 5 )
{
errorMessage = tr( "The inserted Ring is not contained in a feature" );
errorMessage = tr( "the inserted Ring is not contained in a feature" );
}
else
{
errorMessage = tr( "An unknown error occured" );
errorMessage = tr( "an unknown error occured" );
}
QMessageBox::critical( 0, tr( "Error, could not add ring" ), errorMessage );
emit messageEmitted( tr( "could not add ring since %1." ).arg( errorMessage ), QgsMessageBar::CRITICAL );
vlayer->destroyEditCommand();
}
else
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsmaptoolidentifyaction.cpp
Expand Up @@ -37,7 +37,6 @@
#include "qgsrendererv2.h"

#include <QSettings>
#include <QMessageBox>
#include <QMouseEvent>
#include <QCursor>
#include <QPixmap>
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsmaptoolmovefeature.cpp
Expand Up @@ -21,7 +21,6 @@
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
#include "qgstolerance.h"
#include <QMessageBox>
#include <QMouseEvent>
#include <QSettings>
#include <limits>
Expand Down
3 changes: 1 addition & 2 deletions src/app/qgsmaptooloffsetcurve.cpp
Expand Up @@ -21,7 +21,6 @@
#include "qgsvertexmarker.h"
#include <QDoubleSpinBox>
#include <QGraphicsProxyWidget>
#include <QMessageBox>
#include <QMouseEvent>
#include "qgisapp.h"

Expand Down Expand Up @@ -376,7 +375,7 @@ void QgsMapToolOffsetCurve::setOffsetForRubberBand( double offset, bool leftSide
mForceCopy = false;
mGeometryModified = false;
deleteDistanceItem();
QMessageBox::critical( 0, tr( "Geometry error" ), tr( "Creating offset geometry failed" ) );
emit messageEmitted( tr( "Creating offset geometry failed" ), QgsMessageBar::CRITICAL );
return;
}

Expand Down
4 changes: 1 addition & 3 deletions src/app/qgsmaptoolreshape.cpp
Expand Up @@ -17,7 +17,6 @@
#include "qgsgeometry.h"
#include "qgsmapcanvas.h"
#include "qgsvectorlayer.h"
#include <QMessageBox>
#include <QMouseEvent>

QgsMapToolReshape::QgsMapToolReshape( QgsMapCanvas* canvas ): QgsMapToolCapture( canvas, QgsMapToolCapture::CaptureLine )
Expand Down Expand Up @@ -59,8 +58,7 @@ void QgsMapToolReshape::canvasReleaseEvent( QMouseEvent * e )
else if ( error == 2 )
{
//problem with coordinate transformation
QMessageBox::information( 0, tr( "Coordinate transform error" ),
tr( "Cannot transform the point to the layers coordinate system" ) );
emit messageEmitted( tr( "Cannot transform the point to the layers coordinate system" ), QgsMessageBar::WARNING );
return;
}

Expand Down
1 change: 0 additions & 1 deletion src/app/qgsmaptoolrotatefeature.cpp
Expand Up @@ -21,7 +21,6 @@
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
#include "qgstolerance.h"
#include <QMessageBox>
#include <QMouseEvent>
#include <QSettings>
#include <limits>
Expand Down
5 changes: 2 additions & 3 deletions src/app/qgsmaptoolrotatepointsymbols.cpp
Expand Up @@ -21,7 +21,6 @@
#include "qgssymbolv2.h"
#include "qgsvectorlayer.h"
#include <QGraphicsPixmapItem>
#include <QMessageBox>
#include <QMouseEvent>

QgsMapToolRotatePointSymbols::QgsMapToolRotatePointSymbols( QgsMapCanvas* canvas ): QgsMapToolEdit( canvas ),
Expand Down Expand Up @@ -96,7 +95,7 @@ void QgsMapToolRotatePointSymbols::canvasPressEvent( QMouseEvent *e )
QList<QgsSnappingResult> snapResults;
if ( canvasSnapper.snapToCurrentLayer( e->pos(), snapResults, QgsSnapper::SnapToVertex, -1 ) != 0 || snapResults.size() < 1 )
{
QMessageBox::critical( 0, tr( "No point feature" ), tr( "No point feature was detected at the clicked position. Please click closer to the feature or enhance the search tolerance under Settings->Options->Digitizing->Serch radius for vertex edits" ) );
emit messageEmitted( tr( "No point feature was detected at the clicked position. Please click closer to the feature or enhance the search tolerance under Settings->Options->Digitizing->Serch radius for vertex edits" ), QgsMessageBar::CRITICAL );
return; //error during snapping
}

Expand All @@ -110,7 +109,7 @@ void QgsMapToolRotatePointSymbols::canvasPressEvent( QMouseEvent *e )

if ( mCurrentRotationAttributes.size() < 1 )
{
QMessageBox::critical( 0, tr( "No rotation Attributes" ), tr( "The active point layer does not have a rotation attribute" ) );
emit messageEmitted( tr( "The active point layer does not have a rotation attribute." ), QgsMessageBar::CRITICAL );
return;
}

Expand Down

0 comments on commit b734e87

Please sign in to comment.