QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
32 #include <QDomElement>
36 #include <QGraphicsProxyWidget>
50 c->setDesignerForm( mDesignerForm );
56 mDesignerForm = uiFile;
57 mDesignerWidget.reset( createDesignerWidget( uiFile ) );
58 if ( mDesignerWidget )
60 mMinimumSize = mDesignerWidget->minimumSize();
64 newFill->
setColor( mDesignerWidget->palette().color( QPalette::Window ) );
73 QWidget *QgsFormAnnotation::createDesignerWidget(
const QString &filePath )
75 QFile file( filePath );
76 if ( !file.open( QFile::ReadOnly ) )
82 const QFileInfo fi( file );
83 loader.setWorkingDirectory( fi.dir() );
84 QWidget *widget = loader.load( &file,
nullptr );
94 for (
int i = 0; i < attrs.count(); ++i )
96 if ( i < fields.
count() )
98 QWidget *attWidget = widget->findChild<QWidget *>( fields.
at( i ).
name() );
105 QVariantList additionalFieldValues;
106 for (
const QString &additionalField : additionalFields )
109 additionalFieldValues.insert( index, attrs.at( index ) );
111 eww->
setValues( attrs.at( i ), additionalFieldValues );
122 if ( !mDesignerWidget )
127 const double scaleFactor = context.
painter()->device()->logicalDpiX() / 96.0;
128 context.
painter()->scale( scaleFactor, scaleFactor );
131 mDesignerWidget->setFixedSize( size.toSize() );
132 context.
painter()->setBrush( Qt::NoBrush );
133 context.
painter()->setPen( Qt::NoPen );
134 mDesignerWidget->render( context.
painter(), QPoint( 0, 0 ) );
139 if ( mDesignerWidget )
141 const QSizeF widgetMinSize = mMinimumSize;
147 return QSizeF( 0, 0 );
153 if ( mDesignerWidget )
155 return mDesignerWidget->sizeHint();
159 return QSizeF( 0, 0 );
165 QDomElement formAnnotationElem = doc.createElement( QStringLiteral(
"FormAnnotationItem" ) );
166 formAnnotationElem.setAttribute( QStringLiteral(
"designerForm" ), mDesignerForm );
167 _writeXml( formAnnotationElem, doc, context );
168 elem.appendChild( formAnnotationElem );
173 mDesignerForm = itemElem.attribute( QStringLiteral(
"designerForm" ), QString() );
174 const QDomElement annotationElem = itemElem.firstChildElement( QStringLiteral(
"AnnotationItem" ) );
175 if ( !annotationElem.isNull() )
177 _readXml( annotationElem, context );
180 if ( !
mapLayer() && itemElem.hasAttribute( QStringLiteral(
"vectorLayer" ) ) )
185 mDesignerWidget.reset( createDesignerWidget( mDesignerForm ) );
189 newFill->
setColor( mDesignerWidget->palette().color( QPalette::Window ) );
199 mDesignerWidget.reset( createDesignerWidget( mDesignerForm ) );
203 newFill->
setColor( mDesignerWidget->palette().color( QPalette::Window ) );
static QgsEditorWidgetRegistry * editorWidgetRegistry()
Returns the global editor widget registry, used for managing all known edit widget factories.
void _readXml(const QDomElement &annotationElem, const QgsReadWriteContext &context)
Reads common annotation properties from a DOM element.
QgsMargins contentsMargin() const
Returns the margins (in millimeters) between the outside of the frame and the annotation content.
The class is used as a container of context for various read/write operations on other objects.
int count() const
Returns number of items.
Container of fields for a vector layer.
Contains information about the context of a rendering operation.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsMapLayer * mapLayer() const
Returns the map layer associated with the annotation.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Abstract base class for annotation items which are drawn over a map.
QgsFillSymbol * fillSymbol() const
Returns the symbol that is used for rendering the annotation frame.
QgsFeature associatedFeature() const
Returns the feature associated with the annotation, or an invalid feature if none has been set.
void _writeXml(QDomElement &itemElem, QDomDocument &doc, const QgsReadWriteContext &context) const
Writes common annotation properties to a DOM element.
Scoped object for saving and restoring a QPainter object's state.
virtual void setAssociatedFeature(const QgsFeature &feature)
Sets the feature associated with the annotation.
void setFrameSizeMm(QSizeF size)
Sets the size (in millimeters) of the annotation's frame (the main area in which the annotation's con...
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Represents a vector layer which manages a vector based data sets.
QgsFillSymbol * clone() const override
Returns a deep copy of this symbol.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
void appearanceChanged()
Emitted whenever the annotation's appearance changes.
void setFillSymbol(QgsFillSymbol *symbol)
Sets the fill symbol used for rendering the annotation frame.
A vector of attributes. Mostly equal to QVector<QVariant>.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
This class contains context information for attribute editor widgets. It will be passed to embedded w...
void setColor(const QColor &color) const
Sets the color for the symbol.
int indexFromName(const QString &fieldName) const
Gets the field index from the field name.
void copyCommonProperties(QgsAnnotation *target) const
Copies common annotation properties to the targe annotation.
void setMapLayer(QgsMapLayer *layer)
Sets the map layer associated with the annotation.