KD Reports API Documentation  2.0
KDReportsHtmlElement.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 "KDReportsHtmlElement.h"
19 #include <QDebug>
20 
21 class KDReports::HtmlElementPrivate
22 {
23 public:
24  QString m_html;
25  QString m_id;
26 };
27 
29  : Element()
30  , d(new HtmlElementPrivate)
31 {
32  d->m_html = html;
33 }
34 
36  : Element(other)
37  , d(new HtmlElementPrivate(*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  delete d;
53 }
54 
56 {
57  QTextCursor &cursor = builder.cursor();
58  const int charPosition = cursor.position();
59  cursor.insertHtml(d->m_html);
60  if (!d->m_id.isEmpty())
61  builder.currentDocumentData().setTextValueMarker(charPosition, d->m_id, cursor.position(), false);
62 }
63 
65 {
66  d->m_html.append(str);
67  return *this;
68 }
69 
70 void KDReports::HtmlElement::setHtml(const QString &html)
71 {
72  d->m_html = html;
73 }
74 
76 {
77  return new HtmlElement(*this);
78 }
79 
80 void KDReports::HtmlElement::setId(const QString &id)
81 {
82  d->m_id = id;
83 }
84 
86 {
87  return d->m_id;
88 }
89 
91 {
92  return d->m_html;
93 }
KDReports::HtmlElement
Definition: KDReportsHtmlElement.h:45
KDReports::ReportBuilder
Definition: KDReportsReportBuilder_p.h:41
KDReports::ReportBuilder::currentDocumentData
TextDocumentData & currentDocumentData()
Definition: KDReportsReportBuilder_p.h:69
KDReportsHtmlElement.h
KDReports::HtmlElement::clone
Element * clone() const override
Definition: KDReportsHtmlElement.cpp:75
KDReports::TextDocumentData::setTextValueMarker
void setTextValueMarker(int pos, const QString &id, int valueLength, bool html)
Definition: KDReportsTextDocumentData.cpp:90
KDReports::Element
Definition: KDReportsElement.h:39
KDReports::HtmlElement::HtmlElement
HtmlElement(const QString &html=QString())
Definition: KDReportsHtmlElement.cpp:28
KDReports::HtmlElement::build
void build(ReportBuilder &builder) const override
Definition: KDReportsHtmlElement.cpp:55
KDReports::HtmlElement::operator=
HtmlElement & operator=(const HtmlElement &other)
Definition: KDReportsHtmlElement.cpp:41
KDReports::Element::operator=
Element & operator=(const Element &other)
Definition: KDReportsElement.cpp:36
KDReports::HtmlElement::setId
void setId(const QString &id)
Definition: KDReportsHtmlElement.cpp:80
KDReportsReportBuilder_p.h
KDReports::HtmlElement::id
QString id() const
Definition: KDReportsHtmlElement.cpp:85
KDReports::HtmlElement::setHtml
void setHtml(const QString &html)
Definition: KDReportsHtmlElement.cpp:70
KDReports::HtmlElement::~HtmlElement
~HtmlElement() override
Definition: KDReportsHtmlElement.cpp:50
KDReports::ReportBuilder::cursor
QTextCursor & cursor()
Definition: KDReportsReportBuilder_p.h:48
KDReports::HtmlElement::html
QString html() const
Definition: KDReportsHtmlElement.cpp:90
KDReports::HtmlElement::operator<<
HtmlElement & operator<<(const QString &)
Definition: KDReportsHtmlElement.cpp:64

© 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