summaryrefslogtreecommitdiffstats
path: root/qt-ui/printlayout.h
blob: ac363ab8dd992fa7d3a0d3de51a30dd99aa1030b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#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