summaryrefslogtreecommitdiffstats
path: root/qt-ui/printlayout.h
blob: 077d7ac14181fb2916344040011d66d53f67a9ed (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
44
45
46
47
48
#ifndef PRINTLAYOUT_H
#define PRINTLAYOUT_H

#include <QObject>
#include <QPrinter>
#include <QList>

class QTableView;
class PrintDialog;
class TablePrintModel;
class ProfilePrintModel;
struct dive;

class PrintLayout : public QObject {
	Q_OBJECT

public:
	PrintLayout(PrintDialog *, QPrinter *, struct options *);
	void print();

private:
	PrintDialog *dialog;
	QPrinter *printer;
	struct options *printOptions;

	int screenDpiX, screenDpiY, printerDpi, scaledPageW, scaledPageH;
	qreal scaleX, scaleY;
	QRect pageRect;

	QList<QString> tablePrintColumnNames;
	unsigned int tablePrintHeadingBackground;
	QList<unsigned int> tablePrintColumnWidths;
	unsigned int profilePrintTableMaxH;
	QList<unsigned int> profilePrintColumnWidths, profilePrintRowHeights;

	void setup();
	int estimateTotalDives() const;
	void printProfileDives(int divesPerRow, int divesPerColumn);
	QTableView *createProfileTable(ProfilePrintModel *model, const int tableW);
	void printTable();
	void addTablePrintDataRow(TablePrintModel *model, int row, struct dive *dive) const;
	void addTablePrintHeadingRow(TablePrintModel *model, int row) const;

signals:
    void signalProgress(int);
};

#endif