QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgshtmlannotation.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgshtmlannotation.h
3  ------------------------
4  begin : February 9, 2010
5  copyright : (C) 2010 by Marco Hugentobler
6  email : marco dot hugentobler at hugis dot net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSHTMLANNOTATION_H
19 #define QGSHTMLANNOTATION_H
20 
21 #include "qgsannotation.h"
22 #include "qgsfeature.h"
23 
24 #include "qgis_core.h"
25 
26 class QgsWebPage;
27 
35 class CORE_EXPORT QgsHtmlAnnotation: public QgsAnnotation
36 {
37  Q_OBJECT
38  public:
39 
43  QgsHtmlAnnotation( QObject *parent SIP_TRANSFERTHIS = nullptr );
44 
45  QgsHtmlAnnotation *clone() const override SIP_FACTORY;
46 
47  QSizeF minimumFrameSize() const override;
48 
53  void setSourceFile( const QString &htmlFile );
54 
59  QString sourceFile() const { return mHtmlFile; }
60 
65  void setHtmlSource( const QString &htmlSource );
66 
70  QString htmlSource() const { return mHtmlSource; }
71 
72  void writeXml( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
73  void readXml( const QDomElement &itemElem, const QgsReadWriteContext &context ) override;
74 
75  void setAssociatedFeature( const QgsFeature &feature ) override;
76 
81 
82  protected:
83 
84  void renderAnnotation( QgsRenderContext &context, QSizeF size ) const override;
85 
86  private slots:
87 
88  void javascript();
89 
90  private:
91  QgsWebPage *mWebPage = nullptr;
92  QString mHtmlFile;
93  QString mHtmlSource;
94 
95 };
96 
97 #endif // QGSHTMLANNOTATION_H
QgsAnnotation::writeXml
virtual void writeXml(QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context) const =0
Writes the annotation state to a DOM element.
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
qgsannotation.h
QgsAnnotation::readXml
virtual void readXml(const QDomElement &itemElem, const QgsReadWriteContext &context)=0
Restores the annotation's state from a DOM element.
qgsfeature.h
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsAnnotation::renderAnnotation
virtual void renderAnnotation(QgsRenderContext &context, QSizeF size) const =0
Renders the annotation's contents to a target /a context at the specified /a size.
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsWebPage
QWebPage subclass which redirects JavaScript errors and console output to the QGIS message log.
Definition: qgswebpage.h:217
QgsAnnotation
Abstract base class for annotation items which are drawn over a map.
Definition: qgsannotation.h:53
QgsHtmlAnnotation::sourceFile
QString sourceFile() const
Returns the file path for the source HTML file.
Definition: qgshtmlannotation.h:59
QgsAnnotation::clone
virtual QgsAnnotation * clone() const =0
Clones the annotation, returning a new copy of the annotation reflecting the annotation's current sta...
QgsHtmlAnnotation
An annotation item that embeds HTML content.
Definition: qgshtmlannotation.h:35
QgsAnnotation::setAssociatedFeature
virtual void setAssociatedFeature(const QgsFeature &feature)
Sets the feature associated with the annotation.
Definition: qgsannotation.cpp:189
QgsHtmlAnnotation::htmlSource
QString htmlSource() const
Returns html source text.
Definition: qgshtmlannotation.h:70
QgsAnnotation::minimumFrameSize
virtual QSizeF minimumFrameSize() const
Returns the minimum frame size for the annotation.
Definition: qgsannotation.cpp:220
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsHtmlAnnotation::create
static QgsHtmlAnnotation * create()
Returns a new QgsHtmlAnnotation object.
Definition: qgshtmlannotation.h:80