Skip to content
Permalink
Browse files

[Geometry checker] Show layer names instead of ids in user-facing str…

…ings
  • Loading branch information
manisandro committed Jul 6, 2017
1 parent 732ce4c commit d6d584b32063544be27e8b941de933cb3bab383e
@@ -36,6 +36,22 @@ bool QgsGeometryDuplicateCheckError::handleFidChanges( const QString &layerId, c
return changed;
}

QString QgsGeometryDuplicateCheckError::duplicatesString( const QMap<QString, QgsFeaturePool *> &featurePools, const QMap<QString, QList<QgsFeatureId>> &duplicates )
{
QStringList str;
for ( const QString &layerId : duplicates.keys() )
{
str.append( featurePools[layerId]->getLayer()->name() + ":" );
QStringList ids;
for ( QgsFeatureId id : duplicates[layerId] )
{
ids.append( QString::number( id ) );
}
str.back() += ids.join( "," );
}
return str.join( QStringLiteral( "; " ) );
}


void QgsGeometryDuplicateCheck::collectErrors( QList<QgsGeometryCheckError *> &errors, QStringList &messages, QAtomicInt *progressCounter, const QMap<QString, QgsFeatureIds> &ids ) const
{
@@ -25,7 +25,7 @@ class QgsGeometryDuplicateCheckError : public QgsGeometryCheckError
const QgsGeometryCheckerUtils::LayerFeature &layerFeature,
const QgsPointXY &errorLocation,
const QMap<QString, QList<QgsFeatureId>> &duplicates )
: QgsGeometryCheckError( check, layerFeature, errorLocation, QgsVertexId(), duplicatesString( duplicates ) )
: QgsGeometryCheckError( check, layerFeature, errorLocation, QgsVertexId(), duplicatesString( check->getContext()->featurePools, duplicates ) )
, mDuplicates( duplicates )
{ }
QMap<QString, QList<QgsFeatureId>> duplicates() const { return mDuplicates; }
@@ -43,21 +43,7 @@ class QgsGeometryDuplicateCheckError : public QgsGeometryCheckError
private:
QMap<QString, QList<QgsFeatureId>> mDuplicates;

static inline QString duplicatesString( const QMap<QString, QList<QgsFeatureId>> &duplicates )
{
QStringList str;
for ( const QString &layerId : duplicates.keys() )
{
str.append( layerId + ": " );
QStringList ids;
for ( QgsFeatureId id : duplicates[layerId] )
{
ids.append( QString::number( id ) );
}
str.append( ids.join( ", " ) );
}
return str.join( QStringLiteral( "; " ) );
}
static QString duplicatesString( const QMap<QString, QgsFeaturePool *> &featurePools, const QMap<QString, QList<QgsFeatureId>> &duplicates );
};

class QgsGeometryDuplicateCheck : public QgsGeometryCheck
@@ -56,9 +56,9 @@ QgsGeometryCheckerResultTab::QgsGeometryCheckerResultTab( QgisInterface *iface,

for ( const QString &layerId : mChecker->getContext()->featurePools.keys() )
{
QTreeWidgetItem *item = new QTreeWidgetItem( ui.treeWidgetMergeAttribute, QStringList() << layerId << "" );
QComboBox *attribCombo = new QComboBox();
QgsVectorLayer *layer = mChecker->getContext()->featurePools[layerId]->getLayer();
QTreeWidgetItem *item = new QTreeWidgetItem( ui.treeWidgetMergeAttribute, QStringList() << layer->name() << "" );
QComboBox *attribCombo = new QComboBox();
for ( int i = 0, n = layer->fields().count(); i < n; ++i )
{
attribCombo->addItem( layer->fields().at( i ).name() );

0 comments on commit d6d584b

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