Quantum GIS API Documentation  1.7.4
Public Slots | Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes
QgsProjectionSelector Class Reference

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

#include <qgsprojectionselector.h>

List of all members.

Public Slots

void setSelectedCrsName (QString theCRSName)
QString selectedName ()
void setSelectedCrsId (long theCRSID)
void setSelectedAuthId (QString authId)
Q_DECL_DEPRECATED void setSelectedEpsg (long epsg)
 Get the selected coordinate system.
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 ()
void on_lstRecent_currentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *)
void on_cbxHideDeprecated_stateChanged ()

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.
Q_DECL_DEPRECATED long selectedEpsg ()
 Gets the current EpsgCrsId-style projection identifier.
long selectedSrsid ()
 Gets the current InternalCrsId-style projection identifier.
QString selectedAuthId ()
 Gets the current authority-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
QStringList authorities ()
 get list of authorities

Private Member Functions

QString ogcWmsCrsFilterAsSqlExpression (QSet< QString > *crsFilter)
 converts the CRS group to a SQL expression fragment
void applySelection ()
 does the legwork of applying CRS Selection
QString getSelectedExpression (QString e)
 gets an arbitrary sqlite3 expression 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.
void insertRecent (long theCrsId)
 add recently used CRS
void hideDeprecated (QTreeWidgetItem *item)
 hide deprecated CRSes

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 mRecentProjListDone
 Has the Recent 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?
bool mAuthIDSelectionPending
 Is there a pending selection to be made by Authority 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.
QString mAuthIDSelection
 The Authority 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.
QStringList mRecentProjections
 Most recently used projections (trimmed at 25 entries)

Detailed Description

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

See also:
QgsGenericProjectionSelector.
Author:
Tim Sutton

Definition at line 28 of file qgsprojectionselector.h.


Constructor & Destructor Documentation

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

Member Function Documentation

does the legwork of applying CRS 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 291 of file qgsprojectionselector.cpp.

References AUTHID_COLUMN, mAuthIDSelection, mAuthIDSelectionPending, mCRSIDSelection, mCRSIDSelectionPending, mCRSNameSelection, mCRSNameSelectionPending, mProjListDone, mUserProjListDone, QGIS_CRS_ID_COLUMN, and QgsDebugMsg.

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

QStringList QgsProjectionSelector::authorities ( ) [private, slot]

get list of authorities

Definition at line 1063 of file qgsprojectionselector.cpp.

References mSrsDatabaseFileName, and QgsDebugMsg.

Referenced by QgsProjectionSelector().

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

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

Definition at line 817 of file qgsprojectionselector.cpp.

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

Referenced by QgsProjectionSelector().

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

Utility method used in conjunction with name based searching tool.

Definition at line 986 of file qgsprojectionselector.cpp.

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

Referenced by on_pbnFind_clicked().

QString QgsProjectionSelector::getSelectedExpression ( QString  e) [private]

gets an arbitrary sqlite3 expression from the selection

Parameters:
eThe sqlite3 expression (typically "srid" or "sridid")

Definition at line 458 of file qgsprojectionselector.cpp.

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

Referenced by selectedAuthId(), selectedEpsg(), and selectedPostgresSrId().

void QgsProjectionSelector::hideDeprecated ( QTreeWidgetItem *  item) [private]

hide deprecated CRSes

Definition at line 841 of file qgsprojectionselector.cpp.

Referenced by on_cbxHideDeprecated_stateChanged().

void QgsProjectionSelector::insertRecent ( long  theCrsId) [private]

add recently used CRS

Definition at line 336 of file qgsprojectionselector.cpp.

References AUTHID_COLUMN, mProjListDone, mUserProjListDone, NAME_COLUMN, and QGIS_CRS_ID_COLUMN.

Referenced by showEvent().

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

Populate the proj tree view with system projection names...

Parameters:
crsFiltera 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 666 of file qgsprojectionselector.cpp.

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

Referenced by showEvent().

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

Populate the proj tree view with user defined projection names...

Parameters:
crsFiltera 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 591 of file qgsprojectionselector.cpp.

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

Referenced by showEvent().

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:
crsFiltera 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.

Definition at line 184 of file qgsprojectionselector.cpp.

References QgsDebugMsg.

Referenced by loadCrsList(), and loadUserCrsList().

Definition at line 857 of file qgsprojectionselector.cpp.

References hideDeprecated().

void QgsProjectionSelector::on_lstRecent_currentItemChanged ( QTreeWidgetItem *  current,
QTreeWidgetItem *  previous 
) [slot]

Definition at line 863 of file qgsprojectionselector.cpp.

References QGIS_CRS_ID_COLUMN, and setSelectedCrsId().

void QgsProjectionSelector::refresh ( ) [signal]

Refresh any listening canvases.

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

Used to manage column sizes.

Definition at line 140 of file qgsprojectionselector.cpp.

References AUTHID_COLUMN, NAME_COLUMN, and QGIS_CRS_ID_COLUMN.

void QgsProjectionSelector::searchBoxHasFocus ( bool  ) [signal]

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

Gets the current authority-style projection identifier.

Definition at line 557 of file qgsprojectionselector.cpp.

References getSelectedExpression(), and USER_CRS_START_ID.

Gets the current QGIS projection identfier.

Definition at line 567 of file qgsprojectionselector.cpp.

References QGIS_CRS_ID_COLUMN.

Referenced by coordinateSystemSelected(), on_pbnFind_clicked(), and ~QgsProjectionSelector().

Gets the current EpsgCrsId-style projection identifier.

Definition at line 538 of file qgsprojectionselector.cpp.

References getSelectedExpression(), and QgsDebugMsg.

Definition at line 353 of file qgsprojectionselector.cpp.

Gets the current PostGIS-style projection identifier.

Definition at line 551 of file qgsprojectionselector.cpp.

References getSelectedExpression().

Gets the current InternalCrsId-style projection identifier.

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:
crsFiltera 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.
Warning:
This function's behaviour is undefined if it is called after the widget is shown.

Definition at line 582 of file qgsprojectionselector.cpp.

References mCrsFilter, mProjListDone, and mUserProjListDone.

void QgsProjectionSelector::setSelectedAuthId ( QString  authId) [slot]
void QgsProjectionSelector::setSelectedCrsId ( long  theCRSID) [slot]
void QgsProjectionSelector::setSelectedCrsName ( QString  theCRSName) [slot]
void QgsProjectionSelector::setSelectedEpsg ( long  epsg) [slot]

Get the selected coordinate system.

Definition at line 278 of file qgsprojectionselector.cpp.

References setSelectedAuthId().

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

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

Definition at line 1117 of file qgsprojectionselector.cpp.

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

void QgsProjectionSelector::showEvent ( QShowEvent *  theEvent) [protected]
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.

  • const QString in The input string to make safe.
    Returns:
    The string made safe for SQL statements.

Definition at line 1107 of file qgsprojectionselector.cpp.

Referenced by on_pbnFind_clicked().

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

Member Data Documentation

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

Definition at line 209 of file qgsprojectionselector.h.

Referenced by applySelection(), and setSelectedAuthId().

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

Definition at line 200 of file qgsprojectionselector.h.

Referenced by applySelection(), setSelectedAuthId(), setSelectedCrsId(), setSelectedCrsName(), and showEvent().

QSet<QString> QgsProjectionSelector::mCrsFilter [private]

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

Definition at line 212 of file qgsprojectionselector.h.

Referenced by setOgcWmsCrsFilter(), and showEvent().

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

Definition at line 206 of file qgsprojectionselector.h.

Referenced by applySelection(), and setSelectedCrsId().

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

Definition at line 197 of file qgsprojectionselector.h.

Referenced by applySelection(), setSelectedAuthId(), setSelectedCrsId(), setSelectedCrsName(), and showEvent().

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

Definition at line 203 of file qgsprojectionselector.h.

Referenced by applySelection(), and setSelectedCrsName().

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

Definition at line 194 of file qgsprojectionselector.h.

Referenced by applySelection(), setSelectedAuthId(), setSelectedCrsId(), setSelectedCrsName(), and showEvent().

Users custom coordinate system file.

Definition at line 172 of file qgsprojectionselector.h.

QTreeWidgetItem* QgsProjectionSelector::mGeoList [private]

GEOGCS node.

Definition at line 167 of file qgsprojectionselector.h.

Referenced by loadCrsList().

QTreeWidgetItem* QgsProjectionSelector::mProjList [private]

PROJCS node.

Definition at line 169 of file qgsprojectionselector.h.

Referenced by loadCrsList().

Has the Projection List been populated?

Definition at line 185 of file qgsprojectionselector.h.

Referenced by applySelection(), insertRecent(), loadCrsList(), setOgcWmsCrsFilter(), and showEvent().

Most recently used projections (trimmed at 25 entries)

Definition at line 215 of file qgsprojectionselector.h.

Referenced by QgsProjectionSelector(), showEvent(), and ~QgsProjectionSelector().

Has the Recent Projection List been populated?

Definition at line 191 of file qgsprojectionselector.h.

Referenced by showEvent().

QTreeWidgetItem* QgsProjectionSelector::mUserProjList [private]

User defined projections node.

Definition at line 165 of file qgsprojectionselector.h.

Referenced by loadUserCrsList().

Has the User Projection List been populated?

Definition at line 188 of file qgsprojectionselector.h.

Referenced by applySelection(), insertRecent(), loadUserCrsList(), setOgcWmsCrsFilter(), and showEvent().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines