QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <QObject>
24 #include <QWebView>
25 #include <QWebFrame>
26 
27 class QGraphicsProxyWidget;
28 
30 class GUI_EXPORT QgsHtmlAnnotationItem: public QObject, public QgsAnnotationItem
31 {
32  Q_OBJECT
33  public:
34  QgsHtmlAnnotationItem( QgsMapCanvas* canvas, QgsVectorLayer* vlayer = 0, bool hasFeature = false, int feature = 0 );
36 
37  void paint( QPainter * painter );
38 
40  void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
41 
42  QSizeF minimumFrameSize() const;
43 
45  void setMapPosition( const QgsPoint& pos );
46 
47  void setHTMLPage( const QString& htmlFile );
48  QString htmlPage() const { return mHtmlFile; }
49 
50  void writeXML( QDomDocument& doc ) const;
51  void readXML( const QDomDocument& doc, const QDomElement& itemElem );
52 
53  QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
54 
55  private slots:
57  void setFeatureForMapPosition();
59  void updateVisibility();
60 
61  void javascript();
62 
63  private:
64  QGraphicsProxyWidget* mWidgetContainer;
65  QWebView* mWebView;
73  QString mHtmlFile;
74  QString mHtmlSource;
75 
76  QString replaceText( QString displayText, QgsVectorLayer *layer, QgsFeature &feat );
77 };
78 
79 #endif // QGSHTMLANNOTATIONITEM_H