Skip to content
Browse files

Return edit types as text

  • Loading branch information
Marco Hugentobler
Marco Hugentobler committed Sep 7, 2012
1 parent 18d7790 commit 0fb66fce81d5743c3665f73c09235b07808bcabd
Showing with 54 additions and 2 deletions.
  1. +51 −2 src/mapserver/qgsprojectparser.cpp
  2. +3 −0 src/mapserver/qgsprojectparser.h
@@ -24,7 +24,6 @@
#include "qgsmapserviceexception.h"
#include "qgsrasterlayer.h"
#include "qgsrenderer.h"
#include "qgsvectorlayer.h"

#include "qgscomposition.h"
#include "qgscomposerarrow.h"
@@ -425,13 +424,63 @@ void QgsProjectParser::addLayerProjectSettings( QDomElement& layerElem, QDomDocu
QDomElement attributeElem = doc.createElement( "Attribute" );
attributeElem.setAttribute( "name", fieldIt->name() );
attributeElem.setAttribute( "type", QVariant::typeToName( fieldIt->type() ) );
attributeElem.setAttribute( "editType", vLayer->editType( fieldIt.key() ) );

//edit type to text
QgsVectorLayer::EditType typeEnum = vLayer->editType( fieldIt.key() );
attributeElem.setAttribute( "editType", editTypeString( typeEnum ) );
attributeElem.setAttribute( "comment", fieldIt->comment() );
attributeElem.setAttribute( "length", fieldIt->length() );
attributeElem.setAttribute( "precision", fieldIt->precision() );
attributesElem.appendChild( attributeElem );
layerElem.appendChild( attributesElem );

//not very nice, needs to be kept in sync with QgsVectorLayer class...
QString QgsProjectParser::editTypeString( QgsVectorLayer::EditType type )
switch ( type )
case QgsVectorLayer::LineEdit:
return "LineEdit";
case QgsVectorLayer::UniqueValues:
return "UniqueValues";
case QgsVectorLayer::UniqueValuesEditable:
return "UniqueValuesEditable";
case QgsVectorLayer::ValueMap:
return "ValueMap";
case QgsVectorLayer::Classification:
return "Classification";
case QgsVectorLayer::EditRange:
return "EditRange";
case QgsVectorLayer::SliderRange:
return "SliderRange";
case QgsVectorLayer::CheckBox:
return "CheckBox";
case QgsVectorLayer::FileName:
return "FileName";
case QgsVectorLayer::Enumeration:
return "Enumeration";
case QgsVectorLayer::Immutable:
return "Immutable";
case QgsVectorLayer::Hidden:
return "Hidden";
case QgsVectorLayer::TextEdit:
return "TextEdit";
case QgsVectorLayer::Calendar:
return "Calendar";
case QgsVectorLayer::DialRange:
return "DialRange";
case QgsVectorLayer::ValueRelation:
return "ValueRelation";
case QgsVectorLayer::UuidGenerator:
return "UuidGenerator";
return "Unknown";

void QgsProjectParser::combineExtentAndCrsOfGroupChildren( QDomElement& groupElem, QDomDocument& doc ) const
QgsRectangle combinedBBox;
@@ -19,6 +19,7 @@

#include "qgsconfigparser.h"
#include "qgsvectorlayer.h"
#include <QList>
#include <QPair>

@@ -178,6 +179,8 @@ class QgsProjectParser: public QgsConfigParser
void setMaxWidthHeight();
/**Reads layer drawing order from the legend section of the project file and appends it to the parent elemen (usually the <Capability> element)*/
void addDrawingOrder( QDomElement& parentElem, QDomDocument& doc ) const;

static QString editTypeString( QgsVectorLayer::EditType type );


0 comments on commit 0fb66fc

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