QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsprojectionselectionwidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsprojectionselectionwidget.cpp
3 --------------------------------------
4 Date : 05.01.2015
5 Copyright : (C) 2015 Denis Rouzaud
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include <QHBoxLayout>
17
19#include "qgsapplication.h"
21#include "qgsproject.h"
22#include "qgssettings.h"
25#include "qgsdatums.h"
26
28 : QWidget( parent )
29 , mDialogTitle( tr( "Select CRS" ) )
30{
31
32 mCrsComboBox = new QgsHighlightableComboBox( this );
33 mCrsComboBox->addItem( tr( "invalid projection" ), QgsProjectionSelectionWidget::CurrentCrs );
34 mCrsComboBox->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );
35
36 const int labelMargin = static_cast< int >( std::round( mCrsComboBox->fontMetrics().horizontalAdvance( 'X' ) ) );
37 QHBoxLayout *layout = new QHBoxLayout();
38 layout->setContentsMargins( 0, 0, 0, 0 );
39 layout->setSpacing( 0 );
40 setLayout( layout );
41
42 mProjectCrs = QgsProject::instance()->crs();
43 addProjectCrsOption();
44
45 const QgsSettings settings;
46 mDefaultCrs = QgsCoordinateReferenceSystem( settings.value( QStringLiteral( "/projections/defaultProjectCrs" ), geoEpsgCrsAuthId(), QgsSettings::App ).toString() );
47 if ( mDefaultCrs.authid() != mProjectCrs.authid() )
48 {
49 //only show default CRS option if it's different to the project CRS, avoids
50 //needlessly cluttering the widget
51 addDefaultCrsOption();
52 }
53
54 addRecentCrs();
55
56 layout->addWidget( mCrsComboBox, 1 );
57
58 // bit of fiddlyness here -- we want the initial spacing to only be visible
59 // when the warning label is shown, so it's embedded inside mWarningLabel
60 // instead of outside it
61 mWarningLabelContainer = new QWidget();
62 QHBoxLayout *warningLayout = new QHBoxLayout();
63 warningLayout->setContentsMargins( 0, 0, 0, 0 );
64 mWarningLabel = new QLabel();
65 const QIcon icon = QgsApplication::getThemeIcon( QStringLiteral( "mIconWarning.svg" ) );
66 const int size = static_cast< int >( std::max( 24.0, mCrsComboBox->minimumSize().height() * 0.5 ) );
67 mWarningLabel->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
68 warningLayout->insertSpacing( 0, labelMargin / 2 );
69 warningLayout->insertWidget( 1, mWarningLabel );
70 mWarningLabelContainer->setLayout( warningLayout );
71 layout->addWidget( mWarningLabelContainer );
72 mWarningLabelContainer->hide();
73
74 layout->addSpacing( labelMargin / 2 );
75
76 mButton = new QToolButton( this );
77 mButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionSetProjection.svg" ) ) );
78 mButton->setToolTip( tr( "Select CRS" ) );
79 layout->addWidget( mButton );
80
81 setFocusPolicy( Qt::StrongFocus );
82 setFocusProxy( mButton );
83 setAcceptDrops( true );
84
85 connect( mButton, &QToolButton::clicked, this, &QgsProjectionSelectionWidget::selectCrs );
86 connect( mCrsComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsProjectionSelectionWidget::comboIndexChanged );
87
89 {
90 mCrs.updateDefinition();
91 mLayerCrs.updateDefinition();
92 mProjectCrs.updateDefinition();
93 mDefaultCrs.updateDefinition();
94 } );
95}
96
97QgsCoordinateReferenceSystem QgsProjectionSelectionWidget::crsAtIndex( int index ) const
98{
99 switch ( static_cast< CrsOption >( mCrsComboBox->itemData( index ).toInt() ) )
100 {
102 return mLayerCrs;
104 return mProjectCrs;
106 return mDefaultCrs;
108 return mCrs;
110 {
111 const long srsid = mCrsComboBox->itemData( index, Qt::UserRole + 1 ).toLongLong();
113 return crs;
114 }
117 }
118 return mCrs;
119}
120
122{
123 return crsAtIndex( mCrsComboBox->currentIndex() );
124}
125
127{
128 const int optionIndex = mCrsComboBox->findData( option );
129
130 if ( visible && optionIndex < 0 )
131 {
132 //add missing CRS option
133 switch ( option )
134 {
136 {
137 setLayerCrs( mLayerCrs );
138 return;
139 }
141 {
142 addProjectCrsOption();
143 return;
144 }
146 {
147 addDefaultCrsOption();
148 return;
149 }
151 {
152 addCurrentCrsOption();
153 return;
154 }
156 //recently used CRS option cannot be readded
157 return;
159 {
160 addNotSetOption();
161
162 if ( optionVisible( CurrentCrs ) && !mCrs.isValid() )
163 {
164 // hide invalid option if not set option is shown
166 }
167
168 return;
169 }
170 }
171 }
172 else if ( !visible && optionIndex >= 0 )
173 {
174 //remove CRS option
175 mCrsComboBox->removeItem( optionIndex );
176
177 if ( option == CrsNotSet )
178 {
180 }
181 }
182}
183
185{
186 mNotSetText = text;
187 const int optionIndex = mCrsComboBox->findData( CrsNotSet );
188 if ( optionIndex >= 0 )
189 {
190 mCrsComboBox->setItemText( optionIndex, mNotSetText );
191 }
192}
193
195{
196 mMessage = text;
197}
198
200{
201 const int optionIndex = mCrsComboBox->findData( option );
202 return optionIndex >= 0;
203}
204
206{
208
209 QSet< QString > ogcFilter;
210 ogcFilter.reserve( mFilter.size( ) );
211 for ( const QgsCoordinateReferenceSystem &crs : std::as_const( mFilter ) )
212 {
213 ogcFilter << crs.authid();
214 }
215
216 if ( panel && panel->dockMode() )
217 {
218 mActivePanel = new QgsCrsSelectionWidget( this );
219 if ( !ogcFilter.isEmpty() )
220 mActivePanel->setOgcWmsCrsFilter( ogcFilter );
221 if ( !mMessage.isEmpty() )
222 mActivePanel->setMessage( mMessage );
223 mActivePanel->setCrs( mCrs );
224
225 if ( !mNotSetText.isEmpty() )
226 mActivePanel->setNotSetText( mNotSetText );
227
228 mActivePanel->setPanelTitle( mDialogTitle );
229
230 if ( optionVisible( QgsProjectionSelectionWidget::CrsOption::CrsNotSet ) )
231 {
232 mActivePanel->setShowNoCrs( true );
233 }
234
235 connect( mActivePanel, &QgsCrsSelectionWidget::crsChanged, this, [ this ]
236 {
237 if ( mIgnorePanelSignals )
238 return;
239
240 if ( !mActivePanel->hasValidSelection() )
241 return;
242
243 mCrsComboBox->blockSignals( true );
244 mCrsComboBox->setCurrentIndex( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ) );
245 mCrsComboBox->blockSignals( false );
246 const QgsCoordinateReferenceSystem crs = mActivePanel->crs();
247
248 mIgnorePanelSignals++;
249 setCrs( crs );
250 mIgnorePanelSignals--;
251
252 emit crsChanged( crs );
253 } );
254 panel->openPanel( mActivePanel );
255 }
256 else
257 {
259 if ( !mMessage.isEmpty() )
260 dlg.setMessage( mMessage );
261 if ( !ogcFilter.isEmpty() )
262 dlg.setOgcWmsCrsFilter( ogcFilter );
263 dlg.setCrs( mCrs );
264 dlg.setWindowTitle( mDialogTitle );
265
266 if ( !mNotSetText.isEmpty() )
267 dlg.setNotSetText( mNotSetText );
268
269 if ( optionVisible( QgsProjectionSelectionWidget::CrsOption::CrsNotSet ) )
270 {
271 dlg.setShowNoProjection( true );
272 }
274
275 if ( dlg.exec() )
276 {
277 mCrsComboBox->blockSignals( true );
278 mCrsComboBox->setCurrentIndex( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ) );
279 mCrsComboBox->blockSignals( false );
281 setCrs( crs );
282 emit crsChanged( crs );
283 }
284 else
285 {
286 QApplication::restoreOverrideCursor();
287 }
288 }
289}
290
292{
293 if ( !( event->possibleActions() & Qt::CopyAction ) )
294 {
295 event->ignore();
296 return;
297 }
298
299 if ( mapLayerFromMimeData( event->mimeData() ) )
300 {
301 // dragged an acceptable layer, phew
302 event->setDropAction( Qt::CopyAction );
303 event->accept();
304 mCrsComboBox->setHighlighted( true );
305 update();
306 }
307 else
308 {
309 event->ignore();
310 }
311}
312
314{
315 if ( mCrsComboBox->isHighlighted() )
316 {
317 event->accept();
318 mCrsComboBox->setHighlighted( false );
319 update();
320 }
321 else
322 {
323 event->ignore();
324 }
325}
326
328{
329 if ( !( event->possibleActions() & Qt::CopyAction ) )
330 {
331 event->ignore();
332 return;
333 }
334
335 if ( QgsMapLayer *layer = mapLayerFromMimeData( event->mimeData() ) )
336 {
337 // dropped a map layer
338 setFocus( Qt::MouseFocusReason );
339 event->setDropAction( Qt::CopyAction );
340 event->accept();
341
342 if ( layer->crs().isValid() )
343 setCrs( layer->crs() );
344 }
345 else
346 {
347 event->ignore();
348 }
349 mCrsComboBox->setHighlighted( false );
350 update();
351}
352
354{
355 return mSourceEnsemble;
356}
357
359{
360 mDialogTitle = title;
361}
362
364{
365 return mDialogTitle;
366}
367
368void QgsProjectionSelectionWidget::setFilter( const QList<QgsCoordinateReferenceSystem> &crses )
369{
370 mFilter = crses;
371
372
373 for ( int i = mCrsComboBox->count() - 1; i >= 0; --i )
374 {
375 if ( !mFilter.contains( crsAtIndex( i ) ) )
376 mCrsComboBox->removeItem( i );
377 }
378}
379
381{
382 if ( mSourceEnsemble == ensemble )
383 return;
384
385 mSourceEnsemble = ensemble;
386 updateWarning();
387}
388
390{
391 return mShowAccuracyWarnings;
392}
393
395{
396 mShowAccuracyWarnings = show;
397 if ( !mShowAccuracyWarnings )
398 mWarningLabelContainer->hide();
399 else
400 updateWarning();
401}
402
403void QgsProjectionSelectionWidget::addNotSetOption()
404{
405 mCrsComboBox->insertItem( 0, mNotSetText, QgsProjectionSelectionWidget::CrsNotSet );
406 if ( !mCrs.isValid() )
407 whileBlocking( mCrsComboBox )->setCurrentIndex( 0 );
408}
409
410void QgsProjectionSelectionWidget::comboIndexChanged( int idx )
411{
412 switch ( static_cast< CrsOption >( mCrsComboBox->itemData( idx ).toInt() ) )
413 {
415 emit crsChanged( mLayerCrs );
416 break;
418 emit crsChanged( mProjectCrs );
419 break;
421 emit crsChanged( mCrs );
422 break;
424 emit crsChanged( mDefaultCrs );
425 break;
427 {
428 const long srsid = mCrsComboBox->itemData( idx, Qt::UserRole + 1 ).toLongLong();
430 emit crsChanged( crs );
431 break;
432 }
434 emit cleared();
436 break;
437 }
438 updateTooltip();
439}
440
441void QgsProjectionSelectionWidget::updateWarning()
442{
443 if ( !mShowAccuracyWarnings )
444 {
445 if ( mWarningLabelContainer->isVisible() )
446 mWarningLabelContainer->hide();
447 return;
448 }
449
450 try
451 {
452 const double crsAccuracyWarningThreshold = QgsSettings().value( QStringLiteral( "/projections/crsAccuracyWarningThreshold" ), 0.0, QgsSettings::App ).toDouble();
453
454 const QgsDatumEnsemble ensemble = crs().datumEnsemble();
455 if ( !ensemble.isValid() || ensemble.name() == mSourceEnsemble || ( ensemble.accuracy() > 0 && ensemble.accuracy() < crsAccuracyWarningThreshold ) )
456 {
457 mWarningLabelContainer->hide();
458 }
459 else
460 {
461 mWarningLabelContainer->show();
462
463 QString warning = QStringLiteral( "<p>" );
464
465 QString id;
466 if ( !ensemble.code().isEmpty() )
467 id = QStringLiteral( "<i>%1</i> (%2:%3)" ).arg( ensemble.name(), ensemble.authority(), ensemble.code() );
468 else
469 id = QStringLiteral( "<i>%</i>”" ).arg( ensemble.name() );
470
471 if ( ensemble.accuracy() > 0 )
472 {
473 warning = tr( "The selected CRS is based on %1, which has a limited accuracy of <b>at best %2 meters</b>." ).arg( id ).arg( ensemble.accuracy() );
474 }
475 else
476 {
477 warning = tr( "The selected CRS is based on %1, which has a limited accuracy." ).arg( id );
478 }
479 warning += QStringLiteral( "</p><p>" ) + tr( "Use an alternative CRS if accurate positioning is required." ) + QStringLiteral( "</p>" );
480
481 const QList< QgsDatumEnsembleMember > members = ensemble.members();
482 if ( !members.isEmpty() )
483 {
484 warning += QStringLiteral( "<p>" ) + tr( "%1 consists of the datums:" ).arg( ensemble.name() ) + QStringLiteral( "</p><ul>" );
485
486 for ( const QgsDatumEnsembleMember &member : members )
487 {
488 if ( !member.code().isEmpty() )
489 id = QStringLiteral( "%1 (%2:%3)" ).arg( member.name(), member.authority(), member.code() );
490 else
491 id = member.name();
492 warning += QStringLiteral( "<li>%1</li>" ).arg( id );
493 }
494
495 warning += QLatin1String( "</ul>" );
496 }
497
498 mWarningLabel->setToolTip( warning );
499 }
500 }
501 catch ( QgsNotSupportedException & )
502 {
503 mWarningLabelContainer->hide();
504 }
505}
506
508{
509 if ( crs.isValid() )
510 {
513 mCrsComboBox->setItemText( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ),
514 crsOptionText( crs ) );
515 mCrsComboBox->blockSignals( true );
516 mCrsComboBox->setCurrentIndex( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ) );
517 mCrsComboBox->blockSignals( false );
518 }
519 else
520 {
521 const int crsNotSetIndex = mCrsComboBox->findData( QgsProjectionSelectionWidget::CrsNotSet );
522 if ( crsNotSetIndex >= 0 )
523 {
524 mCrsComboBox->blockSignals( true );
525 mCrsComboBox->setCurrentIndex( crsNotSetIndex );
526 mCrsComboBox->blockSignals( false );
527 }
528 else
529 {
530 mCrsComboBox->setItemText( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ),
531 crsOptionText( crs ) );
532 }
533 }
534 if ( mActivePanel && !mIgnorePanelSignals )
535 {
536 mIgnorePanelSignals++;
537 mActivePanel->setCrs( crs );
538 mIgnorePanelSignals--;
539 }
540 if ( mCrs != crs )
541 {
542 mCrs = crs;
543 emit crsChanged( crs );
544 }
545 updateTooltip();
546}
547
549{
550 const int layerItemIndex = mCrsComboBox->findData( QgsProjectionSelectionWidget::LayerCrs );
551 if ( crs.isValid() )
552 {
553 if ( layerItemIndex > -1 )
554 {
555 mCrsComboBox->setItemText( layerItemIndex, tr( "Layer CRS: %1" ).arg( crs.userFriendlyIdentifier() ) );
556 }
557 else
558 {
559 mCrsComboBox->insertItem( firstRecentCrsIndex(), tr( "Layer CRS: %1" ).arg( crs.userFriendlyIdentifier() ), QgsProjectionSelectionWidget::LayerCrs );
560 }
561 }
562 else
563 {
564 if ( layerItemIndex > -1 )
565 {
566 mCrsComboBox->removeItem( layerItemIndex );
567 }
568 }
569 mLayerCrs = crs;
570}
571
572void QgsProjectionSelectionWidget::addProjectCrsOption()
573{
574 if ( mProjectCrs.isValid() )
575 {
576 mCrsComboBox->addItem( tr( "Project CRS: %1" ).arg( mProjectCrs.userFriendlyIdentifier() ), QgsProjectionSelectionWidget::ProjectCrs );
577 }
578}
579
580void QgsProjectionSelectionWidget::addDefaultCrsOption()
581{
582 mCrsComboBox->addItem( tr( "Default CRS: %1" ).arg( mDefaultCrs.userFriendlyIdentifier() ), QgsProjectionSelectionWidget::DefaultCrs );
583}
584
585void QgsProjectionSelectionWidget::addCurrentCrsOption()
586{
587 const int index = optionVisible( CrsNotSet ) ? 1 : 0;
588 mCrsComboBox->insertItem( index, crsOptionText( mCrs ), QgsProjectionSelectionWidget::CurrentCrs );
589
590}
591
593{
594 if ( crs.isValid() )
596 else
597 return tr( "invalid projection" );
598}
599
600void QgsProjectionSelectionWidget::addRecentCrs()
601{
602 const QList< QgsCoordinateReferenceSystem> recentProjections = QgsCoordinateReferenceSystem::recentCoordinateReferenceSystems();
603 for ( const QgsCoordinateReferenceSystem &crs : recentProjections )
604 {
605 const long srsid = crs.srsid();
606
607 //check if already shown
608 if ( crsIsShown( srsid ) )
609 {
610 continue;
611 }
612
613 if ( crs.isValid() && ( mFilter.isEmpty() || mFilter.contains( crs ) ) )
614 {
616 mCrsComboBox->setItemData( mCrsComboBox->count() - 1, QVariant( ( long long )srsid ), Qt::UserRole + 1 );
617 }
618 }
619}
620
621bool QgsProjectionSelectionWidget::crsIsShown( const long srsid ) const
622{
623 return srsid == mLayerCrs.srsid() || srsid == mDefaultCrs.srsid() || srsid == mProjectCrs.srsid();
624}
625
626int QgsProjectionSelectionWidget::firstRecentCrsIndex() const
627{
628 for ( int i = 0; i < mCrsComboBox->count(); ++i )
629 {
630 if ( static_cast< CrsOption >( mCrsComboBox->itemData( i ).toInt() ) == RecentCrs )
631 {
632 return i;
633 }
634 }
635 return -1;
636}
637
638void QgsProjectionSelectionWidget::updateTooltip()
639{
641 if ( c.isValid() )
642 setToolTip( c.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED, true ) );
643 else
644 setToolTip( QString() );
645 updateWarning();
646}
647
648QgsMapLayer *QgsProjectionSelectionWidget::mapLayerFromMimeData( const QMimeData *data ) const
649{
651 for ( const QgsMimeDataUtils::Uri &u : uriList )
652 {
653 // is this uri from the current project?
654 if ( QgsMapLayer *layer = u.mapLayer() )
655 {
656 return layer;
657 }
658 }
659 return nullptr;
660}
661
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsCoordinateReferenceSystemRegistry * coordinateReferenceSystemRegistry()
Returns the application's coordinate reference system (CRS) registry, which handles known CRS definit...
void userCrsChanged(const QString &id)
Emitted whenever an existing user CRS definition is changed.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QgsDatumEnsemble datumEnsemble() const SIP_THROW(QgsNotSupportedException)
Attempts to retrieve datum ensemble details from the CRS.
void updateDefinition()
Updates the definition and parameters of the coordinate reference system to their latest values.
static QList< QgsCoordinateReferenceSystem > recentCoordinateReferenceSystems()
Returns a list of recently used CRS.
QString userFriendlyIdentifier(IdentifierType type=MediumString) const
Returns a user friendly identifier for the CRS.
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
static QgsCoordinateReferenceSystem fromSrsId(long srsId)
Creates a CRS from a specified QGIS SRS ID.
long srsid() const
Returns the internal CRS ID, if available.
A generic widget allowing users to pick a Coordinate Reference System (or define their own).
void crsChanged()
Emitted when the CRS defined in the widget is changed.
Contains information about a member of a datum ensemble.
Definition: qgsdatums.h:35
Contains information about a datum ensemble.
Definition: qgsdatums.h:95
QString code() const
Identification code, e.g.
Definition: qgsdatums.h:122
QString authority() const
Authority name, e.g.
Definition: qgsdatums.h:117
bool isValid() const
Returns true if the datum ensemble is a valid object, or false if it is a null/invalid object.
Definition: qgsdatums.h:102
QList< QgsDatumEnsembleMember > members() const
Contains a list of members of the ensemble.
Definition: qgsdatums.h:137
QString name() const
Display name of datum ensemble.
Definition: qgsdatums.h:107
double accuracy() const
Positional accuracy (in meters).
Definition: qgsdatums.h:112
A QComboBox subclass with the ability to "highlight" the edges of the widget.
void setHighlighted(bool highlighted)
Sets whether the combo box is currently highlighted.
bool isHighlighted() const
Returns true if the combo box is currently highlighted.
Base class for all map layer types.
Definition: qgsmaplayer.h:73
QList< QgsMimeDataUtils::Uri > UriList
static UriList decodeUriList(const QMimeData *data)
Custom exception class which is raised when an operation is not supported.
Definition: qgsexception.h:118
Base class for any widget that can be shown as a inline panel.
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
bool dockMode()
Returns the dock mode state.
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:477
QgsCoordinateReferenceSystem crs
Definition: qgsproject.h:109
A generic dialog to prompt the user for a Coordinate Reference System.
void setShowNoProjection(bool show)
Sets whether a "no/invalid" projection option should be shown.
void setNotSetText(const QString &text, const QString &description=QString())
Sets the text to show for the not set option.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the initial crs to show within the dialog.
void setMessage(const QString &message)
Sets a message to show in the dialog.
QgsCoordinateReferenceSystem crs() const
Returns the CRS currently selected in the widget.
void setRequireValidSelection()
Sets the dialog to require a valid selection only, preventing users from accepting the dialog if no s...
void setOgcWmsCrsFilter(const QSet< QString > &crsFilter)
filters this dialog by the given CRSs
void setFilter(const QList< QgsCoordinateReferenceSystem > &crses)
Sets a filtered list of CRSes to show in the widget.
bool showAccuracyWarnings() const
Returns true if the widget will show a warning to users when they select a CRS which has low accuracy...
void cleared()
Emitted when the not set option is selected.
void selectCrs()
Opens the dialog for selecting a new CRS.
void crsChanged(const QgsCoordinateReferenceSystem &)
Emitted when the selected CRS is changed.
CrsOption
Predefined CRS options shown in widget.
@ CrsNotSet
Not set (hidden by default)
@ ProjectCrs
Current project CRS (if OTF reprojection enabled)
@ CurrentCrs
Current user selected CRS.
QgsProjectionSelectionWidget(QWidget *parent=nullptr)
Constructor for QgsProjectionSelectionWidget.
bool optionVisible(CrsOption option) const
Returns whether the specified CRS option is visible in the widget.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the current CRS for the widget.
void setNotSetText(const QString &text)
Sets the text to show for the not set option.
void setLayerCrs(const QgsCoordinateReferenceSystem &crs)
Sets the layer CRS for the widget.
void setOptionVisible(CrsOption option, bool visible)
Sets whether a predefined CRS option should be shown in the widget.
QString sourceEnsemble() const
Returns the original source ensemble datum name.
QgsCoordinateReferenceSystem crs() const
Returns the currently selected CRS for the widget.
QString dialogTitle() const
Returns the title for the CRS selector dialog window.
void dragEnterEvent(QDragEnterEvent *event) override
void setMessage(const QString &text)
Sets a message to show in the dialog.
static QString crsOptionText(const QgsCoordinateReferenceSystem &crs)
Returns display text for the specified crs.
void dragLeaveEvent(QDragLeaveEvent *event) override
void setShowAccuracyWarnings(bool show)
Sets whether the widget will show warnings to users when they select a CRS which has low accuracy.
void setDialogTitle(const QString &title)
Sets the title for the CRS selector dialog window.
void setSourceEnsemble(const QString &ensemble)
Sets the original source ensemble datum name.
void dropEvent(QDropEvent *event) override
This class is a composition of two QSettings instances:
Definition: qgssettings.h:62
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:2453
CONSTLATIN1STRING geoEpsgCrsAuthId()
Geographic coord sys from EPSG authority.
Definition: qgis.h:2973
const QgsCoordinateReferenceSystem & crs