QGIS API Documentation  2.7.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 );
53 
55  virtual bool notify( QObject * receiver, QEvent * event );
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 
88  static const QString sponsorsFilePath();
89 
91  static const QString donorsFilePath();
92 
96  static const QString translatorsFilePath();
97 
101  static const QString licenceFilePath();
102 
104  static const QString helpAppPath();
105 
107  static const QString i18nPath();
108 
110  static const QString qgisMasterDbFilePath();
111 
113  static const QString qgisSettingsDirPath();
114 
116  static const QString qgisUserDbFilePath();
117 
119  static const QString splashPath();
120 
122  static const QString iconsPath();
123 
125  static const QString srsDbFilePath();
126 
128  static const QStringList svgPaths();
129 
131  static const QMap<QString, QString> systemEnvVars() { return ABISYM( mSystemEnvVars ); }
132 
134  static const QString prefixPath();
135 
137  static const QString pluginPath();
138 
140  static const QString pkgDataPath();
141 
143  static const QString activeThemePath();
144 
146  static const QString defaultThemePath();
147 
150  static QString iconPath( QString iconFile );
151 
154  static QIcon getThemeIcon( const QString &theName );
155 
158  static QPixmap getThemePixmap( const QString &theName );
159 
161  static const QString userStyleV2Path();
162 
164  static const QString defaultStyleV2Path();
165 
167  static const QString libraryPath();
168 
170  static const QString libexecPath();
171 
173  static void setPrefixPath( const QString &thePrefixPath, bool useDefaultPaths = false );
174 
176  static void setPluginPath( const QString &thePluginPath );
177 
179  static void setPkgDataPath( const QString &thePkgDataPath );
180 
182  static void setDefaultSvgPaths( const QStringList& pathList );
183 
185  static void initQgis();
186 
188  static bool createDB( QString* errorMessage = 0 );
189 
191  static void exitQgis();
192 
194  typedef enum ENDIAN
195  {
196  XDR = 0, // network, or big-endian, byte order
197  NDR = 1 // little-endian byte order
198  }
199  endian_t;
200 
202  static endian_t endian();
203 
212  static QString reportStyleSheet();
213 
216  static QString showSettings();
217 
224  static void registerOgrDrivers();
225 
227  static QString absolutePathToRelativePath( QString apath, QString targetPath );
229  static QString relativePathToAbsolutePath( QString rpath, QString targetPath );
230 
232  static bool isRunningFromBuildDir() { return ABISYM( mRunningFromBuildDir ); }
233 #ifdef _MSC_VER
234  static QString cfgIntDir() { return ABISYM( mCfgIntDir ); }
235 #endif
236 
237  static QString buildSourcePath() { return ABISYM( mBuildSourcePath ); }
239  static QString buildOutputPath() { return ABISYM( mBuildOutputPath ); }
240 
245  static void skipGdalDriver( QString theDriver );
246 
251  static void restoreGdalDriver( QString theDriver );
252 
256  static QStringList skippedGdalDrivers() { return ABISYM( mGdalSkipList ); }
257 
262  static void applyGdalSkippedDrivers();
263 
266  static int maxThreads() { return ABISYM( mMaxThreads ); }
270  static void setMaxThreads( int maxThreads );
271 
272 #ifdef ANDROID
273  //dummy method to workaround sip generation issue issue
274  bool x11EventFilter( XEvent * event )
275  {
276  return 0;
277  }
278 #endif
279 
280  signals:
282  void preNotify( QObject * receiver, QEvent * event, bool * done );
283 
284  private:
285  static QObject* ABISYM( mFileOpenEventReceiver );
286  static QStringList ABISYM( mFileOpenEventList );
287 
288  static QString ABISYM( mPrefixPath );
289  static QString ABISYM( mPluginPath );
290  static QString ABISYM( mPkgDataPath );
291  static QString ABISYM( mLibraryPath );
292  static QString ABISYM( mLibexecPath );
293  static QString ABISYM( mThemeName );
294  static QStringList ABISYM( mDefaultSvgPaths );
295  static QMap<QString, QString> ABISYM( mSystemEnvVars );
296 
297  static QString ABISYM( mConfigPath );
298 
300  static bool ABISYM( mRunningFromBuildDir );
302  static QString ABISYM( mBuildSourcePath );
303 #ifdef _MSC_VER
304 
305  static QString ABISYM( mCfgIntDir );
306 #endif
307 
308  static QString ABISYM( mBuildOutputPath );
311  static QStringList ABISYM( mGdalSkipList );
314  static int ABISYM( mMaxThreads );
315 };
316 
317 #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