Skip to content
Permalink
Browse files

[needs-docs] Drop unused/misleading 'tolerance' setting from topology

checker

Fixes #9621
  • Loading branch information
nyalldawson committed Mar 30, 2018
1 parent d9e9f2a commit 8ebd47bfb2b672dfdcdefa09e2b564688f4707ad
@@ -324,9 +324,8 @@ void checkDock::runTests( ValidateType type )
for ( int i = 0; i < mTestTable->rowCount(); ++i )
{
QString testName = mTestTable->item( i, 0 )->text();
QString toleranceStr = mTestTable->item( i, 3 )->text();
QString layer1Str = mTestTable->item( i, 4 )->text();
QString layer2Str = mTestTable->item( i, 5 )->text();
QString layer1Str = mTestTable->item( i, 3 )->text();
QString layer2Str = mTestTable->item( i, 4 )->text();

// test if layer1 is in the registry
if ( !( ( QgsVectorLayer * )QgsProject::instance()->mapLayers().contains( layer1Str ) ) )
@@ -348,7 +347,7 @@ void checkDock::runTests( ValidateType type )
connect( mTest, &topolTest::progress, &progress, &QProgressDialog::setValue );
// run the test

ErrorList errors = mTest->runTest( testName, layer1, layer2, type, toleranceStr.toDouble() );
ErrorList errors = mTest->runTest( testName, layer1, layer2, type );

QList<TopolError *>::Iterator it;

@@ -38,8 +38,8 @@ rulesDialog::rulesDialog( const QMap<QString, TopologyRule> &testMap, QgisInterf
mQgisIface = qgisIface;

//setHorizontalHeaderItems();
mRulesTable->hideColumn( 3 );
mRulesTable->hideColumn( 4 );
mRulesTable->hideColumn( 5 );

mTestConfMap = testMap;
mRulesTable->setSelectionBehavior( QAbstractItemView::SelectRows );
@@ -69,7 +69,7 @@ rulesDialog::rulesDialog( const QMap<QString, TopologyRule> &testMap, QgisInterf
void rulesDialog::setHorizontalHeaderItems()
{
QStringList labels;
labels << tr( "Test" ) << tr( "Layer #1" ) << tr( "Layer #2" ) << tr( "Tolerance" ) << QLatin1String( "" ) << QLatin1String( "" );
labels << tr( "Test" ) << tr( "Layer #1" ) << tr( "Layer #2" ) << QLatin1String( "" ) << QLatin1String( "" );
mRulesTable->setHorizontalHeaderLabels( labels );
}

@@ -78,11 +78,9 @@ void rulesDialog::readTest( int index, QgsProject *project )
QString testName;
QString layer1Id;
QString layer2Id;
QString tolerance;
QString postfix = QStringLiteral( "%1" ).arg( index );

testName = project->readEntry( QStringLiteral( "Topol" ), "/testname_" + postfix, QLatin1String( "" ) );
tolerance = project->readEntry( QStringLiteral( "Topol" ), "/tolerance_" + postfix, QLatin1String( "" ) );
layer1Id = project->readEntry( QStringLiteral( "Topol" ), "/layer1_" + postfix, QLatin1String( "" ) );
layer2Id = project->readEntry( QStringLiteral( "Topol" ), "/layer2_" + postfix, QLatin1String( "" ) );

@@ -127,19 +125,11 @@ void rulesDialog::readTest( int index, QgsProject *project )
newItem->setFlags( newItem->flags() & ~Qt::ItemIsEditable );
mRulesTable->setItem( row, 2, newItem );

if ( mTestConfMap[testName].useTolerance )
newItem = new QTableWidgetItem( tolerance );
else
newItem = new QTableWidgetItem( tr( "No tolerance" ) );

newItem->setFlags( newItem->flags() & ~Qt::ItemIsEditable );
mRulesTable->setItem( row, 3, newItem );

// add layer ids to hidden columns
newItem = new QTableWidgetItem( layer1Id );
mRulesTable->setItem( row, 4, newItem );
mRulesTable->setItem( row, 3, newItem );
newItem = new QTableWidgetItem( layer2Id );
mRulesTable->setItem( row, 5, newItem );
mRulesTable->setItem( row, 4, newItem );
}

void rulesDialog::projectRead()
@@ -197,19 +187,6 @@ void rulesDialog::showControls( const QString &testName )
{
mLayer2Box->setVisible( false );
}


if ( topologyRule.useTolerance )
{
mToleranceBox->setVisible( true );
mToleranceLabel->setVisible( true );
}
else
{
mToleranceBox->setVisible( false );
mToleranceLabel->setVisible( false );
}

}

void rulesDialog::addRule()
@@ -250,13 +227,6 @@ void rulesDialog::addRule()

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

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

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

QString layer1ID, layer2ID;
// add layer ids to hidden columns
// -1 for "No layer" string
@@ -269,25 +239,23 @@ void rulesDialog::addRule()

//TODO: use setItemData (or something like that) instead of hidden columns
newItem = new QTableWidgetItem( layer1ID );
mRulesTable->setItem( row, 4, newItem );
mRulesTable->setItem( row, 3, newItem );
newItem = new QTableWidgetItem( layer2ID );
mRulesTable->setItem( row, 5, newItem );
mRulesTable->setItem( row, 4, newItem );

// save state to the project file.....
QString postfix = QStringLiteral( "%1" ).arg( row );
QgsProject *project = QgsProject::instance();

project->writeEntry( QStringLiteral( "Topol" ), QStringLiteral( "/testCount" ), row + 1 );
project->writeEntry( QStringLiteral( "Topol" ), "/testname_" + postfix, test );
project->writeEntry( QStringLiteral( "Topol" ), "/tolerance_" + postfix, QStringLiteral( "%1" ).arg( mToleranceBox->value() ) );
project->writeEntry( QStringLiteral( "Topol" ), "/layer1_" + postfix, layer1ID );
project->writeEntry( QStringLiteral( "Topol" ), "/layer2_" + postfix, layer2ID );

// reset controls to default
mRuleBox->setCurrentIndex( 0 );
mLayer1Box->setCurrentIndex( 0 );
mLayer2Box->setCurrentIndex( 0 );
mToleranceBox->setValue( 0 );
}

void rulesDialog::deleteTest()
@@ -58,20 +58,6 @@
</item>
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="mToleranceLabel">
<property name="text">
<string>Tolerance</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="mToleranceBox"/>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
@@ -86,22 +72,18 @@
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="mAddTestButton">
<property name="text">
<string>Add Rule</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mDeleteTestButton">
<property name="text">
<string>Delete Rule</string>
</property>
</widget>
</item>
</layout>
<widget class="QPushButton" name="mAddTestButton">
<property name="text">
<string>Add Rule</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mDeleteTestButton">
<property name="text">
<string>Delete Rule</string>
</property>
</widget>
</item>
</layout>
</item>
@@ -122,11 +104,6 @@
<string>Layer #2</string>
</property>
</column>
<column>
<property name="text">
<string>Tolerance</string>
</property>
</column>
<column>
<property name="text">
<string>Layer1ID</string>
@@ -155,7 +132,6 @@
<tabstop>mLayer1Box</tabstop>
<tabstop>mRuleBox</tabstop>
<tabstop>mLayer2Box</tabstop>
<tabstop>mToleranceBox</tabstop>
<tabstop>mAddTestButton</tabstop>
<tabstop>mDeleteTestButton</tabstop>
<tabstop>mRulesTable</tabstop>

0 comments on commit 8ebd47b

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