QGIS API Documentation  2.14.0-Essen
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, const QString& customConfigPath = QString(), const QString& platformName = "desktop" );
42  virtual ~QgsApplication();
43 
50  static void init( QString customConfigPath = QString() );
51 
53  virtual bool event( QEvent * event ) override;
54 
56  virtual bool notify( QObject * receiver, QEvent * event ) override;
57 
59  static void setFileOpenEventReceiver( QObject * receiver );
60 
70  static void setThemeName( const QString &theThemeName );
71 
78  static QString themeName();
79 
87  static void setUITheme( const QString &themeName );
88 
95  static QHash<QString, QString> uiThemes();
96 
98  static QString authorsFilePath();
99 
103  static QString contributorsFilePath();
104 
109  static QString developersMapFilePath();
110 
112  static QString sponsorsFilePath();
113 
115  static QString donorsFilePath();
116 
120  static QString translatorsFilePath();
121 
125  static QString licenceFilePath();
126 
128  static QString helpAppPath();
129 
131  static QString i18nPath();
132 
134  static QString qgisMasterDbFilePath();
135 
137  static QString qgisSettingsDirPath();
138 
140  static QString qgisUserDbFilePath();
141 
143  static QString qgisAuthDbFilePath();
144 
146  static QString splashPath();
147 
149  static QString iconsPath();
150 
152  static QString srsDbFilePath();
153 
155  static QStringList svgPaths();
156 
158  static QStringList composerTemplatePaths();
159 
161  static QMap<QString, QString> systemEnvVars() { return ABISYM( mSystemEnvVars ); }
162 
164  static QString prefixPath();
165 
167  static QString pluginPath();
168 
170  static QString pkgDataPath();
171 
173  static QString activeThemePath();
174 
176  static QString defaultThemePath();
177 
180  static QString iconPath( const QString& iconFile );
181 
184  static QIcon getThemeIcon( const QString &theName );
185 
188  static QPixmap getThemePixmap( const QString &theName );
189 
191  static QString userStyleV2Path();
192 
194  static QRegExp shortNameRegExp();
195 
200  static QString userLoginName();
201 
206  static QString userFullName();
207 
212  static QString osName();
213 
218  static QString platform();
219 
221  static QString userThemesFolder();
222 
224  static QString defaultStyleV2Path();
225 
227  static QString defaultThemesFolder();
228 
230  static QString libraryPath();
231 
233  static QString libexecPath();
234 
236  static void setPrefixPath( const QString &thePrefixPath, bool useDefaultPaths = false );
237 
239  static void setPluginPath( const QString &thePluginPath );
240 
242  static void setPkgDataPath( const QString &thePkgDataPath );
243 
245  static void setDefaultSvgPaths( const QStringList& pathList );
246 
248  static void setAuthDbDirPath( const QString& theAuthDbDirPath );
249 
251  static void initQgis();
252 
254  static bool createDB( QString* errorMessage = nullptr );
255 
257  static bool createThemeFolder();
258 
260  static void exitQgis();
261 
263  static QString appIconPath();
264 
266  enum endian_t
267  {
268  XDR = 0, // network, or big-endian, byte order
269  NDR = 1 // little-endian byte order
270  };
271 
273  static endian_t endian();
274 
278  template<typename T>
279  static void endian_swap( T& value )
280  {
281  char* data = reinterpret_cast<char*>( &value );
282  std::size_t n = sizeof( value );
283  for ( std::size_t i = 0, m = n / 2; i < m; ++i )
284  {
285  std::swap( data[i], data[n - 1 - i] );
286  }
287  }
288 
297  static QString reportStyleSheet();
298 
301  static QString showSettings();
302 
309  static void registerOgrDrivers();
310 
312  static QString absolutePathToRelativePath( const QString& apath, const QString& targetPath );
314  static QString relativePathToAbsolutePath( const QString& rpath, const QString& targetPath );
315 
317  static bool isRunningFromBuildDir() { return ABISYM( mRunningFromBuildDir ); }
318 #ifdef _MSC_VER
319  static QString cfgIntDir() { return ABISYM( mCfgIntDir ); }
320 #endif
321 
322  static QString buildSourcePath() { return ABISYM( mBuildSourcePath ); }
324  static QString buildOutputPath() { return ABISYM( mBuildOutputPath ); }
325 
330  static void skipGdalDriver( const QString& theDriver );
331 
336  static void restoreGdalDriver( const QString& theDriver );
337 
341  static QStringList skippedGdalDrivers() { return ABISYM( mGdalSkipList ); }
342 
347  static void applyGdalSkippedDrivers();
348 
351  static int maxThreads() { return ABISYM( mMaxThreads ); }
355  static void setMaxThreads( int maxThreads );
356 
357 #ifdef ANDROID
358  //dummy method to workaround sip generation issue issue
359  bool x11EventFilter( XEvent * event )
360  {
361  Q_UNUSED( event );
362  return 0;
363  }
364 #endif
365 
366  signals:
368  void preNotify( QObject * receiver, QEvent * event, bool * done );
369 
370  private:
371  static void copyPath( const QString& src, const QString& dst );
372  static QObject* ABISYM( mFileOpenEventReceiver );
373  static QStringList ABISYM( mFileOpenEventList );
374 
375  static QString ABISYM( mUIThemeName );
376  static QString ABISYM( mPrefixPath );
377  static QString ABISYM( mPluginPath );
378  static QString ABISYM( mPkgDataPath );
379  static QString ABISYM( mLibraryPath );
380  static QString ABISYM( mLibexecPath );
381  static QString ABISYM( mThemeName );
382  static QStringList ABISYM( mDefaultSvgPaths );
383  static QMap<QString, QString> ABISYM( mSystemEnvVars );
384 
385  static QString ABISYM( mConfigPath );
386 
388  static bool ABISYM( mRunningFromBuildDir );
390  static QString ABISYM( mBuildSourcePath );
391 #ifdef _MSC_VER
392 
393  static QString ABISYM( mCfgIntDir );
394 #endif
395 
396  static QString ABISYM( mBuildOutputPath );
399  static QStringList ABISYM( mGdalSkipList );
402  static int ABISYM( mMaxThreads );
405  static QString ABISYM( mAuthDbDirPath );
406 
407  static QString sUserName;
408  static QString sUserFullName;
409  static QString sPlatformName;
410 };
411 
412 #endif
static void endian_swap(T &value)
Swap the endianness of the specified value.
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(const QString &iconFile)
static QMap< QString, QString > systemEnvVars()
Returns the system environment variables passed to application.
endian_t
Constants for endian-ness.
static QString buildOutputPath()
Returns path to the build output directory.
QStringList ABISYM(QgsApplication::mFileOpenEventList)
static const char * QGIS_ORGANIZATION_NAME
virtual bool x11EventFilter(XEvent *event)
static QString buildSourcePath()
Returns path to the source directory.
static const char * QGIS_ORGANIZATION_DOMAIN
virtual bool event(QEvent *e)
static const char * QGIS_APPLICATION_NAME
virtual bool notify(QObject *receiver, QEvent *e)