KD Reports API Documentation  2.0
KDReportsHLineElement.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 "KDReportsHLineElement.h"
19 #include "KDReportsLayoutHelper_p.h" // mmToPixels
21 #include <QDebug>
22 
23 class KDReports::HLineElementPrivate
24 {
25 public:
26  QString m_id;
27  QColor m_color;
28 
29  qreal m_thickness;
30  int m_margin;
31 };
32 
34  : Element()
35  , d(new HLineElementPrivate)
36 {
37  d->m_color = Qt::gray;
38  d->m_thickness = 2;
39  d->m_margin = 6;
40 }
41 
43  : Element(other)
44  , d(new HLineElementPrivate(*other.d))
45 {
46 }
47 
49 {
50  if (&other == this)
51  return *this;
52  Element::operator=(other);
53  *d = *other.d;
54  return *this;
55 }
56 
58 {
59  delete d;
60 }
61 
62 void KDReports::HLineElement::setColor(const QColor &color)
63 {
64  d->m_color = color;
65 }
66 
68 {
69  return d->m_color;
70 }
71 
73 {
74  d->m_thickness = t;
75 }
76 
78 {
79  return d->m_thickness;
80 }
81 
83 {
84  d->m_margin = m; // in mm
85 }
86 
88 {
89  return d->m_margin;
90 }
91 
93 {
94  QTextCursor &cursor = builder.cursor();
95 
96  QTextCharFormat fmt;
97 
98  fmt.setObjectType(HLineTextObject::HLineTextFormat);
99  fmt.setProperty(HLineTextObject::Color, d->m_color);
100  fmt.setProperty(HLineTextObject::Thickness, d->m_thickness);
101  // qDebug() << "Setting Margin to" << d->m_margin << "mm" << mmToPixels( d->m_margin ) << "px";
102  fmt.setProperty(HLineTextObject::Margin, double(mmToPixels(d->m_margin)));
103 
104  cursor.insertText(QString(QChar::ObjectReplacementCharacter), fmt);
105 }
106 
108 {
109  return new HLineElement(*this);
110 }
KDReports::HLineElement::setThickness
void setThickness(qreal t)
Definition: KDReportsHLineElement.cpp:72
KDReports::HLineElement::setMargin
void setMargin(int m)
Definition: KDReportsHLineElement.cpp:82
KDReports::ReportBuilder
Definition: KDReportsReportBuilder_p.h:41
KDReportsHLineTextObject_p.h
KDReports::HLineElement
Definition: KDReportsHLineElement.h:36
KDReports::HLineElement::setColor
void setColor(const QColor &color)
Definition: KDReportsHLineElement.cpp:62
KDReports::HLineElement::color
QColor color() const
Definition: KDReportsHLineElement.cpp:67
KDReports::Element
Definition: KDReportsElement.h:39
KDReports::HLineElement::HLineElement
HLineElement()
Definition: KDReportsHLineElement.cpp:33
KDReports::HLineTextObject::Color
@ Color
Definition: KDReportsHLineTextObject_p.h:40
KDReports::HLineElement::~HLineElement
~HLineElement() override
Definition: KDReportsHLineElement.cpp:57
KDReports::HLineElement::margin
int margin() const
Definition: KDReportsHLineElement.cpp:87
KDReports::HLineTextObject::Thickness
@ Thickness
Definition: KDReportsHLineTextObject_p.h:41
KDReports::HLineElement::clone
Element * clone() const override
Definition: KDReportsHLineElement.cpp:107
KDReports::Element::operator=
Element & operator=(const Element &other)
Definition: KDReportsElement.cpp:36
KDReports::HLineElement::operator=
HLineElement & operator=(const HLineElement &other)
Definition: KDReportsHLineElement.cpp:48
KDReportsReportBuilder_p.h
KDReports::HLineTextObject::Margin
@ Margin
Definition: KDReportsHLineTextObject_p.h:42
KDReports::mmToPixels
KDREPORTS_EXPORT qreal mmToPixels(qreal mm)
Definition: KDReportsLayoutHelper.cpp:23
KDReportsLayoutHelper_p.h
KDReports::ReportBuilder::cursor
QTextCursor & cursor()
Definition: KDReportsReportBuilder_p.h:48
KDReportsHLineElement.h
KDReports::HLineTextObject::HLineTextFormat
@ HLineTextFormat
Definition: KDReportsHLineTextObject_p.h:39
KDReports::HLineElement::build
void build(ReportBuilder &builder) const override
Definition: KDReportsHLineElement.cpp:92
KDReports::HLineElement::thickness
qreal thickness() const
Definition: KDReportsHLineElement.cpp:77

© 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