Skip to content
Permalink
Browse files

Remember last annotation form for a layer and store it in project

git-svn-id: http://svn.osgeo.org/qgis/trunk@13291 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Apr 9, 2010
1 parent 6b44aab commit f930a163df83cc5e659b67555a9767fac63554bb
@@ -444,6 +444,15 @@ public:
*/
void setEditForm( QString ui );

/** get annotation form
@note added in 1.5*/
QString annotationForm() const;

/** set annotation form for layer
@note added in 1.5*/
void setAnnotationForm( const QString& ui );


/** get edit form init function
@note added in 1.4
*/
@@ -1,5 +1,6 @@
#include "qgsformannotationdialog.h"
#include "qgsannotationwidget.h"
#include "qgsvectorlayer.h"
#include <QFileDialog>
#include <QFileInfo>
#include <QGraphicsScene>
@@ -40,6 +41,12 @@ void QgsFormAnnotationDialog::applySettingsToItem()
if ( mItem )
{
mItem->setDesignerForm( mFileLineEdit->text() );
QgsVectorLayer* layer = mItem->vectorLayer();
if ( layer )
{
//set last used annotation form as default for the layer
layer->setAnnotationForm( mFileLineEdit->text() );
}
mItem->update();
}
}
@@ -2797,6 +2797,13 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
mEditFormInit = editFormInitNode.toElement().text();
}

QDomNode annotationFormNode = node.namedItem( "annotationform" );
if ( !annotationFormNode.isNull() )
{
QDomElement e = annotationFormNode.toElement();
mAnnotationForm = QgsProject::instance()->readPath( e.text() );
}

mAttributeAliasMap.clear();
QDomNode aliasesNode = node.namedItem( "aliases" );
if ( !aliasesNode.isNull() )
@@ -2943,6 +2950,11 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
efiField.appendChild( efiText );
node.appendChild( efiField );

QDomElement afField = doc.createElement( "annotationform" );
QDomText afText = doc.createTextNode( QgsProject::instance()->writePath( mAnnotationForm ) );
afField.appendChild( afText );
node.appendChild( afField );

//attribute aliases
if ( mAttributeAliasMap.size() > 0 )
{
@@ -4142,6 +4154,11 @@ void QgsVectorLayer::setEditForm( QString ui )
mEditForm = ui;
}

void QgsVectorLayer::setAnnotationForm( const QString& ui )
{
mAnnotationForm = ui;
}

QString QgsVectorLayer::editFormInit()
{
return mEditFormInit;
@@ -480,6 +480,12 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/** set edit form (added in 1.4) */
void setEditForm( QString ui );

/** get annotation form (added in 1.5)*/
QString annotationForm() const { return mAnnotationForm; }

/** set annotation form for layer (added in 1.5)*/
void setAnnotationForm( const QString& ui );

/** get python function for edit form initialization (added in 1.4) */
QString editFormInit();

@@ -775,6 +781,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
QMap< QString, QPair<QString, QString> > mCheckedStates;

QString mEditForm, mEditFormInit;
//annotation form for this layer
QString mAnnotationForm;

bool mFetching;
QgsRectangle mFetchRect;
@@ -39,7 +39,7 @@ QgsFormAnnotationItem::QgsFormAnnotationItem( QgsMapCanvas* canvas, QgsVectorLay
mWidgetContainer = new QGraphicsProxyWidget( this );
if ( mVectorLayer && mMapCanvas ) //default to the layers edit form
{
mDesignerForm = mVectorLayer->editForm();
mDesignerForm = mVectorLayer->annotationForm();
QObject::connect( mVectorLayer, SIGNAL( layerModified( bool ) ), this, SLOT( setFeatureForMapPosition() ) );
QObject::connect( mMapCanvas, SIGNAL( renderComplete( QPainter* ) ), this, SLOT( setFeatureForMapPosition() ) );
QObject::connect( mMapCanvas, SIGNAL( layersChanged() ), this, SLOT( updateVisibility() ) );
@@ -49,6 +49,8 @@ class GUI_EXPORT QgsFormAnnotationItem: public QObject, public QgsAnnotationItem
void writeXML( QDomDocument& doc ) const;
void readXML( const QDomDocument& doc, const QDomElement& itemElem );

QgsVectorLayer* vectorLayer() const { return mVectorLayer; }

private slots:
/**Sets a feature for the current map position and updates the dialog*/
void setFeatureForMapPosition();

0 comments on commit f930a16

Please sign in to comment.
You can’t perform that action at this time.