26 #include <QDomElement>
30 #include <QGraphicsProxyWidget>
37 :
QgsAnnotationItem( canvas ), mWidgetContainer( 0 ), mDesignerWidget( 0 ), mVectorLayer( vlayer ),
38 mHasAssociatedFeature( hasFeature ), mFeature( feature )
74 QFile
file( filePath );
75 if ( !file.open( QFile::ReadOnly ) )
82 loader.setWorkingDirectory( fi.dir() );
83 QWidget* widget = loader.load( &file, 0 );
94 for (
int i = 0; i < attrs.count(); ++i )
96 if ( i < fields.
count() )
98 QWidget* attWidget = widget->findChild<QWidget*>( fields[i].name() );
155 return QSizeF( 0, 0 );
167 return QSizeF( 0, 0 );
173 QDomElement documentElem = doc.documentElement();
174 if ( documentElem.isNull() )
179 QDomElement formAnnotationElem = doc.createElement(
"FormAnnotationItem" );
182 formAnnotationElem.setAttribute(
"vectorLayer",
mVectorLayer->
id() );
185 formAnnotationElem.setAttribute(
"feature",
mFeature );
186 formAnnotationElem.setAttribute(
"designerForm",
mDesignerForm );
188 documentElem.appendChild( formAnnotationElem );
194 if ( itemElem.hasAttribute(
"vectorLayer" ) )
205 mFeature = itemElem.attribute(
"feature",
"0" ).toInt();
207 QDomElement annotationElem = itemElem.firstChildElement(
"AnnotationItem" );
208 if ( !annotationElem.isNull() )
237 bool featureFound =
false;
239 while ( fit.nextFeature( currentFeature ) )
241 currentFeatureId = currentFeature.
id();
267 setVisible( visible );
QgsFeatureId id() const
Get the feature id for this feature.
Wrapper for iterator of features from vector data provider or vector layer.
QString annotationForm() const
get annotation form (added in 1.5)
A rectangle specified with double values.
void _readXML(const QDomDocument &doc, const QDomElement &annotationElem)
double mFrameBorderWidth
Width of the frame.
Use exact geometry intersection (slower) instead of bounding boxes.
QPointF mOffsetFromReferencePoint
Describes the shift of the item content box to the reference point.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
QList< QgsMapLayer * > layers() const
return list of layers within map canvas. Added in v1.5
Container of fields for a vector layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Map canvas is a class for displaying all GIS data types on a canvas.
void drawSelectionBoxes(QPainter *p)
virtual void setMapPosition(const QgsPoint &pos)
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QList< int > QgsAttributeList
const QgsAttributes & attributes() const
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
void drawMarkerSymbol(QPainter *p)
int count() const
Return number of items.
A class to represent a point geometry.
An annotation item can be either placed either on screen corrdinates or on map coordinates.
bool mMapPositionFixed
True: the item stays at the same map position, False: the item stays on same screen position...
static Q_DECL_DEPRECATED QWidget * createAttributeEditor(QWidget *parent, QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value, QMap< int, QWidget * > &proxyWidgets)
Creates or prepares a attribute editor widget.
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
void _writeXML(QDomDocument &doc, QDomElement &itemElem) const
QVector< QVariant > QgsAttributes
QgsMapCanvas * mMapCanvas
pointer to map canvas
void setFrameSize(const QSizeF &size)
void drawFrame(QPainter *p)
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
QColor mFrameBackgroundColor
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
bool nextFeature(QgsFeature &f)
Geometry is not required. It may still be returned if e.g. required for a filter condition.
Represents a vector layer which manages a vector based data sets.
QgsPoint mMapPosition
Map position (in case mMapPositionFixed is true)
QSizeF mFrameSize
Size of the frame (without balloon)