Skip to content

Commit

Permalink
[Geometry checker] Show layer names instead of ids in user-facing str…
Browse files Browse the repository at this point in the history
…ings
  • Loading branch information
manisandro committed Oct 23, 2017
1 parent 732ce4c commit d6d584b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
16 changes: 16 additions & 0 deletions src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
18 changes: 2 additions & 16 deletions src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down

0 comments on commit d6d584b

Please sign in to comment.