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 QString themeName();
78 
85  static void setUITheme( const QString &themeName );
86 
91  static QString uiThemeName();
92 
99  static QHash<QString, QString> uiThemes();
100 
102  static QString authorsFilePath();
103 
107  static QString contributorsFilePath();
108 
113  static QString developersMapFilePath();
114 
117  static QString whatsNewFilePath();
118 
120  static QString sponsorsFilePath();
121 
123  static QString donorsFilePath();
124 
128  static QString translatorsFilePath();
129 
133  static QString licenceFilePath();
134 
136  static QString helpAppPath();
137 
139  static QString i18nPath();
140 
142  static QString qgisMasterDbFilePath();
143 
145  static QString qgisSettingsDirPath();
146 
148  static QString qgisUserDbFilePath();
149 
151  static QString splashPath();
152 
154  static QString iconsPath();
155 
157  static QString srsDbFilePath();
158 
160  static QStringList svgPaths();
161 
163  static QMap<QString, QString> systemEnvVars() { return ABISYM( mSystemEnvVars ); }
164 
166  static QString prefixPath();
167 
169  static QString pluginPath();
170 
172  static QString pkgDataPath();
173 
175  static QString activeThemePath();
176 
178  static QString defaultThemePath();
179 
182  static QString iconPath( QString iconFile );
183 
186  static QIcon getThemeIcon( const QString &theName );
187 
190  static QPixmap getThemePixmap( const QString &theName );
191 
193  static QString userStyleV2Path();
194 
196  static QString userThemesFolder();
197 
199  static QString defaultStyleV2Path();
200 
202  static QString defaultThemesFolder();
203 
205  static QString libraryPath();
206 
208  static QString libexecPath();
209 
211  static void setPrefixPath( const QString &thePrefixPath, bool useDefaultPaths = false );
212 
214  static void setPluginPath( const QString &thePluginPath );
215 
217  static void setPkgDataPath( const QString &thePkgDataPath );
218 
220  static void setDefaultSvgPaths( const QStringList& pathList );
221 
223  static void initQgis();
224 
226  static bool createDB( QString* errorMessage = 0 );
227 
229  static bool createThemeFolder( );
230 
232  static void exitQgis();
233 
235  typedef enum ENDIAN
236  {
237  XDR = 0, // network, or big-endian, byte order
238  NDR = 1 // little-endian byte order
239  }
240  endian_t;
241 
243  static endian_t endian();
244 
246  template<typename T>
247  static void endian_swap( T& value )
248  {
249  char* data = reinterpret_cast<char*>( &value );
250  std::size_t n = sizeof( value );
251  for ( std::size_t i = 0, m = n / 2; i < m; ++i )
252  {
253  std::swap( data[i], data[n - 1 - i] );
254  }
255  }
256 
265  static QString reportStyleSheet();
266 
269  static QString showSettings();
270 
277  static void registerOgrDrivers();
278 
280  static QString absolutePathToRelativePath( QString apath, QString targetPath );
282  static QString relativePathToAbsolutePath( QString rpath, QString targetPath );
283 
285  static bool isRunningFromBuildDir() { return ABISYM( mRunningFromBuildDir ); }
286 #ifdef _MSC_VER
287  static QString cfgIntDir() { return ABISYM( mCfgIntDir ); }
288 #endif
289 
290  static QString buildSourcePath() { return ABISYM( mBuildSourcePath ); }
292  static QString buildOutputPath() { return ABISYM( mBuildOutputPath ); }
293 
298  static void skipGdalDriver( QString theDriver );
299 
304  static void restoreGdalDriver( QString theDriver );
305 
309  static QStringList skippedGdalDrivers() { return ABISYM( mGdalSkipList ); }
310 
315  static void applyGdalSkippedDrivers();
316 
319  static int maxThreads() { return ABISYM( mMaxThreads ); }
323  static void setMaxThreads( int maxThreads );
324 
325 #ifdef ANDROID
326  //dummy method to workaround sip generation issue issue
327  bool x11EventFilter( XEvent * event )
328  {
329  return 0;
330  }
331 #endif
332 
333  signals:
335  void preNotify( QObject * receiver, QEvent * event, bool * done );
336 
337  private:
338  static void copyPath( QString src, QString dst );
339  static QObject* ABISYM( mFileOpenEventReceiver );
340  static QStringList ABISYM( mFileOpenEventList );
341 
342  static QString ABISYM( mUIThemeName );
343  static QString ABISYM( mPrefixPath );
344  static QString ABISYM( mPluginPath );
345  static QString ABISYM( mPkgDataPath );
346  static QString ABISYM( mLibraryPath );
347  static QString ABISYM( mLibexecPath );
348  static QString ABISYM( mThemeName );
349  static QStringList ABISYM( mDefaultSvgPaths );
350  static QMap<QString, QString> ABISYM( mSystemEnvVars );
351 
352  static QString ABISYM( mConfigPath );
353 
355  static bool ABISYM( mRunningFromBuildDir );
357  static QString ABISYM( mBuildSourcePath );
358 #ifdef _MSC_VER
359 
360  static QString ABISYM( mCfgIntDir );
361 #endif
362 
363  static QString ABISYM( mBuildOutputPath );
366  static QStringList ABISYM( mGdalSkipList );
369  static int ABISYM( mMaxThreads );
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.
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 QMap< QString, QString > systemEnvVars()
Returns the system environment variables passed to application.
static QString buildOutputPath()
Returns path to the build output directory.
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)