summaryrefslogtreecommitdiffstats
path: root/qt-ui/printlayout.h
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-07-25 12:52:20 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-08-05 06:59:19 +0200
commite5b18db8026f1488f73b5fed7fa62ba4990cea46 (patch)
treea96a8a9226272afc1ea8bcaec2e496fc8df554ec /qt-ui/printlayout.h
parent1f976371bff0a3c23119165aa601e27da458c22d (diff)
downloadsubsurface-e5b18db8026f1488f73b5fed7fa62ba4990cea46.tar.gz
Print: improve table printing by using QTableView
The current QTextDocument implementation is slow due to HTML parsing. By using QTableView with QAbstractTableModel we boost the performance of the table print drastically. This patch completely replaces the old solution. There is a hidden QTableView widget which is populated with all data and rendered using a QPainter attached to the printer device. A couple of new classes are added in models.h/cpp that handle the table print model and these are then used in printlayout.h/cpp. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/printlayout.h')
-rw-r--r--qt-ui/printlayout.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/qt-ui/printlayout.h b/qt-ui/printlayout.h
index 7a1922e4a..ac363ab8d 100644
--- a/qt-ui/printlayout.h
+++ b/qt-ui/printlayout.h
@@ -1,10 +1,13 @@
#ifndef PRINTLAYOUT_H
#define PRINTLAYOUT_H
+#include <QObject>
#include <QPrinter>
-#include <QStringList>
+#include <QList>
class PrintDialog;
+class TablePrintModel;
+struct dive;
class PrintLayout : public QObject {
Q_OBJECT
@@ -19,21 +22,21 @@ private:
struct options *printOptions;
QPainter *painter;
- int screenDpiX, screenDpiY, printerDpi;
+ int screenDpiX, screenDpiY, printerDpi, scaledPageW, scaledPageH;
qreal scaleX, scaleY;
QRect pageRect;
- QStringList tableColumnNames;
- QStringList tableColumnWidths;
+ QList<QString> tablePrintColumnNames;
+ QList<unsigned int> tablePrintColumnWidths;
+ unsigned int tablePrintHeadingBackground;
void setup();
void printSixDives() const;
void printTwoDives() const;
- void printTable() const;
- QString insertTableHeadingRow() const;
- QString insertTableHeadingCol(int) const;
- QString insertTableDataRow(struct dive *) const;
- QString insertTableDataCol(QString) const;
+ void printTable();
+ void addTablePrintDataRow(TablePrintModel *model, int row, struct dive *dive) const;
+ void addTablePrintHeadingRow(TablePrintModel *model, int row) const;
+
QPixmap convertPixmapToGrayscale(QPixmap) const;
};