KD Reports API Documentation  2.2
KDReportsSpreadsheetReportLayout_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 KDREPORTSSPREADSHEETREPORTLAYOUT_H
12 #define KDREPORTSSPREADSHEETREPORTLAYOUT_H
13 
15 #include "KDReportsReport.h"
16 #include "KDReportsTableLayout_p.h"
17 #include <QBrush>
18 
19 namespace KDReports {
20 class Report;
21 class MainTable;
22 
24 {
25 public:
27 
29  void setLayoutDirty() override;
31  void setDefaultFont(const QFont &font) override;
33  QFont defaultFont() const override;
35  void paintPageContent(int pageNumber, QPainter &painter) override;
37  int numberOfPages() override; // not const, since it can trigger a layout
39  qreal idealWidth() override;
41  void setPageContentSize(QSizeF size) override;
43  void ensureLayouted() override;
45  void updateTextValue(const QString &id, const QString &newValue) override;
47  qreal layoutAsOnePage(qreal width) override;
49  bool scaleTo(int numPagesHorizontally, int numPagesVertically) override;
51  void setFixedRowHeight(qreal height) override;
57  void setUserRequestedFontScalingFactor(qreal factor) override;
59  qreal userRequestedFontScalingFactor() const override;
61  QString anchorAt(int pageNumber, QPoint pos) override;
63  QString toHtml() const override;
65  void finishHtmlExport() override;
66 
67  void setModel(QAbstractItemModel *model);
68  void setVerticalHeaderVisible(bool visible);
69  void setHorizontalHeaderVisible(bool visible);
70  void setCellPadding(qreal padding);
71  void setIconSize(QSize iconSize);
72  void setCellBorder(qreal border, const QBrush &borderBrush);
73  void setHeaderBackground(const QBrush &headerBackground);
74 
76  {
77  return m_tableBreakingPageOrder;
78  }
80  void setHorizontalHeaderFont(const QFont &font);
81  void setVerticalHeaderFont(const QFont &font);
82 
83 private:
84  void drawBorder(const QRectF &cellRect, QPainter &painter) const;
85  void breakHorizontally();
86  // Return sum of m_tableLayout.m_columnWidths; caller must ensure updateColumnWidths was called before.
87  qreal totalWidth() const;
88  qreal cellWidth(int col, int horizSpan) const;
89  qreal paintTableVerticalHeader(qreal x, qreal y, QPainter &painter, int row);
90  void paintTableHorizontalHeader(const QRectF &cellRect, QPainter &painter, int col);
91  void paintIcon(QPainter &painter, const QRectF &cellContentsRect, const QVariant &cellDecoration) const;
92  void paintTextAndIcon(QPainter &painter, const QRectF &cellContentsRect, const QString &cellText, const QVariant &cellDecoration, const QVariant &decorationAlignment, Qt::Alignment alignment);
93 
94  KDReports::TableLayout m_tableLayout;
95  KDReports::Report::TableBreakingPageOrder m_tableBreakingPageOrder;
96  int m_numHorizontalPages; // for scaleTo(). 1 if not set.
97  int m_numVerticalPages; // for scaleTo(). "Maximum" number of vertical pages. 0 if not set.
98  bool m_layoutDirty;
99  qreal m_userRequestedFontScalingFactor; // for scaleFontsBy(), 1.0 otherwise.
100  QSizeF m_pageContentSize;
101 
102  // table-specific settings used during painting (and not during layouting)
103  struct TableSettings
104  {
105  TableSettings()
106  : m_border(1.0)
107  , m_borderBrush(Qt::gray)
108  , m_headerBackground(Qt::gray)
109  {
110  }
111  qreal m_border;
112  QBrush m_borderBrush;
113  QBrush m_headerBackground;
114  };
115  TableSettings m_tableSettings;
116 
117  // The result of the layout:
118  // a list of rects, each rect points to an "area" of the table
119  // (in number of cells). For instance
120  // Page 0 -> QRect(0,0,20,10), page 1 -> QRect(20,0,15,10)
121  QList<QRect> m_pageRects;
122  friend class MainTable;
123 };
124 
125 }
126 
127 #endif // KDREPORTSSPREADSHEETREPORTLAYOUT_H
int maximumNumberOfPagesForVerticalScaling() const override
Reimplemented for internal purposes. .
void setTableBreakingPageOrder(KDReports::Report::TableBreakingPageOrder order)
int maximumNumberOfPagesForHorizontalScaling() const override
Reimplemented for internal purposes. .
QString toHtml() const override
Reimplemented for internal purposes. .
KDReports::Report::TableBreakingPageOrder tableBreakingPageOrder() const
int numberOfPages() override
Reimplemented for internal purposes. .
void setVerticalHeaderVisible(bool visible)
void setCellBorder(qreal border, const QBrush &borderBrush)
void setUserRequestedFontScalingFactor(qreal factor) override
Reimplemented for internal purposes. .
void ensureLayouted() override
Reimplemented for internal purposes. .
bool scaleTo(int numPagesHorizontally, int numPagesVertically) override
Reimplemented for internal purposes. .
void setPageContentSize(QSizeF size) override
Reimplemented for internal purposes. .
void updateTextValue(const QString &id, const QString &newValue) override
Reimplemented for internal purposes. .
void setHorizontalHeaderFont(const QFont &font)
QFont defaultFont() const override
Reimplemented for internal purposes. .
void setHeaderBackground(const QBrush &headerBackground)
qreal idealWidth() override
Reimplemented for internal purposes. .
void paintPageContent(int pageNumber, QPainter &painter) override
Reimplemented for internal purposes. .
QString anchorAt(int pageNumber, QPoint pos) override
Reimplemented for internal purposes. .
void setCellPadding(qreal padding)
void finishHtmlExport() override
Reimplemented for internal purposes. .
void setDefaultFont(const QFont &font) override
Reimplemented for internal purposes. .
qreal userRequestedFontScalingFactor() const override
Reimplemented for internal purposes. .
qreal layoutAsOnePage(qreal width) override
Reimplemented for internal purposes. .
void setVerticalHeaderFont(const QFont &font)
void setFixedRowHeight(qreal height) override
Reimplemented for internal purposes. .
void setHorizontalHeaderVisible(bool visible)
void setLayoutDirty() override
Reimplemented for internal purposes. .

© 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 by doxygen 1.9.1