Skip to content

Commit

Permalink
Make composer a bit more robust against accidential mouse clicks
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12801 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jan 20, 2010
1 parent 7f6c995 commit 40ee48c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/core/composer/qgspaperitem.cpp
Expand Up @@ -20,19 +20,17 @@

QgsPaperItem::QgsPaperItem( QgsComposition* c ): QgsComposerItem( c, false )
{
setFlag( QGraphicsItem::ItemIsSelectable, false );
setZValue( 0 );
initialize();
}

QgsPaperItem::QgsPaperItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition ): QgsComposerItem( x, y, width, height, composition, false )
{
setFlag( QGraphicsItem::ItemIsSelectable, false );
setZValue( 0 );
initialize();
}

QgsPaperItem::QgsPaperItem(): QgsComposerItem( 0, false )
{

initialize();
}

QgsPaperItem::~QgsPaperItem()
Expand Down Expand Up @@ -119,3 +117,10 @@ bool QgsPaperItem::readXML( const QDomElement& itemElem, const QDomDocument& doc
{
return true;
}

void QgsPaperItem::initialize()
{
setFlag( QGraphicsItem::ItemIsSelectable, false );
setFlag( QGraphicsItem::ItemIsMovable, false );
setZValue( 0 );
}
2 changes: 2 additions & 0 deletions src/core/composer/qgspaperitem.h
Expand Up @@ -45,6 +45,8 @@ class CORE_EXPORT QgsPaperItem: public QgsComposerItem

private:
QgsPaperItem();
/**Set flags and z-value*/
void initialize();
};

#endif
9 changes: 9 additions & 0 deletions src/gui/qgscomposerview.cpp
Expand Up @@ -106,6 +106,7 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e )
mRubberBandLineItem->setZValue( 100 );
scene()->addItem( mRubberBandLineItem );
scene()->update();
break;
}

//create rubber band for map and ellipse items
Expand Down Expand Up @@ -157,13 +158,15 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e )
addComposerPicture( newPicture );
newPicture->setSceneRect( QRectF( snappedScenePoint.x(), snappedScenePoint.y(), 30, 30 ) );
emit actionFinished();
break;
}
case AddTable:
{
QgsComposerTable* newTable = new QgsComposerTable( composition() );
addComposerTable( newTable );
newTable->setSceneRect( QRectF( snappedScenePoint.x(), snappedScenePoint.y(), 50, 50 ) );
emit actionFinished();
break;
}

default:
Expand Down Expand Up @@ -233,6 +236,7 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e )
addComposerShape( composerShape );
scene()->removeItem( mRubberBandItem );
delete mRubberBandItem;
mRubberBandItem = 0;
emit actionFinished();
break;
}
Expand Down Expand Up @@ -358,6 +362,11 @@ void QgsComposerView::mouseMoveEvent( QMouseEvent* e )
}
}

void QgsComposerView::mouseDoubleClickEvent( QMouseEvent* e )
{
e->ignore();
}

void QgsComposerView::keyPressEvent( QKeyEvent * e )
{
if ( e->key() == Qt::Key_Shift )
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgscomposerview.h
Expand Up @@ -102,6 +102,7 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView
void mousePressEvent( QMouseEvent* );
void mouseReleaseEvent( QMouseEvent* );
void mouseMoveEvent( QMouseEvent* );
void mouseDoubleClickEvent( QMouseEvent* e );

void keyPressEvent( QKeyEvent * e );
void keyReleaseEvent( QKeyEvent * e );
Expand Down

0 comments on commit 40ee48c

Please sign in to comment.