Skip to content

Commit 30d7795

Browse files
committed
changes to annotations mark the project dirty (fixes #7586)
this includes adding, editing, moving, resizing and deleting
1 parent 5387fd1 commit 30d7795

5 files changed

+15
-1
lines changed

src/app/qgsmaptoolannotation.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "qgstextannotationitem.h"
2727
#include "qgssvgannotationdialog.h"
2828
#include "qgssvgannotationitem.h"
29+
#include "qgsproject.h"
2930
#include <QDialog>
3031
#include <QMouseEvent>
3132

@@ -141,6 +142,7 @@ void QgsMapToolAnnotation::keyPressEvent( QKeyEvent* e )
141142
mCanvas->scene()->removeItem( sItem );
142143
delete sItem;
143144
mCanvas->setCursor( neutralCursor );
145+
QgsProject::instance()->setDirty( true ); // TODO QGIS3: Rework the whole annotation code to be MVC compliant, see PR #2506
144146

145147
// Override default shortcut management in MapCanvas
146148
e->ignore();
@@ -158,6 +160,7 @@ void QgsMapToolAnnotation::canvasMoveEvent( QgsMapMouseEvent* e )
158160
{
159161
sItem->setMapPosition( toMapCoordinates( e->pos() ) );
160162
sItem->update();
163+
QgsProject::instance()->setDirty( true );
161164
}
162165
else if ( mCurrentMoveAction == QgsAnnotationItem::MoveFramePosition )
163166
{
@@ -171,6 +174,7 @@ void QgsMapToolAnnotation::canvasMoveEvent( QgsMapMouseEvent* e )
171174
sItem->setMapPosition( toMapCoordinates( newCanvasPos.toPoint() ) );
172175
}
173176
sItem->update();
177+
QgsProject::instance()->setDirty( true );
174178
}
175179
else if ( mCurrentMoveAction != QgsAnnotationItem::NoAction )
176180
{
@@ -220,6 +224,7 @@ void QgsMapToolAnnotation::canvasMoveEvent( QgsMapMouseEvent* e )
220224
sItem->setOffsetFromReferencePoint( QPointF( xmin, ymin ) );
221225
sItem->setFrameSize( QSizeF( xmax - xmin, ymax - ymin ) );
222226
sItem->update();
227+
QgsProject::instance()->setDirty( true );
223228
}
224229
}
225230
else if ( sItem )
@@ -243,7 +248,8 @@ void QgsMapToolAnnotation::canvasDoubleClickEvent( QgsMapMouseEvent* e )
243248
QDialog* itemEditor = createItemEditor( item );
244249
if ( itemEditor )
245250
{
246-
itemEditor->exec();
251+
if ( itemEditor->exec() )
252+
QgsProject::instance()->setDirty( true );
247253
delete itemEditor;
248254
}
249255
}

src/app/qgsmaptoolformannotation.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "qgsformannotationitem.h"
2020
#include "qgsmapcanvas.h"
2121
#include "qgsvectorlayer.h"
22+
#include "qgsproject.h"
2223
#include <QMouseEvent>
2324

2425
QgsMapToolFormAnnotation::QgsMapToolFormAnnotation( QgsMapCanvas* canvas ): QgsMapToolAnnotation( canvas )
@@ -48,6 +49,7 @@ QgsAnnotationItem* QgsMapToolFormAnnotation::createItem( QMouseEvent* e )
4849
formItem->setMapPosition( toMapCoordinates( e->pos() ) );
4950
formItem->setSelected( true );
5051
formItem->setFrameSize( QSizeF( 200, 100 ) );
52+
QgsProject::instance()->setDirty( true );
5153
return formItem;
5254
}
5355

src/app/qgsmaptoolhtmlannotation.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "qgshtmlannotationitem.h"
2020
#include "qgsmapcanvas.h"
2121
#include "qgsvectorlayer.h"
22+
#include "qgsproject.h"
2223
#include <QMouseEvent>
2324

2425
QgsMapToolHtmlAnnotation::QgsMapToolHtmlAnnotation( QgsMapCanvas* canvas ): QgsMapToolAnnotation( canvas )
@@ -48,6 +49,7 @@ QgsAnnotationItem* QgsMapToolHtmlAnnotation::createItem( QMouseEvent* e )
4849
formItem->setMapPosition( toMapCoordinates( e->pos() ) );
4950
formItem->setSelected( true );
5051
formItem->setFrameSize( QSizeF( 200, 100 ) );
52+
QgsProject::instance()->setDirty( true );
5153
return formItem;
5254
}
5355

src/app/qgsmaptoolsvgannotation.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "qgsmaptoolsvgannotation.h"
1919
#include "qgssvgannotationitem.h"
20+
#include "qgsproject.h"
2021
#include <QMouseEvent>
2122

2223
QgsMapToolSvgAnnotation::QgsMapToolSvgAnnotation( QgsMapCanvas* canvas ): QgsMapToolAnnotation( canvas )
@@ -35,5 +36,6 @@ QgsAnnotationItem* QgsMapToolSvgAnnotation::createItem( QMouseEvent* e )
3536
svgItem->setMapPosition( toMapCoordinates( e->pos() ) );
3637
svgItem->setSelected( true );
3738
svgItem->setFrameSize( QSizeF( 200, 100 ) );
39+
QgsProject::instance()->setDirty( true );
3840
return svgItem;
3941
}

src/app/qgsmaptooltextannotation.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "qgsmaptooltextannotation.h"
1919
#include "qgstextannotationitem.h"
20+
#include "qgsproject.h"
2021
#include <QMouseEvent>
2122

2223
QgsMapToolTextAnnotation::QgsMapToolTextAnnotation( QgsMapCanvas* canvas ): QgsMapToolAnnotation( canvas )
@@ -36,6 +37,7 @@ QgsAnnotationItem* QgsMapToolTextAnnotation::createItem( QMouseEvent* e )
3637
textItem->setMapPosition( toMapCoordinates( e->pos() ) );
3738
textItem->setFrameSize( QSizeF( 200, 100 ) );
3839
textItem->setSelected( true );
40+
QgsProject::instance()->setDirty( true );
3941
return textItem;
4042
}
4143

0 commit comments

Comments
 (0)