diff --git a/src/gui/qgscoordinatereferencesystemmodel.cpp b/src/gui/qgscoordinatereferencesystemmodel.cpp index 3025ee3c4bf7..2834817c319b 100644 --- a/src/gui/qgscoordinatereferencesystemmodel.cpp +++ b/src/gui/qgscoordinatereferencesystemmodel.cpp @@ -140,7 +140,10 @@ QVariant QgsCoordinateReferenceSystemModel::data( const QModelIndex &index, int return crsNode->record().description; case RoleAuthId: - return QStringLiteral( "%1:%2" ).arg( crsNode->record().authName, crsNode->record().authId ); + if ( !crsNode->record().authId.isEmpty() ) + return QStringLiteral( "%1:%2" ).arg( crsNode->record().authName, crsNode->record().authId ); + else + return QVariant(); case RoleDeprecated: return crsNode->record().deprecated; diff --git a/src/gui/qgsprojectionselectiontreewidget.cpp b/src/gui/qgsprojectionselectiontreewidget.cpp index cf0a223fecc2..d379cf937136 100644 --- a/src/gui/qgsprojectionselectiontreewidget.cpp +++ b/src/gui/qgsprojectionselectiontreewidget.cpp @@ -227,7 +227,6 @@ void QgsProjectionSelectionTreeWidget::setCrs( const QgsCoordinateReferenceSyste } else { - bool changed = false; mBlockSignals = true; mCheckBoxNoProjection->setChecked( false ); mBlockSignals = false; @@ -237,6 +236,7 @@ void QgsProjectionSelectionTreeWidget::setCrs( const QgsCoordinateReferenceSyste else loadUnknownCrs( crs ); + const bool changed = crs != QgsProjectionSelectionTreeWidget::crs(); if ( changed ) { emit crsSelected(); diff --git a/tests/src/python/test_qgscoordinatereferencesystemmodel.py b/tests/src/python/test_qgscoordinatereferencesystemmodel.py index 08664754c213..b2781a6bba96 100644 --- a/tests/src/python/test_qgscoordinatereferencesystemmodel.py +++ b/tests/src/python/test_qgscoordinatereferencesystemmodel.py @@ -329,6 +329,8 @@ def test_model(self): Qt.DisplayRole)) self.assertEqual(model.data(custom_crs_index, QgsCoordinateReferenceSystemModel.RoleName), 'Custom CRS') + self.assertFalse(model.data(custom_crs_index, + QgsCoordinateReferenceSystemModel.RoleAuthId)) self.assertFalse(model.data(custom_crs_index, QgsCoordinateReferenceSystemModel.RoleDeprecated)) # the proj and wkt roles are only available for non-standard CRS diff --git a/tests/src/python/test_qgsprojectionselectionwidgets.py b/tests/src/python/test_qgsprojectionselectionwidgets.py index 0e5c708f96a3..dee8fa43ce3f 100644 --- a/tests/src/python/test_qgsprojectionselectionwidgets.py +++ b/tests/src/python/test_qgsprojectionselectionwidgets.py @@ -154,7 +154,6 @@ def testSignal(self): def testTreeWidgetGettersSetters(self): """ basic tests for QgsProjectionSelectionTreeWidget """ w = QgsProjectionSelectionTreeWidget() - w.show() self.assertFalse(w.hasValidSelection()) w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111')) self.assertEqual(w.crs().authid(), 'EPSG:3111') @@ -162,9 +161,10 @@ def testTreeWidgetGettersSetters(self): def testTreeWidgetUnknownCrs(self): w = QgsProjectionSelectionTreeWidget() - w.show() self.assertFalse(w.hasValidSelection()) - w.setCrs(QgsCoordinateReferenceSystem.fromWkt('GEOGCS["WGS 84",DATUM["unknown",SPHEROID["WGS84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]')) + crs = QgsCoordinateReferenceSystem.fromWkt('GEOGCS["WGS 84",DATUM["unknown",SPHEROID["WGS84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]') + self.assertTrue(crs.isValid()) + w.setCrs(crs) self.assertTrue(w.crs().isValid()) self.assertFalse(w.crs().authid()) self.assertTrue(w.hasValidSelection()) @@ -173,7 +173,6 @@ def testTreeWidgetUnknownCrs(self): def testTreeWidgetNotSetOption(self): """ test allowing no projection option for QgsProjectionSelectionTreeWidget """ w = QgsProjectionSelectionTreeWidget() - w.show() w.setShowNoProjection(True) self.assertTrue(w.showNoProjection()) w.setShowNoProjection(False) @@ -188,14 +187,12 @@ def testTreeWidgetNotSetOption(self): def testDialogGettersSetters(self): """ basic tests for QgsProjectionSelectionTreeWidget """ w = QgsProjectionSelectionDialog() - w.show() w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111')) self.assertEqual(w.crs().authid(), 'EPSG:3111') def testDialogNotSetOption(self): """ test allowing no projection option for QgsProjectionSelectionTreeWidget """ w = QgsProjectionSelectionDialog() - w.show() w.setShowNoProjection(True) self.assertTrue(w.showNoProjection()) w.setShowNoProjection(False) @@ -235,7 +232,6 @@ def testTreeWidgetDeferredLoad(self): self.assertFalse(w.hasValidSelection()) w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111')) self.assertEqual(len(spy), 1) - w.show() self.assertTrue(w.hasValidSelection()) self.assertEqual(w.crs().authid(), 'EPSG:3111') self.assertEqual(len(spy), 1) @@ -245,7 +241,6 @@ def testTreeWidgetDeferredLoad(self): self.assertFalse(w.hasValidSelection()) w.setCrs(QgsCoordinateReferenceSystem()) self.assertEqual(len(spy), 1) - w.show() self.assertTrue(w.hasValidSelection()) self.assertFalse(w.crs().isValid()) self.assertEqual(len(spy), 1) @@ -264,7 +259,6 @@ def testTreeWidgetDeferredLoad(self): self.assertFalse(w.hasValidSelection()) w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111')) w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111')) - w.show() w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111')) self.assertEqual(len(spy), 1) w.setCrs(QgsCoordinateReferenceSystem('EPSG:4326'))