Skip to content

Commit

Permalink
improve i18n of topology checker plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jan 17, 2015
1 parent 3404d55 commit 063b70d
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 110 deletions.
22 changes: 11 additions & 11 deletions src/plugins/topology/rulesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ rulesDialog::~rulesDialog()
void rulesDialog::setHorizontalHeaderItems()
{
QStringList labels;
labels << "Test" << "Layer #1" << "Layer #2" << "Tolerance" << "" << "";
labels << tr( "Test" ) << tr( "Layer #1" ) << tr( "Layer #2" ) << tr( "Tolerance" ) << "" << "";
mRulesTable->setHorizontalHeaderLabels( labels );
}

Expand Down Expand Up @@ -134,7 +134,7 @@ void rulesDialog::readTest( int index, QgsMapLayerRegistry* layerRegistry )
if ( mTestConfMap[testName].useTolerance )
newItem = new QTableWidgetItem( tolerance );
else
newItem = new QTableWidgetItem( QString( "No tolerance" ) );
newItem = new QTableWidgetItem( tr( "No tolerance" ) );

newItem->setFlags( newItem->flags() & ~Qt::ItemIsEditable );
mRulesTable->setItem( row, 3, newItem );
Expand Down Expand Up @@ -165,7 +165,7 @@ void rulesDialog::showControls( const QString& testName )
}

mLayer2Box->clear();
mLayer2Box->addItem( "No layer" );
mLayer2Box->addItem( tr( "No layer" ) );
TopologyRule topologyRule = mTestConfMap[testName];
QgsMapLayerRegistry* layerRegistry = QgsMapLayerRegistry::instance();
QList<QString> layerList = layerRegistry->mapLayers().keys();
Expand Down Expand Up @@ -222,11 +222,11 @@ void rulesDialog::addRule()
//sanity checks
QString test = mRuleBox->currentText();
QString layer1 = mLayer1Box->currentText();
if ( layer1 == "No layer" )
if ( layer1 == tr( "No layer" ) )
return;

QString layer2 = mLayer2Box->currentText();
if ( layer2 == "No layer" && mTestConfMap[test].useSecondLayer )
if ( layer2 == tr( "No layer" ) && mTestConfMap[test].useSecondLayer )
return;

for ( int i = 0; i < mRulesTable->rowCount(); ++i )
Expand All @@ -251,14 +251,14 @@ void rulesDialog::addRule()
if ( mTestConfMap[test].useSecondLayer )
newItem = new QTableWidgetItem( layer2 );
else
newItem = new QTableWidgetItem( "No layer" );
newItem = new QTableWidgetItem( tr( "No layer" ) );

mRulesTable->setItem( row, 2, newItem );

if ( mTestConfMap[test].useTolerance )
newItem = new QTableWidgetItem( QString( "%1" ).arg( mToleranceBox->value() ) );
else
newItem = new QTableWidgetItem( QString( "No tolerance" ) );
newItem = new QTableWidgetItem( tr( "No tolerance" ) );

mRulesTable->setItem( row, 3, newItem );

Expand All @@ -268,7 +268,7 @@ void rulesDialog::addRule()
if ( mTestConfMap[test].useSecondLayer )
layer2ID = mLayer2Box->itemData( mLayer2Box->currentIndex() ).toString();
else
layer2ID = "No layer";
layer2ID = tr( "No layer" );

layer1ID = mLayer1Box->itemData( mLayer1Box->currentIndex() ).toString();

Expand Down Expand Up @@ -311,7 +311,7 @@ void rulesDialog::updateRuleItems( const QString &layerName )

mRuleBox->clear();

if ( layerName == "No layer" )
if ( layerName == tr( "No layer" ) )
{
return;
}
Expand Down Expand Up @@ -345,10 +345,10 @@ void rulesDialog::initGui()
QList<QString> layerList = layerRegistry->mapLayers().keys();

mLayer1Box->clear();
mLayer1Box->addItem( "No layer" );
mLayer1Box->addItem( tr( "No layer" ) );

mLayer2Box->clear();
mLayer2Box->addItem( "No layer" );
mLayer2Box->addItem( tr( "No layer" ) );

mLayer1Box->blockSignals( true );
for ( int i = 0; i < layerList.size(); ++i )
Expand Down
172 changes: 80 additions & 92 deletions src/plugins/topology/topolTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,100 +36,88 @@ topolTest::topolTest( QgisInterface* qgsIface )
mTestCancelled = false;

// one layer tests
mTopologyRuleMap[QObject::tr( "must not have invalid geometries" )].f = &topolTest::checkValid;
mTopologyRuleMap[QObject::tr( "must not have invalid geometries" )].useSecondLayer = false;
mTopologyRuleMap[QObject::tr( "must not have invalid geometries" )].useTolerance = false;
mTopologyRuleMap[QObject::tr( "must not have invalid geometries" )].useSpatialIndex = false;
mTopologyRuleMap[QObject::tr( "must not have invalid geometries" )].layer1SupportedTypes << QGis::Point << QGis::Polygon << QGis::Line;

//mTopologyRuleMap[QObject::tr("segments must have minimum length")].f = &topolTest::checkSegmentLength;
//mTopologyRuleMap[QObject::tr("segments must have minimum length")].useTolerance = true;
//mTopologyRuleMap[QObject::tr("segments must have minimum length")].useSecondLayer = false;
//mTopologyRuleMap[QObject::tr("segments must have minimum length")].useSpatialIndex = false;

mTopologyRuleMap[QObject::tr( "must not have dangles" )].f = &topolTest::checkDanglingLines;
mTopologyRuleMap[QObject::tr( "must not have dangles" )].useSecondLayer = false;
mTopologyRuleMap[QObject::tr( "must not have dangles" )].useTolerance = false;
mTopologyRuleMap[QObject::tr( "must not have dangles" )].useSpatialIndex = false;
mTopologyRuleMap[QObject::tr( "must not have dangles" )].layer1SupportedTypes << QGis::Line;

mTopologyRuleMap[QObject::tr( "must not have duplicates" )].f = &topolTest::checkDuplicates;
mTopologyRuleMap[QObject::tr( "must not have duplicates" )].useTolerance = false;
mTopologyRuleMap[QObject::tr( "must not have duplicates" )].useSecondLayer = false;
mTopologyRuleMap[QObject::tr( "must not have duplicates" )].useSpatialIndex = true;
mTopologyRuleMap[QObject::tr( "must not have duplicates" )].layer1SupportedTypes << QGis::Point << QGis::Polygon << QGis::Line;

mTopologyRuleMap[QObject::tr( "must not have pseudos" )].f = &topolTest::checkPseudos;
mTopologyRuleMap[QObject::tr( "must not have pseudos" )].useTolerance = false;
mTopologyRuleMap[QObject::tr( "must not have pseudos" )].useSecondLayer = false;
mTopologyRuleMap[QObject::tr( "must not have pseudos" )].useSpatialIndex = false;
mTopologyRuleMap[QObject::tr( "must not have pseudos" )].layer1SupportedTypes << QGis::Line;

mTopologyRuleMap[QObject::tr( "must not overlap" )].f = &topolTest::checkOverlaps;
mTopologyRuleMap[QObject::tr( "must not overlap" )].useTolerance = false;
mTopologyRuleMap[QObject::tr( "must not overlap" )].useSecondLayer = false;
mTopologyRuleMap[QObject::tr( "must not overlap" )].useSpatialIndex = true;
mTopologyRuleMap[QObject::tr( "must not overlap" )].layer1SupportedTypes << QGis::Polygon;

mTopologyRuleMap[QObject::tr( "must not have gaps" )].f = &topolTest::checkGaps;
mTopologyRuleMap[QObject::tr( "must not have gaps" )].useTolerance = false;
mTopologyRuleMap[QObject::tr( "must not have gaps" )].useSecondLayer = false;
mTopologyRuleMap[QObject::tr( "must not have gaps" )].useSpatialIndex = false;
mTopologyRuleMap[QObject::tr( "must not have gaps" )].layer1SupportedTypes << QGis::Polygon;

mTopologyRuleMap[QObject::tr( "must not have multi-part geometries" )].f = &topolTest::checkMultipart;
mTopologyRuleMap[QObject::tr( "must not have multi-part geometries" )].useSecondLayer = false;
mTopologyRuleMap[QObject::tr( "must not have multi-part geometries" )].useTolerance = false;
mTopologyRuleMap[QObject::tr( "must not have multi-part geometries" )].useSpatialIndex = false;
mTopologyRuleMap[QObject::tr( "must not have multi-part geometries" )].layer1SupportedTypes << QGis::Point << QGis::Polygon << QGis::Line;
mTopologyRuleMap.insert( tr( "must not have invalid geometries" ),
TopologyRule( &topolTest::checkValid,
false, false, false,
QList<QGis::GeometryType>() << QGis::Point << QGis::Polygon << QGis::Line ) );

#if 0
mTopologyRuleMap.insert( tr( "segments must have minimum length" ),
TopologyRule( &topolTest::checkSegmentLength, false, true, false ) );
#endif

mTopologyRuleMap.insert( tr( "must not have dangles" ),
TopologyRule( &topolTest::checkDanglingLines,
false, false, false,
QList<QGis::GeometryType>() << QGis::Line ) );

mTopologyRuleMap.insert( tr( "must not have duplicates" ),
TopologyRule( &topolTest::checkDuplicates,
false, false, true,
QList<QGis::GeometryType>() << QGis::Point << QGis::Polygon << QGis::Line ) );

mTopologyRuleMap.insert( tr( "must not have pseudos" ),
TopologyRule( &topolTest::checkPseudos,
false, false, false,
QList<QGis::GeometryType>() << QGis::Line ) );

mTopologyRuleMap.insert( tr( "must not overlap" ),
TopologyRule( &topolTest::checkOverlaps,
false, false, true,
QList<QGis::GeometryType>() << QGis::Polygon ) );

mTopologyRuleMap.insert( tr( "must not have gaps" ),
TopologyRule( &topolTest::checkGaps,
false, false, false,
QList<QGis::GeometryType>() << QGis::Polygon ) );

mTopologyRuleMap.insert( tr( "must not have multi-part geometries" ),
TopologyRule( &topolTest::checkMultipart,
false, false, false,
QList<QGis::GeometryType>() << QGis::Point << QGis::Polygon << QGis::Line ) );

// two layer tests
mTopologyRuleMap[QObject::tr( "must not overlap with" )].f = &topolTest::checkOverlapWithLayer;
mTopologyRuleMap[QObject::tr( "must not overlap with" )].useSecondLayer = true;
mTopologyRuleMap[QObject::tr( "must not overlap with" )].useTolerance = false;
mTopologyRuleMap[QObject::tr( "must not overlap with" )].useSpatialIndex = true;
mTopologyRuleMap[QObject::tr( "must not overlap with" )].layer1SupportedTypes << QGis::Polygon;
mTopologyRuleMap[QObject::tr( "must not overlap with" )].layer2SupportedTypes << QGis::Polygon;

mTopologyRuleMap[QObject::tr( "must be covered by" )].f = &topolTest::checkPointCoveredBySegment;
mTopologyRuleMap[QObject::tr( "must be covered by" )].useSecondLayer = true;
mTopologyRuleMap[QObject::tr( "must be covered by" )].useTolerance = false;
mTopologyRuleMap[QObject::tr( "must be covered by" )].useSpatialIndex = true;
mTopologyRuleMap[QObject::tr( "must be covered by" )].layer1SupportedTypes << QGis::Point;
mTopologyRuleMap[QObject::tr( "must be covered by" )].layer2SupportedTypes << QGis::Line << QGis::Polygon;

//mTopologyRuleMap[QObject::tr("features must not be closer than tolerance")].f = &topolTest::checkCloseFeature;
//mTopologyRuleMap[QObject::tr("features must not be closer than tolerance")].useSecondLayer = true;
//mTopologyRuleMap[QObject::tr("features must not be closer than tolerance")].useTolerance = false;
//mTopologyRuleMap[QObject::tr("features must not be closer than tolerance")].useSpatialIndex = false;

mTopologyRuleMap[QObject::tr( "must be covered by endpoints of" )].f = &topolTest::checkPointCoveredByLineEnds;
mTopologyRuleMap[QObject::tr( "must be covered by endpoints of" )].useSecondLayer = true;
mTopologyRuleMap[QObject::tr( "must be covered by endpoints of" )].useTolerance = false;
mTopologyRuleMap[QObject::tr( "must be covered by endpoints of" )].useSpatialIndex = true;
mTopologyRuleMap[QObject::tr( "must be covered by endpoints of" )].layer1SupportedTypes << QGis::Point;
mTopologyRuleMap[QObject::tr( "must be covered by endpoints of" )].layer2SupportedTypes << QGis::Line;

mTopologyRuleMap[QObject::tr( "end points must be covered by" )].f = &topolTest::checkyLineEndsCoveredByPoints;
mTopologyRuleMap[QObject::tr( "end points must be covered by" )].useSecondLayer = true;
mTopologyRuleMap[QObject::tr( "end points must be covered by" )].useTolerance = false;
mTopologyRuleMap[QObject::tr( "end points must be covered by" )].useSpatialIndex = true;
mTopologyRuleMap[QObject::tr( "end points must be covered by" )].layer1SupportedTypes << QGis::Line;
mTopologyRuleMap[QObject::tr( "end points must be covered by" )].layer2SupportedTypes << QGis::Point;

mTopologyRuleMap[QObject::tr( "must be inside" )].f = &topolTest::checkPointInPolygon;
mTopologyRuleMap[QObject::tr( "must be inside" )].useSecondLayer = true;
mTopologyRuleMap[QObject::tr( "must be inside" )].useTolerance = false;
mTopologyRuleMap[QObject::tr( "must be inside" )].useSpatialIndex = true;
mTopologyRuleMap[QObject::tr( "must be inside" )].layer1SupportedTypes << QGis::Point;
mTopologyRuleMap[QObject::tr( "must be inside" )].layer2SupportedTypes << QGis::Polygon;

mTopologyRuleMap[QObject::tr( "must contain" )].f = &topolTest::checkPolygonContainsPoint;
mTopologyRuleMap[QObject::tr( "must contain" )].useSecondLayer = true;
mTopologyRuleMap[QObject::tr( "must contain" )].useTolerance = false;
mTopologyRuleMap[QObject::tr( "must contain" )].useSpatialIndex = true;
mTopologyRuleMap[QObject::tr( "must contain" )].layer1SupportedTypes << QGis::Polygon;
mTopologyRuleMap[QObject::tr( "must contain" )].layer2SupportedTypes << QGis::Point;
mTopologyRuleMap.insert( tr( "must not overlap with" ),
TopologyRule( &topolTest::checkOverlapWithLayer,
true, false, true,
QList<QGis::GeometryType>() << QGis::Polygon,
QList<QGis::GeometryType>() << QGis::Polygon ) );

mTopologyRuleMap.insert( tr( "must be covered by" ),
TopologyRule( &topolTest::checkPointCoveredBySegment,
true, false, true,
QList<QGis::GeometryType>() << QGis::Point,
QList<QGis::GeometryType>() << QGis::Line << QGis::Polygon ) );

#if 0
mTopologyRuleMap.insert( tr( "features must not be closer than tolerance" ),
TopologyRule( &topolTest::checkCloseFeature,
true, false, false ) );
#endif

mTopologyRuleMap.insert( tr( "must be covered by endpoints of" ),
TopologyRule( &topolTest::checkPointCoveredByLineEnds,
true, false, true,
QList<QGis::GeometryType>() << QGis::Point,
QList<QGis::GeometryType>() << QGis::Line ) );

mTopologyRuleMap.insert( tr( "end points must be covered by" ),
TopologyRule( &topolTest::checkyLineEndsCoveredByPoints,
true, false, true,
QList<QGis::GeometryType>() << QGis::Line,
QList<QGis::GeometryType>() << QGis::Point ) );

mTopologyRuleMap.insert( tr( "must be inside" ),
TopologyRule( &topolTest::checkPointInPolygon,
true, false, true,
QList<QGis::GeometryType>() << QGis::Point,
QList<QGis::GeometryType>() << QGis::Polygon ) );

mTopologyRuleMap.insert( tr( "must contain" ),
TopologyRule( &topolTest::checkPolygonContainsPoint,
true, false, true,
QList<QGis::GeometryType>() << QGis::Polygon,
QList<QGis::GeometryType>() << QGis::Point ) );
}

topolTest::~topolTest()
Expand Down
21 changes: 14 additions & 7 deletions src/plugins/topology/topolTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,20 @@ class TopologyRule
* Constructor
* initializes the test to use both layers and not to use the tolerance
*/
TopologyRule()
{
useSecondLayer = true;
useTolerance = false;

f = 0;
}
TopologyRule( testFunction f0 = 0,
bool useSecondLayer0 = true,
bool useTolerance0 = false,
bool useSpatialIndex0 = false,
QList<QGis::GeometryType> layer1SupportedTypes0 = QList<QGis::GeometryType>(),
QList<QGis::GeometryType> layer2SupportedTypes0 = QList<QGis::GeometryType>()
)
: f( f0 )
, useSecondLayer( useSecondLayer0 )
, useTolerance( useTolerance0 )
, useSpatialIndex( useSpatialIndex0 )
, layer1SupportedTypes( layer1SupportedTypes0 )
, layer2SupportedTypes( layer2SupportedTypes0 )
{}
};

/**
Expand Down

0 comments on commit 063b70d

Please sign in to comment.