QGIS API Documentation  2.9.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgsapplication.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsapplication.h - Accessors for application-wide data
3  --------------------------------------
4  Date : 02-Jan-2006
5  Copyright : (C) 2006 by Tom Elwertowski
6  Email : telwertowski at users dot sourceforge dot net
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSAPPLICATION_H
16 #define QGSAPPLICATION_H
17 
18 #include <QApplication>
19 #include <QEvent>
20 #include <QStringList>
21 
22 #include <qgis.h>
23 #include <qgsconfig.h>
24 
30 #ifdef ANDROID
31 typedef void XEvent;
32 #endif
33 
34 class CORE_EXPORT QgsApplication : public QApplication
35 {
36  Q_OBJECT
37  public:
38  static const char* QGIS_ORGANIZATION_NAME;
39  static const char* QGIS_ORGANIZATION_DOMAIN;
40  static const char* QGIS_APPLICATION_NAME;
41  QgsApplication( int & argc, char ** argv, bool GUIenabled, QString customConfigPath = QString() );
42  virtual ~QgsApplication();
43 
49  static void init( QString customConfigPath = QString() );
50 
52  virtual bool event( QEvent * event ) override;
53 
55  virtual bool notify( QObject * receiver, QEvent * event ) override;
56 
58  static void setFileOpenEventReceiver( QObject * receiver );
59 
69  static void setThemeName( const QString &theThemeName );
70 
77  static const QString themeName();
78 
80  static const QString authorsFilePath();
81 
85  static const QString contributorsFilePath();
86 
91  static const QString developersMapFilePath();
92 
94  static const QString sponsorsFilePath();
95 
97  static const QString donorsFilePath();
98 
102  static const QString translatorsFilePath();
103 
107  static const QString licenceFilePath();
108 
110  static const QString helpAppPath();
111 
113  static const QString i18nPath();
114 
116  static const QString qgisMasterDbFilePath();
117 
119  static const QString qgisSettingsDirPath();
120 
122  static const QString qgisUserDbFilePath();
123 
125  static const QString splashPath();
126 
128  static const QString iconsPath();
129 
131  static const QString srsDbFilePath();
132 
134  static const QStringList svgPaths();
135 
137  static const QMap<QString, QString> systemEnvVars() { return ABISYM( mSystemEnvVars ); }
138 
140  static const QString prefixPath();
141 
143  static const QString pluginPath();
144 
146  static const QString pkgDataPath();
147 
149  static const QString activeThemePath();
150 
152  static const QString defaultThemePath();
153 
156  static QString iconPath( QString iconFile );
157 
160  static QIcon getThemeIcon( const QString &theName );
161 
164  static QPixmap getThemePixmap( const QString &theName );
165 
167  static const QString userStyleV2Path();
168 
170  static const QString defaultStyleV2Path();
171 
173  static const QString libraryPath();
174 
176  static const QString libexecPath();
177 
179  static void setPrefixPath( const QString &thePrefixPath, bool useDefaultPaths = false );
180 
182  static void setPluginPath( const QString &thePluginPath );
183 
185  static void setPkgDataPath( const QString &thePkgDataPath );
186 
188  static void setDefaultSvgPaths( const QStringList& pathList );
189 
191  static void initQgis();
192 
194  static bool createDB( QString* errorMessage = 0 );
195 
197  static void exitQgis();
198 
200  typedef enum ENDIAN
201  {
202  XDR = 0, // network, or big-endian, byte order
203  NDR = 1 // little-endian byte order
204  }
205  endian_t;
206 
208  static endian_t endian();
209 
218  static QString reportStyleSheet();
219 
222  static QString showSettings();
223 
230  static void registerOgrDrivers();
231 
233  static QString absolutePathToRelativePath( QString apath, QString targetPath );
235  static QString relativePathToAbsolutePath( QString rpath, QString targetPath );
236 
238  static bool isRunningFromBuildDir() { return ABISYM( mRunningFromBuildDir ); }
239 #ifdef _MSC_VER
240  static QString cfgIntDir() { return ABISYM( mCfgIntDir ); }
241 #endif
242 
243  static QString buildSourcePath() { return ABISYM( mBuildSourcePath ); }
245  static QString buildOutputPath() { return ABISYM( mBuildOutputPath ); }
246 
251  static void skipGdalDriver( QString theDriver );
252 
257  static void restoreGdalDriver( QString theDriver );
258 
262  static QStringList skippedGdalDrivers() { return ABISYM( mGdalSkipList ); }
263 
268  static void applyGdalSkippedDrivers();
269 
272  static int maxThreads() { return ABISYM( mMaxThreads ); }
276  static void setMaxThreads( int maxThreads );
277 
278 #ifdef ANDROID
279  //dummy method to workaround sip generation issue issue
280  bool x11EventFilter( XEvent * event )
281  {
282  return 0;
283  }
284 #endif
285 
286  signals:
288  void preNotify( QObject * receiver, QEvent * event, bool * done );
289 
290  private:
291  static QObject* ABISYM( mFileOpenEventReceiver );
292  static QStringList ABISYM( mFileOpenEventList );
293 
294  static QString ABISYM( mPrefixPath );
295  static QString ABISYM( mPluginPath );
296  static QString ABISYM( mPkgDataPath );
297  static QString ABISYM( mLibraryPath );
298  static QString ABISYM( mLibexecPath );
299  static QString ABISYM( mThemeName );
300  static QStringList ABISYM( mDefaultSvgPaths );
301  static QMap<QString, QString> ABISYM( mSystemEnvVars );
302 
303  static QString ABISYM( mConfigPath );
304 
306  static bool ABISYM( mRunningFromBuildDir );
308  static QString ABISYM( mBuildSourcePath );
309 #ifdef _MSC_VER
310 
311  static QString ABISYM( mCfgIntDir );
312 #endif
313 
314  static QString ABISYM( mBuildOutputPath );
317  static QStringList ABISYM( mGdalSkipList );
320  static int ABISYM( mMaxThreads );
321 };
322 
323 #endif
Extends QApplication to provide access to QGIS specific resources such as theme paths, database paths etc.
static QStringList skippedGdalDrivers()
Returns the list of gdal drivers that should be skipped (based on GDAL_SKIP environment variable) ...
static bool isRunningFromBuildDir()
Indicates whether running from build directory (not installed)
static int maxThreads()
Get maximum concurrent thread count.
QString iconPath(QString iconFile)
static QString buildOutputPath()
Returns path to the build output directory.
static const char * QGIS_ORGANIZATION_NAME
static const QMap< QString, QString > systemEnvVars()
Returns the system environment variables passed to application.
ENDIAN
constants for endian-ness
static QString buildSourcePath()
Returns path to the source directory.
static const char * QGIS_ORGANIZATION_DOMAIN
QObject * ABISYM(QgsApplication::mFileOpenEventReceiver)
static const char * QGIS_APPLICATION_NAME