KD Reports API Documentation  2.0
KDReportsReport_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** This file is part of the KD Reports library.
4 **
5 ** SPDX-FileCopyrightText: 2007-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6 **
7 ** SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDAB-KDReports OR LicenseRef-KDAB-KDReports-US
8 **
9 ** Licensees holding valid commercial KD Reports licenses may use this file in
10 ** accordance with the KD Reports Commercial License Agreement provided with
11 ** the Software.
12 **
13 ** Contact info@kdab.com if any conditions of this licensing are not clear to you.
14 **
15 ****************************************************************************/
16 
17 #ifndef KDREPORTSREPORT_P_H
18 #define KDREPORTSREPORT_P_H
19 
20 //
21 // W A R N I N G
22 // -------------
23 //
24 // This file is not part of the KD Reports API. It exists purely as an
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
27 //
28 // We mean it.
29 //
30 
31 #include "KDReportsHeader.h"
32 #include "KDReportsReport.h"
35 #include <QHash>
36 #include <QMap>
37 
38 namespace KDReports {
39 class XmlElementHandler;
40 class MainTable;
41 class AbstractReportLayout;
42 
46 QAbstractItemModel *modelForKey(const QString &key);
47 
48 class Header;
52 class KDREPORTS_EXPORT HeaderMap : public QMap<HeaderLocations, Header *>
53 {
54 public:
55  HeaderMap() = default;
56  ~HeaderMap()
57  {
58  for (iterator it = begin(); it != end(); ++it) {
59  delete *it;
60  }
61  }
62  HeaderMap(const HeaderMap &) = delete;
63  HeaderMap &operator=(const HeaderMap &) = delete;
64 
65  void layoutWithTextWidth(qreal w)
66  {
67  for (const_iterator it = constBegin(); it != constEnd(); ++it) {
68  it.value()->doc().layoutWithTextWidth(w);
69  }
70  }
71 
72  void updateTextValue(const QString &id, const QString &newValue)
73  {
74  for (const_iterator it = constBegin(); it != constEnd(); ++it) {
75  it.value()->doc().updateTextValue(id, newValue);
76  }
77  }
78 
79  qreal height() const
80  {
81  qreal maxHeight = 0;
82  for (const_iterator it = begin(); it != end(); ++it) {
83  Header *header = it.value();
84  maxHeight = qMax(maxHeight, header->doc().contentDocument().size().height());
85  }
86  return maxHeight;
87  }
88 
89  Header *headerForPage(int pageNumber, int pageCount) const;
90  KDReports::HeaderLocations headerLocation(Header *header) const;
91 };
92 
94 {
95 public:
96  explicit ReportPrivate(Report *report);
98 
100  void ensureLayouted();
101  QSizeF paperSize() const;
102  void paintPage(int pageNumber, QPainter &painter);
103  bool doPrint(QPrinter *printer, QWidget *parent);
104  QSizeF layoutAsOnePage(qreal docWidth);
105  bool wantEndlessPrinting() const;
106  bool hasNonLayoutedTextDocument() const;
108 
109  void headerChanged(); // called by Header
110  qreal textDocumentWidth() const; // called by ImageElement, ChartElement
111  bool skipHeadersFooters() const;
112  qreal rawMainTextDocHeight() const;
113  qreal mainTextDocHeight() const;
114  QRect mainTextDocRect() const;
115 #ifndef NDEBUG
116  // for calling from gdb
117  void debugLayoutToPdf(const char *fileName);
118 #endif
119 
120  ReportPrivate(const ReportPrivate &) = delete;
121  ReportPrivate &operator=(const ReportPrivate &) = delete;
122 
123  qreal m_layoutWidth; // in pixels; used for layoutAsOnePage only
124  qreal m_endlessPrinterWidth; // in mm
125  mutable QSizeF m_paperSize; // in pixels
126  QPageLayout::Orientation m_orientation;
127  QPageSize m_pageSize;
128  QString m_documentName;
129  qreal m_marginTop;
130  qreal m_marginLeft;
131  qreal m_marginBottom;
132  qreal m_marginRight;
133  qreal m_headerBodySpacing;
134  qreal m_footerBodySpacing;
144 
145  // int m_numHorizontalPages; // for scaleTo(). 1 if not set.
146  // int m_numVerticalPages; // for scaleTo(). 0 if not set.
147  // qreal m_scaleFontsBy; // for scaleFontsBy(), 1.0 otherwise.
148  // bool m_autoScale; // if scaleTo() was called.
149  // KDReports::Report::TableBreakingPageOrder m_tableBreakingPageOrder;
150 
151  QHash<QString, QString> m_textValues;
152  QHash<QString, QImage> m_imageValues;
155  const QAbstractItemModel *m_currentModel;
160 };
161 
162 }
163 
164 #endif /* KDREPORTSREPORT_P_H */
KDReports::ReportPrivate::headerChanged
void headerChanged()
Definition: KDReportsReport.cpp:354
KDReports::ReportPrivate::hasNonLayoutedTextDocument
bool hasNonLayoutedTextDocument() const
KDReports::ReportPrivate::m_marginTop
qreal m_marginTop
Definition: KDReportsReport_p.h:143
KDReports::ReportBuilder
Definition: KDReportsReportBuilder_p.h:41
KDReports::ReportPrivate::m_currentModel
const QAbstractItemModel * m_currentModel
Definition: KDReportsReport_p.h:169
KDReports::ReportPrivate::paintPage
void paintPage(int pageNumber, QPainter &painter)
KDReports::ReportPrivate::m_watermarkImage
QImage m_watermarkImage
Definition: KDReportsReport_p.h:155
KDReports::modelForKey
QAbstractItemModel * modelForKey(const QString &key)
Definition: KDReportsReport.cpp:426
KDReports::ReportPrivate::~ReportPrivate
~ReportPrivate()
Definition: KDReportsReport.cpp:86
KDReports::ReportPrivate::m_footers
HeaderMap m_footers
Definition: KDReportsReport_p.h:150
KDReports::ReportPrivate::m_watermarkRotation
int m_watermarkRotation
Definition: KDReportsReport_p.h:152
KDReports::ReportPrivate::m_mainTable
MainTable * m_mainTable
Definition: KDReportsReport_p.h:172
KDReportsTextDocument_p.h
KDReports::ReportPrivate::m_paperSize
QSizeF m_paperSize
Definition: KDReportsReport_p.h:139
KDReports::HeaderMap
Definition: KDReportsReport_p.h:66
KDReports::ReportPrivate::m_pageSize
QPageSize m_pageSize
Definition: KDReportsReport_p.h:141
KDReports::TextDocument::contentDocument
QTextDocument & contentDocument()
Definition: KDReportsTextDocument.cpp:43
KDReports::ReportPrivate::builder
ReportBuilder * builder() const
Definition: KDReportsReport.cpp:436
KDReports::ReportPrivate::m_headers
HeaderMap m_headers
Definition: KDReportsReport_p.h:149
KDReports::ReportPrivate::m_imageValues
QHash< QString, QImage > m_imageValues
Definition: KDReportsReport_p.h:166
KDReports::ReportPrivate::debugLayoutToPdf
void debugLayoutToPdf(const char *fileName)
Definition: KDReportsReport.cpp:402
KDReports::ReportPrivate
Definition: KDReportsReport_p.h:107
KDReports::ReportPrivate::m_orientation
QPageLayout::Orientation m_orientation
Definition: KDReportsReport_p.h:140
KDReports::XmlElementHandler
Definition: KDReportsXmlElementHandler.h:84
KDReports::Report
Definition: KDReportsReport.h:80
KDReports::ReportPrivate::operator=
ReportPrivate & operator=(const ReportPrivate &)=delete
KDReports::ReportPrivate::m_currentRow
int m_currentRow
Definition: KDReportsReport_p.h:168
KDReports::ReportPrivate::doPrint
bool doPrint(QPrinter *printer, QWidget *parent)
Definition: KDReportsReport.cpp:359
KDReports::ReportPrivate::m_marginBottom
qreal m_marginBottom
Definition: KDReportsReport_p.h:145
KDReports::ReportPrivate::m_firstPageNumber
int m_firstPageNumber
Definition: KDReportsReport_p.h:156
KDReportsReport.h
KDReports::ReportPrivate::mainTextDocHeight
qreal mainTextDocHeight() const
Definition: KDReportsReport.cpp:159
KDReportsHeader.h
KDReports::ReportPrivate::m_endlessPrinterWidth
qreal m_endlessPrinterWidth
Definition: KDReportsReport_p.h:138
KDReports::ReportPrivate::mainTextDocRect
QRect mainTextDocRect() const
Definition: KDReportsReport.cpp:172
KDReports::ReportPrivate::m_watermarkColor
QColor m_watermarkColor
Definition: KDReportsReport_p.h:153
KDReports::ReportPrivate::skipHeadersFooters
bool skipHeadersFooters() const
Definition: KDReportsReport.cpp:150
KDReportsReportBuilder_p.h
KDReports::ReportPrivate::m_marginRight
qreal m_marginRight
Definition: KDReportsReport_p.h:146
KDReports::ReportPrivate::m_layout
KDReports::AbstractReportLayout * m_layout
Definition: KDReportsReport_p.h:171
KDReports::ReportPrivate::ReportPrivate
ReportPrivate(Report *report)
Definition: KDReportsReport.cpp:48
KDReports::AbstractReportLayout
Definition: KDReportsAbstractReportLayout_p.h:32
KDReports::ReportPrivate::m_watermarkText
QString m_watermarkText
Definition: KDReportsReport_p.h:151
KDReports::ReportPrivate::paperSize
QSizeF paperSize() const
Definition: KDReportsReport.cpp:97
KDReports::ReportPrivate::textDocumentWidth
qreal textDocumentWidth() const
Definition: KDReportsReport.cpp:431
KDReports::ReportPrivate::layoutAsOnePage
QSizeF layoutAsOnePage(qreal docWidth)
Definition: KDReportsReport.cpp:336
KDReports::ReportPrivate::m_layoutWidth
qreal m_layoutWidth
Definition: KDReportsReport_p.h:137
KDReports::ReportPrivate::q
KDReports::Report * q
Definition: KDReportsReport_p.h:173
KDReports::ReportPrivate::m_pageContentSizeDirty
bool m_pageContentSizeDirty
Definition: KDReportsReport_p.h:157
KDReports::ReportPrivate::m_reportMode
KDReports::Report::ReportMode m_reportMode
Definition: KDReportsReport_p.h:170
KDReports::Report::ReportMode
ReportMode
Definition: KDReportsReport.h:96
KDReports::MainTable
Definition: KDReportsMainTable.h:57
KDReports::ReportPrivate::setPaperSizeFromPrinter
void setPaperSizeFromPrinter(QSizeF paperSize)
Definition: KDReportsReport.cpp:191
KDReports::ReportPrivate::m_headerBodySpacing
qreal m_headerBodySpacing
Definition: KDReportsReport_p.h:147
KDREPORTS_EXPORT
#define KDREPORTS_EXPORT
Definition: KDReportsGlobal.h:29
KDReports::ReportPrivate::m_textValues
QHash< QString, QString > m_textValues
Definition: KDReportsReport_p.h:165
KDReports::Header
Definition: KDReportsHeader.h:49
KDReports::ReportPrivate::m_footerBodySpacing
qreal m_footerBodySpacing
Definition: KDReportsReport_p.h:148
KDReports::ReportPrivate::ensureLayouted
void ensureLayouted()
Definition: KDReportsReport.cpp:111
KDReports::ReportPrivate::rawMainTextDocHeight
qreal rawMainTextDocHeight() const
Definition: KDReportsReport.cpp:136
KDReports::ReportPrivate::wantEndlessPrinting
bool wantEndlessPrinting() const
Definition: KDReportsReport.cpp:92
KDReports::ReportPrivate::m_xmlElementHandler
XmlElementHandler * m_xmlElementHandler
Definition: KDReportsReport_p.h:167
KDReports::ReportPrivate::m_watermarkFont
QFont m_watermarkFont
Definition: KDReportsReport_p.h:154
KDReports::ReportPrivate::m_marginLeft
qreal m_marginLeft
Definition: KDReportsReport_p.h:144
KDReports::ReportPrivate::m_documentName
QString m_documentName
Definition: KDReportsReport_p.h:142
KDReports
Definition: KDReportsAbstractReportLayout_p.h:30

© 2007-2021 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-reports/
Generated on Sat Jan 8 2022 02:38:32 for KD Reports API Documentation by doxygen 1.8.17