QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 
80  static const QString authorsFilePath();
81 
85  static const QString contributorsFilePath();
86 
91  static const QString developersMapFilePath();
92 
94  static const QString sponsorsFilePath();
95 
97  static const QString donorsFilePath();
98 
102  static const QString translatorsFilePath();
103 
107  static const QString licenceFilePath();
108 
110  static const QString helpAppPath();
111 
113  static const QString i18nPath();
114 
116  static const QString qgisMasterDbFilePath();
117 
119  static const QString qgisSettingsDirPath();
120 
122  static const QString qgisUserDbFilePath();
123 
125  static const QString splashPath();
126 
128  static const QString iconsPath();
129 
131  static const QString srsDbFilePath();
132 
134  static const QStringList svgPaths();
135 
137  static const QMap<QString, QString> systemEnvVars() { return ABISYM( mSystemEnvVars ); }
138 
140  static const QString prefixPath();
141 
143  static const QString pluginPath();
144 
146  static const QString pkgDataPath();
147 
149  static const QString activeThemePath();
150 
152  static const QString defaultThemePath();
153 
156  static QString iconPath( QString iconFile );
157 
160  static QIcon getThemeIcon( const QString &theName );
161 
164  static QPixmap getThemePixmap( const QString &theName );
165 
167  static const QString userStyleV2Path();
168 
170  static const QString defaultStyleV2Path();
171 
173  static const QString libraryPath();
174 
176  static const QString libexecPath();
177 
179  static void setPrefixPath( const QString &thePrefixPath, bool useDefaultPaths = false );
180 
182  static void setPluginPath( const QString &thePluginPath );
183 
185  static void setPkgDataPath( const QString &thePkgDataPath );
186 
188  static void setDefaultSvgPaths( const QStringList& pathList );
189 
191  static void initQgis();
192 
194  static bool createDB( QString* errorMessage = 0 );
195 
197  static void exitQgis();
198 
200  typedef enum ENDIAN
201  {
202  XDR = 0, // network, or big-endian, byte order
203  NDR = 1 // little-endian byte order
204  }
205  endian_t;
206 
208  static endian_t endian();
209 
211  template<typename T>
212  static void endian_swap( T& value )
213  {
214  char* data = reinterpret_cast<char*>( &value );
215  std::size_t n = sizeof( value );
216  for ( std::size_t i = 0, m = n / 2; i < m; ++i )
217  {
218  std::swap( data[i], data[n - 1 - i] );
219  }
220  }
221 
230  static QString reportStyleSheet();
231 
234  static QString showSettings();
235 
242  static void registerOgrDrivers();
243 
245  static QString absolutePathToRelativePath( QString apath, QString targetPath );
247  static QString relativePathToAbsolutePath( QString rpath, QString targetPath );
248 
250  static bool isRunningFromBuildDir() { return ABISYM( mRunningFromBuildDir ); }
251 #ifdef _MSC_VER
252  static QString cfgIntDir() { return ABISYM( mCfgIntDir ); }
253 #endif
254 
255  static QString buildSourcePath() { return ABISYM( mBuildSourcePath ); }
257  static QString buildOutputPath() { return ABISYM( mBuildOutputPath ); }
258 
263  static void skipGdalDriver( QString theDriver );
264 
269  static void restoreGdalDriver( QString theDriver );
270 
274  static QStringList skippedGdalDrivers() { return ABISYM( mGdalSkipList ); }
275 
280  static void applyGdalSkippedDrivers();
281 
284  static int maxThreads() { return ABISYM( mMaxThreads ); }
288  static void setMaxThreads( int maxThreads );
289 
290 #ifdef ANDROID
291  //dummy method to workaround sip generation issue issue
292  bool x11EventFilter( XEvent * event )
293  {
294  return 0;
295  }
296 #endif
297 
298  signals:
300  void preNotify( QObject * receiver, QEvent * event, bool * done );
301 
302  private:
303  static QObject* ABISYM( mFileOpenEventReceiver );
304  static QStringList ABISYM( mFileOpenEventList );
305 
306  static QString ABISYM( mPrefixPath );
307  static QString ABISYM( mPluginPath );
308  static QString ABISYM( mPkgDataPath );
309  static QString ABISYM( mLibraryPath );
310  static QString ABISYM( mLibexecPath );
311  static QString ABISYM( mThemeName );
312  static QStringList ABISYM( mDefaultSvgPaths );
313  static QMap<QString, QString> ABISYM( mSystemEnvVars );
314 
315  static QString ABISYM( mConfigPath );
316 
318  static bool ABISYM( mRunningFromBuildDir );
320  static QString ABISYM( mBuildSourcePath );
321 #ifdef _MSC_VER
322 
323  static QString ABISYM( mCfgIntDir );
324 #endif
325 
326  static QString ABISYM( mBuildOutputPath );
329  static QStringList ABISYM( mGdalSkipList );
332  static int ABISYM( mMaxThreads );
333 };
334 
335 #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.
ENDIAN
constants for endian-ness
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)
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)