KD Reports API Documentation  2.1
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 }
53 
55 {
56  QTextCursor &cursor = builder.cursor();
57  const int charPosition = cursor.position();
58  cursor.insertHtml(d->m_html);
59  if (!d->m_id.isEmpty())
60  builder.currentDocumentData().setTextValueMarker(charPosition, d->m_id, cursor.position(), false);
61 }
62 
64 {
65  d->m_html.append(str);
66  return *this;
67 }
68 
70 {
71  d->m_html = html;
72 }
73 
75 {
76  return new HtmlElement(*this);
77 }
78 
80 {
81  d->m_id = id;
82 }
83 
85 {
86  return d->m_id;
87 }
88 
90 {
91  return d->m_html;
92 }
KDReports::HtmlElement
Definition: KDReportsHtmlElement.h:32
KDReports::ReportBuilder
Definition: KDReportsReportBuilder_p.h:42
KDReports::ReportBuilder::currentDocumentData
TextDocumentData & currentDocumentData()
Definition: KDReportsReportBuilder_p.h:69
KDReportsHtmlElement.h
KDReports::HtmlElement::clone
Element * clone() const override
Definition: KDReportsHtmlElement.cpp:74
KDReports::TextDocumentData::setTextValueMarker
void setTextValueMarker(int pos, const QString &id, int valueLength, bool html)
Definition: KDReportsTextDocumentData.cpp:87
KDReports::Element
Definition: KDReportsElement.h:41
KDReports::HtmlElement::HtmlElement
HtmlElement(const QString &html=QString())
Definition: KDReportsHtmlElement.cpp:28
KDReports::HtmlElement::build
void build(ReportBuilder &builder) const override
Definition: KDReportsHtmlElement.cpp:54
KDReports::HtmlElement::operator=
HtmlElement & operator=(const HtmlElement &other)
Definition: KDReportsHtmlElement.cpp:41
QString
KDReports::Element::operator=
Element & operator=(const Element &other)
Definition: KDReportsElement.cpp:36
KDReports::HtmlElement::setId
void setId(const QString &id)
Definition: KDReportsHtmlElement.cpp:79
KDReportsReportBuilder_p.h
KDReports::HtmlElement::id
QString id() const
Definition: KDReportsHtmlElement.cpp:84
QTextCursor::insertHtml
void insertHtml(const QString &html)
KDReports::HtmlElement::setHtml
void setHtml(const QString &html)
Definition: KDReportsHtmlElement.cpp:69
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:89
KDReports::HtmlElement::operator<<
HtmlElement & operator<<(const QString &)
Definition: KDReportsHtmlElement.cpp:63
QTextCursor::position
int position() const const
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