QGIS API Documentation  master-59fd5e0
src/gui/qgsgenericprojectionselector.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           qgsgenericprojectionselector.cpp
00003                     Set user defined CRS using projection selector widget
00004                              -------------------
00005     begin                : May 28, 2004
00006     copyright            : (C) 2004 by Gary E.Sherman
00007     email                : sherman at mrcc.com
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 #include "qgsapplication.h"
00019 
00020 #include <qgsgenericprojectionselector.h>
00021 #include <QApplication>
00022 #include <QSettings>
00023 
00028 QgsGenericProjectionSelector::QgsGenericProjectionSelector( QWidget *parent,
00029     Qt::WFlags fl )
00030     : QDialog( parent, fl )
00031 {
00032   setupUi( this );
00033 
00034   QSettings settings;
00035   restoreGeometry( settings.value( "/Windows/ProjectionSelector/geometry" ).toByteArray() );
00036 
00037   //we will show this only when a message is set
00038   textEdit->hide();
00039 }
00040 
00041 void QgsGenericProjectionSelector::setMessage( QString theMessage )
00042 {
00043   //short term kludge to make the layer selector default to showing
00044   //a layer projection selection message. If you want the selector
00045   if ( theMessage.isEmpty() )
00046   {
00047     // Set up text edit pane
00048     QString format( "<h1>%1</h1>%2 %3" );
00049     QString header = tr( "Define this layer's coordinate reference system:" );
00050     QString sentence1 = tr( "This layer appears to have no projection specification." );
00051     QString sentence2 = tr( "By default, this layer will now have its projection set to that of the project, "
00052                             "but you may override this by selecting a different projection below." );
00053     theMessage = format.arg( header ).arg( sentence1 ).arg( sentence2 );
00054   }
00055 
00056   QString myStyle = QgsApplication::reportStyleSheet();
00057   theMessage = "<head><style>" + myStyle + "</style></head><body>" + theMessage + "</body>";
00058   textEdit->setHtml( theMessage );
00059   textEdit->show();
00060 }
00062 QgsGenericProjectionSelector::~QgsGenericProjectionSelector()
00063 {
00064   QSettings settings;
00065   settings.setValue( "/Windows/ProjectionSelector/geometry", saveGeometry() );
00066 }
00067 
00068 void QgsGenericProjectionSelector::setSelectedCrsName( QString theName )
00069 {
00070   projectionSelector->setSelectedCrsName( theName );
00071 }
00072 
00073 void QgsGenericProjectionSelector::setSelectedCrsId( long theID )
00074 {
00075   projectionSelector->setSelectedCrsId( theID );
00076 }
00077 
00078 void QgsGenericProjectionSelector::setSelectedAuthId( QString theID )
00079 {
00080   projectionSelector->setSelectedAuthId( theID );
00081 }
00082 
00083 long QgsGenericProjectionSelector::selectedCrsId()
00084 {
00085   //@note don't use getSelectedWkt as that just returns the name part!
00086   return projectionSelector->selectedCrsId();
00087 }
00088 
00089 QString QgsGenericProjectionSelector::selectedAuthId()
00090 {
00091   return projectionSelector->selectedAuthId();
00092 }
00093 
00094 void QgsGenericProjectionSelector::setOgcWmsCrsFilter( QSet<QString> crsFilter )
00095 {
00096   projectionSelector->setOgcWmsCrsFilter( crsFilter );
00097 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines