Skip to content
Permalink
Browse files

indentation update

git-svn-id: http://svn.osgeo.org/qgis/trunk@10872 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Jun 1, 2009
1 parent adf2437 commit dac08c8d6b6fea0b0898249953f310a96ea88030
Showing with 132 additions and 132 deletions.
  1. +68 −68 src/core/composer/qgscomposeritem.cpp
  2. +48 −48 src/gui/qgscomposerview.cpp
  3. +16 −16 src/plugins/diagram_overlay/qgsdiagramoverlay.cpp
@@ -34,7 +34,7 @@
#define FONT_WORKAROUND_SCALE 10 //scale factor for upscaling fontsize and downscaling painter

QgsComposerItem::QgsComposerItem( QgsComposition* composition, bool manageZValue ): QGraphicsRectItem( 0 ), mComposition( composition ), mBoundingResizeRectangle( 0 ), \
mFrame( true ), mItemPositionLocked(false)
mFrame( true ), mItemPositionLocked( false )
{
setFlag( QGraphicsItem::ItemIsSelectable, true );
setAcceptsHoverEvents( true );
@@ -125,13 +125,13 @@ bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc ) cons
composerItemElem.setAttribute( "outlineWidth", QString::number( pen().widthF() ) );

//position lock for mouse moves/resizes
if(mItemPositionLocked)
if ( mItemPositionLocked )
{
composerItemElem.setAttribute( "positionLock", "true");
composerItemElem.setAttribute( "positionLock", "true" );
}
else
{
composerItemElem.setAttribute( "positionLock", "false");
composerItemElem.setAttribute( "positionLock", "false" );
}


@@ -177,14 +177,14 @@ bool QgsComposerItem::_readXML( const QDomElement& itemElem, const QDomDocument&
}

//position lock for mouse moves/resizes
QString positionLock = itemElem.attribute("positionLock");
if(positionLock.compare("true", Qt::CaseInsensitive) == 0)
QString positionLock = itemElem.attribute( "positionLock" );
if ( positionLock.compare( "true", Qt::CaseInsensitive ) == 0 )
{
mItemPositionLocked = true;
mItemPositionLocked = true;
}
else
{
mItemPositionLocked = false;
mItemPositionLocked = false;
}

//position
@@ -246,10 +246,10 @@ bool QgsComposerItem::_readXML( const QDomElement& itemElem, const QDomDocument&

void QgsComposerItem::mouseMoveEvent( QGraphicsSceneMouseEvent * event )
{
if(mItemPositionLocked)
{
return;
}
if ( mItemPositionLocked )
{
return;
}

if ( mBoundingResizeRectangle )
{
@@ -263,10 +263,10 @@ void QgsComposerItem::mouseMoveEvent( QGraphicsSceneMouseEvent * event )

void QgsComposerItem::mousePressEvent( QGraphicsSceneMouseEvent * event )
{
if(mItemPositionLocked)
{
return;
}
if ( mItemPositionLocked )
{
return;
}

//set current position and type of mouse move action
mMouseMoveStartPos = event->lastScenePos();
@@ -297,10 +297,10 @@ void QgsComposerItem::mousePressEvent( QGraphicsSceneMouseEvent * event )
void QgsComposerItem::mouseReleaseEvent( QGraphicsSceneMouseEvent * event )
{

if(mItemPositionLocked)
{
return;
}
if ( mItemPositionLocked )
{
return;
}

//delete frame rectangle
if ( mBoundingResizeRectangle )
@@ -331,9 +331,9 @@ Qt::CursorShape QgsComposerItem::cursorForPosition( const QPointF& itemCoordPos
{
QgsComposerItem::MouseMoveAction mouseAction = mouseMoveActionForPosition( itemCoordPos );

if( mouseAction == QgsComposerItem::NoAction)
if ( mouseAction == QgsComposerItem::NoAction )
{
return Qt::ForbiddenCursor;
return Qt::ForbiddenCursor;
}
if ( mouseAction == QgsComposerItem::MoveItem )
{
@@ -361,9 +361,9 @@ QgsComposerItem::MouseMoveAction QgsComposerItem::mouseMoveActionForPosition( co
{

//no action at all if item position is locked for mouse
if(mItemPositionLocked)
if ( mItemPositionLocked )
{
return QgsComposerItem::NoAction;
return QgsComposerItem::NoAction;
}

bool nearLeftBorder = false;
@@ -434,7 +434,7 @@ void QgsComposerItem::changeItemRectangle( const QPointF& currentPosition, const
}

//test if change item is a composer item. If so, prefer call to setSceneRect() instead of setTransform() and setRect()
QgsComposerItem* changeComposerItem = dynamic_cast<QgsComposerItem*>(changeItem);
QgsComposerItem* changeComposerItem = dynamic_cast<QgsComposerItem*>( changeItem );

double mx = 0.0, my = 0.0, rx = 0.0, ry = 0.0;
QPointF snappedPosition = mComposition->snapPointToGrid( currentPosition );
@@ -504,22 +504,22 @@ void QgsComposerItem::changeItemRectangle( const QPointF& currentPosition, const
double moveRectX = snappedLeftPoint.x() - originalItem->transform().dx();
double moveRectY = snappedLeftPoint.y() - originalItem->transform().dy();

if(!changeComposerItem)
if ( !changeComposerItem )
{
QTransform moveTransform;
moveTransform.translate( originalItem->transform().dx() + moveRectX, originalItem->transform().dy() + moveRectY );
changeItem->setTransform( moveTransform );
}
else //for composer items, we prefer setSceneRect as subclasses can implement custom behaviour (e.g. item group)
{
changeComposerItem->setSceneRect(QRectF(originalItem->transform().dx() + moveRectX, \
originalItem->transform().dy() + moveRectY, \
originalItem->rect().width(), originalItem->rect().height()));
changeComposerItem->setSceneRect( QRectF( originalItem->transform().dx() + moveRectX, \
originalItem->transform().dy() + moveRectY, \
originalItem->rect().width(), originalItem->rect().height() ) );
}
return;
}

if(!changeComposerItem)
if ( !changeComposerItem )
{
QTransform itemTransform;
itemTransform.translate( originalItem->transform().dx() + mx, originalItem->transform().dy() + my );
@@ -529,8 +529,8 @@ void QgsComposerItem::changeItemRectangle( const QPointF& currentPosition, const
}
else //for composer items, we prefer setSceneRect as subclasses can implement custom behaviour (e.g. item group)
{
changeComposerItem->setSceneRect( QRectF(originalItem->transform().dx() + mx, originalItem->transform().dy() + my, \
originalItem->rect().width() + rx, originalItem->rect().height() + ry) );
changeComposerItem->setSceneRect( QRectF( originalItem->transform().dx() + mx, originalItem->transform().dy() + my, \
originalItem->rect().width() + rx, originalItem->rect().height() + ry ) );
}
}

@@ -548,29 +548,29 @@ void QgsComposerItem::drawSelectionBoxes( QPainter* p )
double rectHandlerSize = rectHandlerBorderTolerance();
double sizeLockSymbol = lockSymbolSize();

if(mItemPositionLocked)
if ( mItemPositionLocked )
{
//draw lock symbol at upper left edge. Use QImage to be independant of the graphic system
QString lockIconPath = QgsApplication::activeThemePath() + "/mIconLock.png";
if(!QFile::exists(lockIconPath))
{
lockIconPath = QgsApplication::defaultThemePath() + "/mIconLock.png";
}

QImage lockImage(lockIconPath);
if(!lockImage.isNull())
{
p->drawImage(QRectF(0, 0, sizeLockSymbol, sizeLockSymbol), lockImage, QRectF(0, 0, lockImage.width(), lockImage.height()));
}
//draw lock symbol at upper left edge. Use QImage to be independant of the graphic system
QString lockIconPath = QgsApplication::activeThemePath() + "/mIconLock.png";
if ( !QFile::exists( lockIconPath ) )
{
lockIconPath = QgsApplication::defaultThemePath() + "/mIconLock.png";
}

QImage lockImage( lockIconPath );
if ( !lockImage.isNull() )
{
p->drawImage( QRectF( 0, 0, sizeLockSymbol, sizeLockSymbol ), lockImage, QRectF( 0, 0, lockImage.width(), lockImage.height() ) );
}
}
else //draw blue squares
{
p->setPen( QPen( QColor( 0, 0, 255 ) ) );
p->setBrush( QBrush( QColor( 0, 0, 255 ) ) );
p->drawRect( QRectF( 0, 0, rectHandlerSize, rectHandlerSize ) );
p->drawRect( QRectF( rect().width() - rectHandlerSize, 0, rectHandlerSize, rectHandlerSize ) );
p->drawRect( QRectF( rect().width() - rectHandlerSize, rect().height() - rectHandlerSize, rectHandlerSize, rectHandlerSize ) );
p->drawRect( QRectF( 0, rect().height() - rectHandlerSize, rectHandlerSize, rectHandlerSize ) );
p->setPen( QPen( QColor( 0, 0, 255 ) ) );
p->setBrush( QBrush( QColor( 0, 0, 255 ) ) );
p->drawRect( QRectF( 0, 0, rectHandlerSize, rectHandlerSize ) );
p->drawRect( QRectF( rect().width() - rectHandlerSize, 0, rectHandlerSize, rectHandlerSize ) );
p->drawRect( QRectF( rect().width() - rectHandlerSize, rect().height() - rectHandlerSize, rectHandlerSize, rectHandlerSize ) );
p->drawRect( QRectF( 0, rect().height() - rectHandlerSize, rectHandlerSize, rectHandlerSize ) );
}
}
}
@@ -749,38 +749,38 @@ double QgsComposerItem::horizontalViewScaleFactor() const

double QgsComposerItem::rectHandlerBorderTolerance() const
{
//size of symbol boxes depends on zoom level in composer view
double viewScaleFactor = horizontalViewScaleFactor();
double rectHandlerSize = 10.0 / viewScaleFactor;
//size of symbol boxes depends on zoom level in composer view
double viewScaleFactor = horizontalViewScaleFactor();
double rectHandlerSize = 10.0 / viewScaleFactor;

//make sure the boxes don't get too large
if(rectHandlerSize > (rect().width() / 3))
{
rectHandlerSize = rect().width() / 3;
}
if(rectHandlerSize > (rect().height() / 3))
{
rectHandlerSize = rect().height() / 3;
}
return rectHandlerSize;
//make sure the boxes don't get too large
if ( rectHandlerSize > ( rect().width() / 3 ) )
{
rectHandlerSize = rect().width() / 3;
}
if ( rectHandlerSize > ( rect().height() / 3 ) )
{
rectHandlerSize = rect().height() / 3;
}
return rectHandlerSize;
}

double QgsComposerItem::lockSymbolSize() const
{
double lockSymbolSize = 20.0 / horizontalViewScaleFactor();

if(lockSymbolSize > (rect().width() / 3))
if ( lockSymbolSize > ( rect().width() / 3 ) )
{
lockSymbolSize = rect().width() / 3;
}
if(lockSymbolSize > (rect().height() / 3))
if ( lockSymbolSize > ( rect().height() / 3 ) )
{
lockSymbolSize = rect().height() / 3;
}
return lockSymbolSize;
}

void QgsComposerItem::updateCursor(const QPointF& itemPos)
void QgsComposerItem::updateCursor( const QPointF& itemPos )
{
setCursor( cursorForPosition(itemPos) );
setCursor( cursorForPosition( itemPos ) );
}
@@ -46,19 +46,19 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e )
QPointF snappedScenePoint = composition()->snapPointToGrid( scenePoint );

//lock/unlock position of item with right click
if(e->button() == Qt::RightButton)
if ( e->button() == Qt::RightButton )
{
QgsComposerItem* selectedItem = composition()->composerItemAt( scenePoint );
if(selectedItem)
{
bool lock = selectedItem->positionLock() ? false : true;
selectedItem->setPositionLock(lock);
selectedItem->update();
//make sure the new cursor is correct
QPointF itemPoint = selectedItem->mapFromScene( scenePoint );
selectedItem->updateCursor(itemPoint);
}
return;
QgsComposerItem* selectedItem = composition()->composerItemAt( scenePoint );
if ( selectedItem )
{
bool lock = selectedItem->positionLock() ? false : true;
selectedItem->setPositionLock( lock );
selectedItem->update();
//make sure the new cursor is correct
QPointF itemPoint = selectedItem->mapFromScene( scenePoint );
selectedItem->updateCursor( itemPoint );
}
return;
}

switch ( mCurrentTool )
@@ -101,7 +101,7 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e )
{
QTransform t;
mRubberBandItem = new QGraphicsRectItem( 0, 0, 0, 0 );
mRubberBandStartPos = QPointF(snappedScenePoint.x(), snappedScenePoint.y());
mRubberBandStartPos = QPointF( snappedScenePoint.x(), snappedScenePoint.y() );
t.translate( snappedScenePoint.x(), snappedScenePoint.y() );
mRubberBandItem->setTransform( t );
mRubberBandItem->setZValue( 100 );
@@ -236,44 +236,44 @@ void QgsComposerView::mouseMoveEvent( QMouseEvent* e )

case AddMap:
//adjust rubber band item
{
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
{
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;
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:
{
//update map preview if composer map

0 comments on commit dac08c8

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