mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-10 00:08:20 -05:00
Small optimisations
This commit is contained in:
parent
a5e3f1931b
commit
4b33e2fb1c
@ -121,7 +121,7 @@ QString QgsJSONExporter::exportFeature( const QgsFeature &feature, const QVarian
|
|||||||
|
|
||||||
if ( mIncludeAttributes )
|
if ( mIncludeAttributes )
|
||||||
{
|
{
|
||||||
QgsFields fields = mLayer.data() ? mLayer->fields() : feature.fields();
|
QgsFields fields = mLayer ? mLayer->fields() : feature.fields();
|
||||||
|
|
||||||
for ( int i = 0; i < fields.count(); ++i )
|
for ( int i = 0; i < fields.count(); ++i )
|
||||||
{
|
{
|
||||||
@ -132,7 +132,7 @@ QString QgsJSONExporter::exportFeature( const QgsFeature &feature, const QVarian
|
|||||||
properties += QLatin1String( ",\n" );
|
properties += QLatin1String( ",\n" );
|
||||||
QVariant val = feature.attributes().at( i );
|
QVariant val = feature.attributes().at( i );
|
||||||
|
|
||||||
if ( mLayer.data() )
|
if ( mLayer )
|
||||||
{
|
{
|
||||||
QgsEditorWidgetSetup setup = fields.at( i ).editorWidgetSetup();
|
QgsEditorWidgetSetup setup = fields.at( i ).editorWidgetSetup();
|
||||||
QgsFieldFormatter *fieldFormatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() );
|
QgsFieldFormatter *fieldFormatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() );
|
||||||
@ -161,7 +161,7 @@ QString QgsJSONExporter::exportFeature( const QgsFeature &feature, const QVarian
|
|||||||
}
|
}
|
||||||
|
|
||||||
// related attributes
|
// related attributes
|
||||||
if ( mLayer.data() && mIncludeRelatedAttributes )
|
if ( mLayer && mIncludeRelatedAttributes )
|
||||||
{
|
{
|
||||||
QList< QgsRelation > relations = QgsProject::instance()->relationManager()->referencedRelations( mLayer.data() );
|
QList< QgsRelation > relations = QgsProject::instance()->relationManager()->referencedRelations( mLayer.data() );
|
||||||
Q_FOREACH ( const QgsRelation &relation, relations )
|
Q_FOREACH ( const QgsRelation &relation, relations )
|
||||||
@ -177,11 +177,13 @@ QString QgsJSONExporter::exportFeature( const QgsFeature &feature, const QVarian
|
|||||||
{
|
{
|
||||||
QgsFeatureIterator it = childLayer->getFeatures( req );
|
QgsFeatureIterator it = childLayer->getFeatures( req );
|
||||||
QVector<QVariant> attributeWidgetCaches;
|
QVector<QVariant> attributeWidgetCaches;
|
||||||
for ( int fieldIndex = 0; fieldIndex < childLayer->fields().count(); ++fieldIndex )
|
int fieldIndex = 0;
|
||||||
|
Q_FOREACH ( const QgsField &field, childLayer->fields() )
|
||||||
{
|
{
|
||||||
QgsEditorWidgetSetup setup = childLayer->fields().at( fieldIndex ).editorWidgetSetup();
|
QgsEditorWidgetSetup setup = field.editorWidgetSetup();
|
||||||
QgsFieldFormatter *fieldFormatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() );
|
QgsFieldFormatter *fieldFormatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() );
|
||||||
attributeWidgetCaches.append( fieldFormatter->createCache( childLayer, fieldIndex, setup.config() ) );
|
attributeWidgetCaches.append( fieldFormatter->createCache( childLayer, fieldIndex, setup.config() ) );
|
||||||
|
fieldIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsFeature relatedFet;
|
QgsFeature relatedFet;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user