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

© 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 Fri Jul 15 2022 13:09:06 for KD Reports API Documentation by doxygen 1.8.20