Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix for bug #1717
git-svn-id: http://svn.osgeo.org/qgis/trunk@10856 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 28, 2009
1 parent 3207598 commit 713bd19
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
42 changes: 38 additions & 4 deletions src/gui/qgscomposerview.cpp
Expand Up @@ -101,6 +101,7 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e )
{
QTransform t;
mRubberBandItem = new QGraphicsRectItem( 0, 0, 0, 0 );
mRubberBandStartPos = QPointF(snappedScenePoint.x(), snappedScenePoint.y());
t.translate( snappedScenePoint.x(), snappedScenePoint.y() );
mRubberBandItem->setTransform( t );
mRubberBandItem->setZValue( 100 );
Expand Down Expand Up @@ -235,10 +236,43 @@ void QgsComposerView::mouseMoveEvent( QMouseEvent* e )

case AddMap:
//adjust rubber band item
newWidth = scenePoint.x() - mRubberBandItem->transform().dx();
newHeight = scenePoint.y() - mRubberBandItem->transform().dy();
mRubberBandItem->setRect( 0, 0, newWidth, newHeight );
break;
{
double x = 0;
double y = 0;
double width = 0;
double height = 0;

double dx = scenePoint.x() - mRubberBandStartPos.x();
double dy = scenePoint.y() - mRubberBandStartPos.y();

if(dx < 0)
{
x = scenePoint.x();
width = -dx;
}
else
{
x = mRubberBandStartPos.x();
width = dx;
}

if(dy < 0)
{
y = scenePoint.y();
height = -dy;
}
else
{
y = mRubberBandStartPos.y();
height = dy;
}

mRubberBandItem->setRect( 0, 0, width, height );
QTransform t;
t.translate(x, y);
mRubberBandItem->setTransform(t);
break;
}

case MoveItemContent:
{
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgscomposerview.h
Expand Up @@ -107,6 +107,8 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView
QgsComposerItem* mMoveContentItem;
/**Start position of content move*/
QPointF mMoveContentStartPos;
/**Start of rubber band creation*/
QPointF mRubberBandStartPos;

public slots:
/**For QgsComposerItemGroup to send its signals to QgsComposer (or other classes that keep track of input widgets)*/
Expand Down

0 comments on commit 713bd19

Please sign in to comment.