QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 
79  static void setUITheme( const QString &themeName );
80 
85  static const QString uiThemeName();
86 
93  static const QHash<QString, QString> uiThemes();
94 
96  static const QString authorsFilePath();
97 
101  static const QString contributorsFilePath();
102 
107  static const QString developersMapFilePath();
108 
111  static const QString whatsNewFilePath();
112 
114  static const QString sponsorsFilePath();
115 
117  static const QString donorsFilePath();
118 
122  static const QString translatorsFilePath();
123 
127  static const QString licenceFilePath();
128 
130  static const QString helpAppPath();
131 
133  static const QString i18nPath();
134 
136  static const QString qgisMasterDbFilePath();
137 
139  static const QString qgisSettingsDirPath();
140 
142  static const QString qgisUserDbFilePath();
143 
145  static const QString splashPath();
146 
148  static const QString iconsPath();
149 
151  static const QString srsDbFilePath();
152 
154  static const QStringList svgPaths();
155 
157  static const QMap<QString, QString> systemEnvVars() { return ABISYM( mSystemEnvVars ); }
158 
160  static const QString prefixPath();
161 
163  static const QString pluginPath();
164 
166  static const QString pkgDataPath();
167 
169  static const QString activeThemePath();
170 
172  static const QString defaultThemePath();
173 
176  static QString iconPath( QString iconFile );
177 
180  static QIcon getThemeIcon( const QString &theName );
181 
184  static QPixmap getThemePixmap( const QString &theName );
185 
187  static const QString userStyleV2Path();
188 
190  static const QString defaultStyleV2Path();
191 
193  static const QString libraryPath();
194 
196  static const QString libexecPath();
197 
199  static void setPrefixPath( const QString &thePrefixPath, bool useDefaultPaths = false );
200 
202  static void setPluginPath( const QString &thePluginPath );
203 
205  static void setPkgDataPath( const QString &thePkgDataPath );
206 
208  static void setDefaultSvgPaths( const QStringList& pathList );
209 
211  static void initQgis();
212 
214  static bool createDB( QString* errorMessage = 0 );
215 
217  static void exitQgis();
218 
220  typedef enum ENDIAN
221  {
222  XDR = 0, // network, or big-endian, byte order
223  NDR = 1 // little-endian byte order
224  }
225  endian_t;
226 
228  static endian_t endian();
229 
231  template<typename T>
232  static void endian_swap( T& value )
233  {
234  char* data = reinterpret_cast<char*>( &value );
235  std::size_t n = sizeof( value );
236  for ( std::size_t i = 0, m = n / 2; i < m; ++i )
237  {
238  std::swap( data[i], data[n - 1 - i] );
239  }
240  }
241 
250  static QString reportStyleSheet();
251 
254  static QString showSettings();
255 
262  static void registerOgrDrivers();
263 
265  static QString absolutePathToRelativePath( QString apath, QString targetPath );
267  static QString relativePathToAbsolutePath( QString rpath, QString targetPath );
268 
270  static bool isRunningFromBuildDir() { return ABISYM( mRunningFromBuildDir ); }
271 #ifdef _MSC_VER
272  static QString cfgIntDir() { return ABISYM( mCfgIntDir ); }
273 #endif
274 
275  static QString buildSourcePath() { return ABISYM( mBuildSourcePath ); }
277  static QString buildOutputPath() { return ABISYM( mBuildOutputPath ); }
278 
283  static void skipGdalDriver( QString theDriver );
284 
289  static void restoreGdalDriver( QString theDriver );
290 
294  static QStringList skippedGdalDrivers() { return ABISYM( mGdalSkipList ); }
295 
300  static void applyGdalSkippedDrivers();
301 
304  static int maxThreads() { return ABISYM( mMaxThreads ); }
308  static void setMaxThreads( int maxThreads );
309 
310 #ifdef ANDROID
311  //dummy method to workaround sip generation issue issue
312  bool x11EventFilter( XEvent * event )
313  {
314  return 0;
315  }
316 #endif
317 
318  signals:
320  void preNotify( QObject * receiver, QEvent * event, bool * done );
321 
322  private:
323  static QObject* ABISYM( mFileOpenEventReceiver );
324  static QStringList ABISYM( mFileOpenEventList );
325 
326  static QString ABISYM( mUIThemeName );
327  static QString ABISYM( mPrefixPath );
328  static QString ABISYM( mPluginPath );
329  static QString ABISYM( mPkgDataPath );
330  static QString ABISYM( mLibraryPath );
331  static QString ABISYM( mLibexecPath );
332  static QString ABISYM( mThemeName );
333  static QStringList ABISYM( mDefaultSvgPaths );
334  static QMap<QString, QString> ABISYM( mSystemEnvVars );
335 
336  static QString ABISYM( mConfigPath );
337 
339  static bool ABISYM( mRunningFromBuildDir );
341  static QString ABISYM( mBuildSourcePath );
342 #ifdef _MSC_VER
343 
344  static QString ABISYM( mCfgIntDir );
345 #endif
346 
347  static QString ABISYM( mBuildOutputPath );
350  static QStringList ABISYM( mGdalSkipList );
353  static int ABISYM( mMaxThreads );
354 };
355 
356 #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.
QStringList ABISYM(QgsApplication::mFileOpenEventList)
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.
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)