KD Reports API Documentation  2.2
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 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6 **
7 ** SPDX-License-Identifier: MIT
8 **
9 ****************************************************************************/
10 
11 #include "KDReportsHLineElement.h"
13 #include "KDReportsLayoutHelper_p.h" // mmToPixels
15 #include <QDebug>
16 
17 class KDReports::HLineElementPrivate
18 {
19 public:
20  QString m_id;
21  QColor m_color;
22 
23  qreal m_thickness;
24  int m_margin;
25 };
26 
28  : Element()
29  , d(new HLineElementPrivate)
30 {
31  d->m_color = Qt::gray;
32  d->m_thickness = 2;
33  d->m_margin = 6;
34 }
35 
37  : Element(other)
38  , d(new HLineElementPrivate(*other.d))
39 {
40 }
41 
43 {
44  if (&other == this)
45  return *this;
46  Element::operator=(other);
47  *d = *other.d;
48  return *this;
49 }
50 
52 {
53 }
54 
55 void KDReports::HLineElement::setColor(const QColor &color)
56 {
57  d->m_color = color;
58 }
59 
61 {
62  return d->m_color;
63 }
64 
66 {
67  d->m_thickness = t;
68 }
69 
71 {
72  return d->m_thickness;
73 }
74 
76 {
77  d->m_margin = m; // in mm
78 }
79 
81 {
82  return d->m_margin;
83 }
84 
86 {
87  QTextCursor &cursor = builder.cursor();
88 
89  QTextCharFormat fmt;
90 
91  fmt.setObjectType(HLineTextObject::HLineTextFormat);
92  fmt.setProperty(HLineTextObject::Color, d->m_color);
93  fmt.setProperty(HLineTextObject::Thickness, d->m_thickness);
94  // qDebug() << "Setting Margin to" << d->m_margin << "mm" << mmToPixels( d->m_margin ) << "px";
95  fmt.setProperty(HLineTextObject::Margin, double(mmToPixels(d->m_margin)));
96 
97  cursor.insertText(QString(QChar::ObjectReplacementCharacter), fmt);
98 }
99 
101 {
102  return new HLineElement(*this);
103 }
Element & operator=(const Element &other)
void build(ReportBuilder &builder) const override
void setColor(const QColor &color)
HLineElement & operator=(const HLineElement &other)
Element * clone() const override
KDREPORTS_EXPORT qreal mmToPixels(qreal mm)

© 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