#include <qgsapplication.h>
This is a subclass of QApplication and should be instantiated in place of QApplication. Most methods are static in keeping witn the design of QApplication.
This class hides platform-specific path information and provides a portable way of referencing specific files and directories. Ideally, hard-coded paths should appear only here and not in other modules so that platform-conditional code is minimized and paths are easier to change due to centralization.
Definition at line 25 of file qgsapplication.h.
Public Types | |
| enum | ENDIAN { XDR = 0, NDR = 1 } |
| constants for endian-ness More... | |
| typedef enum QgsApplication::ENDIAN | endian_t |
| constants for endian-ness | |
Public Member Functions | |
| QgsApplication (int &argc, char **argv, bool GUIenabled) | |
| virtual | ~QgsApplication () |
| virtual bool | notify (QObject *receiver, QEvent *event) |
| Catch exceptions when sending event to receiver. | |
Static Public Member Functions | |
| static void | setThemeName (const QString theThemeName) |
| Set the active theme to the specified theme. | |
| static const QString | themeName () |
| Set the active theme to the specified theme. | |
| static const QString | authorsFilePath () |
| Returns the path to the authors file. | |
| static const QString | sponsorsFilePath () |
| Returns the path to the sponsors file. | |
| static const QString | developerPath () |
| Returns the path to the developer image directory. | |
| static const QString | helpAppPath () |
| Returns the path to the help application. | |
| static const QString | msexportAppPath () |
| Returns the path to the mapserver export application. | |
| static const QString | i18nPath () |
| Returns the path to the translation directory. | |
| static const QString | qgisMasterDbFilePath () |
| Returns the path to the master qgis.db file. | |
| static const QString | qgisSettingsDirPath () |
| Returns the path to the settings directory in user's home dir. | |
| static const QString | qgisUserDbFilePath () |
| Returns the path to the user qgis.db file. | |
| static const QString | splashPath () |
| Returns the path to the splash screen image directory. | |
| static const QString | iconsPath () |
| Returns the path to the icons image directory. | |
| static const QString | srsDbFilePath () |
| Returns the path to the srs.db file. | |
| static const QString | svgPath () |
| Returns the path to the svg directory. | |
| static const QString | prefixPath () |
| Returns the path to the application prefix directory. | |
| static const QString | pluginPath () |
| Returns the path to the application plugin directory. | |
| static const QString | pkgDataPath () |
| Returns the common root path of all application data directories. | |
| static const QString | activeThemePath () |
| Returns the path to the currently active theme directory. | |
| static const QString | defaultThemePath () |
| Returns the path to the default theme directory. | |
| static void | setPrefixPath (const QString thePrefixPath, bool useDefaultPaths=FALSE) |
| Alters prefix path - used by 3rd party apps. | |
| static void | setPluginPath (const QString thePluginPath) |
| Alters plugin path - used by 3rd party apps. | |
| static void | setPkgDataPath (const QString thePkgDataPath) |
| Alters pkg data path - used by 3rd party apps. | |
| static void | initQgis () |
| loads providers | |
| static void | exitQgis () |
| deletes provider registry and map layer registry | |
| static endian_t | endian () |
| Returns whether this machine uses big or little endian. | |
| static QString | reportStyleSheet () |
| get a standard css style sheet for reports. | |
| static QString | showSettings () |
| Convenience function to get a summary of the paths used in this application instance useful for debugging mainly. | |
| static void | registerOgrDrivers () |
| Register OGR drivers ensuring this only happens once. | |
Static Private Attributes | |
| static QString | mPrefixPath |
| static QString | mPluginPath |
| static QString | mPkgDataPath |
| static QString | mThemeName |
| typedef enum QgsApplication::ENDIAN QgsApplication::endian_t |
constants for endian-ness
| QgsApplication::QgsApplication | ( | int & | argc, | |
| char ** | argv, | |||
| bool | GUIenabled | |||
| ) |
| QgsApplication::~QgsApplication | ( | ) | [virtual] |
Definition at line 67 of file qgsapplication.cpp.
| bool QgsApplication::notify | ( | QObject * | receiver, | |
| QEvent * | event | |||
| ) | [virtual] |
| void QgsApplication::setThemeName | ( | const QString | theThemeName | ) | [static] |
Set the active theme to the specified theme.
The theme name should be a single word e.g. 'default','classic'. The theme search path usually will be pkgDataPath + "/themes/" + themName + "/" but plugin writers etc can use themeName() as a basis for searching for resources in their own datastores e.g. a Qt4 resource bundle.
Definition at line 137 of file qgsapplication.cpp.
References mPkgDataPath, and mThemeName.
| const QString QgsApplication::themeName | ( | ) | [static] |
Set the active theme to the specified theme.
The theme name should be a single word e.g. 'default','classic'. The theme search path usually will be pkgDataPath + "/themes/" + themName + "/" but plugin writers etc can use this method as a basis for searching for resources in their own datastores e.g. a Qt4 resource bundle.
Definition at line 153 of file qgsapplication.cpp.
References mThemeName.
Referenced by showSettings().
| const QString QgsApplication::authorsFilePath | ( | ) | [static] |
Returns the path to the authors file.
Returns the path to the authors file.
Definition at line 160 of file qgsapplication.cpp.
References mPkgDataPath.
| const QString QgsApplication::sponsorsFilePath | ( | ) | [static] |
Returns the path to the sponsors file.
Returns the path to the sponsors file.
Definition at line 167 of file qgsapplication.cpp.
References mPkgDataPath.
| const QString QgsApplication::developerPath | ( | ) | [static] |
Returns the path to the developer image directory.
Returns the path to the developer image directory.
Definition at line 174 of file qgsapplication.cpp.
References mPkgDataPath.
| const QString QgsApplication::helpAppPath | ( | ) | [static] |
Returns the path to the help application.
Returns the path to the help application.
Definition at line 182 of file qgsapplication.cpp.
Referenced by QgsContextHelp::start().
| const QString QgsApplication::msexportAppPath | ( | ) | [static] |
Returns the path to the mapserver export application.
Returns the path to the mapserverexport application.
Definition at line 194 of file qgsapplication.cpp.
| const QString QgsApplication::i18nPath | ( | ) | [static] |
Returns the path to the translation directory.
Returns the path to the translation directory.
Definition at line 207 of file qgsapplication.cpp.
References mPkgDataPath.
| const QString QgsApplication::qgisMasterDbFilePath | ( | ) | [static] |
Returns the path to the master qgis.db file.
Returns the path to the master qgis.db file.
Definition at line 215 of file qgsapplication.cpp.
References mPkgDataPath.
Referenced by showSettings().
| const QString QgsApplication::qgisSettingsDirPath | ( | ) | [static] |
Returns the path to the settings directory in user's home dir.
Returns the path to the settings directory in user's home dir
Definition at line 223 of file qgsapplication.cpp.
Referenced by QgsMapLayer::loadNamedStyle(), qgisUserDbFilePath(), and QgsMapLayer::saveNamedStyle().
| const QString QgsApplication::qgisUserDbFilePath | ( | ) | [static] |
Returns the path to the user qgis.db file.
Returns the path to the user qgis.db file.
Definition at line 231 of file qgsapplication.cpp.
References qgisSettingsDirPath().
Referenced by QgsCoordinateReferenceSystem::createFromSrsId(), QgsCoordinateReferenceSystem::findMatchingProj(), QgsProjectionSelector::getLargestCRSIDMatch(), QgsCoordinateReferenceSystem::getRecord(), QgsProjectionSelector::getSelectedLongAttribute(), QgsProjectionSelector::loadUserCrsList(), QgsProjectionSelector::on_pbnFind_clicked(), QgsCoordinateReferenceSystem::proj4FromSrsId(), QgsProjectionSelector::selectedProj4String(), and QgsDistanceArea::setEllipsoid().
| const QString QgsApplication::splashPath | ( | ) | [static] |
Returns the path to the splash screen image directory.
Returns the path to the splash screen image directory.
Definition at line 239 of file qgsapplication.cpp.
References mPkgDataPath.
| const QString QgsApplication::iconsPath | ( | ) | [static] |
Returns the path to the icons image directory.
Returns the path to the icons image directory.
Definition at line 247 of file qgsapplication.cpp.
References mPkgDataPath.
| const QString QgsApplication::srsDbFilePath | ( | ) | [static] |
Returns the path to the srs.db file.
Returns the path to the srs.db file.
Definition at line 254 of file qgsapplication.cpp.
References mPkgDataPath.
Referenced by QgsCoordinateReferenceSystem::createFromEpsg(), QgsCoordinateReferenceSystem::createFromSrid(), QgsCoordinateReferenceSystem::createFromSrsId(), QgsCoordinateReferenceSystem::findMatchingProj(), QgsCoordinateReferenceSystem::getRecord(), QgsCoordinateReferenceSystem::proj4FromSrsId(), and QgsProjectionSelector::QgsProjectionSelector().
| const QString QgsApplication::svgPath | ( | ) | [static] |
Returns the path to the svg directory.
Returns the path to the svg directory.
Definition at line 262 of file qgsapplication.cpp.
References mPkgDataPath.
Referenced by QgsMarkerCatalogue::QgsMarkerCatalogue(), and QgsSymbol::setNamedPointSymbol().
| const QString QgsApplication::prefixPath | ( | ) | [static] |
Returns the path to the application prefix directory.
Definition at line 113 of file qgsapplication.cpp.
References mPrefixPath.
| const QString QgsApplication::pluginPath | ( | ) | [static] |
Returns the path to the application plugin directory.
Definition at line 117 of file qgsapplication.cpp.
References mPluginPath.
Referenced by initQgis().
| const QString QgsApplication::pkgDataPath | ( | ) | [static] |
Returns the common root path of all application data directories.
Definition at line 121 of file qgsapplication.cpp.
References mPkgDataPath.
Referenced by QgsMapLayer::loadNamedStyle().
| const QString QgsApplication::activeThemePath | ( | ) | [static] |
Returns the path to the currently active theme directory.
Definition at line 129 of file qgsapplication.cpp.
References mPkgDataPath, and mThemeName.
Referenced by QgsRasterLayer::legendAsPixmap(), QgsProjectionSelector::loadCrsList(), QgsProjectionSelector::loadUserCrsList(), and showSettings().
| const QString QgsApplication::defaultThemePath | ( | ) | [static] |
Returns the path to the default theme directory.
Definition at line 125 of file qgsapplication.cpp.
References mPkgDataPath.
Referenced by showSettings().
| void QgsApplication::setPrefixPath | ( | const QString | thePrefixPath, | |
| bool | useDefaultPaths = FALSE | |||
| ) | [static] |
Alters prefix path - used by 3rd party apps.
Definition at line 87 of file qgsapplication.cpp.
References mPrefixPath, setPkgDataPath(), and setPluginPath().
Referenced by QgsApplication().
| void QgsApplication::setPluginPath | ( | const QString | thePluginPath | ) | [static] |
Alters plugin path - used by 3rd party apps.
Definition at line 103 of file qgsapplication.cpp.
References mPluginPath.
Referenced by setPrefixPath().
| void QgsApplication::setPkgDataPath | ( | const QString | thePkgDataPath | ) | [static] |
Alters pkg data path - used by 3rd party apps.
Definition at line 108 of file qgsapplication.cpp.
References mPkgDataPath.
Referenced by setPrefixPath().
| void QgsApplication::initQgis | ( | ) | [static] |
loads providers
Definition at line 272 of file qgsapplication.cpp.
References QgsMapLayerRegistry::instance(), QgsProviderRegistry::instance(), and pluginPath().
| void QgsApplication::exitQgis | ( | ) | [static] |
deletes provider registry and map layer registry
Definition at line 281 of file qgsapplication.cpp.
References QgsProviderRegistry::instance(), and QgsMapLayerRegistry::instance().
| QgsApplication::endian_t QgsApplication::endian | ( | ) | [static] |
Returns whether this machine uses big or little endian.
Definition at line 267 of file qgsapplication.cpp.
Referenced by QgsGeometry::convertToMultiType(), and QgsGeometry::exportGeosToWkb().
| QString QgsApplication::reportStyleSheet | ( | ) | [static] |
get a standard css style sheet for reports.
Typically you will use this method by doing: QString myStyle = QgsApplication::reportStyleSheet(); textBrowserReport->document()->setDefaultStyleSheet(myStyle);
Definition at line 307 of file qgsapplication.cpp.
| QString QgsApplication::showSettings | ( | ) | [static] |
Convenience function to get a summary of the paths used in this application instance useful for debugging mainly.
Definition at line 287 of file qgsapplication.cpp.
References activeThemePath(), defaultThemePath(), mPkgDataPath, mPluginPath, mPrefixPath, qgisMasterDbFilePath(), and themeName().
| void QgsApplication::registerOgrDrivers | ( | ) | [static] |
Register OGR drivers ensuring this only happens once.
This is a workaround for an issue with older gdal versions that caused duplicate driver name entries to appear in the list of registered drivers when QgsApplication::registerOgrDrivers was called multiple times.
Definition at line 335 of file qgsapplication.cpp.
Referenced by QgsVectorFileWriter::QgsVectorFileWriter().
QString QgsApplication::mPrefixPath [static, private] |
Definition at line 154 of file qgsapplication.h.
Referenced by prefixPath(), setPrefixPath(), and showSettings().
QString QgsApplication::mPluginPath [static, private] |
Definition at line 155 of file qgsapplication.h.
Referenced by pluginPath(), setPluginPath(), and showSettings().
QString QgsApplication::mPkgDataPath [static, private] |
Definition at line 156 of file qgsapplication.h.
Referenced by activeThemePath(), authorsFilePath(), defaultThemePath(), developerPath(), i18nPath(), iconsPath(), pkgDataPath(), qgisMasterDbFilePath(), setPkgDataPath(), setThemeName(), showSettings(), splashPath(), sponsorsFilePath(), srsDbFilePath(), and svgPath().
QString QgsApplication::mThemeName [static, private] |
Definition at line 157 of file qgsapplication.h.
Referenced by activeThemePath(), setThemeName(), and themeName().
1.5.1