KD Reports API Documentation  2.0
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-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 
17 #ifndef KDREPORTSTABLELAYOUT_H
18 #define KDREPORTSTABLELAYOUT_H
19 
20 #include "KDReportsFontScaler_p.h"
21 #include <QFont>
22 #include <QVector>
23 
24 QT_BEGIN_NAMESPACE
25 class QAbstractItemModel;
26 QT_END_NAMESPACE
27 
28 namespace KDReports {
29 
31 {
32 public:
33  TableLayout();
34 
35  void setInitialFontScalingFactor(qreal fontScalingFactor);
36 
37  // Determine "ideal" column widths, based on contents
38  void updateColumnWidths();
39  // Return row height (determined during call to columnWidths), padding included
40  qreal rowHeight() const { return m_rowHeight; }
41  // Return the width of the vertical header, 0 if not shown
42  qreal vHeaderWidth() const { return m_vHeaderWidth; }
43  // Return the height of the horizontal header, 0 if not shown
44  qreal hHeaderHeight() const { return m_hHeaderHeight; }
45 
46  // void updateColumnWidthsByFactor( qreal factor );
47 
48  QFont scaledFont() const { return m_cellFontScaler.font(); }
49  QFont horizontalHeaderScaledFont() const { return m_horizontalHeaderFontScaler.font(); }
50  QFont verticalHeaderScaledFont() const { return m_verticalHeaderFontScaler.font(); }
51 
52  // QFontMetricsF scaledFontMetrics() const { return m_cellFontScaler.fontMetrics(); }
53  qreal scalingFactor() const { return m_cellFontScaler.scalingFactor(); }
55  void ensureScalingFactorForHeight(qreal maxRowHeight);
56  qreal scaledCellPadding() const { return m_cellPadding * scalingFactor(); }
57 
58  QSize decorationSize(const QVariant &cellDecoration) const;
59 
60  QAbstractItemModel *m_model;
61 
62  QFont m_cellFont;
65 
68 
69  // All measurements below are in pixels
71  QVector<qreal> m_columnWidths;
73 
74  QVector<QString> m_widestTextPerColumn;
75 
76  QSize m_iconSize;
77 
78 private:
79  qreal addIconWidth(qreal textWidth, const QVariant &cellDecoration) const;
80  void updateRowHeight();
81 
82  qreal m_rowHeight;
83  qreal m_vHeaderWidth;
84  qreal m_hHeaderHeight;
85 
86  FontScaler m_cellFontScaler;
87  FontScaler m_horizontalHeaderFontScaler;
88  FontScaler m_verticalHeaderFontScaler;
89 };
90 
91 }
92 
93 #endif /* KDREPORTSTABLELAYOUT_H */
KDReports::TableLayout::m_horizontalHeaderVisible
bool m_horizontalHeaderVisible
Definition: KDReportsTableLayout_p.h:66
KDReports::TableLayout::m_verticalHeaderVisible
bool m_verticalHeaderVisible
Definition: KDReportsTableLayout_p.h:67
KDReports::TableLayout::verticalHeaderScaledFont
QFont verticalHeaderScaledFont() const
Definition: KDReportsTableLayout_p.h:50
KDReports::TableLayout::horizontalHeaderScaledFont
QFont horizontalHeaderScaledFont() const
Definition: KDReportsTableLayout_p.h:49
KDReports::TableLayout::ensureScalingFactorForWidth
void ensureScalingFactorForWidth(qreal scalingFactor)
Definition: KDReportsTableLayout.cpp:168
KDReports::FontScaler::font
QFont font() const
Definition: KDReportsFontScaler_p.h:81
KDReports::TableLayout::m_verticalHeaderFont
QFont m_verticalHeaderFont
Definition: KDReportsTableLayout_p.h:64
KDReports::TableLayout
Definition: KDReportsTableLayout_p.h:30
KDReports::TableLayout::TableLayout
TableLayout()
Definition: KDReportsTableLayout.cpp:26
KDReports::TableLayout::m_fixedRowHeight
qreal m_fixedRowHeight
Definition: KDReportsTableLayout_p.h:72
KDReports::FontScaler::scalingFactor
qreal scalingFactor() const
Definition: KDReportsFontScaler_p.h:83
KDReports::TableLayout::m_columnWidths
QVector< qreal > m_columnWidths
Definition: KDReportsTableLayout_p.h:71
KDReports::TableLayout::m_iconSize
QSize m_iconSize
Definition: KDReportsTableLayout_p.h:76
KDReports::TableLayout::updateColumnWidths
void updateColumnWidths()
Definition: KDReportsTableLayout.cpp:79
KDReports::TableLayout::scaledFont
QFont scaledFont() const
Definition: KDReportsTableLayout_p.h:48
KDReports::FontScaler
Definition: KDReportsFontScaler_p.h:56
KDReportsFontScaler_p.h
KDReports::TableLayout::m_widestTextPerColumn
QVector< QString > m_widestTextPerColumn
Definition: KDReportsTableLayout_p.h:74
KDReports::TableLayout::rowHeight
qreal rowHeight() const
Definition: KDReportsTableLayout_p.h:40
KDReports::TableLayout::m_model
QAbstractItemModel * m_model
Definition: KDReportsTableLayout_p.h:60
KDReports::TableLayout::m_cellFont
QFont m_cellFont
Definition: KDReportsTableLayout_p.h:62
KDReports::TableLayout::ensureScalingFactorForHeight
void ensureScalingFactorForHeight(qreal maxRowHeight)
Definition: KDReportsTableLayout.cpp:195
KDReports::TableLayout::scaledCellPadding
qreal scaledCellPadding() const
Definition: KDReportsTableLayout_p.h:56
KDReports::TableLayout::m_horizontalHeaderFont
QFont m_horizontalHeaderFont
Definition: KDReportsTableLayout_p.h:63
KDReports::TableLayout::setInitialFontScalingFactor
void setInitialFontScalingFactor(qreal fontScalingFactor)
Definition: KDReportsTableLayout.cpp:45
KDReports::TableLayout::scalingFactor
qreal scalingFactor() const
Definition: KDReportsTableLayout_p.h:53
KDReports::TableLayout::decorationSize
QSize decorationSize(const QVariant &cellDecoration) const
Definition: KDReportsTableLayout.cpp:251
KDReports::TableLayout::m_cellPadding
qreal m_cellPadding
Definition: KDReportsTableLayout_p.h:70
KDReports::TableLayout::vHeaderWidth
qreal vHeaderWidth() const
Definition: KDReportsTableLayout_p.h:42
KDReports::TableLayout::hHeaderHeight
qreal hHeaderHeight() const
Definition: KDReportsTableLayout_p.h:44
KDReports
Definition: KDReportsAbstractReportLayout_p.h:30

© 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