KD Reports API Documentation  2.0
KDReportsTextDocument.cpp
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 
19 
20 #include <QDebug>
21 
22 //#define DEBUG_TABLEBREAKING
23 
25 
27 
29 {
30  m_contentDocument.layoutWithTextWidth(w);
31 }
32 
34 {
35  m_contentDocument.setPageSize(size);
36 }
37 
39 {
40  return m_contentDocument;
41 }
42 
44 {
45  return contentDocumentData().document();
46 }
47 
49 {
50  return m_contentDocument.document().defaultFont();
51 }
52 
54 {
55  m_contentDocument.scaleFontsBy(factor);
56 }
57 
58 void KDReports::TextDocument::updateTextValue(const QString &id, const QString &newValue)
59 {
60  m_contentDocument.updateTextValue(id, newValue);
61 }
62 
63 //@cond PRIVATE
64 QString KDReports::TextDocument::asHtml() const
65 {
66  return m_contentDocument.asHtml();
67 }
68 //@endcond
69 
71 {
72 #if 0
73  qDebug() << "Dumping document:";
74  QTextCursor cursor( &m_contentDocument );
75  int i = 0;
76  int currentBlock = -1;
77  Q_FOREVER {
78  const int blockNumber = cursor.block().blockNumber(); // needs Qt-4.4
79  if ( blockNumber != currentBlock ) {
80  currentBlock = blockNumber;
81  qDebug() << " block" << currentBlock << "starts at char" << i;
82  QTextFormat::PageBreakFlags flags = cursor.block().blockFormat().pageBreakPolicy();
83  if ( flags & QTextFormat::PageBreak_AlwaysBefore )
84  qDebug() << " block" << currentBlock << "says: BREAK BEFORE";
85  if ( flags & QTextFormat::PageBreak_AlwaysAfter )
86  qDebug() << " block" << currentBlock << "says: BREAK AFTER";
87  }
88  const QChar ch = m_contentDocument.characterAt( i );
89  qDebug() << " char" << i << ch << ch.unicode(); // 8233 == paragraph separator
90 
91  if ( cursor.atEnd() ) {
92  qDebug() << " document ends at" << cursor.position();
93  break;
94  }
95  cursor.movePosition( QTextCursor::NextCharacter );
96  ++i;
97  }
98 #endif
99 }
100 
101 //@cond PRIVATE
103 {
104  return m_contentDocument.autoTableElements(); // doesn't matter in which one we call it
105 }
106 
107 //@cond PRIVATE
109 {
110  m_contentDocument.regenerateAutoTables();
111 }
112 
113 void KDReports::TextDocument::regenerateAutoTableForModel(QAbstractItemModel *model)
114 {
115  m_contentDocument.regenerateAutoTableForModel(model);
116 }
117 //@endcond
KDReports::TextDocument::regenerateAutoTables
void regenerateAutoTables()
KDReports::TextDocument::updateTextValue
void updateTextValue(const QString &id, const QString &newValue)
Definition: KDReportsTextDocument.cpp:58
KDReports::TextDocumentData
Definition: KDReportsTextDocumentData_p.h:56
KDReports::TextDocument::preciseDump
void preciseDump()
Definition: KDReportsTextDocument.cpp:70
KDReportsTextDocument_p.h
QList
Definition: KDReportsAbstractTableElement.h:25
KDReports::TextDocument::defaultFont
QFont defaultFont() const
Definition: KDReportsTextDocument.cpp:48
KDReports::TextDocument::contentDocument
QTextDocument & contentDocument()
Definition: KDReportsTextDocument.cpp:43
KDReports::TextDocument::TextDocument
TextDocument()
Definition: KDReportsTextDocument.cpp:24
KDReports::TextDocument::regenerateAutoTableForModel
void regenerateAutoTableForModel(QAbstractItemModel *model)
KDReports::TextDocument::scaleFontsBy
void scaleFontsBy(qreal factor)
Definition: KDReportsTextDocument.cpp:53
KDReports::TextDocument::asHtml
QString asHtml() const
KDReports::TextDocument::~TextDocument
~TextDocument()
Definition: KDReportsTextDocument.cpp:26
KDReportsLayoutHelper_p.h
KDReports::TextDocument::contentDocumentData
TextDocumentData & contentDocumentData()
Definition: KDReportsTextDocument.cpp:38
KDReports::TextDocument::autoTableElements
QList< KDReports::AutoTableElement * > autoTableElements()
KDReports::TextDocument::setPageSize
void setPageSize(QSizeF size)
Definition: KDReportsTextDocument.cpp:33
KDReports::TextDocument::layoutWithTextWidth
void layoutWithTextWidth(qreal w)
Definition: KDReportsTextDocument.cpp:28

© 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