Skip to content

Commit b2c396f

Browse files
committedNov 27, 2017
Fix #17510 - Better scoping of QgsProjectionSelectionDialog inside QgsProjectionSelectionWidget
1 parent 0717835 commit b2c396f

File tree

6 files changed

+33
-25
lines changed

6 files changed

+33
-25
lines changed
 

‎python/gui/qgsprojectionselectionwidget.sip

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ class QgsProjectionSelectionWidget : QWidget
3535

3636
explicit QgsProjectionSelectionWidget( QWidget *parent /TransferThis/ = 0 );
3737

38-
QgsProjectionSelectionDialog *dialog();
39-
%Docstring
40-
Returns a pointer to the projection selector dialog used by the widget.
41-
Can be used to modify how the projection selector dialog behaves.
42-
:return: projection selector dialog
43-
:rtype: QgsProjectionSelectionDialog
44-
%End
45-
4638
QgsCoordinateReferenceSystem crs() const;
4739
%Docstring
4840
Returns the currently selected CRS for the widget
@@ -71,6 +63,14 @@ class QgsProjectionSelectionWidget : QWidget
7163
Sets the text to show for the not set option. Note that this option is not shown
7264
by default and must be set visible by calling setOptionVisible().
7365
.. versionadded:: 3.0
66+
%End
67+
68+
void setMessage( const QString &text );
69+
%Docstring
70+
Sets a ``message`` to show in the dialog. If an empty string is
71+
passed, the message will be a generic
72+
'define the CRS for this layer'.
73+
.. versionadded:: 3.0
7474
%End
7575

7676
signals:

‎src/app/dwg/qgsdwgimportdialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ QgsDwgImportDialog::QgsDwgImportDialog( QWidget *parent, Qt::WindowFlags f )
9090
QgsCoordinateReferenceSystem crs( crsid, QgsCoordinateReferenceSystem::InternalCrsId );
9191
mCrsSelector->setCrs( crs );
9292
mCrsSelector->setLayerCrs( crs );
93-
mCrsSelector->dialog()->setMessage( tr( "Select the coordinate reference system for the dxf file. "
94-
"The data points will be transformed from the layer coordinate reference system." ) );
93+
mCrsSelector->setMessage( tr( "Select the coordinate reference system for the dxf file. "
94+
"The data points will be transformed from the layer coordinate reference system." ) );
9595

9696
pbLoadDatabase_clicked();
9797
updateUI();

‎src/app/qgsdxfexportdialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,8 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f )
474474
mCRS = QgsCoordinateReferenceSystem::fromSrsId( crsid );
475475
mCrsSelector->setCrs( mCRS );
476476
mCrsSelector->setLayerCrs( mCRS );
477-
mCrsSelector->dialog()->setMessage( tr( "Select the coordinate reference system for the dxf file. "
478-
"The data points will be transformed from the layer coordinate reference system." ) );
477+
mCrsSelector->setMessage( tr( "Select the coordinate reference system for the dxf file. "
478+
"The data points will be transformed from the layer coordinate reference system." ) );
479479

480480
mEncoding->addItems( QgsDxfExport::encodings() );
481481
mEncoding->setCurrentIndex( mEncoding->findText( QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfEncoding" ), s.value( QStringLiteral( "qgis/lastDxfEncoding" ), "CP1252" ).toString() ) ) );

‎src/gui/ogr/qgsvectorlayersaveasdialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ void QgsVectorLayerSaveAsDialog::setup()
120120
QgsCoordinateReferenceSystem srs = QgsCoordinateReferenceSystem::fromSrsId( mCRS );
121121
mCrsSelector->setCrs( srs );
122122
mCrsSelector->setLayerCrs( srs );
123-
mCrsSelector->dialog()->setMessage( tr( "Select the coordinate reference system for the vector file. "
124-
"The data points will be transformed from the layer coordinate reference system." ) );
123+
mCrsSelector->setMessage( tr( "Select the coordinate reference system for the vector file. "
124+
"The data points will be transformed from the layer coordinate reference system." ) );
125125

126126
mEncodingComboBox->setCurrentIndex( idx );
127127
mFormatComboBox_currentIndexChanged( mFormatComboBox->currentIndex() );

‎src/gui/qgsprojectionselectionwidget.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
QgsProjectionSelectionWidget::QgsProjectionSelectionWidget( QWidget *parent )
2525
: QWidget( parent )
2626
{
27-
mDialog = new QgsProjectionSelectionDialog( this );
2827

2928

3029
QHBoxLayout *layout = new QHBoxLayout();
@@ -157,6 +156,11 @@ void QgsProjectionSelectionWidget::setNotSetText( const QString &text )
157156
}
158157
}
159158

159+
void QgsProjectionSelectionWidget::setMessage( const QString &text )
160+
{
161+
mMessage = text;
162+
}
163+
160164
bool QgsProjectionSelectionWidget::optionVisible( QgsProjectionSelectionWidget::CrsOption option ) const
161165
{
162166
int optionIndex = mCrsComboBox->findData( option );
@@ -166,17 +170,19 @@ bool QgsProjectionSelectionWidget::optionVisible( QgsProjectionSelectionWidget::
166170
void QgsProjectionSelectionWidget::selectCrs()
167171
{
168172
//find out crs id of current proj4 string
173+
QgsProjectionSelectionDialog dlg( this );
174+
dlg.setMessage( mMessage );
169175
if ( mCrs.isValid() )
170176
{
171-
mDialog->setCrs( mCrs );
177+
dlg.setCrs( mCrs );
172178
}
173179

174-
if ( mDialog->exec() )
180+
if ( dlg.exec() )
175181
{
176182
mCrsComboBox->blockSignals( true );
177183
mCrsComboBox->setCurrentIndex( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ) );
178184
mCrsComboBox->blockSignals( false );
179-
QgsCoordinateReferenceSystem crs = mDialog->crs();
185+
QgsCoordinateReferenceSystem crs = dlg.crs();
180186
setCrs( crs );
181187
emit crsChanged( crs );
182188
}

‎src/gui/qgsprojectionselectionwidget.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@ class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
5454

5555
explicit QgsProjectionSelectionWidget( QWidget *parent SIP_TRANSFERTHIS = 0 );
5656

57-
/**
58-
* Returns a pointer to the projection selector dialog used by the widget.
59-
* Can be used to modify how the projection selector dialog behaves.
60-
* \returns projection selector dialog
61-
*/
62-
QgsProjectionSelectionDialog *dialog() { return mDialog; }
63-
6457
/**
6558
* Returns the currently selected CRS for the widget
6659
* \returns current CRS
@@ -89,6 +82,14 @@ class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
8982
*/
9083
void setNotSetText( const QString &text );
9184

85+
/**
86+
* Sets a \a message to show in the dialog. If an empty string is
87+
* passed, the message will be a generic
88+
* 'define the CRS for this layer'.
89+
* \since QGIS 3.0
90+
*/
91+
void setMessage( const QString &text );
92+
9293
signals:
9394

9495
/**
@@ -132,6 +133,7 @@ class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
132133
QToolButton *mButton = nullptr;
133134
QgsProjectionSelectionDialog *mDialog = nullptr;
134135
QString mNotSetText;
136+
QString mMessage;
135137

136138
void addNotSetOption();
137139
void addProjectCrsOption();

0 commit comments

Comments
 (0)
Please sign in to comment.