QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsformannotationitem.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsformannotationitem.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 QGSFORMANNOTATIONITEM_H
19 #define QGSFORMANNOTATIONITEM_H
20 
21 #include "qgsannotationitem.h"
22 #include "qgsfeature.h"
23 #include <QObject>
24 
25 class QGraphicsProxyWidget;
26 
28 class GUI_EXPORT QgsFormAnnotationItem: public QObject, public QgsAnnotationItem
29 {
30  Q_OBJECT
31  public:
32  QgsFormAnnotationItem( QgsMapCanvas* canvas, QgsVectorLayer* vlayer = 0, bool hasFeature = false, int feature = 0 );
34 
35  void paint( QPainter * painter ) override;
36 
38  void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ) override;
39 
40  QSizeF minimumFrameSize() const override;
42  QSizeF preferredFrameSize() const;
43 
45  void setMapPosition( const QgsPoint& pos ) override;
46 
47  void setDesignerForm( const QString& uiFile );
48  QString designerForm() const { return mDesignerForm; }
49 
50  void writeXML( QDomDocument& doc ) const override;
51  void readXML( const QDomDocument& doc, const QDomElement& itemElem ) override;
52 
53  QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
54 
55  private slots:
57  void setFeatureForMapPosition();
59  void updateVisibility();
60 
61  private:
62  QGraphicsProxyWidget* mWidgetContainer;
63  QWidget* mDesignerWidget;
65  QgsVectorLayer* mVectorLayer;
67  bool mHasAssociatedFeature;
69  QgsFeatureId mFeature;
71  QString mDesignerForm;
72 
73  QWidget* createDesignerWidget( const QString& filePath );
74 };
75 
76 #endif // QGSFORMANNOTATIONITEM_H