Skip to content

Commit

Permalink
Return edit types as text
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Hugentobler committed Sep 7, 2012
1 parent 18d7790 commit 0fb66fc
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
53 changes: 51 additions & 2 deletions src/mapserver/qgsprojectparser.cpp
Expand Up @@ -24,7 +24,6 @@
#include "qgsmapserviceexception.h"
#include "qgsrasterlayer.h"
#include "qgsrenderer.h"
#include "qgsvectorlayer.h"

#include "qgscomposition.h"
#include "qgscomposerarrow.h"
Expand Down Expand Up @@ -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";
default:
return "Unknown";
}
}

void QgsProjectParser::combineExtentAndCrsOfGroupChildren( QDomElement& groupElem, QDomDocument& doc ) const
{
QgsRectangle combinedBBox;
Expand Down
3 changes: 3 additions & 0 deletions src/mapserver/qgsprojectparser.h
Expand Up @@ -19,6 +19,7 @@
#define QGSPROJECTPARSER_H

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

Expand Down Expand Up @@ -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 );
};

#endif // QGSPROJECTPARSER_H

0 comments on commit 0fb66fc

Please sign in to comment.