Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add missing crsChanged signal in QgsProjectionSelectionWidget (#7079)
  • Loading branch information
3nids committed May 27, 2018
1 parent c8a5992 commit 487a6a8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/gui/qgsprojectionselectionwidget.cpp
Expand Up @@ -256,7 +256,11 @@ void QgsProjectionSelectionWidget::setCrs( const QgsCoordinateReferenceSystem &c
currentCrsOptionText( crs ) );
}
}
mCrs = crs;
if ( mCrs != crs )
{
mCrs = crs;
emit crsChanged( crs );
}
}

void QgsProjectionSelectionWidget::setLayerCrs( const QgsCoordinateReferenceSystem &crs )
Expand Down
12 changes: 12 additions & 0 deletions tests/src/python/test_qgsprojectionselectionwidgets.py
Expand Up @@ -14,6 +14,7 @@

import qgis # NOQA

from qgis.PyQt.QtTest import QSignalSpy
from qgis.gui import (QgsProjectionSelectionWidget,
QgsProjectionSelectionTreeWidget,
QgsProjectionSelectionDialog)
Expand Down Expand Up @@ -115,6 +116,17 @@ def testShowingNotSetOption(self):
self.assertTrue(w.optionVisible(QgsProjectionSelectionWidget.CurrentCrs))
self.assertTrue(w.optionVisible(QgsProjectionSelectionWidget.CrsNotSet))

def testSignal(self):
w = QgsProjectionSelectionWidget()
w.show()
spy = QSignalSpy(w.crsChanged)
w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
self.assertEqual(w.crs().authid(), 'EPSG:3111')
self.assertEqual(len(spy), 1)
# setting the same crs doesn't emit the signal
w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
self.assertEqual(len(spy), 1)

def testTreeWidgetGettersSetters(self):
""" basic tests for QgsProjectionSelectionTreeWidget """
w = QgsProjectionSelectionTreeWidget()
Expand Down

0 comments on commit 487a6a8

Please sign in to comment.