Skip to content

Commit 00e2b23

Browse files
committed
Some further small improvements to QgsRubberband
1 parent ed1e19f commit 00e2b23

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/gui/qgsrubberband.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -399,20 +399,18 @@ void QgsRubberBand::setToCanvasRectangle( const QRect& rect )
399399
*/
400400
void QgsRubberBand::paint( QPainter* p )
401401
{
402-
QList<QgsPoint> currentList;
403402
if ( mPoints.size() > 0 )
404403
{
405404
p->setBrush( mBrush );
406405
mPen.setWidth( mWidth );
407406
p->setPen( mPen );
408407

409-
for ( int i = 0; i < mPoints.size(); ++i )
408+
Q_FOREACH( const QList<QgsPoint>& line, mPoints )
410409
{
411410
QVector<QPointF> pts;
412-
QList<QgsPoint>::const_iterator it = mPoints.at( i ).constBegin();
413-
for ( ; it != mPoints.at( i ).constEnd(); ++it )
411+
Q_FOREACH( const QgsPoint& pt, line )
414412
{
415-
const QPointF cur = toCanvasCoordinates( QgsPoint( it->x() + mTranslationOffsetX, it->y() + mTranslationOffsetY ) ) - pos();
413+
const QPointF cur = toCanvasCoordinates( QgsPoint( pt.x() + mTranslationOffsetX, pt.y() + mTranslationOffsetY ) ) - pos();
416414
if ( pts.empty() || std::abs( pts.back().x() - cur.x() ) > 1 || std::abs( pts.back().y() - cur.y() ) > 1 )
417415
pts.append( cur );
418416
}
@@ -427,11 +425,10 @@ void QgsRubberBand::paint( QPainter* p )
427425

428426
case QGis::Point:
429427
{
430-
QVector<QPointF>::const_iterator ptIt = pts.constBegin();
431-
for ( ; ptIt != pts.constEnd(); ++ptIt )
428+
Q_FOREACH( const QPointF& pt, pts )
432429
{
433-
double x = ( *ptIt ).x();
434-
double y = ( *ptIt ).y();
430+
double x = pt.x();
431+
double y = pt.y();
435432

436433
qreal s = ( mIconSize - 1 ) / 2;
437434

0 commit comments

Comments
 (0)