QGIS API Documentation  2.12.0-Lyon
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() );
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 QString themeName();
78 
86  static void setUITheme( const QString &themeName );
87 
94  static QHash<QString, QString> uiThemes();
95 
97  static QString authorsFilePath();
98 
102  static QString contributorsFilePath();
103 
108  static QString developersMapFilePath();
109 
111  static QString sponsorsFilePath();
112 
114  static QString donorsFilePath();
115 
119  static QString translatorsFilePath();
120 
124  static QString licenceFilePath();
125 
127  static QString helpAppPath();
128 
130  static QString i18nPath();
131 
133  static QString qgisMasterDbFilePath();
134 
136  static QString qgisSettingsDirPath();
137 
139  static QString qgisUserDbFilePath();
140 
142  static QString qgisAuthDbFilePath();
143 
145  static QString splashPath();
146 
148  static QString iconsPath();
149 
151  static QString srsDbFilePath();
152 
154  static QStringList svgPaths();
155 
157  static QMap<QString, QString> systemEnvVars() { return ABISYM( mSystemEnvVars ); }
158 
160  static QString prefixPath();
161 
163  static QString pluginPath();
164 
166  static QString pkgDataPath();
167 
169  static QString activeThemePath();
170 
172  static QString defaultThemePath();
173 
176  static QString iconPath( const QString& iconFile );
177 
180  static QIcon getThemeIcon( const QString &theName );
181 
184  static QPixmap getThemePixmap( const QString &theName );
185 
187  static QString userStyleV2Path();
188 
190  static QString userThemesFolder();
191 
193  static QString defaultStyleV2Path();
194 
196  static QString defaultThemesFolder();
197 
199  static QString libraryPath();
200 
202  static QString libexecPath();
203 
205  static void setPrefixPath( const QString &thePrefixPath, bool useDefaultPaths = false );
206 
208  static void setPluginPath( const QString &thePluginPath );
209 
211  static void setPkgDataPath( const QString &thePkgDataPath );
212 
214  static void setDefaultSvgPaths( const QStringList& pathList );
215 
217  static void setAuthDbDirPath( const QString& theAuthDbDirPath );
218 
220  static void initQgis();
221 
223  static bool createDB( QString* errorMessage = 0 );
224 
226  static bool createThemeFolder( );
227 
229  static void exitQgis();
230 
232  typedef enum ENDIAN
233  {
234  XDR = 0, // network, or big-endian, byte order
235  NDR = 1 // little-endian byte order
236  }
237  endian_t;
238 
240  static endian_t endian();
241 
243  template<typename T>
244  static void endian_swap( T& value )
245  {
246  char* data = reinterpret_cast<char*>( &value );
247  std::size_t n = sizeof( value );
248  for ( std::size_t i = 0, m = n / 2; i < m; ++i )
249  {
250  std::swap( data[i], data[n - 1 - i] );
251  }
252  }
253 
262  static QString reportStyleSheet();
263 
266  static QString showSettings();
267 
274  static void registerOgrDrivers();
275 
277  static QString absolutePathToRelativePath( QString apath, QString targetPath );
279  static QString relativePathToAbsolutePath( QString rpath, QString targetPath );
280 
282  static bool isRunningFromBuildDir() { return ABISYM( mRunningFromBuildDir ); }
283 #ifdef _MSC_VER
284  static QString cfgIntDir() { return ABISYM( mCfgIntDir ); }
285 #endif
286 
287  static QString buildSourcePath() { return ABISYM( mBuildSourcePath ); }
289  static QString buildOutputPath() { return ABISYM( mBuildOutputPath ); }
290 
295  static void skipGdalDriver( const QString& theDriver );
296 
301  static void restoreGdalDriver( const QString& theDriver );
302 
306  static QStringList skippedGdalDrivers() { return ABISYM( mGdalSkipList ); }
307 
312  static void applyGdalSkippedDrivers();
313 
316  static int maxThreads() { return ABISYM( mMaxThreads ); }
320  static void setMaxThreads( int maxThreads );
321 
322 #ifdef ANDROID
323  //dummy method to workaround sip generation issue issue
324  bool x11EventFilter( XEvent * event )
325  {
326  return 0;
327  }
328 #endif
329 
330  signals:
332  void preNotify( QObject * receiver, QEvent * event, bool * done );
333 
334  private:
335  static void copyPath( const QString& src, const QString& dst );
336  static QObject* ABISYM( mFileOpenEventReceiver );
337  static QStringList ABISYM( mFileOpenEventList );
338 
339  static QString ABISYM( mUIThemeName );
340  static QString ABISYM( mPrefixPath );
341  static QString ABISYM( mPluginPath );
342  static QString ABISYM( mPkgDataPath );
343  static QString ABISYM( mLibraryPath );
344  static QString ABISYM( mLibexecPath );
345  static QString ABISYM( mThemeName );
346  static QStringList ABISYM( mDefaultSvgPaths );
347  static QMap<QString, QString> ABISYM( mSystemEnvVars );
348 
349  static QString ABISYM( mConfigPath );
350 
352  static bool ABISYM( mRunningFromBuildDir );
354  static QString ABISYM( mBuildSourcePath );
355 #ifdef _MSC_VER
356 
357  static QString ABISYM( mCfgIntDir );
358 #endif
359 
360  static QString ABISYM( mBuildOutputPath );
363  static QStringList ABISYM( mGdalSkipList );
366  static int ABISYM( mMaxThreads );
369  static QString ABISYM( mAuthDbDirPath );
370 };
371 
372 #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.
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)
ENDIAN
Constants for endian-ness.
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)