QGIS API Documentation  2.99.0-Master (c42dad3)
qgsgenericprojectionselector.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 
21 #include <QApplication>
22 #include <QSettings>
23 
29  Qt::WindowFlags fl )
30  : QDialog( parent, fl )
31 {
32  setupUi( this );
33 
34  QSettings settings;
35  restoreGeometry( settings.value( QStringLiteral( "/Windows/ProjectionSelector/geometry" ) ).toByteArray() );
36 
37  //we will show this only when a message is set
38  textEdit->hide();
39 
40  //apply selected projection upon double click on item
41  connect( projectionSelector, SIGNAL( projectionDoubleClicked() ), this, SLOT( accept() ) );
42 }
43 
44 void QgsGenericProjectionSelector::setMessage( QString theMessage )
45 {
46  //short term kludge to make the layer selector default to showing
47  //a layer projection selection message. If you want the selector
48  if ( theMessage.isEmpty() )
49  {
50  // Set up text edit pane
51  QString format( QStringLiteral( "<h1>%1</h1>%2 %3" ) );
52  QString header = tr( "Define this layer's coordinate reference system:" );
53  QString sentence1 = tr( "This layer appears to have no projection specification." );
54  QString sentence2 = tr( "By default, this layer will now have its projection set to that of the project, "
55  "but you may override this by selecting a different projection below." );
56  theMessage = format.arg( header, sentence1, sentence2 );
57  }
58 
59  QString myStyle = QgsApplication::reportStyleSheet();
60  theMessage = "<head><style>" + myStyle + "</style></head><body>" + theMessage + "</body>";
61  textEdit->setHtml( theMessage );
62  textEdit->show();
63 }
66 {
67  QSettings settings;
68  settings.setValue( QStringLiteral( "/Windows/ProjectionSelector/geometry" ), saveGeometry() );
69 }
70 
72 {
73  projectionSelector->setSelectedCrsName( theName );
74 }
75 
77 {
78  projectionSelector->setSelectedCrsId( theID );
79 }
80 
82 {
83  projectionSelector->setSelectedAuthId( theID );
84 }
85 
87 {
88  [email protected] don't use getSelectedWkt as that just returns the name part!
89  return projectionSelector->selectedCrsId();
90 }
91 
93 {
94  return projectionSelector->selectedAuthId();
95 }
96 
97 void QgsGenericProjectionSelector::setOgcWmsCrsFilter( const QSet<QString>& crsFilter )
98 {
99  projectionSelector->setOgcWmsCrsFilter( crsFilter );
100 }
void setOgcWmsCrsFilter(const QSet< QString > &crsFilter)
filters this dialog by the given CRSs
static QString reportStyleSheet()
get a standard css style sheet for reports.
void setMessage(QString theMessage=QStringLiteral(""))
If no parameter is passed, the message will be a generic &#39;define the CRS for this layer&#39;...
void setSelectedCrsName(const QString &theName)
void setSelectedAuthId(const QString &authId)
QgsGenericProjectionSelector(QWidget *parent=nullptr, Qt::WindowFlags fl=QgisGui::ModalDialogFlags)
Constructor.