Skip to content

Commit 52ea4ac

Browse files
author
mhugent
committed
Make composer a bit more robust against accidential mouse clicks
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12801 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b4507be commit 52ea4ac

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

src/core/composer/qgspaperitem.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,17 @@
2020

2121
QgsPaperItem::QgsPaperItem( QgsComposition* c ): QgsComposerItem( c, false )
2222
{
23-
setFlag( QGraphicsItem::ItemIsSelectable, false );
24-
setZValue( 0 );
23+
initialize();
2524
}
2625

2726
QgsPaperItem::QgsPaperItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition ): QgsComposerItem( x, y, width, height, composition, false )
2827
{
29-
setFlag( QGraphicsItem::ItemIsSelectable, false );
30-
setZValue( 0 );
28+
initialize();
3129
}
3230

3331
QgsPaperItem::QgsPaperItem(): QgsComposerItem( 0, false )
3432
{
35-
33+
initialize();
3634
}
3735

3836
QgsPaperItem::~QgsPaperItem()
@@ -119,3 +117,10 @@ bool QgsPaperItem::readXML( const QDomElement& itemElem, const QDomDocument& doc
119117
{
120118
return true;
121119
}
120+
121+
void QgsPaperItem::initialize()
122+
{
123+
setFlag( QGraphicsItem::ItemIsSelectable, false );
124+
setFlag( QGraphicsItem::ItemIsMovable, false );
125+
setZValue( 0 );
126+
}

src/core/composer/qgspaperitem.h

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class CORE_EXPORT QgsPaperItem: public QgsComposerItem
4545

4646
private:
4747
QgsPaperItem();
48+
/**Set flags and z-value*/
49+
void initialize();
4850
};
4951

5052
#endif

src/gui/qgscomposerview.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e )
106106
mRubberBandLineItem->setZValue( 100 );
107107
scene()->addItem( mRubberBandLineItem );
108108
scene()->update();
109+
break;
109110
}
110111

111112
//create rubber band for map and ellipse items
@@ -157,13 +158,15 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e )
157158
addComposerPicture( newPicture );
158159
newPicture->setSceneRect( QRectF( snappedScenePoint.x(), snappedScenePoint.y(), 30, 30 ) );
159160
emit actionFinished();
161+
break;
160162
}
161163
case AddTable:
162164
{
163165
QgsComposerTable* newTable = new QgsComposerTable( composition() );
164166
addComposerTable( newTable );
165167
newTable->setSceneRect( QRectF( snappedScenePoint.x(), snappedScenePoint.y(), 50, 50 ) );
166168
emit actionFinished();
169+
break;
167170
}
168171

169172
default:
@@ -233,6 +236,7 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e )
233236
addComposerShape( composerShape );
234237
scene()->removeItem( mRubberBandItem );
235238
delete mRubberBandItem;
239+
mRubberBandItem = 0;
236240
emit actionFinished();
237241
break;
238242
}
@@ -358,6 +362,11 @@ void QgsComposerView::mouseMoveEvent( QMouseEvent* e )
358362
}
359363
}
360364

365+
void QgsComposerView::mouseDoubleClickEvent( QMouseEvent* e )
366+
{
367+
e->ignore();
368+
}
369+
361370
void QgsComposerView::keyPressEvent( QKeyEvent * e )
362371
{
363372
if ( e->key() == Qt::Key_Shift )

src/gui/qgscomposerview.h

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView
102102
void mousePressEvent( QMouseEvent* );
103103
void mouseReleaseEvent( QMouseEvent* );
104104
void mouseMoveEvent( QMouseEvent* );
105+
void mouseDoubleClickEvent( QMouseEvent* e );
105106

106107
void keyPressEvent( QKeyEvent * e );
107108
void keyReleaseEvent( QKeyEvent * e );

0 commit comments

Comments
 (0)