22#include "moc_qgsprojectionselectiondialog.cpp" 
   24#include <QDialogButtonBox> 
   25#include <QApplication> 
   38  projectionSelector->setFilters( 
filters );
 
   43  mNotSetText = tr( 
"No CRS (or unknown/non-Earth projection)" );
 
   44  mLabelNoCrs->setText( tr( 
"Use this option to treat all coordinates as Cartesian coordinates in an unknown reference system." ) );
 
   46  mComboCrsType->addItem( tr( 
"Predefined CRS" ), 
static_cast<int>( CrsType::Predefined ) );
 
   47  mComboCrsType->addItem( tr( 
"Custom CRS" ), 
static_cast<int>( CrsType::Custom ) );
 
   49  mStackedWidget->setCurrentWidget( mPageDatabase );
 
   50  mComboCrsType->setCurrentIndex( mComboCrsType->findData( 
static_cast<int>( CrsType::Predefined ) ) );
 
   52  connect( mComboCrsType, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, [
this]( 
int ) {
 
   53    if ( !mComboCrsType->currentData().isValid() )
 
   54      mStackedWidget->setCurrentWidget( mPageNoCrs );
 
   57      switch ( 
static_cast<CrsType
>( mComboCrsType->currentData().toInt() ) )
 
   59        case QgsCrsSelectionWidget::CrsType::Predefined:
 
   60          mStackedWidget->setCurrentWidget( mPageDatabase );
 
   62        case QgsCrsSelectionWidget::CrsType::Custom:
 
   63          mStackedWidget->setCurrentWidget( mPageCustom );
 
   90      mDeferredInvalidCrsSet = 
false;
 
  105  mSplitter->restoreState( settings.value( QStringLiteral( 
"Windows/ProjectionSelectorDialog/splitterState" ) ).toByteArray() );
 
 
  111  settings.
setValue( QStringLiteral( 
"Windows/ProjectionSelectorDialog/splitterState" ), mSplitter->saveState() );
 
 
  122  if ( mShowNoCrsOption == show )
 
  126  mShowNoCrsOption = show;
 
  127  if ( mShowNoCrsOption )
 
  129    mComboCrsType->insertItem( 0, mNotSetText );
 
  133    mComboCrsType->removeItem( 0 );
 
  136  if ( show && mDeferredInvalidCrsSet )
 
  138    mComboCrsType->setCurrentIndex( 0 );
 
  143  if ( mDeferredInvalidCrsSet )
 
  146  mDeferredInvalidCrsSet = 
false;
 
 
  153  return mShowNoCrsOption;
 
 
  160  if ( mShowNoCrsOption )
 
  162    mComboCrsType->setItemText( 0, mNotSetText );
 
  165  mLabelNoCrs->setText( description.isEmpty() ? text : description );
 
 
  170  if ( !mComboCrsType->currentData().isValid() )
 
  172  else if ( mDeferredInvalidCrsSet )
 
  176    switch ( 
static_cast<CrsType
>( mComboCrsType->currentData().toInt() ) )
 
  178      case QgsCrsSelectionWidget::CrsType::Predefined:
 
  179        return projectionSelector->hasValidSelection();
 
  180      case QgsCrsSelectionWidget::CrsType::Custom:
 
  181        return mCrsDefinitionWidget->crs().isValid();
 
 
  189  return projectionSelector->filters();
 
 
  194  projectionSelector->setFilters( 
filters );
 
 
  199  if ( !mComboCrsType->currentData().isValid() )
 
  203    switch ( 
static_cast<CrsType
>( mComboCrsType->currentData().toInt() ) )
 
  205      case QgsCrsSelectionWidget::CrsType::Predefined:
 
  206        return projectionSelector->crs();
 
  207      case QgsCrsSelectionWidget::CrsType::Custom:
 
  208        return mCrsDefinitionWidget->crs();
 
 
  219    if ( mShowNoCrsOption )
 
  220      mComboCrsType->setCurrentIndex( 0 );
 
  222      mDeferredInvalidCrsSet = 
true;
 
  226    projectionSelector->setCrs( 
crs );
 
  227    mCrsDefinitionWidget->setCrs( 
crs );
 
  230      mComboCrsType->setCurrentIndex( mComboCrsType->findData( 
static_cast<int>( CrsType::Custom ) ) );
 
  231      mStackedWidget->setCurrentWidget( mPageCustom );
 
  235      mComboCrsType->setCurrentIndex( mComboCrsType->findData( 
static_cast<int>( CrsType::Predefined ) ) );
 
  236      mStackedWidget->setCurrentWidget( mPageDatabase );
 
 
  247  projectionSelector->setOgcWmsCrsFilter( crsFilter );
 
 
  256  : QDialog( parent, fl )
 
  258  QVBoxLayout *vlayout = 
new QVBoxLayout();
 
  261  vlayout->addWidget( mCrsWidget, 1 );
 
  263  mButtonBox = 
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok );
 
  264  connect( mButtonBox, &QDialogButtonBox::accepted, 
this, &QgsProjectionSelectionDialog::accept );
 
  265  connect( mButtonBox, &QDialogButtonBox::rejected, 
this, &QgsProjectionSelectionDialog::reject );
 
  266  connect( mButtonBox, &QDialogButtonBox::helpRequested, 
this, &QgsProjectionSelectionDialog::showHelp );
 
  268  vlayout->addWidget( mButtonBox );
 
  270  setLayout( vlayout );
 
 
  285  setMessage( tr( 
"This layer appears to have no projection specification." ) + 
' ' + tr( 
"By default, this layer will now have its projection set to that of the project, " 
  286                                                                                          "but you may override this by selecting a different projection below." ) );
 
 
  306  mRequireValidSelection = 
true;
 
  310    mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( isValid );
 
 
  331  return mCrsWidget->
crs();
 
 
  338  if ( mRequireValidSelection )
 
 
  347void QgsProjectionSelectionDialog::showHelp()
 
  349  QgsHelp::openHelp( QStringLiteral( 
"working_with_projections/working_with_projections.html" ) );
 
static QString reportStyleSheet(QgsApplication::StyleSheetType styleSheetType=QgsApplication::StyleSheetType::Qt)
Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet...
 
Represents a coordinate reference system (CRS).
 
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
 
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
 
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
 
void showNoCrsForLayerMessage()
When called, the dialog will show a default "layer has no CRS set" message above the projection selec...
 
void setShowNoProjection(bool show)
Sets whether a "no/invalid" projection option should be shown.
 
bool showNoProjection() const
Returns whether the "no/invalid" projection option is shown.
 
QgsCoordinateReferenceSystemProxyModel::Filters filters() const
Returns the filters set on the available CRS.
 
bool hasValidSelection() const
Returns true if the dialog has a valid CRS defined.
 
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.
 
QgsProjectionSelectionDialog(QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, QgsCoordinateReferenceSystemProxyModel::Filters filters=QgsCoordinateReferenceSystemProxyModel::FilterHorizontal|QgsCoordinateReferenceSystemProxyModel::FilterCompound)
Constructor for QgsProjectionSelectionDialog.
 
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 setFilters(QgsCoordinateReferenceSystemProxyModel::Filters filters)
Sets filters for the available CRS.
 
Stores settings for use within QGIS.
 
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
 
#define BUILTIN_UNREACHABLE
 
const QgsCoordinateReferenceSystem & crs