QGIS API Documentation  2.17.0-Master (f49f7ce)
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 #include "qgswebview.h"
24 #include "qgswebframe.h"
25 
26 #include <QObject>
27 
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 
42  void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr ) override;
43 
44  QSizeF minimumFrameSize() const override;
45 
47  void setMapPosition( const QgsPoint& pos ) override;
48 
49  void setHTMLPage( const QString& htmlFile );
50  QString htmlPage() const { return mHtmlFile; }
51 
52  void writeXML( QDomDocument& doc ) const override;
53  void readXML( const QDomDocument& doc, const QDomElement& itemElem ) override;
54 
55  QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
56 
57  private slots:
59  void setFeatureForMapPosition();
61  void updateVisibility();
62 
63  void javascript();
64 
65  private:
66  QGraphicsProxyWidget* mWidgetContainer;
67  QgsWebView* mWebView;
69  QgsVectorLayer* mVectorLayer;
71  bool mHasAssociatedFeature;
73  QgsFeatureId mFeatureId;
74  QgsFeature mFeature;
75  QString mHtmlFile;
76  QString mHtmlSource;
77 
78  QString replaceText( QString displayText, QgsVectorLayer *layer, QgsFeature &feat );
79 };
80 
81 #endif // QGSHTMLANNOTATIONITEM_H
virtual QSizeF minimumFrameSize() const
QgsVectorLayer * vectorLayer() const
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:109
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:57
A class to represent a point.
Definition: qgspoint.h:117
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override
Paint the annotation to a destination painter.
An annotation item can be either placed either on screen corrdinates or on map coordinates.
virtual void readXML(const QDomDocument &doc, const QDomElement &itemElem)=0
qint64 QgsFeatureId
Definition: qgsfeature.h:31
Represents a vector layer which manages a vector based data sets.
virtual void writeXML(QDomDocument &doc) const =0