KD Reports API Documentation  2.0
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-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 #include "KDReportsCell.h"
18 #include "KDReportsElement.h"
19 #include "KDReportsElementData_p.h"
21 
22 class KDReports::CellPrivate
23 {
24 public:
25  CellPrivate()
26  : m_columnSpan(1)
27  , m_rowSpan(1)
28  {
29  }
30  ~CellPrivate() { }
31  QList<ElementData> m_elements;
32  int m_columnSpan;
33  int m_rowSpan;
34 };
35 
37  : d(new CellPrivate)
38 {
39 }
40 
42  : Element(other)
43  , d(new CellPrivate(*other.d))
44 {
45 }
46 
48 {
49  if (&other == this)
50  return *this;
51  Element::operator=(other);
52  *d = *other.d;
53  return *this;
54 }
55 
57 {
58  delete d;
59 }
60 
61 void KDReports::Cell::setColumnSpan(int columnSpan)
62 {
63  d->m_columnSpan = columnSpan;
64 }
65 
67 {
68  return d->m_columnSpan;
69 }
70 
71 void KDReports::Cell::setRowSpan(int rowSpan)
72 {
73  d->m_rowSpan = rowSpan;
74 }
75 
77 {
78  return d->m_rowSpan;
79 }
80 
82 {
83  d->m_elements.append(KDReports::ElementData(element.clone()));
84 }
85 
86 void KDReports::Cell::addElement(const Element &element, Qt::AlignmentFlag horizontalAlignment)
87 {
88  d->m_elements.append(KDReports::ElementData(element.clone(), horizontalAlignment));
89 }
90 
92 {
93  d->m_elements.append(KDReports::ElementData(variable));
94 }
95 
97 {
98  foreach (const KDReports::ElementData &ed, d->m_elements) {
99  switch (ed.m_type) {
101  builder.addInlineElement(*ed.m_element);
102  break;
104  builder.addBlockElement(*ed.m_element, ed.m_align);
105  break;
107  builder.addVariable(ed.m_variableType);
108  break;
109  }
110  }
111 }
KDReports::ReportBuilder
Definition: KDReportsReportBuilder_p.h:41
KDReports::Cell::build
void build(ReportBuilder &builder) const override
Definition: KDReportsCell.cpp:96
KDReports::ElementData::m_type
Type m_type
Definition: KDReportsElementData_p.h:107
KDReports::ElementData::m_element
Element * m_element
Definition: KDReportsElementData_p.h:106
KDReports::ElementData::Inline
@ Inline
Definition: KDReportsElementData_p.h:85
QList
Definition: KDReportsAbstractTableElement.h:25
KDReports::ElementData::m_variableType
KDReports::VariableType m_variableType
Definition: KDReportsElementData_p.h:109
KDReports::Element
Definition: KDReportsElement.h:39
KDReports::Element::clone
virtual Element * clone() const =0
KDReportsElement.h
KDReports::ElementData::Block
@ Block
Definition: KDReportsElementData_p.h:86
KDReports::Cell::addInlineElement
void addInlineElement(const Element &element)
Definition: KDReportsCell.cpp:81
KDReports::Cell::Cell
Cell(const Cell &other)
Definition: KDReportsCell.cpp:41
KDReports::Element::operator=
Element & operator=(const Element &other)
Definition: KDReportsElement.cpp:36
KDReports::ReportBuilder::addVariable
virtual void addVariable(KDReports::VariableType variable)
Definition: KDReportsReportBuilder.cpp:87
KDReports::ElementData
Definition: KDReportsElementData_p.h:55
KDReports::Cell
Definition: KDReportsCell.h:52
KDReportsReportBuilder_p.h
KDReports::ReportBuilder::addInlineElement
virtual void addInlineElement(const Element &element)
Definition: KDReportsReportBuilder.cpp:34
KDReports::ElementData::Variable
@ Variable
Definition: KDReportsElementData_p.h:87
KDReports::Cell::operator=
Cell & operator=(const Cell &other)
Definition: KDReportsCell.cpp:47
KDReports::Cell::setColumnSpan
void setColumnSpan(int columnSpan)
Definition: KDReportsCell.cpp:61
KDReportsCell.h
KDReportsElementData_p.h
KDReports::Cell::addElement
void addElement(const Element &element, Qt::AlignmentFlag horizontalAlignment=Qt::AlignLeft)
Definition: KDReportsCell.cpp:86
KDReports::ReportBuilder::addBlockElement
virtual void addBlockElement(const Element &element, Qt::AlignmentFlag horizontalAlignment, const QColor &backgroundColor=QColor())
Definition: KDReportsReportBuilder.cpp:47
KDReports::Cell::columnSpan
int columnSpan() const
Definition: KDReportsCell.cpp:66
KDReports::VariableType
VariableType
Definition: KDReportsVariableType.h:29
KDReports::Cell::rowSpan
int rowSpan() const
Definition: KDReportsCell.cpp:76
KDReports::Cell::addVariable
void addVariable(VariableType variable)
Definition: KDReportsCell.cpp:91
KDReports::ElementData::m_align
Qt::AlignmentFlag m_align
Definition: KDReportsElementData_p.h:110
KDReports::Cell::setRowSpan
void setRowSpan(int rowSpan)
Definition: KDReportsCell.cpp:71
KDReports::Cell::~Cell
~Cell() override
Definition: KDReportsCell.cpp:56

© 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