mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Use combo box instead of tab in projection selection dialog
to select CRS type, and split widget out from dialog class
This commit is contained in:
parent
ac11fc7912
commit
e692969896
@ -10,6 +10,120 @@
|
||||
|
||||
|
||||
|
||||
class QgsCrsSelectionWidget : QgsPanelWidget
|
||||
{
|
||||
%Docstring(signature="appended")
|
||||
A generic widget allowing users to pick a Coordinate Reference System (or define their own).
|
||||
|
||||
.. versionadded:: 3.24
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsprojectionselectiondialog.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
enum class CrsType
|
||||
{
|
||||
Predefined,
|
||||
Custom,
|
||||
};
|
||||
|
||||
QgsCrsSelectionWidget( QWidget *parent /TransferThis/ = 0 );
|
||||
%Docstring
|
||||
Constructor for QgsCrsSelectionWidget, with the specified ``parent`` widget.
|
||||
%End
|
||||
|
||||
~QgsCrsSelectionWidget();
|
||||
|
||||
QgsCoordinateReferenceSystem crs() const;
|
||||
%Docstring
|
||||
Returns the CRS currently selected in the widget.
|
||||
|
||||
.. seealso:: :py:func:`setCrs`
|
||||
%End
|
||||
|
||||
void setMessage( const QString &message );
|
||||
%Docstring
|
||||
Sets a ``message`` to show in the dialog.
|
||||
%End
|
||||
|
||||
void setShowNoCrs( bool show );
|
||||
%Docstring
|
||||
Sets whether a "no/invalid" CRS option should be shown. If this
|
||||
option is selected, calling :py:func:`~QgsCrsSelectionWidget.crs` will return an invalid :py:class:`QgsCoordinateReferenceSystem`.
|
||||
|
||||
.. seealso:: :py:func:`showNoCrs`
|
||||
%End
|
||||
|
||||
bool showNoCrs() const;
|
||||
%Docstring
|
||||
Returns whether the "no/invalid" CRS option is shown. If this
|
||||
option is selected, calling :py:func:`~QgsCrsSelectionWidget.crs` will return an invalid :py:class:`QgsCoordinateReferenceSystem`.
|
||||
|
||||
.. seealso:: :py:func:`setShowNoCrs`
|
||||
%End
|
||||
|
||||
void setNotSetText( const QString &text, const QString &description = QString() );
|
||||
%Docstring
|
||||
Sets the text to show for the not set option. Note that this option is not shown
|
||||
by default and must be set visible by calling :py:func:`~QgsCrsSelectionWidget.setShowNoCrs`.
|
||||
|
||||
The ``description`` argument can be used to specify a detailed description which
|
||||
is shown when the option is selected.
|
||||
%End
|
||||
|
||||
bool hasValidSelection() const;
|
||||
%Docstring
|
||||
Returns ``True`` if the widget has a valid CRS defined.
|
||||
%End
|
||||
|
||||
public slots:
|
||||
|
||||
void setCrs( const QgsCoordinateReferenceSystem &crs );
|
||||
%Docstring
|
||||
Sets the ``crs`` to show within the widget.
|
||||
|
||||
.. seealso:: :py:func:`crs`
|
||||
%End
|
||||
|
||||
void setOgcWmsCrsFilter( const QSet<QString> &crsFilter );
|
||||
%Docstring
|
||||
filters this dialog by the given CRSs
|
||||
|
||||
Sets this dialog to filter the available CRSs to those listed
|
||||
by the given Coordinate Reference Systems.
|
||||
|
||||
:param crsFilter: a list of OGC Coordinate Reference Systems to filter the
|
||||
list of CRS by. This is useful in (e.g.) WMS situations
|
||||
where you just want to offer what the WMS server can support.
|
||||
|
||||
.. warning::
|
||||
|
||||
This function's behavior is undefined if it is called after the dialog is shown.
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
void crsChanged();
|
||||
%Docstring
|
||||
Emitted when the CRS defined in the widget is changed.
|
||||
%End
|
||||
|
||||
void crsDoubleClicked( const QgsCoordinateReferenceSystem &crs );
|
||||
%Docstring
|
||||
Emitted when a CRS entry in the widget is double-clicked.
|
||||
%End
|
||||
|
||||
void hasValidSelectionChanged( bool isValid );
|
||||
%Docstring
|
||||
Emitted when the widget has a valid selection or not.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class QgsProjectionSelectionDialog : QDialog
|
||||
{
|
||||
%Docstring(signature="appended")
|
||||
@ -44,8 +158,6 @@ the you probably want to look at :py:class:`QgsProjectionSelectionWidget` instea
|
||||
Constructor for QgsProjectionSelectionDialog.
|
||||
%End
|
||||
|
||||
~QgsProjectionSelectionDialog();
|
||||
|
||||
QgsCoordinateReferenceSystem crs() const;
|
||||
%Docstring
|
||||
Returns the CRS currently selected in the widget.
|
||||
@ -91,11 +203,14 @@ option is selected, calling :py:func:`~QgsProjectionSelectionDialog.crs` will re
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
void setNotSetText( const QString &text );
|
||||
void setNotSetText( const QString &text, const QString &description = QString() );
|
||||
%Docstring
|
||||
Sets the text to show for the not set option. Note that this option is not shown
|
||||
by default and must be set visible by calling :py:func:`~QgsProjectionSelectionDialog.setShowNoProjection`.
|
||||
|
||||
Since QGIS 3.24, the ``description`` argument can be used to specify a detailed description which
|
||||
is shown when the option is selected.
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
|
||||
@ -20,64 +20,250 @@
|
||||
|
||||
#include "qgsprojectionselectiondialog.h"
|
||||
#include "qgshelp.h"
|
||||
#include <QDialogButtonBox>
|
||||
#include <QApplication>
|
||||
#include "qgsgui.h"
|
||||
#include <QPushButton>
|
||||
|
||||
QgsProjectionSelectionDialog::QgsProjectionSelectionDialog( QWidget *parent,
|
||||
Qt::WindowFlags fl )
|
||||
: QDialog( parent, fl )
|
||||
|
||||
//
|
||||
// QgsCrsSelectionWidget
|
||||
//
|
||||
QgsCrsSelectionWidget::QgsCrsSelectionWidget( QWidget *parent )
|
||||
: QgsPanelWidget( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
QgsGui::enableAutoGeometryRestore( this );
|
||||
connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsProjectionSelectionDialog::showHelp );
|
||||
|
||||
//we will show this only when a message is set
|
||||
textEdit->hide();
|
||||
|
||||
tabWidget->setCurrentWidget( mTabDatabase );
|
||||
mNotSetText = tr( "No CRS (or unknown/non-Earth projection)" );
|
||||
mLabelNoCrs->setText( tr( "Use this option to treat all coordinates as Cartesian coordinates in an unknown reference system." ) );
|
||||
|
||||
mCheckBoxNoProjection->setHidden( true );
|
||||
mCheckBoxNoProjection->setEnabled( false );
|
||||
connect( mCheckBoxNoProjection, &QCheckBox::toggled, this, [ = ]
|
||||
mComboCrsType->addItem( tr( "Predefined CRS" ), static_cast< int >( CrsType::Predefined ) );
|
||||
mComboCrsType->addItem( tr( "Custom CRS" ), static_cast< int >( CrsType::Custom ) );
|
||||
|
||||
mStackedWidget->setCurrentWidget( mPageDatabase );
|
||||
mComboCrsType->setCurrentIndex( mComboCrsType->findData( static_cast< int >( CrsType::Predefined ) ) );
|
||||
|
||||
connect( mComboCrsType, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]( int )
|
||||
{
|
||||
#if 0
|
||||
if ( !mComboCrsType->currentData().isValid() )
|
||||
mStackedWidget->setCurrentWidget( mPageNoCrs );
|
||||
else
|
||||
{
|
||||
switch ( static_cast< CrsType >( mComboCrsType->currentData().toInt() ) )
|
||||
{
|
||||
case QgsCrsSelectionWidget::CrsType::Predefined:
|
||||
mStackedWidget->setCurrentWidget( mPageDatabase );
|
||||
break;
|
||||
case QgsCrsSelectionWidget::CrsType::Custom:
|
||||
mStackedWidget->setCurrentWidget( mPageCustom );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !mBlockSignals )
|
||||
{
|
||||
emit crsSelected();
|
||||
emit crsChanged();
|
||||
emit hasValidSelectionChanged( hasValidSelection() );
|
||||
}
|
||||
#endif
|
||||
} );
|
||||
connect( mCheckBoxNoProjection, &QCheckBox::toggled, this, [ = ]( bool checked )
|
||||
|
||||
connect( projectionSelector, &QgsProjectionSelectionTreeWidget::projectionDoubleClicked, this, [ = ]
|
||||
{
|
||||
if ( mCheckBoxNoProjection->isEnabled() )
|
||||
emit crsDoubleClicked( projectionSelector->crs() );
|
||||
} );
|
||||
|
||||
connect( mCrsDefinitionWidget, &QgsCrsDefinitionWidget::crsChanged, this, [ = ]()
|
||||
{
|
||||
if ( !mBlockSignals )
|
||||
{
|
||||
tabWidget->setDisabled( checked );
|
||||
emit crsChanged();
|
||||
emit hasValidSelectionChanged( hasValidSelection() );
|
||||
}
|
||||
} );
|
||||
|
||||
connect( projectionSelector, &QgsProjectionSelectionTreeWidget::crsSelected, this, [ = ]()
|
||||
{
|
||||
if ( !mBlockSignals )
|
||||
{
|
||||
emit crsChanged();
|
||||
emit hasValidSelectionChanged( hasValidSelection() );
|
||||
}
|
||||
} );
|
||||
|
||||
//apply selected projection upon double-click on item
|
||||
connect( projectionSelector, &QgsProjectionSelectionTreeWidget::projectionDoubleClicked, this, &QgsProjectionSelectionDialog::accept );
|
||||
connect( projectionSelector, &QgsProjectionSelectionTreeWidget::hasValidSelectionChanged, this, [ = ]()
|
||||
{
|
||||
if ( !mBlockSignals )
|
||||
{
|
||||
emit crsChanged();
|
||||
emit hasValidSelectionChanged( hasValidSelection() );
|
||||
}
|
||||
} );
|
||||
|
||||
const QgsSettings settings;
|
||||
mSplitter->restoreState( settings.value( QStringLiteral( "Windows/ProjectionSelectorDialog/splitterState" ) ).toByteArray() );
|
||||
}
|
||||
|
||||
QgsProjectionSelectionDialog::~QgsProjectionSelectionDialog()
|
||||
QgsCrsSelectionWidget::~QgsCrsSelectionWidget()
|
||||
{
|
||||
QgsSettings settings;
|
||||
settings.setValue( QStringLiteral( "Windows/ProjectionSelectorDialog/splitterState" ), mSplitter->saveState() );
|
||||
}
|
||||
|
||||
void QgsProjectionSelectionDialog::setMessage( const QString &message )
|
||||
void QgsCrsSelectionWidget::setMessage( const QString &message )
|
||||
{
|
||||
textEdit->setHtml( QStringLiteral( "<head><style>%1</style></head><body>%2</body>" ).arg( QgsApplication::reportStyleSheet(),
|
||||
message ) );
|
||||
textEdit->show();
|
||||
}
|
||||
|
||||
void QgsCrsSelectionWidget::setShowNoCrs( bool show )
|
||||
{
|
||||
if ( mShowNoCrsOption == show )
|
||||
return;
|
||||
|
||||
mShowNoCrsOption = show;
|
||||
if ( mShowNoCrsOption )
|
||||
{
|
||||
mComboCrsType->insertItem( 0, mNotSetText );
|
||||
}
|
||||
else
|
||||
{
|
||||
mComboCrsType->removeItem( 0 );
|
||||
}
|
||||
|
||||
if ( show && mDeferedInvalidCrsSet )
|
||||
{
|
||||
mComboCrsType->setCurrentIndex( 0 );
|
||||
}
|
||||
|
||||
mDeferedInvalidCrsSet = false;
|
||||
|
||||
emit hasValidSelectionChanged( hasValidSelection() );
|
||||
}
|
||||
|
||||
bool QgsCrsSelectionWidget::showNoCrs() const
|
||||
{
|
||||
return mShowNoCrsOption;
|
||||
}
|
||||
|
||||
void QgsCrsSelectionWidget::setNotSetText( const QString &text, const QString &description )
|
||||
{
|
||||
mNotSetText = text;
|
||||
|
||||
if ( mShowNoCrsOption )
|
||||
{
|
||||
mComboCrsType->setItemText( 0, mNotSetText );
|
||||
}
|
||||
|
||||
mLabelNoCrs->setText( description.isEmpty() ? text : description );
|
||||
}
|
||||
|
||||
bool QgsCrsSelectionWidget::hasValidSelection() const
|
||||
{
|
||||
if ( !mComboCrsType->currentData().isValid() )
|
||||
return true;
|
||||
else
|
||||
{
|
||||
switch ( static_cast< CrsType >( mComboCrsType->currentData().toInt() ) )
|
||||
{
|
||||
case QgsCrsSelectionWidget::CrsType::Predefined:
|
||||
return projectionSelector->hasValidSelection();
|
||||
case QgsCrsSelectionWidget::CrsType::Custom:
|
||||
return mCrsDefinitionWidget->crs().isValid();
|
||||
}
|
||||
BUILTIN_UNREACHABLE
|
||||
}
|
||||
}
|
||||
|
||||
QgsCoordinateReferenceSystem QgsCrsSelectionWidget::crs() const
|
||||
{
|
||||
if ( !mComboCrsType->currentData().isValid() )
|
||||
return QgsCoordinateReferenceSystem();
|
||||
else
|
||||
{
|
||||
switch ( static_cast< CrsType >( mComboCrsType->currentData().toInt() ) )
|
||||
{
|
||||
case QgsCrsSelectionWidget::CrsType::Predefined:
|
||||
return projectionSelector->crs();
|
||||
case QgsCrsSelectionWidget::CrsType::Custom:
|
||||
return mCrsDefinitionWidget->crs();
|
||||
}
|
||||
BUILTIN_UNREACHABLE
|
||||
}
|
||||
}
|
||||
|
||||
void QgsCrsSelectionWidget::setCrs( const QgsCoordinateReferenceSystem &crs )
|
||||
{
|
||||
if ( !crs.isValid() )
|
||||
{
|
||||
if ( mShowNoCrsOption )
|
||||
mComboCrsType->setCurrentIndex( 0 );
|
||||
else
|
||||
mDeferedInvalidCrsSet = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectionSelector->setCrs( crs );
|
||||
mCrsDefinitionWidget->setCrs( crs );
|
||||
if ( crs.isValid() && crs.authid().isEmpty() )
|
||||
{
|
||||
mComboCrsType->setCurrentIndex( mComboCrsType->findData( static_cast< int>( CrsType::Custom ) ) );
|
||||
mStackedWidget->setCurrentWidget( mPageCustom );
|
||||
}
|
||||
else
|
||||
{
|
||||
mComboCrsType->setCurrentIndex( mComboCrsType->findData( static_cast< int>( CrsType::Predefined ) ) );
|
||||
mStackedWidget->setCurrentWidget( mPageDatabase );
|
||||
}
|
||||
}
|
||||
|
||||
emit crsChanged();
|
||||
emit hasValidSelectionChanged( hasValidSelection() );
|
||||
}
|
||||
|
||||
void QgsCrsSelectionWidget::setOgcWmsCrsFilter( const QSet<QString> &crsFilter )
|
||||
{
|
||||
projectionSelector->setOgcWmsCrsFilter( crsFilter );
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// QgsProjectionSelectionDialog
|
||||
//
|
||||
|
||||
QgsProjectionSelectionDialog::QgsProjectionSelectionDialog( QWidget *parent,
|
||||
Qt::WindowFlags fl )
|
||||
: QDialog( parent, fl )
|
||||
{
|
||||
QVBoxLayout *vlayout = new QVBoxLayout();
|
||||
|
||||
mCrsWidget = new QgsCrsSelectionWidget();
|
||||
vlayout->addWidget( mCrsWidget, 1 );
|
||||
|
||||
mButtonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok );
|
||||
connect( mButtonBox, &QDialogButtonBox::accepted, this, &QgsProjectionSelectionDialog::accept );
|
||||
connect( mButtonBox, &QDialogButtonBox::rejected, this, &QgsProjectionSelectionDialog::reject );
|
||||
connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsProjectionSelectionDialog::showHelp );
|
||||
|
||||
vlayout->addWidget( mButtonBox );
|
||||
|
||||
setLayout( vlayout );
|
||||
|
||||
QgsGui::enableAutoGeometryRestore( this );
|
||||
|
||||
//apply selected projection upon double-click on item
|
||||
connect( mCrsWidget, &QgsCrsSelectionWidget::crsDoubleClicked, this, &QgsProjectionSelectionDialog::accept );
|
||||
}
|
||||
|
||||
void QgsProjectionSelectionDialog::setMessage( const QString &message )
|
||||
{
|
||||
mCrsWidget->setMessage( message );
|
||||
}
|
||||
|
||||
void QgsProjectionSelectionDialog::showNoCrsForLayerMessage()
|
||||
{
|
||||
setMessage( tr( "This layer appears to have no projection specification." )
|
||||
@ -88,91 +274,43 @@ void QgsProjectionSelectionDialog::showNoCrsForLayerMessage()
|
||||
|
||||
void QgsProjectionSelectionDialog::setShowNoProjection( bool show )
|
||||
{
|
||||
mCheckBoxNoProjection->setVisible( show );
|
||||
mCheckBoxNoProjection->setEnabled( show );
|
||||
if ( show )
|
||||
{
|
||||
tabWidget->setDisabled( mCheckBoxNoProjection->isChecked() );
|
||||
}
|
||||
|
||||
if ( mRequireValidSelection )
|
||||
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( hasValidSelection() );
|
||||
mCrsWidget->setShowNoCrs( show );
|
||||
}
|
||||
|
||||
bool QgsProjectionSelectionDialog::showNoProjection() const
|
||||
{
|
||||
return !mCheckBoxNoProjection->isHidden();
|
||||
return mCrsWidget->showNoCrs();
|
||||
}
|
||||
|
||||
void QgsProjectionSelectionDialog::setNotSetText( const QString &text )
|
||||
void QgsProjectionSelectionDialog::setNotSetText( const QString &text, const QString &description )
|
||||
{
|
||||
mCheckBoxNoProjection->setText( text );
|
||||
mCrsWidget->setNotSetText( text, description );
|
||||
}
|
||||
|
||||
void QgsProjectionSelectionDialog::setRequireValidSelection()
|
||||
{
|
||||
mRequireValidSelection = true;
|
||||
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( hasValidSelection() );
|
||||
|
||||
connect( projectionSelector, &QgsProjectionSelectionTreeWidget::hasValidSelectionChanged, this, [ = ]( bool )
|
||||
connect( mCrsWidget, &QgsCrsSelectionWidget::hasValidSelectionChanged, this, [ = ]( bool isValid )
|
||||
{
|
||||
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( hasValidSelection() );
|
||||
} );
|
||||
|
||||
connect( mCheckBoxNoProjection, &QCheckBox::toggled, this, [ = ]( bool )
|
||||
{
|
||||
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( hasValidSelection() );
|
||||
} );
|
||||
|
||||
connect( mCrsDefinitionWidget, &QgsCrsDefinitionWidget::crsChanged, this, [ = ]()
|
||||
{
|
||||
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( hasValidSelection() );
|
||||
} );
|
||||
|
||||
connect( tabWidget, &QTabWidget::currentChanged, this, [ = ]()
|
||||
{
|
||||
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( hasValidSelection() );
|
||||
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( isValid );
|
||||
} );
|
||||
}
|
||||
|
||||
bool QgsProjectionSelectionDialog::hasValidSelection() const
|
||||
{
|
||||
if ( mCheckBoxNoProjection->isChecked() )
|
||||
return true;
|
||||
|
||||
if ( tabWidget->currentWidget() == mTabCustom )
|
||||
return mCrsDefinitionWidget->crs().isValid();
|
||||
else
|
||||
return projectionSelector->hasValidSelection();
|
||||
return mCrsWidget->hasValidSelection();
|
||||
}
|
||||
|
||||
QgsCoordinateReferenceSystem QgsProjectionSelectionDialog::crs() const
|
||||
{
|
||||
if ( mCheckBoxNoProjection->isEnabled() && mCheckBoxNoProjection->isChecked() )
|
||||
return QgsCoordinateReferenceSystem();
|
||||
|
||||
if ( tabWidget->currentWidget() == mTabCustom )
|
||||
return mCrsDefinitionWidget->crs();
|
||||
else
|
||||
return projectionSelector->crs();
|
||||
return mCrsWidget->crs();
|
||||
}
|
||||
|
||||
void QgsProjectionSelectionDialog::setCrs( const QgsCoordinateReferenceSystem &crs )
|
||||
{
|
||||
if ( !crs.isValid() )
|
||||
{
|
||||
mCheckBoxNoProjection->setChecked( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
mCheckBoxNoProjection->setChecked( false );
|
||||
|
||||
projectionSelector->setCrs( crs );
|
||||
mCrsDefinitionWidget->setCrs( crs );
|
||||
if ( crs.isValid() && crs.authid().isEmpty() )
|
||||
tabWidget->setCurrentWidget( mTabCustom );
|
||||
else
|
||||
tabWidget->setCurrentWidget( mTabDatabase );
|
||||
}
|
||||
mCrsWidget->setCrs( crs );
|
||||
|
||||
if ( mRequireValidSelection )
|
||||
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( hasValidSelection() );
|
||||
@ -180,7 +318,7 @@ void QgsProjectionSelectionDialog::setCrs( const QgsCoordinateReferenceSystem &c
|
||||
|
||||
void QgsProjectionSelectionDialog::setOgcWmsCrsFilter( const QSet<QString> &crsFilter )
|
||||
{
|
||||
projectionSelector->setOgcWmsCrsFilter( crsFilter );
|
||||
mCrsWidget->setOgcWmsCrsFilter( crsFilter );
|
||||
}
|
||||
|
||||
void QgsProjectionSelectionDialog::showHelp()
|
||||
|
||||
@ -22,10 +22,130 @@
|
||||
#include "qgsguiutils.h"
|
||||
|
||||
#include <QSet>
|
||||
#include <QDialog>
|
||||
|
||||
#include "qgis_gui.h"
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
|
||||
class QDialogButtonBox;
|
||||
|
||||
/**
|
||||
* \class QgsCrsSelectionWidget
|
||||
* \ingroup gui
|
||||
* \brief A generic widget allowing users to pick a Coordinate Reference System (or define their own).
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
class GUI_EXPORT QgsCrsSelectionWidget : public QgsPanelWidget, private Ui::QgsGenericProjectionSelectorBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
* CRS types
|
||||
*/
|
||||
enum class CrsType
|
||||
{
|
||||
Predefined, //!< Predefined (from database )
|
||||
Custom, //!< Custom CRS
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor for QgsCrsSelectionWidget, with the specified \a parent widget.
|
||||
*/
|
||||
QgsCrsSelectionWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
|
||||
|
||||
~QgsCrsSelectionWidget() override;
|
||||
|
||||
/**
|
||||
* Returns the CRS currently selected in the widget.
|
||||
* \see setCrs()
|
||||
*/
|
||||
QgsCoordinateReferenceSystem crs() const;
|
||||
|
||||
/**
|
||||
* Sets a \a message to show in the dialog.
|
||||
*/
|
||||
void setMessage( const QString &message );
|
||||
|
||||
/**
|
||||
* Sets whether a "no/invalid" CRS option should be shown. If this
|
||||
* option is selected, calling crs() will return an invalid QgsCoordinateReferenceSystem.
|
||||
* \see showNoCrs()
|
||||
*/
|
||||
void setShowNoCrs( bool show );
|
||||
|
||||
/**
|
||||
* Returns whether the "no/invalid" CRS option is shown. If this
|
||||
* option is selected, calling crs() will return an invalid QgsCoordinateReferenceSystem.
|
||||
* \see setShowNoCrs()
|
||||
*/
|
||||
bool showNoCrs() const;
|
||||
|
||||
/**
|
||||
* Sets the text to show for the not set option. Note that this option is not shown
|
||||
* by default and must be set visible by calling setShowNoCrs().
|
||||
*
|
||||
* The \a description argument can be used to specify a detailed description which
|
||||
* is shown when the option is selected.
|
||||
*/
|
||||
void setNotSetText( const QString &text, const QString &description = QString() );
|
||||
|
||||
/**
|
||||
* Returns TRUE if the widget has a valid CRS defined.
|
||||
*/
|
||||
bool hasValidSelection() const;
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
* Sets the \a crs to show within the widget.
|
||||
* \see crs()
|
||||
*/
|
||||
void setCrs( const QgsCoordinateReferenceSystem &crs );
|
||||
|
||||
/**
|
||||
* \brief filters this dialog by the given CRSs
|
||||
*
|
||||
* Sets this dialog to filter the available CRSs to those listed
|
||||
* by the given Coordinate Reference Systems.
|
||||
*
|
||||
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
|
||||
* list of CRS by. This is useful in (e.g.) WMS situations
|
||||
* where you just want to offer what the WMS server can support.
|
||||
*
|
||||
* \warning This function's behavior is undefined if it is called after the dialog is shown.
|
||||
*/
|
||||
void setOgcWmsCrsFilter( const QSet<QString> &crsFilter );
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
* Emitted when the CRS defined in the widget is changed.
|
||||
*/
|
||||
void crsChanged();
|
||||
|
||||
/**
|
||||
* Emitted when a CRS entry in the widget is double-clicked.
|
||||
*/
|
||||
void crsDoubleClicked( const QgsCoordinateReferenceSystem &crs );
|
||||
|
||||
/**
|
||||
* Emitted when the widget has a valid selection or not.
|
||||
*/
|
||||
void hasValidSelectionChanged( bool isValid );
|
||||
|
||||
private:
|
||||
|
||||
QString mNotSetText;
|
||||
bool mShowNoCrsOption = false;
|
||||
bool mDeferedInvalidCrsSet = false;
|
||||
int mBlockSignals = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \class QgsProjectionSelectionDialog
|
||||
* \ingroup gui
|
||||
@ -47,8 +167,7 @@
|
||||
* the you probably want to look at QgsProjectionSelectionWidget instead.
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
|
||||
class GUI_EXPORT QgsProjectionSelectionDialog : public QDialog, private Ui::QgsGenericProjectionSelectorBase
|
||||
class GUI_EXPORT QgsProjectionSelectionDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -59,8 +178,6 @@ class GUI_EXPORT QgsProjectionSelectionDialog : public QDialog, private Ui::QgsG
|
||||
QgsProjectionSelectionDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr,
|
||||
Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
|
||||
|
||||
~QgsProjectionSelectionDialog() override;
|
||||
|
||||
/**
|
||||
* Returns the CRS currently selected in the widget.
|
||||
* \see setCrs()
|
||||
@ -102,9 +219,13 @@ class GUI_EXPORT QgsProjectionSelectionDialog : public QDialog, private Ui::QgsG
|
||||
/**
|
||||
* Sets the text to show for the not set option. Note that this option is not shown
|
||||
* by default and must be set visible by calling setShowNoProjection().
|
||||
*
|
||||
* Since QGIS 3.24, the \a description argument can be used to specify a detailed description which
|
||||
* is shown when the option is selected.
|
||||
*
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
void setNotSetText( const QString &text );
|
||||
void setNotSetText( const QString &text, const QString &description = QString() );
|
||||
|
||||
/**
|
||||
* Sets the dialog to require a valid selection only, preventing users from accepting the
|
||||
@ -150,6 +271,9 @@ class GUI_EXPORT QgsProjectionSelectionDialog : public QDialog, private Ui::QgsG
|
||||
|
||||
private:
|
||||
|
||||
QDialogButtonBox *mButtonBox = nullptr;
|
||||
QgsCrsSelectionWidget *mCrsWidget = nullptr;
|
||||
|
||||
bool mRequireValidSelection = false;
|
||||
};
|
||||
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QgsGenericProjectionSelectorBase</class>
|
||||
<widget class="QDialog" name="QgsGenericProjectionSelectorBase">
|
||||
<widget class="QgsPanelWidget" name="QgsGenericProjectionSelectorBase">
|
||||
<property name="modal" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>605</width>
|
||||
<height>563</height>
|
||||
<width>342</width>
|
||||
<height>636</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -17,89 +20,116 @@
|
||||
<iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mCheckBoxNoProjection">
|
||||
<property name="toolTip">
|
||||
<string>Use this option to treat all coordinates as Cartesian coordinates in an unknown reference system.</string>
|
||||
<widget class="QSplitter" name="mSplitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>No CRS (or unknown/non-Earth projection)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="mTabDatabase">
|
||||
<attribute name="title">
|
||||
<string>CRS Database</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>160</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QSplitter" name="mSplitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<widget class="QComboBox" name="mComboCrsType"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="mStackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="childrenCollapsible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>160</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="mPageDatabase">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QgsProjectionSelectionTreeWidget" name="projectionSelector" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="mPageCustom">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QgsCrsDefinitionWidget" name="mCrsDefinitionWidget" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="mPageNoCrs">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="mLabelNoCrs">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QgsProjectionSelectionTreeWidget" name="projectionSelector" native="true"/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="mTabCustom">
|
||||
<attribute name="title">
|
||||
<string>Custom CRS</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QgsCrsDefinitionWidget" name="mCrsDefinitionWidget" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="mButtonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -118,40 +148,13 @@
|
||||
<header>qgsprojectionselectiontreewidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsPanelWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qgspanelwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>mButtonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>QgsGenericProjectionSelectorBase</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>409</x>
|
||||
<y>534</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>417</x>
|
||||
<y>559</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>mButtonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>QgsGenericProjectionSelectorBase</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>471</x>
|
||||
<y>537</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>594</x>
|
||||
<y>563</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user