-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdfrankingprinter.hpp
104 lines (84 loc) · 4.87 KB
/
pdfrankingprinter.hpp
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*****************************************************************************
* Copyright (C) 2021 by Lorenzo Buzzi ([email protected]) *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
*****************************************************************************/
#ifndef PDFRANKINGPRINTER_H
#define PDFRANKINGPRINTER_H
#include <QString>
#include <QList>
#include <QFont>
#include <QRectF>
#include <QPainter>
#include <QPdfWriter>
#include <QScopedPointer>
#include "rankingprinter.hpp"
class PDFRankingPrinter final : public RankingPrinter
{
Q_OBJECT
public:
explicit PDFRankingPrinter(uint indexFieldWidth, uint bibFieldWidth);
void init(QString *outFileName, QString const &title, QString const &subject) override;
void printStartList(QList<Competitor const *> const &startList) override;
void printRanking(Ranking const &categories, QList<ClassEntry const *> const &ranking) override;
void printRanking(Ranking const &categories, QList<TeamClassEntry const *> const &ranking) override;
bool finalize() override;
QString getFileFilter() override;
private:
enum class RankingType
{
START_LIST,
INDIVIDUAL_SINGLE,
INDIVIDUAL_MULTI,
TEAM_SINGLE,
TEAM_MULTI
};
uint currentPage { 0 };
QPainter painter;
QScopedPointer<QPdfWriter> writer { Q_NULLPTR };
QString &buildOutFileName(QString &outFileBaseName) override;
QString &checkOutFileNameExtension(QString &outFileBaseName) override;
qreal toHdots(qreal mm) const;
qreal toVdots(qreal mm) const;
void fitRectToLogo(QRectF &rect, QPixmap const &pixmap) const;
QList<QList<Competitor const *>> splitStartList(QList<Competitor const *> const &startList) const;
QList<QList<Competitor const *>> splitStartListSingleLeg(QList<Competitor const *> const &startList) const;
QList<QList<Competitor const *>> splitStartListMultiLeg(QList<Competitor const *> const &startList) const;
QList<QList<ClassEntry const *>> splitIndividualRanking(QList<ClassEntry const *> const ranking) const;
QList<QList<ClassEntry const *>> splitIndividualRankingSingleLeg(QList<ClassEntry const *> const ranking) const;
QList<QList<ClassEntry const *>> splitIndividualRankingMultiLeg(QList<ClassEntry const *> const ranking) const;
QList<QList<TeamClassEntry const *>> splitTeamRanking(QList<TeamClassEntry const *> const ranking) const;
QList<QList<TeamClassEntry const *>> splitTeamRankingSingleLeg(QList<TeamClassEntry const *> const ranking) const;
QList<QList<TeamClassEntry const *>> splitTeamRankingMultiLeg(QList<TeamClassEntry const *> const ranking) const;
void printHeaderSingleLeg(QRectF &writeRect, int page, RankingType type);
void printHeaderMultiLeg(QRectF &writeRect, int page, RankingType type);
void printEntrySingleLeg(QRectF &writeRect, ClassEntry const *c, int &posIndex, int cIndex, uint referenceTime, RankingType type);
void printPageSingleLeg(QRectF &writeRect, QList<ClassEntry const *> const &page, int &posIndex, uint referenceTime);
void printPageSingleLeg(QRectF &writeRect, QList<TeamClassEntry const *> const &page, int &posIndex);
void printEntryMultiLeg(QRectF &writeRect, ClassEntry const *r, int &posIndex, int rIndex, uint referenceTime, RankingType type);
void printPageMultiLeg(QRectF &writeRect, QList<ClassEntry const *> const &page, int &posIndex, uint referenceTime);
void printPageMultiLeg(QRectF &writeRect, QList<TeamClassEntry const *> const &page, int &posIndex);
void drawTemplatePortrait(QString const &fullDescription, int page, int pages, bool startList = false);
//NOSONAR void drawTemplateLandscape(QString const &fullDescription, int page, int pages, bool startList = false);
qreal ratioX;
qreal ratioY;
qreal areaWidth;
qreal areaHeight;
// Fonts
QFont rnkFont;
QFont rnkFontItalic;
QFont rnkFontBold;
QFont rnkFontBoldItal;
};
#endif // PDFRANKINGPRINTER_H