[qet] [3062] Previous comit was wrong and add memory leak.

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 3062
Author:   blacksun
Date:     2014-05-10 19:13:09 +0200 (Sat, 10 May 2014)
Log Message:
-----------
Previous comit was wrong and add memory leak.
This comit fix regression come from previous comit and improve how diagram folio list is drawed 

Modified Paths:
--------------
    trunk/sources/diagramfoliolist.cpp
    trunk/sources/diagramfoliolist.h

Modified: trunk/sources/diagramfoliolist.cpp
===================================================================
--- trunk/sources/diagramfoliolist.cpp	2014-05-10 16:00:23 UTC (rev 3061)
+++ trunk/sources/diagramfoliolist.cpp	2014-05-10 17:13:09 UTC (rev 3062)
@@ -34,17 +34,6 @@
 	}
 	else
 		id = 0;
-
-	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);
 }
 
 /**
@@ -89,19 +78,7 @@
 	qreal y0 = border_and_titleblock.columnsHeaderHeight();
 	QRectF row_RectBorder(x0, y0, width, height);
 
-	// 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;
-		foreach(QGraphicsItem *qgi, items()) {
-			removeItem(qgi);
-			qgiManager().release(qgi);
-		}
-		qDeleteAll (list_lines_);
-		list_lines_.clear();
-		qDeleteAll (list_rectangles_);
-		list_rectangles_.clear();
-		buildGrid(row_RectBorder,30,2,colWidths);
-	}
+	buildGrid(p, row_RectBorder,30,2,colWidths);
 
 	x0 = list_rectangles_[0] -> topLeft().x();
 	y0 = list_rectangles_[0] -> topLeft().y();
@@ -197,8 +174,13 @@
 	qp -> drawText(QRectF(x, y, colWidths[3]*row_rect.width(), row_rect.height()), Qt::AlignCenter, date);
 }
 
-void DiagramFolioList::buildGrid(const QRectF &rect, int rows, int tables, qreal colWidths[])
+void DiagramFolioList::buildGrid(QPainter *qp, const QRectF &rect, int rows, int tables, qreal colWidths[])
 {
+	qDeleteAll (list_lines_);
+	list_lines_.clear();
+	qDeleteAll (list_rectangles_);
+	list_rectangles_.clear();
+
 	qreal sum = 0;
 	for (int i = 0; i < 4; i++ )
 		sum += colWidths[i];
@@ -217,16 +199,16 @@
 
 	for (int i = 0; i < tables; ++i) {
 		QRectF *tableRect = new QRectF(x0, y0, tableWidth, rect.height() - 2*tablesSpacing);
-		addRect(*tableRect);
+		qp->drawRect(*tableRect);
 		list_rectangles_.push_back(tableRect);
 		for (int j = 1; j < rows; ++j) {
 			QLineF *line = new QLineF(x0, y0 + j*rowHeight, x0 + tableWidth,y0 + j*rowHeight);
-			addLine(*line);
+			qp->drawLine(*line);
 			list_lines_.push_back(line);
 		}
 		for (int j = 0; j < cols-1; ++j) {
 			QLineF *line = new QLineF(x0 + colWidths[j]*tableWidth, y0, x0 + colWidths[j]*tableWidth,y0 + rows*rowHeight);
-			addLine(*line);
+			qp->drawLine(*line);
 			list_lines_.push_back(line);
 			x0 += colWidths[j]*tableWidth;
 		}

Modified: trunk/sources/diagramfoliolist.h
===================================================================
--- trunk/sources/diagramfoliolist.h	2014-05-10 16:00:23 UTC (rev 3061)
+++ trunk/sources/diagramfoliolist.h	2014-05-10 17:13:09 UTC (rev 3062)
@@ -38,7 +38,7 @@
 
 	private:
 	void fillRow(QPainter *, const QRectF &, QString, QString, QString, QString);
-	void buildGrid(const QRectF &, int, int, qreal[]);
+	void buildGrid(QPainter *, const QRectF &, int, int, qreal[]);
 	void fillHeader(QPainter *, const QRectF &);
 
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/