21 #include <QAbstractTextDocumentLayout>
22 #include <QApplication>
24 #include <QDomDocument>
25 #include <QDomElement>
30 #include <QPrintDialog>
31 #include <QProgressDialog>
33 #include <QStyleOption>
44 , m_endlessPrinterWidth(0)
45 , m_orientation(QPageLayout::Portrait)
46 , m_pageSize(QPageSize::A4)
50 , m_marginBottom(20.0)
52 , m_headerBodySpacing(0)
53 , m_footerBodySpacing(0)
56 , m_watermarkRotation(0)
57 , m_watermarkColor(QColor(204, 204, 204))
58 , m_watermarkFont(QFont(QStringLiteral(
"Helvetica"), 48))
62 m_numHorizontalPages( 1 ),
63 m_numVerticalPages( 0 ),
64 m_scaleFontsBy( 1.0 ),
69 , m_pageContentSizeDirty(true)
70 , m_xmlElementHandler(nullptr)
72 , m_currentModel(nullptr)
88 return m_layoutWidth > 0;
94 if (m_paperSize.isEmpty()) {
95 const auto mmSize = m_pageSize.size(QPageSize::Millimeter);
97 if (m_orientation == QPageLayout::Landscape) {
98 m_paperSize.transpose();
109 if (m_pageContentSizeDirty) {
110 if (!wantEndlessPrinting()) {
111 setPaperSizeFromPrinter(paperSize());
114 Q_ASSERT(m_layoutWidth != 0);
115 qreal textDocWidth = m_layoutWidth -
mmToPixels(m_marginLeft + m_marginRight);
116 m_paperSize = layoutAsOnePage(textDocWidth);
118 qDebug() <<
"setPaperSizeFromPrinter: endless printer. m_layoutWidth=" << m_layoutWidth <<
"textDocWidth=" << textDocWidth <<
"single page has size" << m_paperSize <<
"pixels";
121 Q_ASSERT(m_layout->numberOfPages() == 1);
126 m_layout->ensureLayouted();
132 qreal textDocHeight = paperSize().height() -
mmToPixels(m_marginTop + m_marginBottom);
133 const qreal headerHeight = m_headers.height();
134 textDocHeight -= headerHeight;
135 textDocHeight -=
mmToPixels(m_headerBodySpacing);
136 const qreal footerHeight = m_footers.height();
137 textDocHeight -=
mmToPixels(m_footerBodySpacing);
138 textDocHeight -= footerHeight;
141 return textDocHeight;
146 const bool skip = rawMainTextDocHeight() <= 0;
148 qDebug() <<
"Not enough height for headers and footers in this page size, hiding headers and footers.";
155 const qreal height = rawMainTextDocHeight();
156 const bool skip = height <= 0;
158 qreal textDocHeight = paperSize().height() -
mmToPixels(m_marginTop + m_marginBottom);
159 textDocHeight -=
mmToPixels(m_headerBodySpacing);
160 textDocHeight -=
mmToPixels(m_footerBodySpacing);
161 return textDocHeight;
168 const int left = qRound(
mmToPixels(m_marginLeft));
169 const int top = qRound(
mmToPixels(m_marginTop));
170 const int headerHeightWithSpacing = qRound((skipHeadersFooters() ? 0 : m_headers.height()) +
mmToPixels(m_headerBodySpacing));
171 const int textDocWidth = qRound(m_paperSize.width() -
mmToPixels(m_marginLeft + m_marginRight));
172 const int textDocHeight = qRound(mainTextDocHeight());
173 return {left, top + headerHeightWithSpacing, textDocWidth, textDocHeight};
187 Q_ASSERT(!wantEndlessPrinting());
189 m_paperSize = paperSize;
190 const qreal marginsInPixels =
mmToPixels(m_marginLeft + m_marginRight);
191 qreal textDocWidth = m_paperSize.width() - marginsInPixels;
193 m_headers.layoutWithTextWidth(textDocWidth);
194 m_footers.layoutWithTextWidth(textDocWidth);
196 const qreal textDocHeight = mainTextDocHeight();
205 m_layout->setPageContentSize(QSizeF(textDocWidth, textDocHeight));
207 m_pageContentSizeDirty =
false;
212 Header *firstPageHeader =
nullptr;
213 Header *lastPageHeader =
nullptr;
214 Header *evenPagesHeader =
nullptr;
215 Header *oddPagesHeader =
nullptr;
216 for (const_iterator it = begin(); it != end(); ++it) {
217 const KDReports::HeaderLocations loc = it.key();
218 Header *
const h = it.value();
228 if (pageNumber == 1 && firstPageHeader)
229 return firstPageHeader;
230 if (pageNumber == pageCount && lastPageHeader)
231 return lastPageHeader;
233 return oddPagesHeader;
235 return evenPagesHeader;
241 for (const_iterator it = begin(); it != end(); ++it) {
242 const KDReports::HeaderLocations loc = it.key();
243 Header *
const h = it.value();
248 KDReports::HeaderLocations loc;
256 const int pageCount = m_layout->numberOfPages();
259 header->preparePaintingPage(pageNumber + m_firstPageNumber - 1);
263 footer->preparePaintingPage(pageNumber + m_firstPageNumber - 1);
266 if (m_watermarkFunction) {
267 m_watermarkFunction(painter, pageNumber);
270 const QRect textDocRect = mainTextDocRect();
271 const bool skipHeadersFooters = this->skipHeadersFooters();
277 if (!m_watermarkText.isEmpty()) {
279 painter.translate(textDocRect.center());
280 painter.rotate(m_watermarkRotation);
281 painter.setFont(m_watermarkFont);
282 painter.setPen(m_watermarkColor);
283 const QSize textSize(painter.fontMetrics().size(Qt::TextSingleLine, m_watermarkText));
284 const QRect textRect(-textSize.width() / 2, -textSize.height() / 2, textSize.width(), textSize.height());
285 painter.drawText(textRect, Qt::AlignCenter, m_watermarkText);
289 if (!m_watermarkImage.isNull()) {
295 const QSize scaledSize = m_watermarkImage.size().scaled(textDocRect.size(), Qt::KeepAspectRatio);
296 const QRect imageRect = QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, scaledSize, textDocRect);
298 painter.drawImage(imageRect, m_watermarkImage);
303 painter.setClipRect(textDocRect);
304 painter.translate(textDocRect.topLeft());
305 m_layout->paintPageContent(pageNumber, painter);
308 QAbstractTextDocumentLayout::PaintContext ctx;
309 ctx.palette.setColor(QPalette::Text, Qt::black);
310 if (header && !skipHeadersFooters) {
312 const int top = qRound(
mmToPixels(m_marginTop));
313 painter.translate(textDocRect.left(), top);
314 ctx.clip = painter.clipRegion().boundingRect();
318 if (footer && !skipHeadersFooters) {
320 const int bottom = qRound(
mmToPixels(m_marginBottom));
321 const int footerHeight = qRound(m_footers.height());
322 painter.translate(textDocRect.left(), m_paperSize.height() - bottom - footerHeight);
323 ctx.clip = painter.clipRegion().boundingRect();
332 m_headers.layoutWithTextWidth(docWidth);
333 m_footers.layoutWithTextWidth(docWidth);
335 const qreal docHeight = m_layout->layoutAsOnePage(docWidth);
337 qreal pageWidth = docWidth +
mmToPixels(m_marginLeft + m_marginRight);
338 qreal pageHeight = docHeight +
mmToPixels(m_marginTop + m_marginBottom);
339 pageHeight += m_headers.height();
340 pageHeight += m_footers.height();
342 m_pageContentSizeDirty =
false;
345 return QSizeF(pageWidth, pageHeight);
350 m_pageContentSizeDirty =
true;
356 const int pageCount = m_layout->numberOfPages();
357 std::unique_ptr<QProgressDialog> dialog;
358 if (m_progressDialogEnabled && QThread::currentThread() == qApp->thread()) {
359 dialog.reset(
new QProgressDialog(QObject::tr(
"Printing"), QObject::tr(
"Cancel"), 0, pageCount, parent));
360 dialog->setWindowModality(Qt::ApplicationModal);
363 if (!painter.begin(printer)) {
364 qWarning() <<
"QPainter failed to initialize on the given printer";
369 int toPage = pageCount;
370 if (printer->printRange() == QPrinter::PageRange) {
371 fromPage = printer->fromPage() - 1;
372 toPage = printer->toPage();
377 bool firstPage =
true;
378 for (
int pageIndex = fromPage; pageIndex < toPage; ++pageIndex) {
380 dialog->setValue(pageIndex);
381 if (dialog->wasCanceled())
384 emit q->printingProgress(pageIndex);
389 paintPage(pageIndex, painter);
401 QFile html(QFile::decodeName(fileName) + QStringLiteral(
".html"));
402 Q_ASSERT(html.open(QIODevice::WriteOnly));
403 const QString htmlText = m_layout->toHtml();
404 html.write(htmlText.toUtf8());
407 bool oldLayoutDirty =
true;
408 m_pageContentSizeDirty =
false;
410 q->setupPrinter(&printer);
411 printer.setOutputFileName(QFile::decodeName(fileName));
412 doPrint(&printer,
nullptr);
413 printer.setOutputFileName(QString());
414 m_pageContentSizeDirty = oldLayoutDirty;
418 typedef QMap<QString, QAbstractItemModel *>
ModelMap;
419 Q_GLOBAL_STATIC(
ModelMap, globalModelMap)
423 return globalModelMap()->value(key, 0);
428 return paperSize().width() -
mmToPixels(m_marginLeft + m_marginRight);
453 if (d->m_reportMode != WordProcessing) {
454 qWarning(
"KDReports: addInlineElement is only supported in WordProcessing mode");
456 d->builder()->addInlineElementPublic(element);
463 if (d->m_reportMode != WordProcessing) {
464 qWarning(
"KDReports: addElement is only supported in WordProcessing mode");
466 d->builder()->addBlockElementPublic(element, horizontalAlignment, backgroundColor);
473 if (d->m_reportMode != WordProcessing) {
474 qWarning(
"KDReports: addVerticalSpacing is only supported in WordProcessing mode");
476 d->builder()->addVerticalSpacingPublic(space);
480 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
483 setPageSize(
static_cast<QPageSize::PageSizeId
>(size));
489 setPageSize(QPageSize {size});
494 d->m_pageSize = size;
495 d->m_paperSize = QSizeF();
496 d->m_pageContentSizeDirty =
true;
503 case QPrinter::DevicePixel:
505 case QPrinter::Millimeter:
508 case QPrinter::Point:
515 qWarning(
"Unsupported printer unit %d", unit);
517 d->m_paperSize = QSizeF(paperSize.width() * factor, paperSize.height() * factor);
518 d->m_pageContentSizeDirty =
true;
521 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
524 return static_cast<QPrinter::PageSize
>(d->m_pageSize.id());
529 return d->m_pageSize;
533 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
534 void KDReports::Report::setOrientation(QPrinter::Orientation orientation)
536 d->m_orientation =
static_cast<QPageLayout::Orientation
>(orientation);
537 d->m_paperSize = QSizeF();
538 d->m_pageContentSizeDirty =
true;
541 QPrinter::Orientation KDReports::Report::orientation()
const
543 return static_cast<QPrinter::Orientation
>(d->m_orientation);
549 d->m_orientation = orientation;
550 d->m_paperSize = QSizeF();
551 d->m_pageContentSizeDirty =
true;
556 return d->m_orientation;
561 d->m_marginTop = top;
562 d->m_marginLeft = left;
563 d->m_marginBottom = bottom;
564 d->m_marginRight = right;
567 d->m_pageContentSizeDirty =
true;
572 *top = d->m_marginTop;
573 *left = d->m_marginLeft;
574 *bottom = d->m_marginBottom;
575 *right = d->m_marginRight;
580 d->m_marginLeft = left;
583 d->m_pageContentSizeDirty =
true;
588 return d->m_marginLeft;
593 d->m_marginRight = right;
596 d->m_pageContentSizeDirty =
true;
601 return d->m_marginRight;
606 d->m_marginTop = top;
609 d->m_pageContentSizeDirty =
true;
614 return d->m_marginTop;
619 d->m_marginBottom = bottom;
622 d->m_pageContentSizeDirty =
true;
627 return d->m_marginBottom;
633 d->m_endlessPrinterWidth = widthMM;
635 d->m_pageContentSizeDirty =
true;
638 d->m_layoutWidth = 0;
639 d->m_pageContentSizeDirty =
true;
646 d->paintPage(pageNumber, painter);
652 return d->m_layout->numberOfPages();
657 qDebug() << asHtml();
660 QString KDReports::Report::asHtml()
const
662 return d->m_layout->toHtml();
667 d->m_progressDialogEnabled = enable;
673 setupPrinter(&printer);
674 QPointer<QPrintDialog> dialog =
new QPrintDialog(&printer, parent);
675 dialog->setMinMax(1, numberOfPages());
677 if (dialog->exec() == QDialog::Accepted) {
680 ok = d->doPrint(&printer, parent);
689 const auto savePageSize = pageSize();
690 if (d->wantEndlessPrinting()) {
694 printer->setPageSize(QPageSize(d->m_paperSize *
pixelsToPointsMultiplier(printer->resolution()), QPageSize::Point));
698 d->setPaperSizeFromPrinter(printer->pageLayout().fullRectPixels(printer->resolution()).size());
701 printer->setFullPage(
true);
705 const bool ret = d->doPrint(printer, parent);
708 setPageSize(savePageSize);
717 printer.setOutputFileName(fileName);
718 setupPrinter(&printer);
719 const bool ret = d->doPrint(&printer, parent);
720 printer.setOutputFileName(QString());
726 const QString html = asHtml();
727 QFile file(fileName);
728 if (file.open(QIODevice::WriteOnly)) {
729 file.write(html.toUtf8());
730 d->m_layout->finishHtmlExport();
740 const auto savePageSize = pageSize();
741 const qreal saveLayoutWidth = d->m_layoutWidth;
742 d->m_layoutWidth = d->m_layout->idealWidth() +
mmToPixels(d->m_marginLeft + d->m_marginRight);
743 d->m_pageContentSizeDirty =
true;
746 const qreal zoomFactor = qMin(( qreal )size.width() / d->m_paperSize.width(), ( qreal )size.height() / d->m_paperSize.height());
749 QImage image(size, QImage::Format_ARGB32_Premultiplied);
750 image.fill(Qt::white);
753 if (!painter.begin(&image)) {
754 qWarning() <<
"QPainter failed to initialize on the given image of size" << size;
757 painter.setRenderHint(QPainter::Antialiasing);
758 painter.setRenderHint(QPainter::SmoothPixmapTransform);
759 painter.fillRect(QRectF(0, 0, size.width(), size.height()), QBrush(Qt::white));
760 painter.scale(zoomFactor, zoomFactor);
761 d->paintPage(0, painter);
764 d->m_layoutWidth = saveLayoutWidth;
765 setPageSize(savePageSize);
766 qDebug() <<
"Saving pixmap" << image.size() <<
"into" << fileName <<
"with format" << format;
767 return image.save(fileName, format);
772 if (!d->m_headers.contains(hl))
773 d->m_headers.insert(hl,
new Header(
this));
774 return *d->m_headers.value(hl);
780 HeaderLocations loc = d->m_headers.headerLocation(header);
781 d->m_headers.remove(loc);
782 d->m_headers.insert(hl, header);
787 if (!d->m_footers.contains(hl))
788 d->m_footers.insert(hl,
new Header(
this));
789 return *d->m_footers.value(hl);
795 HeaderLocations loc = d->m_footers.headerLocation(footer);
796 d->m_footers.remove(loc);
797 d->m_footers.insert(hl, footer);
814 if (iodevice->isOpen())
817 iodevice->open(QIODevice::ReadOnly);
822 bool ret = doc.setContent(iodevice,
true, &errorMsg, &errorLine, &errorColumn);
829 qWarning(
"Malformed XML read in KDReports::Report::loadFromXML(): error message = %s, error line = %d, error column = %d", qPrintable(errorMsg), errorLine, errorColumn);
832 return loadFromXML(doc, details);
837 XmlParser parser(d->m_textValues, d->m_imageValues, d->m_xmlElementHandler,
this, details);
838 d->m_pageContentSizeDirty =
true;
844 globalModelMap()->insert(modelKey, model);
849 Q_ASSERT(d->m_reportMode == WordProcessing);
855 d->builder()->contentDocumentCursor().beginEditBlock();
860 d->builder()->contentDocumentCursor().endEditBlock();
865 const QRect textDocRect = d->mainTextDocRect();
866 const QPoint textPos = pos - textDocRect.topLeft();
867 return d->m_layout->anchorAt(pageNumber, textPos);
872 if (d->m_reportMode == WordProcessing) {
881 d->m_watermarkText = text;
882 d->m_watermarkRotation = rotation;
883 d->m_watermarkColor = color;
884 d->m_watermarkFont = font;
889 return d->m_watermarkText;
894 return d->m_watermarkRotation;
899 return d->m_watermarkColor;
904 return d->m_watermarkFont;
912 opt.palette = QApplication::palette();
913 pix = qApp->style()->generatedIconPixmap(QIcon::Disabled, pixmap, &opt);
915 setWatermarkImage(pix.toImage());
920 return QPixmap::fromImage(d->m_watermarkImage);
925 d->m_watermarkImage = image;
930 return d->m_watermarkImage;
935 d->m_watermarkFunction = std::move(
function);
940 return d->m_watermarkFunction;
945 d->builder()->addPageBreakPublic();
950 d->m_layout->updateTextValue(
id, value);
951 d->m_headers.updateTextValue(
id, value);
952 d->m_footers.updateTextValue(
id, value);
953 d->m_textValues.insert(
id, value);
958 d->m_imageValues.insert(
id, value.toImage());
963 d->m_imageValues.insert(
id, value);
968 return d->paperSize();
973 d->builder()->insertFragmentPublic(fragment);
978 d->m_layout->setDefaultFont(font);
979 d->m_pageContentSizeDirty =
true;
984 return d->m_layout->defaultFont();
989 d->m_headerBodySpacing = spacing;
990 d->m_pageContentSizeDirty =
true;
995 return d->m_headerBodySpacing;
1000 d->m_footerBodySpacing = spacing;
1001 d->m_pageContentSizeDirty =
true;
1006 return d->m_footerBodySpacing;
1011 d->m_layout->scaleTo(numPagesHorizontally, numPagesVertically);
1016 return d->m_layout->maximumNumberOfPagesForHorizontalScaling();
1021 return d->m_layout->maximumNumberOfPagesForVerticalScaling();
1026 d->m_layout->setFixedRowHeight(
mmToPixels(mm));
1031 d->m_layout->setUserRequestedFontScalingFactor(factor);
1036 return d->m_layout->userRequestedFontScalingFactor();
1041 return maximumNumberOfPagesForHorizontalScaling() != 1 || maximumNumberOfPagesForVerticalScaling() > 0;
1046 if (d->m_reportMode != SpreadSheet) {
1047 qWarning(
"setTableBreakingPageOrder is only supported in SpreadSheet mode");
1049 mainTable()->setTableBreakingPageOrder(pageOrder);
1055 if (d->m_reportMode != SpreadSheet) {
1056 qWarning(
"tableBreakingPageOrder is only supported in SpreadSheet mode");
1057 return DownThenRight;
1059 return mainTable()->tableBreakingPageOrder();
1065 if (d->m_reportMode == WordProcessing)
1066 doc().regenerateAutoTables();
1071 if (d->m_reportMode == WordProcessing)
1072 doc().regenerateAutoTableForModel(model);
1077 if (d->m_reportMode == WordProcessing)
1078 return doc().autoTableElements();
1084 d->m_xmlElementHandler = handler;
1089 d->m_currentModel = model;
1090 d->m_currentRow = row;
1095 d->m_documentName = name;
1100 return d->m_documentName;
1105 d->builder()->setTabPositions(tabs);
1110 d->builder()->setParagraphMargins(left, top, right, bottom);
1115 if (d->m_reportMode != reportMode) {
1116 d->m_reportMode = reportMode;
1118 switch (reportMode) {
1119 case WordProcessing:
1124 d->m_layout = sslayout;
1125 mainTable()->setLayout(sslayout);
1133 return d->m_reportMode;
1138 Q_ASSERT(d->m_reportMode == SpreadSheet);
1139 return d->m_mainTable;
1144 QTextOption::Tab tab;
1146 tab.type = QTextOption::RightTab;
1147 tab.delimiter = QChar::fromLatin1(
'P');
1153 QTextOption::Tab tab;
1155 tab.type = QTextOption::CenterTab;
1156 tab.delimiter = QChar::fromLatin1(
'P');
1162 return d->m_headers.headerLocation(header);
1167 return d->m_footers.headerLocation(footer);
1172 return d->builder()->currentPosition();
1177 d->m_firstPageNumber = num;
1182 return d->m_firstPageNumber;
1185 void KDReports::Report::setupPrinter(QPrinter *printer)
1187 printer->setFullPage(
true);
1188 printer->setPageOrientation(d->m_orientation);
1190 printer->setPageSize(d->m_pageSize);
1191 printer->setDocName(d->m_documentName);
QMap< QString, QAbstractItemModel * > ModelMap
QT_BEGIN_NAMESPACE Q_GUI_EXPORT int qt_defaultDpi()
void setColumn(int column)
void setDriverMessage(const QString &message)
qreal textDocumentWidth() const
void paintPage(int pageNumber, QPainter &painter)
void debugLayoutToPdf(const char *fileName)
qreal rawMainTextDocHeight() const
void setPaperSizeFromPrinter(QSizeF paperSize)
bool doPrint(QPrinter *printer, QWidget *parent)
QSizeF layoutAsOnePage(qreal docWidth)
qreal mainTextDocHeight() const
bool skipHeadersFooters() const
QRect mainTextDocRect() const
ReportBuilder * builder() const
bool wantEndlessPrinting() const
ReportPrivate(Report *report)
void associateTextValue(const QString &id, const QString &value)
void addElement(const Element &element, Qt::AlignmentFlag horizontalAlignment=Qt::AlignLeft, const QColor &backgroundColor=QColor())
bool isTableBreakingEnabled() const
void setWatermarkPixmap(const QPixmap &pixmap, bool autoGrayOut=true)
void setWatermarkImage(const QImage &image)
QPageSize pageSize() const
qreal leftPageMargins() const
void setTopPageMargin(qreal top)
void setPageSize(QPageSize::PageSizeId size)
void setWatermarkText(const QString &text, int rotation=0, const QColor &color=QColor(204, 204, 204), const QFont &font=QFont(QStringLiteral("Helvetica"), 48))
QString watermarkText() const
Header & header(HeaderLocations hl=AllPages)
qreal headerBodySpacing() const
void setFontScalingFactor(qreal factor)
Scale the fonts in the document by a given factor.
qreal bottomPageMargins() const
QFont watermarkFont() const
qreal topPageMargins() const
bool print(QPrinter *printer, QWidget *parent=nullptr)
void setDefaultFont(const QFont &font)
static QTextOption::Tab rightAlignedTab()
void associateModel(const QString &modelKey, QAbstractItemModel *model)
void associateImageValue(const QString &id, const QPixmap &value)
Footer & footer(HeaderLocations hl=AllPages)
int currentPosition() const
bool exportToImage(QSize size, const QString &fileName, const char *format)
void getMargins(qreal *top, qreal *left, qreal *bottom, qreal *right) const
void paintPage(int pageNumber, QPainter &painter)
qreal rightPageMargins() const
int maximumNumberOfPagesForVerticalScaling() const
void setFixedRowHeight(qreal mm)
void setWatermarkFunction(WatermarkFunction function)
void setTableBreakingPageOrder(TableBreakingPageOrder pageOrder)
QPageLayout::Orientation pageOrientation() const
static QTextOption::Tab middleAlignedTab()
void setPaperSize(QSizeF paperSize, QPrinter::Unit unit)
void regenerateAutoTableForModel(QAbstractItemModel *model)
int watermarkRotation() const
QColor watermarkColor() const
void setTabPositions(const QList< QTextOption::Tab > &tabs)
static qreal mmToPixels(qreal mm)
QFont defaultFont() const
bool printWithDialog(QWidget *parent)
void setMargins(qreal top, qreal left, qreal bottom, qreal right)
void addVerticalSpacing(qreal space)
void setWidthForEndlessPrinter(qreal widthMM)
void addFragment(const QTextDocumentFragment &fragment)
int maximumNumberOfPagesForHorizontalScaling() const
void setHeaderLocation(HeaderLocations hl, Header *header)
void setXmlElementHandler(KDReports::XmlElementHandler *handler)
void setHeaderBodySpacing(qreal spacing)
void setProgressDialogEnabled(bool enable)
WatermarkFunction watermarkFunction() const
MainTable * mainTable() const
qreal fontScalingFactor() const
std::function< void(QPainter &, int)> WatermarkFunction
int numberOfPages() const
QTextDocument * mainTextDocument() const
bool exportToFile(const QString &fileName, QWidget *parent=nullptr)
void setCurrentRow(const QAbstractItemModel *model, int row)
ReportMode reportMode() const
void setParagraphMargins(qreal left, qreal top, qreal right, qreal bottom)
void setBottomPageMargin(qreal bottom)
void scaleTo(int numPagesHorizontally, int numPagesVertically)
Ensure that the report fits into a number of pages.
QImage watermarkImage() const
void setFirstPageNumber(int num)
Report(QObject *parent=nullptr)
QPixmap watermarkPixmap() const
qreal footerBodySpacing() const
KDReports::HeaderLocations footerLocation(KDReports::Footer *footer) const
bool exportToHtml(const QString &fileName)
void setLeftPageMargin(qreal left)
KDReports::HeaderLocations headerLocation(Header *header) const
void setRightPageMargin(qreal right)
void addInlineElement(const Element &element)
TableBreakingPageOrder tableBreakingPageOrder() const
void setReportMode(ReportMode reportMode)
void setFooterLocation(HeaderLocations hl, Footer *footer)
bool loadFromXML(QIODevice *iodevice, ErrorDetails *details=nullptr)
void regenerateAutoTables()
QString anchorAt(int pageNumber, QPoint pos) const
void setDocumentName(const QString &name)
void setPageOrientation(QPageLayout::Orientation orientation)
int firstPageNumber() const
void setFooterBodySpacing(qreal spacing)
QList< KDReports::AutoTableElement * > autoTableElements() const
QTextDocument & contentDocument()
bool processDocument(const QDomDocument &document, KDReports::ReportBuilder *builder)
KDREPORTS_EXPORT qreal mmToPixels(qreal mm)
KDREPORTS_EXPORT qreal pixelsToPointsMultiplier(double resolution)
QAbstractItemModel * modelForKey(const QString &key)
@ FirstPage
The first page of the report.
@ EvenPages
The even pages of the report: 2, 4, 6 etc.
@ LastPage
The last page of the report.
@ OddPages
The odd pages of the report: 1 (unless FirstPage has its own header), 3, 5, 7 etc.