QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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( "/Windows/ProjectionSelector/geometry" ).toByteArray() );
36 
37  //we will show this only when a message is set
38  textEdit->hide();
39 }
40 
41 void QgsGenericProjectionSelector::setMessage( QString theMessage )
42 {
43  //short term kludge to make the layer selector default to showing
44  //a layer projection selection message. If you want the selector
45  if ( theMessage.isEmpty() )
46  {
47  // Set up text edit pane
48  QString format( "<h1>%1</h1>%2 %3" );
49  QString header = tr( "Define this layer's coordinate reference system:" );
50  QString sentence1 = tr( "This layer appears to have no projection specification." );
51  QString sentence2 = tr( "By default, this layer will now have its projection set to that of the project, "
52  "but you may override this by selecting a different projection below." );
53  theMessage = format.arg( header ).arg( sentence1 ).arg( sentence2 );
54  }
55 
56  QString myStyle = QgsApplication::reportStyleSheet();
57  theMessage = "<head><style>" + myStyle + "</style></head><body>" + theMessage + "</body>";
58  textEdit->setHtml( theMessage );
59  textEdit->show();
60 }
63 {
64  QSettings settings;
65  settings.setValue( "/Windows/ProjectionSelector/geometry", saveGeometry() );
66 }
67 
69 {
70  projectionSelector->setSelectedCrsName( theName );
71 }
72 
74 {
75  projectionSelector->setSelectedCrsId( theID );
76 }
77 
79 {
80  projectionSelector->setSelectedAuthId( theID );
81 }
82 
84 {
85  //@note don't use getSelectedWkt as that just returns the name part!
86  return projectionSelector->selectedCrsId();
87 }
88 
90 {
91  return projectionSelector->selectedAuthId();
92 }
93 
94 void QgsGenericProjectionSelector::setOgcWmsCrsFilter( QSet<QString> crsFilter )
95 {
96  projectionSelector->setOgcWmsCrsFilter( crsFilter );
97 }
static QString reportStyleSheet()
get a standard css style sheet for reports.
void setMessage(QString theMessage="")
If no parameter is passed, the message will be a generic 'define the CRS for this layer'...
QgsGenericProjectionSelector(QWidget *parent=0, Qt::WindowFlags fl=QgisGui::ModalDialogFlags)
Constructor.
void setOgcWmsCrsFilter(QSet< QString > crsFilter)
filters this dialog by the given CRSs
#define tr(sourceText)