QGIS API Documentation  2.99.0-Master (0a63d1f)
qgshtmlannotationitem.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgshtmlannotationitem.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 QGSHTMLANNOTATIONITEM_H
19 #define QGSHTMLANNOTATIONITEM_H
20 
21 #include "qgsannotationitem.h"
22 #include "qgsfeature.h"
23 
24 #include <QObject>
25 #include "qgis_gui.h"
26 
27 class QGraphicsProxyWidget;
28 class QgsWebView;
29 
32 class GUI_EXPORT QgsHtmlAnnotationItem: public QObject, public QgsAnnotationItem
33 {
34  Q_OBJECT
35  public:
36  QgsHtmlAnnotationItem( QgsMapCanvas* canvas, QgsVectorLayer* vlayer = nullptr, bool hasFeature = false, int feature = 0 );
38 
39  void paint( QPainter * painter ) override;
40  void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr ) override;
41 
42  QSizeF minimumFrameSize() const override;
43 
44  void setMapPosition( const QgsPoint& pos ) override;
45 
46  void setHTMLPage( const QString& htmlFile );
47  QString htmlPage() const { return mHtmlFile; }
48 
49  void writeXml( QDomDocument& doc ) const override;
50  void readXml( const QDomDocument& doc, const QDomElement& itemElem ) override;
51 
52  QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
53 
54  private slots:
56  void setFeatureForMapPosition();
58  void updateVisibility();
59 
60  void javascript();
61 
62  private:
63  QGraphicsProxyWidget* mWidgetContainer;
64  QgsWebView* mWebView;
66  QgsVectorLayer* mVectorLayer;
68  bool mHasAssociatedFeature;
70  QgsFeatureId mFeatureId;
71  QgsFeature mFeature;
72  QString mHtmlFile;
73  QString mHtmlSource;
74 
75  QString replaceText( QString displayText, QgsVectorLayer *layer, QgsFeature &feat );
76 };
77 
78 #endif // QGSHTMLANNOTATIONITEM_H
virtual void readXml(const QDomDocument &doc, const QDomElement &itemElem)=0
Deserialize from XML.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:136
virtual void writeXml(QDomDocument &doc) const =0
Serialize to XML.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:74
An annotation item that embedds a designer form showing the feature attribute.
virtual void setMapPosition(const QgsPoint &pos)
The QgsWebView class is a collection of stubs to mimic the API of QWebView on systems where the real ...
Definition: qgswebview.h:61
virtual QSizeF minimumFrameSize() const
A class to represent a point.
Definition: qgspoint.h:143
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override
Paint the annotation to a destination painter.
QgsVectorLayer * vectorLayer() const
An annotation item can be either placed either on screen corrdinates or on map coordinates.
qint64 QgsFeatureId
Definition: qgsfeature.h:33
Represents a vector layer which manages a vector based data sets.