[QGIS Commit] r10872 - in trunk/qgis/src: core/composer gui
plugins/diagram_overlay
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Jun 1 17:18:16 EDT 2009
Author: jef
Date: 2009-06-01 17:18:16 -0400 (Mon, 01 Jun 2009)
New Revision: 10872
Modified:
trunk/qgis/src/core/composer/qgscomposeritem.cpp
trunk/qgis/src/gui/qgscomposerview.cpp
trunk/qgis/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp
Log:
indentation update
Modified: trunk/qgis/src/core/composer/qgscomposeritem.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposeritem.cpp 2009-06-01 14:17:54 UTC (rev 10871)
+++ trunk/qgis/src/core/composer/qgscomposeritem.cpp 2009-06-01 21:18:16 UTC (rev 10872)
@@ -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 @@
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 @@
}
//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 @@
void QgsComposerItem::mouseMoveEvent( QGraphicsSceneMouseEvent * event )
{
- if(mItemPositionLocked)
- {
- return;
- }
+ if ( mItemPositionLocked )
+ {
+ return;
+ }
if ( mBoundingResizeRectangle )
{
@@ -263,10 +263,10 @@
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::mouseReleaseEvent( QGraphicsSceneMouseEvent * event )
{
- if(mItemPositionLocked)
- {
- return;
- }
+ if ( mItemPositionLocked )
+ {
+ return;
+ }
//delete frame rectangle
if ( mBoundingResizeRectangle )
@@ -331,9 +331,9 @@
{
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 @@
{
//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 @@
}
//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,7 +504,7 @@
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 );
@@ -512,14 +512,14 @@
}
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 @@
}
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 @@
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";
- }
+ //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()));
- }
+ 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::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 ) );
}
Modified: trunk/qgis/src/gui/qgscomposerview.cpp
===================================================================
--- trunk/qgis/src/gui/qgscomposerview.cpp 2009-06-01 14:17:54 UTC (rev 10871)
+++ trunk/qgis/src/gui/qgscomposerview.cpp 2009-06-01 21:18:16 UTC (rev 10872)
@@ -46,19 +46,19 @@
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 @@
{
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 @@
case AddMap:
//adjust rubber band item
- {
- double x = 0;
- double y = 0;
- double width = 0;
- double height = 0;
+ {
+ double x = 0;
+ double y = 0;
+ double width = 0;
+ double height = 0;
- double dx = scenePoint.x() - mRubberBandStartPos.x();
- double dy = scenePoint.y() - mRubberBandStartPos.y();
+ 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 ( 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;
+ 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
Modified: trunk/qgis/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp
===================================================================
--- trunk/qgis/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp 2009-06-01 14:17:54 UTC (rev 10871)
+++ trunk/qgis/src/plugins/diagram_overlay/qgsdiagramoverlay.cpp 2009-06-01 21:18:16 UTC (rev 10872)
@@ -104,9 +104,9 @@
currentGeometry = currentFeature.geometryAndOwnership();
//overlay objects needs the geometry in map coordinates
- if(currentGeometry && renderContext.coordinateTransform())
+ if ( currentGeometry && renderContext.coordinateTransform() )
{
- currentGeometry->transform(*(renderContext.coordinateTransform()));
+ currentGeometry->transform( *( renderContext.coordinateTransform() ) );
}
mOverlayObjects.insert( currentFeature.id(), new QgsOverlayObject( width, height, 0, currentGeometry ) );
}
@@ -152,21 +152,21 @@
const QgsCoordinateTransform* ct = context.coordinateTransform();
QList<QgsPoint>::const_iterator positionIt = positionList.constBegin();
- for(; positionIt != positionList.constEnd(); ++positionIt)
+ for ( ; positionIt != positionList.constEnd(); ++positionIt )
{
- QgsPoint overlayPosition = *positionIt;
- context.mapToPixel().transform( &overlayPosition );
- int shiftX = currentDiagramImage->width() / 2;
- int shiftY = currentDiagramImage->height() / 2;
+ QgsPoint overlayPosition = *positionIt;
+ context.mapToPixel().transform( &overlayPosition );
+ int shiftX = currentDiagramImage->width() / 2;
+ int shiftY = currentDiagramImage->height() / 2;
- if ( painter )
- {
- painter->save();
- painter->scale( 1.0 / context.rasterScaleFactor(), 1.0 / context.rasterScaleFactor() );
- //painter->drawRect(( int )( overlayPosition.x() * context.rasterScaleFactor() ) - shiftX, ( int )( overlayPosition.y() * context.rasterScaleFactor() ) - shiftY, it.value()->width(), it.value()->height());
- painter->drawImage(( int )( overlayPosition.x() * context.rasterScaleFactor() ) - shiftX, ( int )( overlayPosition.y() * context.rasterScaleFactor() ) - shiftY, *currentDiagramImage );
- painter->restore();
- }
+ if ( painter )
+ {
+ painter->save();
+ painter->scale( 1.0 / context.rasterScaleFactor(), 1.0 / context.rasterScaleFactor() );
+ //painter->drawRect(( int )( overlayPosition.x() * context.rasterScaleFactor() ) - shiftX, ( int )( overlayPosition.y() * context.rasterScaleFactor() ) - shiftY, it.value()->width(), it.value()->height());
+ painter->drawImage(( int )( overlayPosition.x() * context.rasterScaleFactor() ) - shiftX, ( int )( overlayPosition.y() * context.rasterScaleFactor() ) - shiftY, *currentDiagramImage );
+ painter->restore();
+ }
}
}
}
More information about the QGIS-commit
mailing list