27 #include <QDomElement>
31 #include <QGraphicsProxyWidget>
38 :
QgsAnnotationItem( canvas ), mWidgetContainer( 0 ), mWebView( 0 ), mVectorLayer( vlayer ),
39 mHasAssociatedFeature( hasFeature ), mFeatureId( feature )
45 QObject::connect(
mWebView->page()->mainFrame(), SIGNAL( javaScriptWindowObjectCleared() ),
this, SLOT(
javascript() ) );
64 QFile
file( htmlFile );
66 if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
72 QTextStream in( &file );
73 in.setCodec(
"UTF-8" );
110 if ( data( 1 ).toString() ==
"composer" )
125 QSizeF widgetMinSize =
mWebView->minimumSize();
130 return QSizeF( 0, 0 );
136 QDomElement documentElem = doc.documentElement();
137 if ( documentElem.isNull() )
142 QDomElement formAnnotationElem = doc.createElement(
"HtmlAnnotationItem" );
145 formAnnotationElem.setAttribute(
"vectorLayer",
mVectorLayer->
id() );
148 formAnnotationElem.setAttribute(
"feature",
mFeatureId );
149 formAnnotationElem.setAttribute(
"htmlfile",
htmlPage() );
152 documentElem.appendChild( formAnnotationElem );
158 if ( itemElem.hasAttribute(
"vectorLayer" ) )
169 mFeatureId = itemElem.attribute(
"feature",
"0" ).toInt();
170 mHtmlFile = itemElem.attribute(
"htmlfile",
"" );
171 QDomElement annotationElem = itemElem.firstChildElement(
"AnnotationItem" );
172 if ( !annotationElem.isNull() )
201 bool featureFound =
false;
203 while ( fit.nextFeature( currentFeature ) )
205 currentFeatureId = currentFeature.
id();
225 setVisible( visible );
230 QWebFrame *frame =
mWebView->page()->mainFrame();
231 frame->addToJavaScriptWindowObject(
"canvas",
mMapCanvas );
232 frame->addToJavaScriptWindowObject(
"layer",
mVectorLayer );