QGIS API Documentation  2.99.0-Master (0a63d1f)
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 "qgis_core.h"
19 #include <QApplication>
20 #include <QEvent>
21 #include <QStringList>
22 
23 #include <qgis.h>
24 #include <qgsconfig.h>
25 
27 class QgsRuntimeProfiler;
28 class QgsTaskManager;
33 class QgsSvgCache;
39 class QgsMessageLog;
41 
47 #ifdef ANDROID
48 typedef void XEvent;
49 #endif
50 
51 class CORE_EXPORT QgsApplication : public QApplication
52 {
53  Q_OBJECT
54 
55  public:
56  static const char* QGIS_ORGANIZATION_NAME;
57  static const char* QGIS_ORGANIZATION_DOMAIN;
58  static const char* QGIS_APPLICATION_NAME;
59  QgsApplication( int & argc, char ** argv, bool GUIenabled, const QString& customConfigPath = QString(), const QString& platformName = "desktop" );
60  virtual ~QgsApplication();
61 
67  static QgsApplication* instance();
68 
75  static void init( QString customConfigPath = QString() );
76 
78  virtual bool event( QEvent * event ) override;
79 
81  virtual bool notify( QObject * receiver, QEvent * event ) override;
82 
84  static void setFileOpenEventReceiver( QObject * receiver );
85 
95  static void setThemeName( const QString &theThemeName );
96 
103  static QString themeName();
104 
112  static void setUITheme( const QString &themeName );
113 
120  static QHash<QString, QString> uiThemes();
121 
123  static QString authorsFilePath();
124 
128  static QString contributorsFilePath();
129 
134  static QString developersMapFilePath();
135 
137  static QString sponsorsFilePath();
138 
140  static QString donorsFilePath();
141 
145  static QString translatorsFilePath();
146 
150  static QString licenceFilePath();
151 
153  static QString helpAppPath();
154 
156  static QString i18nPath();
157 
159  static QString qgisMasterDbFilePath();
160 
162  static QString qgisSettingsDirPath();
163 
165  static QString qgisUserDbFilePath();
166 
168  static QString qgisAuthDbFilePath();
169 
171  static QString splashPath();
172 
174  static QString iconsPath();
175 
177  static QString srsDbFilePath();
178 
180  static QStringList svgPaths();
181 
183  static QStringList composerTemplatePaths();
184 
186  static QMap<QString, QString> systemEnvVars() { return ABISYM( mSystemEnvVars ); }
187 
189  static QString prefixPath();
190 
192  static QString pluginPath();
193 
195  static QString pkgDataPath();
196 
198  static QString activeThemePath();
199 
201  static QString defaultThemePath();
202 
205  static QString iconPath( const QString& iconFile );
206 
209  static QIcon getThemeIcon( const QString &theName );
210 
213  static QPixmap getThemePixmap( const QString &theName );
214 
216  static QString userStylePath();
217 
219  static QRegExp shortNameRegExp();
220 
225  static QString userLoginName();
226 
231  static QString userFullName();
232 
237  static QString osName();
238 
243  static QString platform();
244 
248  static QString locale();
249 
251  static QString userThemesFolder();
252 
254  static QString defaultStylePath();
255 
257  static QString defaultThemesFolder();
258 
260  static QString libraryPath();
261 
263  static QString libexecPath();
264 
266  static void setPrefixPath( const QString &thePrefixPath, bool useDefaultPaths = false );
267 
269  static void setPluginPath( const QString &thePluginPath );
270 
272  static void setPkgDataPath( const QString &thePkgDataPath );
273 
275  static void setDefaultSvgPaths( const QStringList& pathList );
276 
278  static void setAuthDbDirPath( const QString& theAuthDbDirPath );
279 
281  static void initQgis();
282 
284  static bool createDB( QString* errorMessage = nullptr );
285 
287  static bool createThemeFolder();
288 
290  static void exitQgis();
291 
293  static QString appIconPath();
294 
296  enum endian_t
297  {
298  XDR = 0, // network, or big-endian, byte order
299  NDR = 1 // little-endian byte order
300  };
301 
303  static endian_t endian();
304 
308  template<typename T>
309  static void endian_swap( T& value )
310  {
311  char* data = reinterpret_cast<char*>( &value );
312  std::size_t n = sizeof( value );
313  for ( std::size_t i = 0, m = n / 2; i < m; ++i )
314  {
315  std::swap( data[i], data[n - 1 - i] );
316  }
317  }
318 
327  static QString reportStyleSheet();
328 
331  static QString showSettings();
332 
339  static void registerOgrDrivers();
340 
342  static QString absolutePathToRelativePath( const QString& apath, const QString& targetPath );
344  static QString relativePathToAbsolutePath( const QString& rpath, const QString& targetPath );
345 
347  static bool isRunningFromBuildDir() { return ABISYM( mRunningFromBuildDir ); }
348 #ifdef _MSC_VER
349  static QString cfgIntDir() { return ABISYM( mCfgIntDir ); }
350 #endif
351  static QString buildSourcePath() { return ABISYM( mBuildSourcePath ); }
354  static QString buildOutputPath() { return ABISYM( mBuildOutputPath ); }
355 
360  static void skipGdalDriver( const QString& theDriver );
361 
366  static void restoreGdalDriver( const QString& theDriver );
367 
371  static QStringList skippedGdalDrivers() { return ABISYM( mGdalSkipList ); }
372 
377  static void applyGdalSkippedDrivers();
378 
381  static int maxThreads() { return ABISYM( mMaxThreads ); }
382 
386  static void setMaxThreads( int maxThreads );
387 
393  static QgsTaskManager* taskManager();
394 
399  static QgsColorSchemeRegistry* colorSchemeRegistry();
400 
405  static QgsPaintEffectRegistry* paintEffectRegistry();
406 
411  static QgsRendererRegistry* rendererRegistry();
412 
418  static QgsRasterRendererRegistry* rasterRendererRegistry();
419 
425  static QgsDataItemProviderRegistry* dataItemProviderRegistry();
426 
432  static QgsSvgCache* svgCache();
433 
438  static QgsSymbolLayerRegistry* symbolLayerRegistry();
439 
444  static QgsGPSConnectionRegistry* gpsConnectionRegistry();
445 
450  static QgsPluginLayerRegistry* pluginLayerRegistry();
451 
456  static QgsMessageLog* messageLog();
457 
463  static QgsProcessingRegistry* processingRegistry();
464 
465 #ifdef ANDROID
466  //dummy method to workaround sip generation issue issue
467  bool x11EventFilter( XEvent * event )
468  {
469  Q_UNUSED( event );
470  return 0;
471  }
472 #endif
473 
479  static QgsActionScopeRegistry* actionScopeRegistry();
480 
485  static QgsRuntimeProfiler* profiler();
486 
490  static QgsFieldFormatterRegistry* fieldFormatterRegistry();
491 
500  static QString nullRepresentation();
501 
505  static void setNullRepresentation( const QString& nullRepresentation );
506 
514  static QVariantMap customVariables();
515 
523  static void setCustomVariables( const QVariantMap& customVariables );
524 
525 
531  static void setCustomVariable( const QString& name, const QVariant& value );
532 
533  signals:
535  void preNotify( QObject * receiver, QEvent * event, bool * done );
536 
541  void customVariablesChanged();
542 
543 
547  void nullRepresentationChanged();
548 
549  private:
550  static void copyPath( const QString& src, const QString& dst );
551  static QObject* ABISYM( mFileOpenEventReceiver );
552  static QStringList ABISYM( mFileOpenEventList );
553 
554  static QString ABISYM( mUIThemeName );
555  static QString ABISYM( mPrefixPath );
556  static QString ABISYM( mPluginPath );
557  static QString ABISYM( mPkgDataPath );
558  static QString ABISYM( mLibraryPath );
559  static QString ABISYM( mLibexecPath );
560  static QString ABISYM( mThemeName );
561  static QStringList ABISYM( mDefaultSvgPaths );
562  static QMap<QString, QString> ABISYM( mSystemEnvVars );
563 
564  static QString ABISYM( mConfigPath );
565 
567  static bool ABISYM( mRunningFromBuildDir );
569  static QString ABISYM( mBuildSourcePath );
570 #ifdef _MSC_VER
571  static QString ABISYM( mCfgIntDir );
573 #endif
574  static QString ABISYM( mBuildOutputPath );
576 
579  static QStringList ABISYM( mGdalSkipList );
580 
583  static int ABISYM( mMaxThreads );
584 
587  static QString ABISYM( mAuthDbDirPath );
588 
589  static QString sUserName;
590  static QString sUserFullName;
591  static QString sPlatformName;
592 
593  QMap<QString, QIcon> mIconCache;
594 
595  QgsActionScopeRegistry* mActionScopeRegistry = nullptr;
596  QgsRuntimeProfiler* mProfiler = nullptr;
597  QgsTaskManager* mTaskManager = nullptr;
598  QgsFieldFormatterRegistry* mFieldFormatterRegistry = nullptr;
599  QgsColorSchemeRegistry* mColorSchemeRegistry = nullptr;
600  QgsPaintEffectRegistry* mPaintEffectRegistry = nullptr;
601  QgsRendererRegistry* mRendererRegistry = nullptr;
602  QgsSvgCache* mSvgCache = nullptr;
603  QgsSymbolLayerRegistry* mSymbolLayerRegistry = nullptr;
604  QgsRasterRendererRegistry* mRasterRendererRegistry = nullptr;
605  QgsGPSConnectionRegistry* mGpsConnectionRegistry = nullptr;
606  QgsDataItemProviderRegistry* mDataItemProviderRegistry = nullptr;
607  QgsPluginLayerRegistry* mPluginLayerRegistry = nullptr;
608  QgsMessageLog* mMessageLog = nullptr;
609  QgsProcessingRegistry* mProcessingRegistry = nullptr;
610  QString mNullRepresentation;
611 };
612 
613 #endif
static void endian_swap(T &value)
Swap the endianness of the specified value.
This class keeps a list of data item providers that may add items to the browser tree.
Extends QApplication to provide access to QGIS specific resources such as theme paths, database paths etc.
Registry of color schemes.
A registry of plugin layers types.
A cache for images / pictures derived from svg files.
Definition: qgssvgcache.h:100
Registry of renderers.
Registry for raster renderers.
static QStringList skippedGdalDrivers()
Returns the list of gdal drivers that should be skipped (based on GDAL_SKIP environment variable) ...
The QgsFieldFormatterRegistry manages registered classes of QgsFieldFormatter.
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.
Registry of available symbol layer classes.
static QString buildOutputPath()
Returns path to the build output directory. Valid only when running from build directory.
static const char * QGIS_ORGANIZATION_NAME
Task manager for managing a set of long-running QgsTask tasks.
A class to register / unregister existing GPS connections such that the information is available to a...
Registry for various processing components, including providers, algorithms and various parameters an...
static const char * QGIS_ORGANIZATION_DOMAIN
QObject * ABISYM(QgsApplication::mFileOpenEventReceiver)
The action scope registry is an application wide registry that contains a list of available action sc...
static const char * QGIS_APPLICATION_NAME
Interface for logging messages from QGIS in GUI independent way.
Definition: qgsmessagelog.h:36
Registry of available paint effects.