QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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  const Qt::WindowFlags& fl )
30  : QDialog( parent, fl )
31 {
32  setupUi( this );
33 
34  QSettings settings;
35  restoreGeometry( settings.value( "/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 
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( "<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 
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( "/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  //@note don't use getSelectedWkt as that just returns the name part!
89  return projectionSelector->selectedCrsId();
90 }
91 
93 {
94  return projectionSelector->selectedAuthId();
95 }
96 
98 {
99  projectionSelector->setOgcWmsCrsFilter( crsFilter );
100 }
QByteArray toByteArray() const
void setupUi(QWidget *widget)
void setOgcWmsCrsFilter(const QSet< QString > &crsFilter)
filters this dialog by the given CRSs
static QString reportStyleSheet()
get a standard css style sheet for reports.
QString tr(const char *sourceText, const char *disambiguation, int n)
void setValue(const QString &key, const QVariant &value)
bool restoreGeometry(const QByteArray &geometry)
bool isEmpty() const
void setMessage(QString theMessage="")
If no parameter is passed, the message will be a generic &#39;define the CRS for this layer&#39;...
virtual void accept()
void setSelectedCrsName(const QString &theName)
QVariant value(const QString &key, const QVariant &defaultValue) const
QByteArray saveGeometry() const
void setSelectedAuthId(const QString &authId)
typedef WindowFlags
QgsGenericProjectionSelector(QWidget *parent=nullptr, const Qt::WindowFlags &fl=QgisGui::ModalDialogFlags)
Constructor.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const