KD Reports API Documentation  2.2
KDReportsTableLayout_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 KDREPORTSTABLELAYOUT_H
12 #define KDREPORTSTABLELAYOUT_H
13 
14 #include "KDReportsFontScaler_p.h"
15 #include <QFont>
16 #include <QVector>
17 
18 QT_BEGIN_NAMESPACE
19 class QAbstractItemModel;
20 QT_END_NAMESPACE
21 
22 namespace KDReports {
23 
25 {
26 public:
27  TableLayout();
28 
29  void setInitialFontScalingFactor(qreal fontScalingFactor);
30 
31  // Determine "ideal" column widths, based on contents
32  void updateColumnWidths();
33  // Return row height (determined during call to columnWidths), padding included
34  qreal rowHeight() const
35  {
36  return m_rowHeight;
37  }
38  // Return the width of the vertical header, 0 if not shown
39  qreal vHeaderWidth() const
40  {
41  return m_vHeaderWidth;
42  }
43  // Return the height of the horizontal header, 0 if not shown
44  qreal hHeaderHeight() const
45  {
46  return m_hHeaderHeight;
47  }
48 
49  // void updateColumnWidthsByFactor( qreal factor );
50 
51  QFont scaledFont() const
52  {
53  return m_cellFontScaler.font();
54  }
56  {
57  return m_horizontalHeaderFontScaler.font();
58  }
60  {
61  return m_verticalHeaderFontScaler.font();
62  }
63 
64  // QFontMetricsF scaledFontMetrics() const { return m_cellFontScaler.fontMetrics(); }
65  qreal scalingFactor() const
66  {
67  return m_cellFontScaler.scalingFactor();
68  }
70  void ensureScalingFactorForHeight(qreal maxRowHeight);
71  qreal scaledCellPadding() const
72  {
73  return m_cellPadding * scalingFactor();
74  }
75 
76  QSize decorationSize(const QVariant &cellDecoration) const;
77 
78  QAbstractItemModel *m_model;
79 
80  QFont m_cellFont;
83 
86 
87  // All measurements below are in pixels
89  QVector<qreal> m_columnWidths;
91 
92  QVector<QString> m_widestTextPerColumn;
93 
94  QSize m_iconSize;
95 
96 private:
97  qreal addIconWidth(qreal textWidth, const QVariant &cellDecoration) const;
98  void updateRowHeight();
99 
100  qreal m_rowHeight;
101  qreal m_vHeaderWidth;
102  qreal m_hHeaderHeight;
103 
104  FontScaler m_cellFontScaler;
105  FontScaler m_horizontalHeaderFontScaler;
106  FontScaler m_verticalHeaderFontScaler;
107 };
108 
109 }
110 
111 #endif /* KDREPORTSTABLELAYOUT_H */
QFont horizontalHeaderScaledFont() const
QAbstractItemModel * m_model
QSize decorationSize(const QVariant &cellDecoration) const
void ensureScalingFactorForHeight(qreal maxRowHeight)
void setInitialFontScalingFactor(qreal fontScalingFactor)
QVector< QString > m_widestTextPerColumn
void ensureScalingFactorForWidth(qreal scalingFactor)
QFont verticalHeaderScaledFont() const

© 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