KD Reports API Documentation  2.1
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 }
60 
62 {
63  d->m_color = color;
64 }
65 
67 {
68  return d->m_color;
69 }
70 
72 {
73  d->m_thickness = t;
74 }
75 
77 {
78  return d->m_thickness;
79 }
80 
82 {
83  d->m_margin = m; // in mm
84 }
85 
87 {
88  return d->m_margin;
89 }
90 
92 {
93  QTextCursor &cursor = builder.cursor();
94 
95  QTextCharFormat fmt;
96 
98  fmt.setProperty(HLineTextObject::Color, d->m_color);
99  fmt.setProperty(HLineTextObject::Thickness, d->m_thickness);
100  // qDebug() << "Setting Margin to" << d->m_margin << "mm" << mmToPixels( d->m_margin ) << "px";
101  fmt.setProperty(HLineTextObject::Margin, double(mmToPixels(d->m_margin)));
102 
104 }
105 
107 {
108  return new HLineElement(*this);
109 }
KDReports::HLineTextObject::Margin
@ Margin
Definition: KDReportsHLineTextObject_p.h:42
KDReports::HLineElement::setThickness
void setThickness(qreal t)
Definition: KDReportsHLineElement.cpp:71
QColor
KDReports::HLineElement::setMargin
void setMargin(int m)
Definition: KDReportsHLineElement.cpp:81
KDReports::ReportBuilder
Definition: KDReportsReportBuilder_p.h:42
KDReportsHLineTextObject_p.h
KDReports::HLineElement
Definition: KDReportsHLineElement.h:37
KDReports::HLineTextObject::Thickness
@ Thickness
Definition: KDReportsHLineTextObject_p.h:41
QTextCharFormat
KDReports::HLineElement::setColor
void setColor(const QColor &color)
Definition: KDReportsHLineElement.cpp:61
KDReports::HLineElement::color
QColor color() const
Definition: KDReportsHLineElement.cpp:66
KDReports::Element
Definition: KDReportsElement.h:41
QTextFormat::setObjectType
void setObjectType(int type)
KDReports::HLineElement::HLineElement
HLineElement()
Definition: KDReportsHLineElement.cpp:33
KDReports::HLineElement::~HLineElement
~HLineElement() override
Definition: KDReportsHLineElement.cpp:57
KDReports::HLineElement::margin
int margin() const
Definition: KDReportsHLineElement.cpp:86
KDReports::HLineTextObject::Color
@ Color
Definition: KDReportsHLineTextObject_p.h:40
KDReports::HLineElement::clone
Element * clone() const override
Definition: KDReportsHLineElement.cpp:106
QString
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
QChar::ObjectReplacementCharacter
ObjectReplacementCharacter
QTextFormat::setProperty
void setProperty(int propertyId, const QVariant &value)
KDReports::HLineTextObject::HLineTextFormat
@ HLineTextFormat
Definition: KDReportsHLineTextObject_p.h:39
KDReports::mmToPixels
KDREPORTS_EXPORT qreal mmToPixels(qreal mm)
Definition: KDReportsLayoutHelper.cpp:23
KDReportsLayoutHelper_p.h
QTextCursor::insertText
void insertText(const QString &text)
KDReports::ReportBuilder::cursor
QTextCursor & cursor()
Definition: KDReportsReportBuilder_p.h:48
KDReportsHLineElement.h
KDReports::HLineElement::build
void build(ReportBuilder &builder) const override
Definition: KDReportsHLineElement.cpp:91
KDReports::HLineElement::thickness
qreal thickness() const
Definition: KDReportsHLineElement.cpp:76
Qt::gray
gray
QTextCursor

© 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