KD Reports API Documentation  2.2
KDReportsCell.cpp
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 #include "KDReportsCell.h"
12 #include "KDReportsElement.h"
13 #include "KDReportsElementData_p.h"
15 
16 class KDReports::CellPrivate
17 {
18 public:
19  QList<ElementData> m_elements;
20  int m_columnSpan = 1;
21  int m_rowSpan = 1;
22  Qt::AlignmentFlag m_verticalAlignment = Qt::AlignmentFlag(0);
23  Cell::CellFormatFunc m_cellFormatFunc;
24 };
25 
27  : d(new CellPrivate)
28 {
29 }
30 
32  : Element(other)
33  , d(new CellPrivate(*other.d))
34 {
35 }
36 
38 {
39  if (&other == this)
40  return *this;
41  Element::operator=(other);
42  *d = *other.d;
43  return *this;
44 }
45 
47 {
48 }
49 
50 void KDReports::Cell::setColumnSpan(int columnSpan)
51 {
52  d->m_columnSpan = columnSpan;
53 }
54 
56 {
57  return d->m_columnSpan;
58 }
59 
60 void KDReports::Cell::setRowSpan(int rowSpan)
61 {
62  d->m_rowSpan = rowSpan;
63 }
64 
66 {
67  return d->m_rowSpan;
68 }
69 
71 {
72  d->m_elements.append(KDReports::ElementData(element.clone()));
73 }
74 
75 void KDReports::Cell::addElement(const Element &element, Qt::AlignmentFlag horizontalAlignment)
76 {
77  d->m_elements.append(KDReports::ElementData(element.clone(), horizontalAlignment));
78 }
79 
81 {
82  d->m_elements.append(KDReports::ElementData(variable));
83 }
84 
86 {
88 }
89 
90 void KDReports::Cell::setVerticalAlignment(Qt::AlignmentFlag verticalAlignment)
91 {
92  d->m_verticalAlignment = verticalAlignment;
93 }
94 
95 Qt::AlignmentFlag KDReports::Cell::verticalAlignment() const
96 {
97  return d->m_verticalAlignment;
98 }
99 
101 {
102  d->m_cellFormatFunc = func;
103 }
104 
106 {
107  return d->m_cellFormatFunc;
108 }
109 
111 {
112  foreach (const KDReports::ElementData &ed, d->m_elements) {
113  switch (ed.m_type) {
115  builder.addInlineElement(*ed.m_element);
116  break;
118  builder.addBlockElement(*ed.m_element, ed.m_align);
119  break;
121  builder.addVariable(ed.m_variableType);
122  break;
124  builder.addVerticalSpacing(ed.m_value);
125  break;
126  }
127  }
128 }
Cell & operator=(const Cell &other)
void addVerticalSpacing(qreal space)
void addElement(const Element &element, Qt::AlignmentFlag horizontalAlignment=Qt::AlignLeft)
void setVerticalAlignment(Qt::AlignmentFlag verticalAlignment)
Set the vertical alignment of the cell contents.
void addInlineElement(const Element &element)
void setColumnSpan(int columnSpan)
Cell(const Cell &other)
void setRowSpan(int rowSpan)
void build(ReportBuilder &builder) const override
int rowSpan() const
void addVariable(VariableType variable)
void setCellFormatFunction(const CellFormatFunc &func)
Sets the function to call in order to customize the format of the cell.
Qt::AlignmentFlag verticalAlignment() const
Returns the vertical alignment of the cell contents.
CellFormatFunc cellFormatFunction() const
Returns the function passed to setCellFormatFunction()
std::function< void(int, int, QTextTableCellFormat &)> CellFormatFunc
Definition: KDReportsCell.h:95
~Cell() override
int columnSpan() const
virtual Element * clone() const =0
Element & operator=(const Element &other)
virtual void addVerticalSpacing(qreal space)
virtual void addBlockElement(const Element &element, Qt::AlignmentFlag horizontalAlignment, const QColor &backgroundColor=QColor())
virtual void addVariable(KDReports::VariableType variable)
virtual void addInlineElement(const Element &element)
KDReports::VariableType m_variableType

© 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