25 #include <QDomElement>
29 #include <QGraphicsProxyWidget>
36 :
QgsAnnotationItem( canvas ), mWidgetContainer( 0 ), mDesignerWidget( 0 ), mVectorLayer( vlayer ),
37 mHasAssociatedFeature( hasFeature ), mFeature( feature )
73 QFile
file( filePath );
74 if ( !file.open( QFile::ReadOnly ) )
81 loader.setWorkingDirectory( fi.dir() );
82 QWidget* widget = loader.load( &file, 0 );
93 for (
int i = 0; i < attrs.count(); ++i )
95 if ( i < fields.
count() )
97 QWidget* attWidget = widget->findChild<QWidget*>( fields[i].name() );
154 return QSizeF( 0, 0 );
166 return QSizeF( 0, 0 );
172 QDomElement documentElem = doc.documentElement();
173 if ( documentElem.isNull() )
178 QDomElement formAnnotationElem = doc.createElement(
"FormAnnotationItem" );
181 formAnnotationElem.setAttribute(
"vectorLayer",
mVectorLayer->
id() );
184 formAnnotationElem.setAttribute(
"feature",
mFeature );
185 formAnnotationElem.setAttribute(
"designerForm",
mDesignerForm );
187 documentElem.appendChild( formAnnotationElem );
193 if ( itemElem.hasAttribute(
"vectorLayer" ) )
204 mFeature = itemElem.attribute(
"feature",
"0" ).toInt();
206 QDomElement annotationElem = itemElem.firstChildElement(
"AnnotationItem" );
207 if ( !annotationElem.isNull() )
238 bool featureFound =
false;
240 while ( fit.nextFeature( currentFeature ) )
242 currentFeatureId = currentFeature.
id();
268 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.
static const double DEFAULT_IDENTIFY_RADIUS
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 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
QgsRectangle extent() const
Returns the current zoom exent of the map canvas.
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.
double width() const
Width of the rectangle.
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)