QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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
6  Email : [email protected]
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 
98 {
99  switch ( static_cast< CrsOption >( mCrsComboBox->currentData().toInt() ) )
100  {
102  return mLayerCrs;
104  return mProjectCrs;
106  return mDefaultCrs;
108  return mCrs;
110  {
111  const long srsid = mCrsComboBox->currentData( Qt::UserRole + 1 ).toLongLong();
113  return crs;
114  }
117  }
118  return mCrs;
119 }
120 
122 {
123  const int optionIndex = mCrsComboBox->findData( option );
124 
125  if ( visible && optionIndex < 0 )
126  {
127  //add missing CRS option
128  switch ( option )
129  {
131  {
132  setLayerCrs( mLayerCrs );
133  return;
134  }
136  {
137  addProjectCrsOption();
138  return;
139  }
141  {
142  addDefaultCrsOption();
143  return;
144  }
146  {
147  addCurrentCrsOption();
148  return;
149  }
151  //recently used CRS option cannot be readded
152  return;
154  {
155  addNotSetOption();
156 
157  if ( optionVisible( CurrentCrs ) && !mCrs.isValid() )
158  {
159  // hide invalid option if not set option is shown
160  setOptionVisible( CurrentCrs, false );
161  }
162 
163  return;
164  }
165  }
166  }
167  else if ( !visible && optionIndex >= 0 )
168  {
169  //remove CRS option
170  mCrsComboBox->removeItem( optionIndex );
171 
172  if ( option == CrsNotSet )
173  {
174  setOptionVisible( CurrentCrs, true );
175  }
176  }
177 }
178 
180 {
181  mNotSetText = text;
182  const int optionIndex = mCrsComboBox->findData( CrsNotSet );
183  if ( optionIndex >= 0 )
184  {
185  mCrsComboBox->setItemText( optionIndex, mNotSetText );
186  }
187 }
188 
189 void QgsProjectionSelectionWidget::setMessage( const QString &text )
190 {
191  mMessage = text;
192 }
193 
195 {
196  const int optionIndex = mCrsComboBox->findData( option );
197  return optionIndex >= 0;
198 }
199 
201 {
203  if ( panel && panel->dockMode() )
204  {
205  mActivePanel = new QgsCrsSelectionWidget( this );
206  if ( !mMessage.isEmpty() )
207  mActivePanel->setMessage( mMessage );
208  mActivePanel->setCrs( mCrs );
209 
210  if ( !mNotSetText.isEmpty() )
211  mActivePanel->setNotSetText( mNotSetText );
212 
213  mActivePanel->setPanelTitle( mDialogTitle );
214 
215  if ( optionVisible( QgsProjectionSelectionWidget::CrsOption::CrsNotSet ) )
216  {
217  mActivePanel->setShowNoCrs( true );
218  }
219 
220  connect( mActivePanel, &QgsCrsSelectionWidget::crsChanged, this, [ this ]
221  {
222  if ( mIgnorePanelSignals )
223  return;
224 
225  if ( !mActivePanel->hasValidSelection() )
226  return;
227 
228  mCrsComboBox->blockSignals( true );
229  mCrsComboBox->setCurrentIndex( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ) );
230  mCrsComboBox->blockSignals( false );
231  const QgsCoordinateReferenceSystem crs = mActivePanel->crs();
232 
233  mIgnorePanelSignals++;
234  setCrs( crs );
235  mIgnorePanelSignals--;
236 
237  emit crsChanged( crs );
238  } );
239  panel->openPanel( mActivePanel );
240  }
241  else
242  {
243  QgsProjectionSelectionDialog dlg( this );
244  if ( !mMessage.isEmpty() )
245  dlg.setMessage( mMessage );
246  dlg.setCrs( mCrs );
247  dlg.setWindowTitle( mDialogTitle );
248 
249  if ( !mNotSetText.isEmpty() )
250  dlg.setNotSetText( mNotSetText );
251 
252  if ( optionVisible( QgsProjectionSelectionWidget::CrsOption::CrsNotSet ) )
253  {
254  dlg.setShowNoProjection( true );
255  }
257 
258  if ( dlg.exec() )
259  {
260  mCrsComboBox->blockSignals( true );
261  mCrsComboBox->setCurrentIndex( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ) );
262  mCrsComboBox->blockSignals( false );
263  const QgsCoordinateReferenceSystem crs = dlg.crs();
264  setCrs( crs );
265  emit crsChanged( crs );
266  }
267  else
268  {
269  QApplication::restoreOverrideCursor();
270  }
271  }
272 }
273 
274 void QgsProjectionSelectionWidget::dragEnterEvent( QDragEnterEvent *event )
275 {
276  if ( !( event->possibleActions() & Qt::CopyAction ) )
277  {
278  event->ignore();
279  return;
280  }
281 
282  if ( mapLayerFromMimeData( event->mimeData() ) )
283  {
284  // dragged an acceptable layer, phew
285  event->setDropAction( Qt::CopyAction );
286  event->accept();
287  mCrsComboBox->setHighlighted( true );
288  update();
289  }
290  else
291  {
292  event->ignore();
293  }
294 }
295 
296 void QgsProjectionSelectionWidget::dragLeaveEvent( QDragLeaveEvent *event )
297 {
298  if ( mCrsComboBox->isHighlighted() )
299  {
300  event->accept();
301  mCrsComboBox->setHighlighted( false );
302  update();
303  }
304  else
305  {
306  event->ignore();
307  }
308 }
309 
311 {
312  if ( !( event->possibleActions() & Qt::CopyAction ) )
313  {
314  event->ignore();
315  return;
316  }
317 
318  if ( QgsMapLayer *layer = mapLayerFromMimeData( event->mimeData() ) )
319  {
320  // dropped a map layer
321  setFocus( Qt::MouseFocusReason );
322  event->setDropAction( Qt::CopyAction );
323  event->accept();
324 
325  if ( layer->crs().isValid() )
326  setCrs( layer->crs() );
327  }
328  else
329  {
330  event->ignore();
331  }
332  mCrsComboBox->setHighlighted( false );
333  update();
334 }
335 
337 {
338  return mSourceEnsemble;
339 }
340 
342 {
343  mDialogTitle = title;
344 }
345 
347 {
348  return mDialogTitle;
349 }
350 
351 void QgsProjectionSelectionWidget::setSourceEnsemble( const QString &ensemble )
352 {
353  if ( mSourceEnsemble == ensemble )
354  return;
355 
356  mSourceEnsemble = ensemble;
357  updateWarning();
358 }
359 
361 {
362  return mShowAccuracyWarnings;
363 }
364 
366 {
367  mShowAccuracyWarnings = show;
368  if ( !mShowAccuracyWarnings )
369  mWarningLabelContainer->hide();
370  else
371  updateWarning();
372 }
373 
374 void QgsProjectionSelectionWidget::addNotSetOption()
375 {
376  mCrsComboBox->insertItem( 0, mNotSetText, QgsProjectionSelectionWidget::CrsNotSet );
377  if ( !mCrs.isValid() )
378  whileBlocking( mCrsComboBox )->setCurrentIndex( 0 );
379 }
380 
381 void QgsProjectionSelectionWidget::comboIndexChanged( int idx )
382 {
383  switch ( static_cast< CrsOption >( mCrsComboBox->itemData( idx ).toInt() ) )
384  {
386  emit crsChanged( mLayerCrs );
387  break;
389  emit crsChanged( mProjectCrs );
390  break;
392  emit crsChanged( mCrs );
393  break;
395  emit crsChanged( mDefaultCrs );
396  break;
398  {
399  const long srsid = mCrsComboBox->itemData( idx, Qt::UserRole + 1 ).toLongLong();
401  emit crsChanged( crs );
402  break;
403  }
405  emit cleared();
407  break;
408  }
409  updateTooltip();
410 }
411 
412 void QgsProjectionSelectionWidget::updateWarning()
413 {
414  if ( !mShowAccuracyWarnings )
415  {
416  if ( mWarningLabelContainer->isVisible() )
417  mWarningLabelContainer->hide();
418  return;
419  }
420 
421  try
422  {
423  const double crsAccuracyWarningThreshold = QgsSettings().value( QStringLiteral( "/projections/crsAccuracyWarningThreshold" ), 0.0, QgsSettings::App ).toDouble();
424 
425  const QgsDatumEnsemble ensemble = crs().datumEnsemble();
426  if ( !ensemble.isValid() || ensemble.name() == mSourceEnsemble || ( ensemble.accuracy() > 0 && ensemble.accuracy() < crsAccuracyWarningThreshold ) )
427  {
428  mWarningLabelContainer->hide();
429  }
430  else
431  {
432  mWarningLabelContainer->show();
433 
434  QString warning = QStringLiteral( "<p>" );
435 
436  QString id;
437  if ( !ensemble.code().isEmpty() )
438  id = QStringLiteral( "<i>%1</i> (%2:%3)" ).arg( ensemble.name(), ensemble.authority(), ensemble.code() );
439  else
440  id = QStringLiteral( "<i>%</i>”" ).arg( ensemble.name() );
441 
442  if ( ensemble.accuracy() > 0 )
443  {
444  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() );
445  }
446  else
447  {
448  warning = tr( "The selected CRS is based on %1, which has a limited accuracy." ).arg( id );
449  }
450  warning += QStringLiteral( "</p><p>" ) + tr( "Use an alternative CRS if accurate positioning is required." ) + QStringLiteral( "</p>" );
451 
452  const QList< QgsDatumEnsembleMember > members = ensemble.members();
453  if ( !members.isEmpty() )
454  {
455  warning += QStringLiteral( "<p>" ) + tr( "%1 consists of the datums:" ).arg( ensemble.name() ) + QStringLiteral( "</p><ul>" );
456 
457  for ( const QgsDatumEnsembleMember &member : members )
458  {
459  if ( !member.code().isEmpty() )
460  id = QStringLiteral( "%1 (%2:%3)" ).arg( member.name(), member.authority(), member.code() );
461  else
462  id = member.name();
463  warning += QStringLiteral( "<li>%1</li>" ).arg( id );
464  }
465 
466  warning += QLatin1String( "</ul>" );
467  }
468 
469  mWarningLabel->setToolTip( warning );
470  }
471  }
472  catch ( QgsNotSupportedException & )
473  {
474  mWarningLabelContainer->hide();
475  }
476 }
477 
479 {
480  if ( crs.isValid() )
481  {
484  mCrsComboBox->setItemText( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ),
485  crsOptionText( crs ) );
486  mCrsComboBox->blockSignals( true );
487  mCrsComboBox->setCurrentIndex( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ) );
488  mCrsComboBox->blockSignals( false );
489  }
490  else
491  {
492  const int crsNotSetIndex = mCrsComboBox->findData( QgsProjectionSelectionWidget::CrsNotSet );
493  if ( crsNotSetIndex >= 0 )
494  {
495  mCrsComboBox->blockSignals( true );
496  mCrsComboBox->setCurrentIndex( crsNotSetIndex );
497  mCrsComboBox->blockSignals( false );
498  }
499  else
500  {
501  mCrsComboBox->setItemText( mCrsComboBox->findData( QgsProjectionSelectionWidget::CurrentCrs ),
502  crsOptionText( crs ) );
503  }
504  }
505  if ( mActivePanel && !mIgnorePanelSignals )
506  {
507  mIgnorePanelSignals++;
508  mActivePanel->setCrs( crs );
509  mIgnorePanelSignals--;
510  }
511  if ( mCrs != crs )
512  {
513  mCrs = crs;
514  emit crsChanged( crs );
515  }
516  updateTooltip();
517 }
518 
520 {
521  const int layerItemIndex = mCrsComboBox->findData( QgsProjectionSelectionWidget::LayerCrs );
522  if ( crs.isValid() )
523  {
524  if ( layerItemIndex > -1 )
525  {
526  mCrsComboBox->setItemText( layerItemIndex, tr( "Layer CRS: %1" ).arg( crs.userFriendlyIdentifier() ) );
527  }
528  else
529  {
530  mCrsComboBox->insertItem( firstRecentCrsIndex(), tr( "Layer CRS: %1" ).arg( crs.userFriendlyIdentifier() ), QgsProjectionSelectionWidget::LayerCrs );
531  }
532  }
533  else
534  {
535  if ( layerItemIndex > -1 )
536  {
537  mCrsComboBox->removeItem( layerItemIndex );
538  }
539  }
540  mLayerCrs = crs;
541 }
542 
543 void QgsProjectionSelectionWidget::addProjectCrsOption()
544 {
545  if ( mProjectCrs.isValid() )
546  {
547  mCrsComboBox->addItem( tr( "Project CRS: %1" ).arg( mProjectCrs.userFriendlyIdentifier() ), QgsProjectionSelectionWidget::ProjectCrs );
548  }
549 }
550 
551 void QgsProjectionSelectionWidget::addDefaultCrsOption()
552 {
553  mCrsComboBox->addItem( tr( "Default CRS: %1" ).arg( mDefaultCrs.userFriendlyIdentifier() ), QgsProjectionSelectionWidget::DefaultCrs );
554 }
555 
556 void QgsProjectionSelectionWidget::addCurrentCrsOption()
557 {
558  const int index = optionVisible( CrsNotSet ) ? 1 : 0;
559  mCrsComboBox->insertItem( index, crsOptionText( mCrs ), QgsProjectionSelectionWidget::CurrentCrs );
560 
561 }
562 
564 {
565  if ( crs.isValid() )
566  return crs.userFriendlyIdentifier();
567  else
568  return tr( "invalid projection" );
569 }
570 
571 void QgsProjectionSelectionWidget::addRecentCrs()
572 {
573  const QList< QgsCoordinateReferenceSystem> recentProjections = QgsCoordinateReferenceSystem::recentCoordinateReferenceSystems();
574  for ( const QgsCoordinateReferenceSystem &crs : recentProjections )
575  {
576  const long srsid = crs.srsid();
577 
578  //check if already shown
579  if ( crsIsShown( srsid ) )
580  {
581  continue;
582  }
583 
584  if ( crs.isValid() )
585  {
587  mCrsComboBox->setItemData( mCrsComboBox->count() - 1, QVariant( ( long long )srsid ), Qt::UserRole + 1 );
588  }
589  }
590 }
591 
592 bool QgsProjectionSelectionWidget::crsIsShown( const long srsid ) const
593 {
594  return srsid == mLayerCrs.srsid() || srsid == mDefaultCrs.srsid() || srsid == mProjectCrs.srsid();
595 }
596 
597 int QgsProjectionSelectionWidget::firstRecentCrsIndex() const
598 {
599  for ( int i = 0; i < mCrsComboBox->count(); ++i )
600  {
601  if ( static_cast< CrsOption >( mCrsComboBox->itemData( i ).toInt() ) == RecentCrs )
602  {
603  return i;
604  }
605  }
606  return -1;
607 }
608 
609 void QgsProjectionSelectionWidget::updateTooltip()
610 {
612  if ( c.isValid() )
613  setToolTip( c.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED, true ) );
614  else
615  setToolTip( QString() );
616  updateWarning();
617 }
618 
619 QgsMapLayer *QgsProjectionSelectionWidget::mapLayerFromMimeData( const QMimeData *data ) const
620 {
622  for ( const QgsMimeDataUtils::Uri &u : uriList )
623  {
624  // is this uri from the current project?
625  if ( QgsMapLayer *layer = u.mapLayer() )
626  {
627  return layer;
628  }
629  }
630  return nullptr;
631 }
QgsDatumEnsembleMember
Contains information about a member of a datum ensemble.
Definition: qgsdatums.h:34
QgsProjectionSelectionWidget::crs
QgsCoordinateReferenceSystem crs() const
Returns the currently selected CRS for the widget.
Definition: qgsprojectionselectionwidget.cpp:97
QgsProjectionSelectionWidget::sourceEnsemble
QString sourceEnsemble() const
Returns the original source ensemble datum name.
Definition: qgsprojectionselectionwidget.cpp:336
QgsCrsSelectionWidget
A generic widget allowing users to pick a Coordinate Reference System (or define their own).
Definition: qgsprojectionselectiondialog.h:39
qgsprojectionselectionwidget.h
QgsProjectionSelectionWidget::selectCrs
void selectCrs()
Opens the dialog for selecting a new CRS.
Definition: qgsprojectionselectionwidget.cpp:200
QgsSettings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Definition: qgssettings.cpp:161
QgsProjectionSelectionWidget::setMessage
void setMessage(const QString &text)
Sets a message to show in the dialog.
Definition: qgsprojectionselectionwidget.cpp:189
qgshighlightablecombobox.h
QgsCoordinateReferenceSystem::userFriendlyIdentifier
QString userFriendlyIdentifier(IdentifierType type=MediumString) const
Returns a user friendly identifier for the CRS.
Definition: qgscoordinatereferencesystem.cpp:1212
QgsSettings::App
@ App
Definition: qgssettings.h:75
QgsPanelWidget::findParentPanel
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
Definition: qgspanelwidget.cpp:54
QgsCoordinateReferenceSystem::WKT_PREFERRED
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
Definition: qgscoordinatereferencesystem.h:680
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsProjectionSelectionWidget::setSourceEnsemble
void setSourceEnsemble(const QString &ensemble)
Sets the original source ensemble datum name.
Definition: qgsprojectionselectionwidget.cpp:351
QgsHighlightableComboBox::isHighlighted
bool isHighlighted() const
Returns true if the combo box is currently highlighted.
Definition: qgshighlightablecombobox.h:48
QgsProjectionSelectionWidget::crsChanged
void crsChanged(const QgsCoordinateReferenceSystem &)
Emitted when the selected CRS is changed.
QgsProjectionSelectionDialog
A generic dialog to prompt the user for a Coordinate Reference System.
Definition: qgsprojectionselectiondialog.h:170
QgsProjectionSelectionDialog::setShowNoProjection
void setShowNoProjection(bool show)
Sets whether a "no/invalid" projection option should be shown.
Definition: qgsprojectionselectiondialog.cpp:285
QgsProjectionSelectionWidget::cleared
void cleared()
Emitted when the not set option is selected.
QgsPanelWidget::openPanel
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
Definition: qgspanelwidget.cpp:84
QgsProjectionSelectionDialog::crs
QgsCoordinateReferenceSystem crs() const
Returns the CRS currently selected in the widget.
Definition: qgsprojectionselectiondialog.cpp:316
QgsProjectionSelectionDialog::setMessage
void setMessage(const QString &message)
Sets a message to show in the dialog.
Definition: qgsprojectionselectiondialog.cpp:272
geoEpsgCrsAuthId
CONSTLATIN1STRING geoEpsgCrsAuthId()
Geographic coord sys from EPSG authority.
Definition: qgis.h:2732
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:480
QgsProjectionSelectionDialog::setNotSetText
void setNotSetText(const QString &text, const QString &description=QString())
Sets the text to show for the not set option.
Definition: qgsprojectionselectiondialog.cpp:295
QgsProjectionSelectionDialog::setCrs
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the initial crs to show within the dialog.
Definition: qgsprojectionselectiondialog.cpp:321
QgsSettings
This class is a composition of two QSettings instances:
Definition: qgssettings.h:61
QgsProjectionSelectionWidget::dialogTitle
QString dialogTitle() const
Returns the title for the CRS selector dialog window.
Definition: qgsprojectionselectionwidget.cpp:346
QgsProjectionSelectionWidget::optionVisible
bool optionVisible(CrsOption option) const
Returns whether the specified CRS option is visible in the widget.
Definition: qgsprojectionselectionwidget.cpp:194
QgsMimeDataUtils::UriList
QList< QgsMimeDataUtils::Uri > UriList
Definition: qgsmimedatautils.h:164
QgsPanelWidget::dockMode
bool dockMode()
Returns the dock mode state.
Definition: qgspanelwidget.h:93
QgsProjectionSelectionWidget::dropEvent
void dropEvent(QDropEvent *event) override
Definition: qgsprojectionselectionwidget.cpp:310
QgsProjectionSelectionWidget::setLayerCrs
void setLayerCrs(const QgsCoordinateReferenceSystem &crs)
Sets the layer CRS for the widget.
Definition: qgsprojectionselectionwidget.cpp:519
qgsapplication.h
qgsprojectionselectiondialog.h
QgsProjectionSelectionWidget::setDialogTitle
void setDialogTitle(const QString &title)
Sets the title for the CRS selector dialog window.
Definition: qgsprojectionselectionwidget.cpp:341
QgsProjectionSelectionDialog::setRequireValidSelection
void setRequireValidSelection()
Sets the dialog to require a valid selection only, preventing users from accepting the dialog if no s...
Definition: qgsprojectionselectiondialog.cpp:300
QgsProjectionSelectionWidget::setOptionVisible
void setOptionVisible(CrsOption option, bool visible)
Sets whether a predefined CRS option should be shown in the widget.
Definition: qgsprojectionselectionwidget.cpp:121
QgsCoordinateReferenceSystem::fromSrsId
static QgsCoordinateReferenceSystem fromSrsId(long srsId)
Creates a CRS from a specified QGIS SRS ID.
Definition: qgscoordinatereferencesystem.cpp:235
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:29
QgsDatumEnsemble::accuracy
double accuracy() const
Positional accuracy (in meters).
Definition: qgsdatums.h:112
QgsCoordinateReferenceSystem::srsid
long srsid() const
Returns the internal CRS ID, if available.
Definition: qgscoordinatereferencesystem.cpp:1185
whileBlocking
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:2191
qgsdatums.h
QgsProjectionSelectionWidget::ProjectCrs
@ ProjectCrs
Current project CRS (if OTF reprojection enabled)
Definition: qgsprojectionselectionwidget.h:51
QgsApplication::coordinateReferenceSystemRegistry
static QgsCoordinateReferenceSystemRegistry * coordinateReferenceSystemRegistry()
Returns the application's coordinate reference system (CRS) registry, which handles known CRS definit...
Definition: qgsapplication.cpp:2355
QgsHighlightableComboBox
A QComboBox subclass with the ability to "highlight" the edges of the widget.
Definition: qgshighlightablecombobox.h:34
QgsCoordinateReferenceSystem::isValid
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Definition: qgscoordinatereferencesystem.cpp:977
QgsProjectionSelectionWidget::setCrs
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the current CRS for the widget.
Definition: qgsprojectionselectionwidget.cpp:478
QgsProjectionSelectionWidget::showAccuracyWarnings
bool showAccuracyWarnings() const
Returns true if the widget will show a warning to users when they select a CRS which has low accuracy...
Definition: qgsprojectionselectionwidget.cpp:360
QgsProjectionSelectionWidget::RecentCrs
@ RecentCrs
Recently used CRS.
Definition: qgsprojectionselectionwidget.h:54
QgsMimeDataUtils::Uri
Definition: qgsmimedatautils.h:40
QgsProjectionSelectionWidget::CrsNotSet
@ CrsNotSet
Not set (hidden by default)
Definition: qgsprojectionselectionwidget.h:55
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsProjectionSelectionWidget::setShowAccuracyWarnings
void setShowAccuracyWarnings(bool show)
Sets whether the widget will show warnings to users when they select a CRS which has low accuracy.
Definition: qgsprojectionselectionwidget.cpp:365
QgsProjectionSelectionWidget::LayerCrs
@ LayerCrs
Optional layer CRS.
Definition: qgsprojectionselectionwidget.h:50
QgsProjectionSelectionWidget::setNotSetText
void setNotSetText(const QString &text)
Sets the text to show for the not set option.
Definition: qgsprojectionselectionwidget.cpp:179
QgsMimeDataUtils::decodeUriList
static UriList decodeUriList(const QMimeData *data)
Definition: qgsmimedatautils.cpp:229
QgsProjectionSelectionWidget::DefaultCrs
@ DefaultCrs
Global default QGIS CRS.
Definition: qgsprojectionselectionwidget.h:53
c
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
Definition: porting_processing.dox:1
QgsCoordinateReferenceSystem::datumEnsemble
QgsDatumEnsemble datumEnsemble() const SIP_THROW(QgsNotSupportedException)
Attempts to retrieve datum ensemble details from the CRS.
Definition: qgscoordinatereferencesystem.cpp:1355
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
QgsProjectionSelectionWidget::crsOptionText
static QString crsOptionText(const QgsCoordinateReferenceSystem &crs)
Returns display text for the specified crs.
Definition: qgsprojectionselectionwidget.cpp:563
QgsDatumEnsemble::members
QList< QgsDatumEnsembleMember > members() const
Contains a list of members of the ensemble.
Definition: qgsdatums.h:137
qgssettings.h
QgsCrsSelectionWidget::crsChanged
void crsChanged()
Emitted when the CRS defined in the widget is changed.
QgsDatumEnsemble::authority
QString authority() const
Authority name, e.g.
Definition: qgsdatums.h:117
QgsCoordinateReferenceSystem::authid
QString authid
Definition: qgscoordinatereferencesystem.h:217
QgsApplication::getThemeIcon
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Definition: qgsapplication.cpp:693
QgsNotSupportedException
Custom exception class which is raised when an operation is not supported.
Definition: qgsexception.h:117
QgsProjectionSelectionWidget::dragLeaveEvent
void dragLeaveEvent(QDragLeaveEvent *event) override
Definition: qgsprojectionselectionwidget.cpp:296
QgsCoordinateReferenceSystem::updateDefinition
void updateDefinition()
Updates the definition and parameters of the coordinate reference system to their latest values.
Definition: qgscoordinatereferencesystem.cpp:1498
QgsProjectionSelectionWidget::CrsOption
CrsOption
Predefined CRS options shown in widget.
Definition: qgsprojectionselectionwidget.h:48
qgscoordinatereferencesystemregistry.h
QgsDatumEnsemble::name
QString name() const
Display name of datum ensemble.
Definition: qgsdatums.h:107
QgsProject::crs
QgsCoordinateReferenceSystem crs
Definition: qgsproject.h:109
QgsHighlightableComboBox::setHighlighted
void setHighlighted(bool highlighted)
Sets whether the combo box is currently highlighted.
Definition: qgshighlightablecombobox.cpp:36
qgsproject.h
QgsDatumEnsemble::isValid
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
QgsProjectionSelectionWidget::QgsProjectionSelectionWidget
QgsProjectionSelectionWidget(QWidget *parent=nullptr)
Constructor for QgsProjectionSelectionWidget.
Definition: qgsprojectionselectionwidget.cpp:27
QgsDatumEnsemble
Contains information about a datum ensemble.
Definition: qgsdatums.h:94
QgsProjectionSelectionWidget::CurrentCrs
@ CurrentCrs
Current user selected CRS.
Definition: qgsprojectionselectionwidget.h:52
QgsDatumEnsemble::code
QString code() const
Identification code, e.g.
Definition: qgsdatums.h:122
QgsCoordinateReferenceSystemRegistry::userCrsChanged
void userCrsChanged(const QString &id)
Emitted whenever an existing user CRS definition is changed.
QgsProjectionSelectionWidget::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *event) override
Definition: qgsprojectionselectionwidget.cpp:274
QgsCoordinateReferenceSystem::recentCoordinateReferenceSystems
static QList< QgsCoordinateReferenceSystem > recentCoordinateReferenceSystems()
Returns a list of recently used CRS.
Definition: qgscoordinatereferencesystem.cpp:2859