mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
e5b18db802
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>
43 lines
939 B
C++
43 lines
939 B
C++
#ifndef PRINTLAYOUT_H
|
|
#define PRINTLAYOUT_H
|
|
|
|
#include <QObject>
|
|
#include <QPrinter>
|
|
#include <QList>
|
|
|
|
class PrintDialog;
|
|
class TablePrintModel;
|
|
struct dive;
|
|
|
|
class PrintLayout : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
PrintLayout(PrintDialog *, QPrinter *, struct options *);
|
|
void print();
|
|
|
|
private:
|
|
PrintDialog *dialog;
|
|
QPrinter *printer;
|
|
struct options *printOptions;
|
|
|
|
QPainter *painter;
|
|
int screenDpiX, screenDpiY, printerDpi, scaledPageW, scaledPageH;
|
|
qreal scaleX, scaleY;
|
|
QRect pageRect;
|
|
|
|
QList<QString> tablePrintColumnNames;
|
|
QList<unsigned int> tablePrintColumnWidths;
|
|
unsigned int tablePrintHeadingBackground;
|
|
|
|
void setup();
|
|
void printSixDives() const;
|
|
void printTwoDives() const;
|
|
void printTable();
|
|
void addTablePrintDataRow(TablePrintModel *model, int row, struct dive *dive) const;
|
|
void addTablePrintHeadingRow(TablePrintModel *model, int row) const;
|
|
|
|
QPixmap convertPixmapToGrayscale(QPixmap) const;
|
|
};
|
|
|
|
#endif
|