11 #ifndef KDREPORTSREPORT_H
12 #define KDREPORTSREPORT_H
22 #include <QTextOption>
28 class QTextDocumentFragment;
32 class QAbstractItemModel;
45 class HeaderReportBuilder;
81 Q_PROPERTY(QString documentName READ documentName WRITE setDocumentName)
88 explicit Report(QObject *parent =
nullptr);
119 void setReportMode(ReportMode reportMode);
125 ReportMode reportMode()
const;
131 void setDefaultFont(
const QFont &font);
137 QFont defaultFont()
const;
151 void addInlineElement(
const Element &element);
167 void addElement(
const Element &element, Qt::AlignmentFlag horizontalAlignment = Qt::AlignLeft,
const QColor &backgroundColor = QColor());
174 void addVerticalSpacing(qreal space);
182 void addFragment(
const QTextDocumentFragment &fragment);
225 static QTextOption::Tab rightAlignedTab();
233 static QTextOption::Tab middleAlignedTab();
240 void setParagraphMargins(qreal left, qreal top, qreal right, qreal bottom);
242 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
249 void setPageSize(QPrinter::PageSize size);
257 void setPageSize(QPageSize::PageSizeId size);
264 void setPageSize(
const QPageSize &size);
266 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
270 QPrinter::PageSize pageSize()
const;
275 QPageSize pageSize()
const;
284 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
289 Q_DECL_DEPRECATED
void setOrientation(QPrinter::Orientation orientation);
294 Q_DECL_DEPRECATED QPrinter::Orientation orientation()
const;
300 void setPageOrientation(QPageLayout::Orientation orientation);
304 QPageLayout::Orientation pageOrientation()
const;
319 void setWidthForEndlessPrinter(qreal widthMM);
324 void setMargins(qreal top, qreal left, qreal bottom, qreal right);
329 void getMargins(qreal *top, qreal *left, qreal *bottom, qreal *right)
const;
335 void setTopPageMargin(qreal top);
341 qreal topPageMargins()
const;
347 void setLeftPageMargin(qreal left);
353 qreal leftPageMargins()
const;
359 void setRightPageMargin(qreal right);
365 qreal rightPageMargins()
const;
371 void setBottomPageMargin(qreal bottom);
377 qreal bottomPageMargins()
const;
384 void setHeaderBodySpacing(qreal spacing);
390 qreal headerBodySpacing()
const;
397 void setFooterBodySpacing(qreal spacing);
403 qreal footerBodySpacing()
const;
438 void associateModel(
const QString &modelKey, QAbstractItemModel *model);
450 void associateTextValue(
const QString &
id,
const QString &value);
461 void associateImageValue(
const QString &
id,
const QPixmap &value);
476 void associateImageValue(
const QString &
id,
const QImage &value);
488 bool loadFromXML(QIODevice *iodevice,
ErrorDetails *details =
nullptr);
502 bool loadFromXML(
const QDomDocument &doc,
ErrorDetails *details =
nullptr);
520 void setCurrentRow(
const QAbstractItemModel *model,
int row);
527 void setDocumentName(
const QString &name);
533 QString documentName()
const;
545 void setProgressDialogEnabled(
bool enable);
553 bool printWithDialog(QWidget *parent);
568 bool print(QPrinter *printer, QWidget *parent =
nullptr);
578 bool exportToFile(
const QString &fileName, QWidget *parent =
nullptr);
586 bool exportToImage(QSize size,
const QString &fileName,
const char *format);
595 bool exportToHtml(
const QString &fileName);
604 void paintPage(
int pageNumber, QPainter &painter);
611 void setFirstPageNumber(
int num);
616 int firstPageNumber()
const;
621 int numberOfPages()
const;
626 bool isTableBreakingEnabled()
const;
641 void setTableBreakingPageOrder(TableBreakingPageOrder pageOrder);
647 TableBreakingPageOrder tableBreakingPageOrder()
const;
658 void setFontScalingFactor(qreal factor);
664 qreal fontScalingFactor()
const;
686 void scaleTo(
int numPagesHorizontally,
int numPagesVertically);
692 int maximumNumberOfPagesForHorizontalScaling()
const;
697 int maximumNumberOfPagesForVerticalScaling()
const;
704 void setFixedRowHeight(qreal mm);
721 void regenerateAutoTables();
728 void regenerateAutoTableForModel(QAbstractItemModel *model);
739 void setWatermarkText(
const QString &text,
int rotation = 0,
const QColor &color = QColor(204, 204, 204),
const QFont &font = QFont(QStringLiteral(
"Helvetica"), 48));
744 QString watermarkText()
const;
749 int watermarkRotation()
const;
754 QColor watermarkColor()
const;
759 QFont watermarkFont()
const;
771 void setWatermarkPixmap(
const QPixmap &pixmap,
bool autoGrayOut =
true);
778 QPixmap watermarkPixmap()
const;
784 void setWatermarkImage(
const QImage &image);
790 QImage watermarkImage()
const;
812 KDReports::HeaderLocations headerLocation(
Header *header)
const;
824 void setHeaderLocation(HeaderLocations hl,
Header *header);
830 void setFooterLocation(HeaderLocations hl,
Footer *footer);
843 QSizeF paperSize()
const;
853 int currentPosition()
const;
883 QString anchorAt(
int pageNumber, QPoint pos)
const;
897 QTextDocument *mainTextDocument()
const;
910 friend class ::ReportData;
911 friend class ::EditorData;
914 QString asHtml()
const;
916 void setupPrinter(QPrinter *printer);
925 friend class PreviewDialogPrivate;
926 friend class PreviewWidgetPrivate;
std::function< void(QPainter &, int)> WatermarkFunction
void printingProgress(int pageIndex)
KDREPORTS_EXPORT qreal mmToPixels(qreal mm)
@ AllPages
All pages (except first and last if FirstPage or LastPage have their own headers)
@ 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.