QgsProjectionSelector Class Reference
[Gui]

#include <qgsprojectionselector.h>

List of all members.


Detailed Description

A widget for selecting a Coordinate reference system from a tree.

See also:
QgsGenericProjectionSelector.
Author:
Tim Sutton

Definition at line 25 of file qgsprojectionselector.h.

Public Slots

void setSelectedCrsName (QString theCRSName)
QString selectedName ()
void setSelectedCrsId (long theCRSID)
void setSelectedEpsg (long epsg)
QString selectedProj4String ()
long selectedPostgresSrId ()
 Gets the current PostGIS-style projection identifier.
long selectedCrsId ()
 Gets the current QGIS projection identfier.
void setOgcWmsCrsFilter (QSet< QString > crsFilter)
 filters this widget by the given CRSs
void on_pbnFind_clicked ()

Signals

void sridSelected (QString theSRID)
void refresh ()
 Refresh any listening canvases.
void searchBoxHasFocus (bool)
 Let listeners know if find has focus so they can adjust the default button.

Public Member Functions

 QgsProjectionSelector (QWidget *parent, const char *name="", Qt::WFlags fl=0)
 ~QgsProjectionSelector ()
void loadUserCrsList (QSet< QString > *crsFilter=0)
 Populate the proj tree view with user defined projection names.
void loadCrsList (QSet< QString > *crsFilter=0)
 Populate the proj tree view with system projection names.
const QString sqlSafeString (const QString theSQL)
 Make the string safe for use in SQL statements. This involves escaping single quotes, double quotes, backslashes, and optionally, percentage symbols. Percentage symbols are used as wildcards sometimes and so when using the string as part of the LIKE phrase of a select statement, should be escaped.
long selectedEpsg ()
 Gets the current EpsgCrsId-style projection identifier.

Protected Member Functions

void showEvent (QShowEvent *theEvent)
 Used to ensure the projection list view is actually populated.
void resizeEvent (QResizeEvent *theEvent)
 Used to manage column sizes.

Private Slots

void coordinateSystemSelected (QTreeWidgetItem *)
 private handler for when user selects a cs it will cause wktSelected and sridSelected events to be spawned

Private Member Functions

QString ogcWmsCrsFilterAsSqlExpression (QSet< QString > *crsFilter)
 converts the CRS group to a SQL expression fragment
void applyCRSNameSelection ()
 does the legwork of applying the CRS Name Selection
void applyCRSIDSelection ()
 does the legwork of applying the CRS ID Selection
long getSelectedLongAttribute (QString attributeName)
 gets an arbitrary sqlite3 attribute of type "long" from the selection
void showDBMissingWarning (const QString theFileName)
 Show the user a warning if the srs database could not be found.
long getLargestCRSIDMatch (QString theSql)
 Utility method used in conjunction with name based searching tool.

Private Attributes

QTreeWidgetItem * mUserProjList
 User defined projections node.
QTreeWidgetItem * mGeoList
 GEOGCS node.
QTreeWidgetItem * mProjList
 PROJCS node.
QString mCustomCsFile
 Users custom coordinate system file.
QString mSrsDatabaseFileName
 File name of the sqlite3 database.
bool mProjListDone
 Has the Projection List been populated?
bool mUserProjListDone
 Has the User Projection List been populated?
bool mCRSNameSelectionPending
 Is there a pending selection to be made by CRS Name?
bool mCRSIDSelectionPending
 Is there a pending selection to be made by CRS ID?
QString mCRSNameSelection
 The CRS Name that wants to be selected on this widget.
long mCRSIDSelection
 The CRS ID that wants to be selected on this widget.
QSet< QString > mCrsFilter
 The set of OGC WMS CRSs that want to be applied to this widget.


Constructor & Destructor Documentation

QgsProjectionSelector::QgsProjectionSelector ( QWidget *  parent,
const char *  name = "",
Qt::WFlags  fl = 0 
)

Definition at line 37 of file qgsprojectionselector.cpp.

References coordinateSystemSelected(), EPSG_COLUMN, mSrsDatabaseFileName, QGIS_CRS_ID_COLUMN, and QgsApplication::srsDbFilePath().

QgsProjectionSelector::~QgsProjectionSelector (  ) 

Definition at line 60 of file qgsprojectionselector.cpp.


Member Function Documentation

void QgsProjectionSelector::loadUserCrsList ( QSet< QString > *  crsFilter = 0  ) 

Populate the proj tree view with user defined projection names.

..

Parameters:
crsFilter a list of OGC Coordinate Reference Systems to filter the list of projections by. This is useful in (e.g.) WMS situations where you just want to offer what the WMS server can support.
Todo:
Should this be public?

Definition at line 482 of file qgsprojectionselector.cpp.

References QgsApplication::activeThemePath(), mUserProjList, mUserProjListDone, ogcWmsCrsFilterAsSqlExpression(), QGIS_CRS_ID_COLUMN, QgsApplication::qgisUserDbFilePath(), QgsDebugMsg, and showDBMissingWarning().

Referenced by showEvent().

void QgsProjectionSelector::loadCrsList ( QSet< QString > *  crsFilter = 0  ) 

Populate the proj tree view with system projection names.

..

Parameters:
crsFilter a list of OGC Coordinate Reference Systems to filter the list of projections by. This is useful in (e.g.) WMS situations where you just want to offer what the WMS server can support.
Todo:
Should this be public?

Definition at line 559 of file qgsprojectionselector.cpp.

References QgsApplication::activeThemePath(), EPSG_COLUMN, mGeoList, mProjList, mProjListDone, mSrsDatabaseFileName, ogcWmsCrsFilterAsSqlExpression(), QGIS_CRS_ID_COLUMN, and showDBMissingWarning().

Referenced by showEvent().

const QString QgsProjectionSelector::sqlSafeString ( const QString  theSQL  ) 

Make the string safe for use in SQL statements. This involves escaping single quotes, double quotes, backslashes, and optionally, percentage symbols. Percentage symbols are used as wildcards sometimes and so when using the string as part of the LIKE phrase of a select statement, should be escaped.

Definition at line 919 of file qgsprojectionselector.cpp.

Referenced by on_pbnFind_clicked().

long QgsProjectionSelector::selectedEpsg (  ) 

Gets the current EpsgCrsId-style projection identifier.

Definition at line 452 of file qgsprojectionselector.cpp.

References getSelectedLongAttribute().

void QgsProjectionSelector::setSelectedCrsName ( QString  theCRSName  )  [slot]

Definition at line 166 of file qgsprojectionselector.cpp.

References applyCRSNameSelection(), mCRSIDSelectionPending, mCRSNameSelection, and mCRSNameSelectionPending.

QString QgsProjectionSelector::selectedName (  )  [slot]

Definition at line 258 of file qgsprojectionselector.cpp.

void QgsProjectionSelector::setSelectedCrsId ( long  theCRSID  )  [slot]

Definition at line 182 of file qgsprojectionselector.cpp.

References applyCRSIDSelection(), mCRSIDSelection, mCRSIDSelectionPending, and mCRSNameSelectionPending.

Referenced by on_pbnFind_clicked().

void QgsProjectionSelector::setSelectedEpsg ( long  epsg  )  [slot]

Definition at line 197 of file qgsprojectionselector.cpp.

QString QgsProjectionSelector::selectedProj4String (  )  [slot]

Definition at line 272 of file qgsprojectionselector.cpp.

References mSrsDatabaseFileName, QGIS_CRS_ID_COLUMN, QgsApplication::qgisUserDbFilePath(), QgsDebugMsg, showDBMissingWarning(), and USER_CRS_START_ID.

Referenced by coordinateSystemSelected().

long QgsProjectionSelector::selectedPostgresSrId (  )  [slot]

Gets the current PostGIS-style projection identifier.

Definition at line 446 of file qgsprojectionselector.cpp.

References getSelectedLongAttribute().

long QgsProjectionSelector::selectedCrsId (  )  [slot]

Gets the current QGIS projection identfier.

Definition at line 458 of file qgsprojectionselector.cpp.

References QGIS_CRS_ID_COLUMN.

Referenced by coordinateSystemSelected(), and on_pbnFind_clicked().

void QgsProjectionSelector::setOgcWmsCrsFilter ( QSet< QString >  crsFilter  )  [slot]

filters this widget by the given CRSs

Sets this widget to filter the available projections to those listed by the given Coordinate Reference Systems.

Parameters:
crsFilter a list of OGC Coordinate Reference Systems to filter the list of projections by. This is useful in (e.g.) WMS situations where you just want to offer what the WMS server can support.
Note:
This function only deals with EpsgCrsId labels only at this time.
Warning:
This function's behaviour is undefined if it is called after the widget is shown.

Definition at line 473 of file qgsprojectionselector.cpp.

References mCrsFilter, mProjListDone, and mUserProjListDone.

void QgsProjectionSelector::on_pbnFind_clicked (  )  [slot]

Definition at line 728 of file qgsprojectionselector.cpp.

References getLargestCRSIDMatch(), mSrsDatabaseFileName, QgsApplication::qgisUserDbFilePath(), QgsDebugMsg, selectedCrsId(), setSelectedCrsId(), showDBMissingWarning(), and sqlSafeString().

void QgsProjectionSelector::showEvent ( QShowEvent *  theEvent  )  [protected]

Used to ensure the projection list view is actually populated.

Definition at line 72 of file qgsprojectionselector.cpp.

References applyCRSIDSelection(), applyCRSNameSelection(), loadCrsList(), loadUserCrsList(), mCrsFilter, mCRSIDSelectionPending, mCRSNameSelectionPending, mProjListDone, and mUserProjListDone.

void QgsProjectionSelector::resizeEvent ( QResizeEvent *  theEvent  )  [protected]

Used to manage column sizes.

Definition at line 64 of file qgsprojectionselector.cpp.

References EPSG_COLUMN, NAME_COLUMN, and QGIS_CRS_ID_COLUMN.

QString QgsProjectionSelector::ogcWmsCrsFilterAsSqlExpression ( QSet< QString > *  crsFilter  )  [private]

converts the CRS group to a SQL expression fragment

Converts the given Coordinate Reference Systems to a format suitable for use in SQL for querying against the QGIS CRS database.

Parameters:
crsFilter a list of OGC Coordinate Reference Systems to filter the list of projections by. This is useful in (e.g.) WMS situations where you just want to offer what the WMS server can support.
Note:
This function only deals with EpsgCrsId labels only at this time.

Definition at line 102 of file qgsprojectionselector.cpp.

References QgsDebugMsg.

Referenced by loadCrsList(), and loadUserCrsList().

void QgsProjectionSelector::applyCRSNameSelection (  )  [private]

does the legwork of applying the CRS Name Selection

Warning:
This function does nothing unless getUserList() and getUserProjList() Have already been called

This function only expands the parents of the selection and does not scroll the list to the selection if the widget is not visible. Therefore you will typically want to use this in a showEvent().

Definition at line 202 of file qgsprojectionselector.cpp.

References mCRSNameSelection, mCRSNameSelectionPending, mProjListDone, mUserProjListDone, and QgsDebugMsg.

Referenced by setSelectedCrsName(), and showEvent().

void QgsProjectionSelector::applyCRSIDSelection (  )  [private]

does the legwork of applying the CRS ID Selection

Warning:
This function does nothing unless getUserList() and getUserProjList() Have already been called

This function only expands the parents of the selection and does not scroll the list to the selection if the widget is not visible. Therefore you will typically want to use this in a showEvent().

Definition at line 229 of file qgsprojectionselector.cpp.

References mCRSIDSelection, mCRSIDSelectionPending, mProjListDone, mUserProjListDone, and QGIS_CRS_ID_COLUMN.

Referenced by setSelectedCrsId(), and showEvent().

long QgsProjectionSelector::getSelectedLongAttribute ( QString  attributeName  )  [private]

gets an arbitrary sqlite3 attribute of type "long" from the selection

Parameters:
attributeName The sqlite3 column name, typically "srid" or "epsg"

Definition at line 364 of file qgsprojectionselector.cpp.

References mSrsDatabaseFileName, QGIS_CRS_ID_COLUMN, QgsApplication::qgisUserDbFilePath(), QgsDebugMsg, showDBMissingWarning(), and USER_CRS_START_ID.

Referenced by selectedEpsg(), and selectedPostgresSrId().

void QgsProjectionSelector::showDBMissingWarning ( const QString  theFileName  )  [private]

Show the user a warning if the srs database could not be found.

Definition at line 929 of file qgsprojectionselector.cpp.

Referenced by getLargestCRSIDMatch(), getSelectedLongAttribute(), loadCrsList(), loadUserCrsList(), on_pbnFind_clicked(), and selectedProj4String().

long QgsProjectionSelector::getLargestCRSIDMatch ( QString  theSql  )  [private]

Utility method used in conjunction with name based searching tool.

Definition at line 834 of file qgsprojectionselector.cpp.

References mSrsDatabaseFileName, QgsApplication::qgisUserDbFilePath(), QgsDebugMsg, and showDBMissingWarning().

Referenced by on_pbnFind_clicked().

void QgsProjectionSelector::coordinateSystemSelected ( QTreeWidgetItem *   )  [private, slot]

private handler for when user selects a cs it will cause wktSelected and sridSelected events to be spawned

Definition at line 707 of file qgsprojectionselector.cpp.

References selectedCrsId(), selectedProj4String(), and sridSelected().

Referenced by QgsProjectionSelector().

void QgsProjectionSelector::sridSelected ( QString  theSRID  )  [signal]

Referenced by coordinateSystemSelected().

void QgsProjectionSelector::refresh (  )  [signal]

Refresh any listening canvases.

void QgsProjectionSelector::searchBoxHasFocus ( bool   )  [signal]

Let listeners know if find has focus so they can adjust the default button.


Member Data Documentation

QTreeWidgetItem* QgsProjectionSelector::mUserProjList [private]

User defined projections node.

Definition at line 164 of file qgsprojectionselector.h.

Referenced by loadUserCrsList().

QTreeWidgetItem* QgsProjectionSelector::mGeoList [private]

GEOGCS node.

Definition at line 166 of file qgsprojectionselector.h.

Referenced by loadCrsList().

QTreeWidgetItem* QgsProjectionSelector::mProjList [private]

PROJCS node.

Definition at line 168 of file qgsprojectionselector.h.

Referenced by loadCrsList().

QString QgsProjectionSelector::mCustomCsFile [private]

Users custom coordinate system file.

Definition at line 171 of file qgsprojectionselector.h.

QString QgsProjectionSelector::mSrsDatabaseFileName [private]

File name of the sqlite3 database.

Definition at line 173 of file qgsprojectionselector.h.

Referenced by getLargestCRSIDMatch(), getSelectedLongAttribute(), loadCrsList(), on_pbnFind_clicked(), QgsProjectionSelector(), and selectedProj4String().

bool QgsProjectionSelector::mProjListDone [private]

Has the Projection List been populated?

Definition at line 181 of file qgsprojectionselector.h.

Referenced by applyCRSIDSelection(), applyCRSNameSelection(), loadCrsList(), setOgcWmsCrsFilter(), and showEvent().

bool QgsProjectionSelector::mUserProjListDone [private]

Has the User Projection List been populated?

Definition at line 184 of file qgsprojectionselector.h.

Referenced by applyCRSIDSelection(), applyCRSNameSelection(), loadUserCrsList(), setOgcWmsCrsFilter(), and showEvent().

bool QgsProjectionSelector::mCRSNameSelectionPending [private]

Is there a pending selection to be made by CRS Name?

Definition at line 187 of file qgsprojectionselector.h.

Referenced by applyCRSNameSelection(), setSelectedCrsId(), setSelectedCrsName(), and showEvent().

bool QgsProjectionSelector::mCRSIDSelectionPending [private]

Is there a pending selection to be made by CRS ID?

Definition at line 190 of file qgsprojectionselector.h.

Referenced by applyCRSIDSelection(), setSelectedCrsId(), setSelectedCrsName(), and showEvent().

QString QgsProjectionSelector::mCRSNameSelection [private]

The CRS Name that wants to be selected on this widget.

Definition at line 193 of file qgsprojectionselector.h.

Referenced by applyCRSNameSelection(), and setSelectedCrsName().

long QgsProjectionSelector::mCRSIDSelection [private]

The CRS ID that wants to be selected on this widget.

Definition at line 196 of file qgsprojectionselector.h.

Referenced by applyCRSIDSelection(), and setSelectedCrsId().

QSet<QString> QgsProjectionSelector::mCrsFilter [private]

The set of OGC WMS CRSs that want to be applied to this widget.

Definition at line 199 of file qgsprojectionselector.h.

Referenced by setOgcWmsCrsFilter(), and showEvent().


The documentation for this class was generated from the following files:
Generated on Tue Jan 6 01:51:24 2009 for Quantum GIS API Documentation by  doxygen 1.5.1