Skip to content
Permalink
Browse files

remove old message boxes from map tools

  • Loading branch information
3nids committed Sep 26, 2014
1 parent a9c97ae commit b734e8797863870ccb388c18e1dc02900055f70f
@@ -27,7 +27,6 @@
#include "qgslogger.h"
#include "qgsfeatureaction.h"

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

@@ -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;
}

@@ -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;
}

@@ -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;
}
}
@@ -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;
}

@@ -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;
}

@@ -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
}
@@ -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
}
@@ -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
@@ -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;
@@ -20,7 +20,6 @@
#include "qgsvectorlayer.h"
#include "qgslogger.h"

#include <QMessageBox>
#include <QMouseEvent>

QgsMapToolAddPart::QgsMapToolAddPart( QgsMapCanvas* canvas )
@@ -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() );

@@ -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;
}

@@ -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
@@ -28,7 +28,6 @@

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

@@ -22,7 +22,6 @@
#include "qgstolerance.h"

#include <QMouseEvent>
#include <QMessageBox>

QgsMapToolDeletePart::QgsMapToolDeletePart( QgsMapCanvas* canvas )
: QgsMapToolEdit( canvas ), mRubberBand( 0 )
@@ -20,7 +20,6 @@
#include "qgsvectorlayer.h"

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

QgsMapToolDeleteRing::QgsMapToolDeleteRing( QgsMapCanvas* canvas )
@@ -32,7 +32,6 @@
#include "qgisapp.h"

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

@@ -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;
}

@@ -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;
}

@@ -21,7 +21,6 @@
#include "qgsattributedialog.h"
#include <qgsapplication.h>

#include <QMessageBox>
#include <QMouseEvent>

#include <limits>
@@ -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;
}

@@ -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
@@ -37,7 +37,6 @@
#include "qgsrendererv2.h"

#include <QSettings>
#include <QMessageBox>
#include <QMouseEvent>
#include <QCursor>
#include <QPixmap>
@@ -21,7 +21,6 @@
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
#include "qgstolerance.h"
#include <QMessageBox>
#include <QMouseEvent>
#include <QSettings>
#include <limits>
@@ -21,7 +21,6 @@
#include "qgsvertexmarker.h"
#include <QDoubleSpinBox>
#include <QGraphicsProxyWidget>
#include <QMessageBox>
#include <QMouseEvent>
#include "qgisapp.h"

@@ -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;
}

@@ -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 )
@@ -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;
}

@@ -21,7 +21,6 @@
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
#include "qgstolerance.h"
#include <QMessageBox>
#include <QMouseEvent>
#include <QSettings>
#include <limits>
@@ -21,7 +21,6 @@
#include "qgssymbolv2.h"
#include "qgsvectorlayer.h"
#include <QGraphicsPixmapItem>
#include <QMessageBox>
#include <QMouseEvent>

QgsMapToolRotatePointSymbols::QgsMapToolRotatePointSymbols( QgsMapCanvas* canvas ): QgsMapToolEdit( canvas ),
@@ -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
}

@@ -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;
}

0 comments on commit b734e87

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