QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
26 
29 class GUI_EXPORT QgsFormAnnotationItem: public QObject, public QgsAnnotationItem
30 {
31  Q_OBJECT
32  public:
33  QgsFormAnnotationItem( QgsMapCanvas* canvas, QgsVectorLayer* vlayer = nullptr, bool hasFeature = false, int feature = 0 );
35 
36  void paint( QPainter * painter ) override;
37 
39  void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr ) override;
40 
41  QSizeF minimumFrameSize() const override;
43  QSizeF preferredFrameSize() const;
44 
46  void setMapPosition( const QgsPoint& pos ) override;
47 
48  void setDesignerForm( const QString& uiFile );
49  QString designerForm() const { return mDesignerForm; }
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  private:
63  QGraphicsProxyWidget* mWidgetContainer;
64  QWidget* mDesignerWidget;
66  QgsVectorLayer* mVectorLayer;
68  bool mHasAssociatedFeature;
70  QgsFeatureId mFeature;
72  QString mDesignerForm;
73 
74  QWidget* createDesignerWidget( const QString& filePath );
75 };
76 
77 #endif // QGSFORMANNOTATIONITEM_H
An annotation item that embedds a designer form showing the feature attribute.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:109
virtual void setMapPosition(const QgsPoint &pos)
virtual QSizeF minimumFrameSize() const
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.
QgsVectorLayer * vectorLayer() const
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