19 #include <QDomDocument> 24 mDocument->setUseDesignMetrics(
true );
39 return mDocument->clone();
45 mDocument = doc->clone();
50 if ( !painter || !mDocument )
67 QRectF clipRect = QRectF( 0, 0,
mFrameSize.width() - frameWidth / 2.0,
mFrameSize.height() - frameWidth / 2.0 );
68 if ( painter->hasClipping() )
73 clipRect = clipRect.intersected( painter->clipRegion().boundingRect() );
76 mDocument->drawContents( painter, clipRect );
86 QDomElement documentElem = doc.documentElement();
87 if ( documentElem.isNull() )
91 QDomElement annotationElem = doc.createElement(
"TextAnnotationItem" );
94 annotationElem.setAttribute(
"document", mDocument->toHtml() );
97 documentElem.appendChild( annotationElem );
103 mDocument =
new QTextDocument;
104 mDocument->setHtml( itemElem.attribute(
"document",
QObject::tr(
"<html>QGIS rocks!</html>" ) ) );
105 QDomElement annotationElem = itemElem.firstChildElement(
"AnnotationItem" );
106 if ( !annotationElem.isNull() )
void _readXML(const QDomDocument &doc, const QDomElement &annotationElem)
double mFrameBorderWidth
Width of the frame.
QPointF mOffsetFromReferencePoint
Describes the shift of the item content box to the reference point.
void paint(QPainter *painter) override
function to be implemented by derived classes
Map canvas is a class for displaying all GIS data types on a canvas.
void drawSelectionBoxes(QPainter *p)
void readXML(const QDomDocument &doc, const QDomElement &itemElem) override
void drawMarkerSymbol(QPainter *p)
QgsTextAnnotationItem(QgsMapCanvas *canvas)
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...
QTextDocument * document() const
Returns document (caller takes ownership)
void _writeXML(QDomDocument &doc, QDomElement &itemElem) const
void drawFrame(QPainter *p)
void writeXML(QDomDocument &doc) const override
void setDocument(const QTextDocument *doc)
Sets document (does not take ownership)
QSizeF mFrameSize
Size of the frame (without balloon)