Skip to content
Permalink
Browse files

Expose method for generating CRS widget text

  • Loading branch information
nyalldawson committed Mar 12, 2019
1 parent b42b348 commit c534cc4839d6d4298f18477006e9a50c447645a4
Showing with 13 additions and 5 deletions.
  1. +4 −4 src/gui/qgsprojectionselectionwidget.cpp
  2. +9 −1 src/gui/qgsprojectionselectionwidget.h
@@ -236,7 +236,7 @@ void QgsProjectionSelectionWidget::setCrs( const QgsCoordinateReferenceSystem &c
if ( !optionVisible( QgsProjectionSelectionWidget::CurrentCrs ) )
setOptionVisible( QgsProjectionSelectionWidget::CurrentCrs, true );
mCrsComboBox->setItemText( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ),
currentCrsOptionText( crs ) );
crsOptionText( crs ) );
mCrsComboBox->blockSignals( true );
mCrsComboBox->setCurrentIndex( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ) );
mCrsComboBox->blockSignals( false );
@@ -253,7 +253,7 @@ void QgsProjectionSelectionWidget::setCrs( const QgsCoordinateReferenceSystem &c
else
{
mCrsComboBox->setItemText( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ),
currentCrsOptionText( crs ) );
crsOptionText( crs ) );
}
}
if ( mCrs != crs )
@@ -303,11 +303,11 @@ void QgsProjectionSelectionWidget::addDefaultCrsOption()
void QgsProjectionSelectionWidget::addCurrentCrsOption()
{
int index = optionVisible( CrsNotSet ) ? 1 : 0;
mCrsComboBox->insertItem( index, currentCrsOptionText( mCrs ), QgsProjectionSelectionWidget::CurrentCrs );
mCrsComboBox->insertItem( index, crsOptionText( mCrs ), QgsProjectionSelectionWidget::CurrentCrs );

}

QString QgsProjectionSelectionWidget::currentCrsOptionText( const QgsCoordinateReferenceSystem &crs ) const
QString QgsProjectionSelectionWidget::crsOptionText( const QgsCoordinateReferenceSystem &crs )
{
if ( crs.isValid() )
return tr( "%1 - %2" ).arg( crs.authid(), crs.description() );
@@ -91,6 +91,14 @@ class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
*/
void setMessage( const QString &text );

/**
* Returns display text for the specified \a crs.
*
* \note Not available in Python bindings
* \since QGIS 3.8
*/
static QString crsOptionText( const QgsCoordinateReferenceSystem &crs ) SIP_SKIP;

signals:

/**
@@ -140,7 +148,7 @@ class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
void addProjectCrsOption();
void addDefaultCrsOption();
void addCurrentCrsOption();
QString currentCrsOptionText( const QgsCoordinateReferenceSystem &crs ) const;

void addRecentCrs();
bool crsIsShown( long srsid ) const;

0 comments on commit c534cc4

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