From 2c8bf84795c6a7ff406ef718ce91c33e87de2c85 Mon Sep 17 00:00:00 2001 From: abhishekm71 Date: Tue, 11 Feb 2014 11:49:03 +0000 Subject: [PATCH] Folio List:QET Crash on print corrected git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2849 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/diagramfoliolist.cpp | 29 +++++++++++++++++++++++------ sources/diagramfoliolist.h | 1 + 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/sources/diagramfoliolist.cpp b/sources/diagramfoliolist.cpp index c6bf0574e..dcd316b89 100644 --- a/sources/diagramfoliolist.cpp +++ b/sources/diagramfoliolist.cpp @@ -34,6 +34,21 @@ DiagramFolioList::DiagramFolioList( QETProject *project, QObject *parent) : Diag } else id = 0; + + clear(); + list_lines_.clear(); + list_rectangles_.clear(); + + qreal width = border_and_titleblock.columnsTotalWidth(); + qreal height = border_and_titleblock.rowsTotalHeight(); + + //top left corner of drawable area + qreal x0 = border_and_titleblock.rowsHeaderWidth(); + qreal y0 = border_and_titleblock.columnsHeaderHeight(); + QRectF row_RectBorder(x0, y0, width, height); + sheetRectangle = row_RectBorder; + + buildGrid(row_RectBorder,30,2,colWidths); } /** @@ -68,11 +83,6 @@ void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r) p -> drawRect(r); p -> setPen(Qt::black); - clear(); - - list_lines_.clear(); - list_rectangles_.clear(); - qreal width = border_and_titleblock.columnsTotalWidth(); qreal height = border_and_titleblock.rowsTotalHeight(); @@ -81,7 +91,14 @@ void DiagramFolioList::drawBackground(QPainter *p, const QRectF &r) qreal y0 = border_and_titleblock.columnsHeaderHeight(); QRectF row_RectBorder(x0, y0, width, height); - buildGrid(row_RectBorder,30,2,colWidths); + // If the sheet size has changed since last paint, then clear the scene and re-draw the grid. + if (sheetRectangle != row_RectBorder) { + sheetRectangle = row_RectBorder; + clear(); + list_lines_.clear(); + list_rectangles_.clear(); + buildGrid(row_RectBorder,30,2,colWidths); + } x0 = list_rectangles_[0] -> topLeft().x(); y0 = list_rectangles_[0] -> topLeft().y(); diff --git a/sources/diagramfoliolist.h b/sources/diagramfoliolist.h index f6602f85c..9f6cfb0ef 100644 --- a/sources/diagramfoliolist.h +++ b/sources/diagramfoliolist.h @@ -44,6 +44,7 @@ class DiagramFolioList : public Diagram QList list_lines_; QList list_rectangles_; + QRectF sheetRectangle; int id; };