QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsprojectionselectiondialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgenericprojectionselector.cpp
3  Set user defined CRS using projection selector widget
4  -------------------
5  begin : May 28, 2004
6  copyright : (C) 2004 by Gary E.Sherman
7  email : sherman at mrcc.com
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 #include "qgsapplication.h"
19 #include "qgssettings.h"
20 
22 #include "qgshelp.h"
23 #include <QApplication>
24 #include "qgsgui.h"
25 
27  Qt::WindowFlags fl )
28  : QDialog( parent, fl )
29 {
30  setupUi( this );
32  connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsProjectionSelectionDialog::showHelp );
33 
34  //we will show this only when a message is set
35  textEdit->hide();
36 
37  //apply selected projection upon double-click on item
38  connect( projectionSelector, &QgsProjectionSelectionTreeWidget::projectionDoubleClicked, this, &QgsProjectionSelectionDialog::accept );
39 
40  QgsSettings settings;
41  mSplitter->restoreState( settings.value( QStringLiteral( "Windows/ProjectionSelectorDialog/splitterState" ) ).toByteArray() );
42 }
43 
45 {
46  QgsSettings settings;
47  settings.setValue( QStringLiteral( "Windows/ProjectionSelectorDialog/splitterState" ), mSplitter->saveState() );
48 }
49 
50 void QgsProjectionSelectionDialog::setMessage( const QString &message )
51 {
52  textEdit->setHtml( QStringLiteral( "<head><style>%1</style></head><body>%2</body>" ).arg( QgsApplication::reportStyleSheet(),
53  message ) );
54  textEdit->show();
55 }
56 
58 {
59  setMessage( tr( "This layer appears to have no projection specification." )
60  + ' '
61  + tr( "By default, this layer will now have its projection set to that of the project, "
62  "but you may override this by selecting a different projection below." ) );
63 }
64 
66 {
67  projectionSelector->setShowNoProjection( show );
68 }
69 
71 {
72  return projectionSelector->showNoProjection();
73 }
74 
76 {
77  projectionSelector->setNotSetText( text );
78 }
79 
81 {
82  return projectionSelector->crs();
83 }
84 
86 {
87  projectionSelector->setCrs( crs );
88 }
89 
90 void QgsProjectionSelectionDialog::setOgcWmsCrsFilter( const QSet<QString> &crsFilter )
91 {
92  projectionSelector->setOgcWmsCrsFilter( crsFilter );
93 }
94 
95 void QgsProjectionSelectionDialog::showHelp()
96 {
97  QgsHelp::openHelp( QStringLiteral( "working_with_projections/working_with_projections.html" ) );
98 }
QgsProjectionSelectionTreeWidget::projectionDoubleClicked
void projectionDoubleClicked()
Emitted when a projection is double clicked in the list.
QgsSettings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Definition: qgssettings.cpp:174
QgsProjectionSelectionDialog::setNotSetText
void setNotSetText(const QString &text)
Sets the text to show for the not set option.
Definition: qgsprojectionselectiondialog.cpp:75
qgsgui.h
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:51
QgsProjectionSelectionDialog::setShowNoProjection
void setShowNoProjection(bool show)
Sets whether a "no/invalid" projection option should be shown.
Definition: qgsprojectionselectiondialog.cpp:65
QgsProjectionSelectionDialog::crs
QgsCoordinateReferenceSystem crs() const
Returns the CRS currently selected in the widget.
Definition: qgsprojectionselectiondialog.cpp:80
QgsProjectionSelectionDialog::setMessage
void setMessage(const QString &message)
Sets a message to show in the dialog.
Definition: qgsprojectionselectiondialog.cpp:50
QgsProjectionSelectionDialog::showNoProjection
bool showNoProjection() const
Returns whether the "no/invalid" projection option is shown.
Definition: qgsprojectionselectiondialog.cpp:70
QgsProjectionSelectionDialog::setCrs
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the initial crs to show within the dialog.
Definition: qgsprojectionselectiondialog.cpp:85
QgsSettings
This class is a composition of two QSettings instances:
Definition: qgssettings.h:62
QgsProjectionSelectionDialog::~QgsProjectionSelectionDialog
~QgsProjectionSelectionDialog() override
Definition: qgsprojectionselectiondialog.cpp:44
QgsProjectionSelectionDialog::setOgcWmsCrsFilter
void setOgcWmsCrsFilter(const QSet< QString > &crsFilter)
filters this dialog by the given CRSs
Definition: qgsprojectionselectiondialog.cpp:90
QgsProjectionSelectionDialog::showNoCrsForLayerMessage
void showNoCrsForLayerMessage()
When called, the dialog will show a default "layer has no CRS set" message above the projection selec...
Definition: qgsprojectionselectiondialog.cpp:57
qgsapplication.h
qgsprojectionselectiondialog.h
QgsGui::enableAutoGeometryRestore
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...
Definition: qgsgui.cpp:139
QgsProjectionSelectionDialog::QgsProjectionSelectionDialog
QgsProjectionSelectionDialog(QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
Constructor for QgsProjectionSelectionDialog.
Definition: qgsprojectionselectiondialog.cpp:26
QgsSettings::setValue
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Definition: qgssettings.cpp:289
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsHelp::openHelp
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
Definition: qgshelp.cpp:36
qgssettings.h
QgsApplication::reportStyleSheet
static QString reportStyleSheet(QgsApplication::StyleSheetType styleSheetType=QgsApplication::StyleSheetType::Qt)
Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet...
Definition: qgsapplication.cpp:1363
qgshelp.h