@@ -277,9 +277,6 @@ void QgsComposerTableV2::render( QPainter *p, const QRectF &renderExtent, const
277
277
QPair< int , int > rowsToShow = rowRange ( renderExtent, frameIndex );
278
278
279
279
double gridSize = mShowGrid ? mGridStrokeWidth : 0 ;
280
- QList<QgsComposerTableColumn*>::const_iterator columnIt = mColumns .constBegin ();
281
-
282
- int col = 0 ;
283
280
double cellHeaderHeight = QgsComposerUtils::fontAscentMM ( mHeaderFont ) + 2 * mCellMargin ;
284
281
double cellBodyHeight = QgsComposerUtils::fontAscentMM ( mContentFont ) + 2 * mCellMargin ;
285
282
QRectF cell;
@@ -326,26 +323,27 @@ void QgsComposerTableV2::render( QPainter *p, const QRectF &renderExtent, const
326
323
}
327
324
328
325
// now draw the text
329
- double currentX = gridSize;
330
- double currentY;
331
326
p->setPen ( Qt::SolidLine );
332
- for ( ; columnIt != mColumns .constEnd (); ++columnIt )
333
- {
334
- currentY = gridSize;
335
- currentX += mCellMargin ;
336
327
337
- Qt::TextFlag textFlag = ( Qt::TextFlag )0 ;
338
- if (( *columnIt )->width () <= 0 )
328
+ double currentX = gridSize;
329
+ double currentY = gridSize;
330
+ if ( drawHeader )
331
+ {
332
+ // draw the headers
333
+ int col = 0 ;
334
+ for ( QList<QgsComposerTableColumn*>::const_iterator columnIt = mColumns .constBegin (); columnIt != mColumns .constEnd (); ++columnIt )
339
335
{
340
- // automatic column width, so we use the Qt::TextDontClip flag when drawing contents, as this works nicer for italicised text
341
- // which may slightly exceed the calculated width
342
- // if column size was manually set then we do apply text clipping, to avoid painting text outside of columns width
343
- textFlag = Qt::TextDontClip;
344
- }
336
+ currentX += mCellMargin ;
337
+
338
+ Qt::TextFlag textFlag = ( Qt::TextFlag )0 ;
339
+ if (( *columnIt )->width () <= 0 )
340
+ {
341
+ // automatic column width, so we use the Qt::TextDontClip flag when drawing contents, as this works nicer for italicised text
342
+ // which may slightly exceed the calculated width
343
+ // if column size was manually set then we do apply text clipping, to avoid painting text outside of columns width
344
+ textFlag = Qt::TextDontClip;
345
+ }
345
346
346
- if ( drawHeader )
347
- {
348
- // draw the header
349
347
cell = QRectF ( currentX, currentY, mMaxColumnWidthMap [col], cellHeaderHeight );
350
348
351
349
// calculate alignment of header
@@ -368,31 +366,53 @@ void QgsComposerTableV2::render( QPainter *p, const QRectF &renderExtent, const
368
366
369
367
QgsComposerUtils::drawText ( p, cell, ( *columnIt )->heading (), mHeaderFont , mHeaderFontColor , headerAlign, Qt::AlignVCenter, textFlag );
370
368
371
- currentY += cellHeaderHeight;
372
- currentY += gridSize;
369
+ currentX += mMaxColumnWidthMap [ col ];
370
+ currentX += mCellMargin ;
371
+ currentX += gridSize;
372
+ col++;
373
373
}
374
374
375
- if ( drawContents )
375
+ currentY += cellHeaderHeight;
376
+ currentY += gridSize;
377
+ }
378
+
379
+ // now draw the body cells
380
+ if ( drawContents )
381
+ {
382
+ // draw the attribute values
383
+ for ( int row = rowsToShow.first ; row < rowsToShow.second ; ++row )
376
384
{
377
- // draw the attribute values
378
- for ( int row = rowsToShow.first ; row < rowsToShow.second ; ++row )
385
+ currentX = gridSize;
386
+ int col = 0 ;
387
+ for ( QList<QgsComposerTableColumn*>::const_iterator columnIt = mColumns .constBegin (); columnIt != mColumns .constEnd (); ++columnIt )
379
388
{
389
+ // currentY = gridSize;
390
+ currentX += mCellMargin ;
391
+
392
+ Qt::TextFlag textFlag = ( Qt::TextFlag )0 ;
393
+ if (( *columnIt )->width () <= 0 )
394
+ {
395
+ // automatic column width, so we use the Qt::TextDontClip flag when drawing contents, as this works nicer for italicised text
396
+ // which may slightly exceed the calculated width
397
+ // if column size was manually set then we do apply text clipping, to avoid painting text outside of columns width
398
+ textFlag = Qt::TextDontClip;
399
+ }
400
+
380
401
cell = QRectF ( currentX, currentY, mMaxColumnWidthMap [col], cellBodyHeight );
381
402
382
403
QVariant cellContents = mTableContents .at ( row ).at ( col );
383
404
QString str = cellContents.toString ();
384
405
385
406
QgsComposerUtils::drawText ( p, cell, str, mContentFont , mContentFontColor , ( *columnIt )->hAlignment (), Qt::AlignVCenter, textFlag );
386
407
387
- currentY += cellBodyHeight;
388
- currentY += gridSize;
408
+ currentX += mMaxColumnWidthMap [ col ];
409
+ currentX += mCellMargin ;
410
+ currentX += gridSize;
411
+ col++;
389
412
}
413
+ currentY += cellBodyHeight;
414
+ currentY += gridSize;
390
415
}
391
-
392
- currentX += mMaxColumnWidthMap [ col ];
393
- currentX += mCellMargin ;
394
- currentX += gridSize;
395
- col++;
396
416
}
397
417
398
418
// and the borders
0 commit comments