QGIS API Documentation  2.9.0-Master
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 
28 class QGraphicsProxyWidget;
29 
31 class GUI_EXPORT QgsHtmlAnnotationItem: public QObject, public QgsAnnotationItem
32 {
33  Q_OBJECT
34  public:
35  QgsHtmlAnnotationItem( QgsMapCanvas* canvas, QgsVectorLayer* vlayer = 0, bool hasFeature = false, int feature = 0 );
37 
38  void paint( QPainter * painter ) override;
39 
41  void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ) override;
42 
43  QSizeF minimumFrameSize() const override;
44 
46  void setMapPosition( const QgsPoint& pos ) override;
47 
48  void setHTMLPage( const QString& htmlFile );
49  QString htmlPage() const { return mHtmlFile; }
50 
51  void writeXML( QDomDocument& doc ) const override;
52  void readXML( const QDomDocument& doc, const QDomElement& itemElem ) override;
53 
54  QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
55 
56  private slots:
58  void setFeatureForMapPosition();
60  void updateVisibility();
61 
62  void javascript();
63 
64  private:
65  QGraphicsProxyWidget* mWidgetContainer;
66  QgsWebView* mWebView;
68  QgsVectorLayer* mVectorLayer;
70  bool mHasAssociatedFeature;
72  QgsFeatureId mFeatureId;
73  QgsFeature mFeature;
74  QString mHtmlFile;
75  QString mHtmlSource;
76 
77  QString replaceText( QString displayText, QgsVectorLayer *layer, QgsFeature &feat );
78 };
79 
80 #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:119
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:105
An annotation item that embedds a designer form showing the feature attribute.
virtual void setMapPosition(const QgsPoint &pos)
A class to represent a point.
Definition: qgspoint.h:63
An annotation item can be either placed either on screen corrdinates or on map coordinates.
virtual void paint(QPainter *painter)=0
function to be implemented by derived classes
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