KD Reports API Documentation 2.2
Loading...
Searching...
No Matches
KDReportsReportBuilder_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 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6**
7** SPDX-License-Identifier: MIT
8**
9****************************************************************************/
10
11#ifndef KDREPORTSREPORTBUILDER_H
12#define KDREPORTSREPORTBUILDER_H
13
16#include <QTextCursor>
17
18QT_BEGIN_NAMESPACE
19class QTextDocument;
20QT_END_NAMESPACE
21
22namespace KDReports {
23class Element;
24class Report;
25class TextDocument;
26class TextDocumentData;
27
28#define REPORTBUILDER_CTOR_ARGDEFS KDReports::TextDocumentData &contentDocument, const QTextCursor &cursor, KDReports::Report *report
29
30#define REPORTBUILDER_CTOR_ARGNAMES contentDocument, cursor, report
31
36{
37
38public:
39 ReportBuilder(KDReports::TextDocumentData &contentDocument, const QTextCursor &cursor, Report *report);
41 {
42 }
43
45 {
46 m_contentDocument.aboutToModifyContents(TextDocumentData::Append);
47 return m_cursor;
48 }
50 {
51 return m_report;
52 }
53
54 // Warning, changes to those virtual methods must be propagated to CellReportBuilder.
55 virtual void addPageBreakPublic();
56 virtual void addInlineElementPublic(const Element &element);
57 virtual void addBlockElementPublic(const Element &element, Qt::AlignmentFlag horizontalAlignment, const QColor &backgroundColor = QColor());
59 virtual void addVerticalSpacingPublic(qreal space);
60 virtual void insertFragmentPublic(const QTextDocumentFragment &fragment);
61
62 // Warning, changes to those virtual methods must be propagated to CellReportBuilder and HeaderReportBuilder.
63 virtual void addInlineElement(const Element &element);
64 virtual void addBlockElement(const Element &element, Qt::AlignmentFlag horizontalAlignment, const QColor &backgroundColor = QColor());
65 virtual void addVariable(KDReports::VariableType variable);
66 virtual void addVerticalSpacing(qreal space);
67
69 {
70 return m_contentDocument;
71 }
72
74 {
75 return currentDocumentData().document();
76 }
77
78 // Store default font in builder, so that toplevel text elements use the report's default font
79 // but table cells use the table's default font (if any)
80 void setDefaultFont(const QFont &font)
81 {
82 m_defaultFont = font;
83 }
84
86 {
87 return m_defaultFont;
88 }
89
90 // should not be used directly, apart for creating another builder (e.g. cell builder)
92 {
93 return m_contentDocument;
94 }
96 {
97 return m_cursor;
98 }
99
100 void setupBlockFormat(QTextBlockFormat &blockFormat) const;
101
102 void setTabPositions(const QList<QTextOption::Tab> &tabs); // in mm
103 // const QList<QTextOption::Tab>& tabPositions() const { return m_tabPositions; }
104 void setParagraphMargins(qreal left, qreal top, qreal right, qreal bottom); // in mm
105 void copyStateFrom(const ReportBuilder &parentBuilder);
106 int currentPosition();
107
108 static QTextCharFormat::VerticalAlignment toVerticalAlignment(Qt::Alignment alignment);
109
110private:
111 ReportBuilder(const ReportBuilder &other) = delete;
112 ReportBuilder &operator=(const ReportBuilder &other) = delete;
113
114 KDReports::TextDocumentData &m_contentDocument;
115 QTextCursor m_cursor;
116 QTextCursor m_layoutDocCursor;
117 QList<QTextOption::Tab> m_tabPositions;
118 qreal m_leftMargin = 0;
119 qreal m_rightMargin = 0;
120 qreal m_topMargin = 0;
121 qreal m_bottomMargin = 0;
122 Report *m_report;
123 QFont m_defaultFont;
124 bool m_first = true;
125};
126}
127
129
130#endif /* KDREPORTSREPORTBUILDER_H */
#define KDREPORTS_EXPORT
QDebug operator<<(QDebug &dbg, const QTextOption::Tab &tab)
TextDocumentData & currentDocumentData()
ReportBuilder(KDReports::TextDocumentData &contentDocument, const QTextCursor &cursor, Report *report)
void setDefaultFont(const QFont &font)
virtual void addVerticalSpacingPublic(qreal space)
virtual void addBlockElementPublic(const Element &element, Qt::AlignmentFlag horizontalAlignment, const QColor &backgroundColor=QColor())
virtual void addVariablePublic(KDReports::VariableType variable)
virtual void addInlineElementPublic(const Element &element)
void setParagraphMargins(qreal left, qreal top, qreal right, qreal bottom)
TextDocumentData & contentDocumentData()
AlignmentFlag

© 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 Tue Jul 9 2024 00:04:17 for KD Reports API Documentation by doxygen 1.9.8