55 #include "qgssettings.h"
56 #include "qgssettingsregistrycore.h"
81 #include "processing/models/qgsprocessingmodelchildparametersource.h"
82 #include "processing/models/qgsprocessingmodelchilddependency.h"
86 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
87 #include <QDesktopWidget>
92 #include <QFileOpenEvent>
93 #include <QMessageBox>
96 #include <QProcessEnvironment>
99 #include <QThreadPool>
102 #include <QLibraryInfo>
103 #include <QStandardPaths>
104 #include <QRegularExpression>
105 #include <QTextStream>
107 #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
108 #include <QRecursiveMutex>
112 #include <netinet/in.h>
118 #define SECURITY_WIN32
119 #include <security.h>
121 #pragma comment( lib, "Secur32.lib" )
125 #include "qgsconfig.h"
129 #include <cpl_conv.h>
136 #define CONN_POOL_MAX_CONCURRENT_CONNS 4
138 QObject *
ABISYM( QgsApplication::mFileOpenEventReceiver ) =
nullptr;
139 bool ABISYM( QgsApplication::mInitialized ) =
false;
140 bool ABISYM( QgsApplication::mRunningFromBuildDir ) =
false;
144 QgsApplication::ApplicationMembers *QgsApplication::sApplicationMembers =
nullptr;
146 int ABISYM( QgsApplication::sMaxThreads ) = -1;
163 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
179 : QApplication( argc, argv, GUIenabled )
181 *sPlatformName() = platformName;
183 if ( *sTranslation() != QLatin1String(
"C" ) )
185 mQgisTranslator =
new QTranslator();
186 if ( mQgisTranslator->load( QStringLiteral(
"qgis_" ) + *sTranslation(), i18nPath() ) )
188 installTranslator( mQgisTranslator );
192 QgsDebugMsgLevel( QStringLiteral(
"loading of qgis translation failed %1/qgis_%2" ).arg( i18nPath(), *sTranslation() ), 2 );
200 mQtTranslator =
new QTranslator();
201 if ( mQtTranslator->load( QStringLiteral(
"qt_" ) + *sTranslation(), QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ) )
203 installTranslator( mQtTranslator );
207 QgsDebugMsgLevel( QStringLiteral(
"loading of qt translation failed %1/qt_%2" ).arg( QLibraryInfo::location( QLibraryInfo::TranslationsPath ), *sTranslation() ), 2 );
211 mApplicationMembers =
new ApplicationMembers();
213 *sProfilePath() = profileFolder;
218 if ( profileFolder.isEmpty() )
220 if ( getenv(
"QGIS_CUSTOM_CONFIG_PATH" ) )
222 profileFolder = getenv(
"QGIS_CUSTOM_CONFIG_PATH" );
226 profileFolder = QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 );
233 profileFolder = profile->
folder();
237 *sProfilePath() = profileFolder;
239 static std::once_flag sMetaTypesRegistered;
240 std::call_once( sMetaTypesRegistered, []
242 qRegisterMetaType<QgsGeometry::Error>(
"QgsGeometry::Error" );
243 qRegisterMetaType<QgsProcessingFeatureSourceDefinition>(
"QgsProcessingFeatureSourceDefinition" );
244 qRegisterMetaType<QgsProcessingOutputLayerDefinition>(
"QgsProcessingOutputLayerDefinition" );
245 qRegisterMetaType<QgsUnitTypes::LayoutUnit>(
"QgsUnitTypes::LayoutUnit" );
246 qRegisterMetaType<QgsFeatureId>(
"QgsFeatureId" );
247 qRegisterMetaType<QgsFeatureIds>(
"QgsFeatureIds" );
248 qRegisterMetaType<QgsProperty>(
"QgsProperty" );
249 qRegisterMetaType<QgsFeatureStoreList>(
"QgsFeatureStoreList" );
250 qRegisterMetaType<Qgis::MessageLevel>(
"Qgis::MessageLevel" );
251 qRegisterMetaType<Qgis::BrowserItemState>(
"Qgis::BrowserItemState" );
252 qRegisterMetaType<QgsReferencedRectangle>(
"QgsReferencedRectangle" );
253 qRegisterMetaType<QgsReferencedPointXY>(
"QgsReferencedPointXY" );
254 qRegisterMetaType<QgsReferencedGeometry>(
"QgsReferencedGeometry" );
255 qRegisterMetaType<QgsLayoutRenderContext::Flags>(
"QgsLayoutRenderContext::Flags" );
256 qRegisterMetaType<QgsStyle::StyleEntity>(
"QgsStyle::StyleEntity" );
257 qRegisterMetaType<QgsCoordinateReferenceSystem>(
"QgsCoordinateReferenceSystem" );
258 qRegisterMetaType<QgsAuthManager::MessageLevel>(
"QgsAuthManager::MessageLevel" );
259 qRegisterMetaType<QgsNetworkRequestParameters>(
"QgsNetworkRequestParameters" );
260 qRegisterMetaType<QgsNetworkReplyContent>(
"QgsNetworkReplyContent" );
261 qRegisterMetaType<QgsGeometry>(
"QgsGeometry" );
262 qRegisterMetaType<QgsDatumTransform::GridDetails>(
"QgsDatumTransform::GridDetails" );
263 qRegisterMetaType<QgsDatumTransform::TransformDetails>(
"QgsDatumTransform::TransformDetails" );
264 qRegisterMetaType<QgsNewsFeedParser::Entry>(
"QgsNewsFeedParser::Entry" );
265 qRegisterMetaType<QgsRectangle>(
"QgsRectangle" );
266 qRegisterMetaType<QgsLocatorResult>(
"QgsLocatorResult" );
267 qRegisterMetaType<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
268 qRegisterMetaTypeStreamOperators<QgsProcessingModelChildParameterSource>(
"QgsProcessingModelChildParameterSource" );
269 qRegisterMetaType<QgsRemappingSinkDefinition>(
"QgsRemappingSinkDefinition" );
270 qRegisterMetaType<QgsProcessingModelChildDependency>(
"QgsProcessingModelChildDependency" );
271 qRegisterMetaType<QgsTextFormat>(
"QgsTextFormat" );
272 QMetaType::registerComparators<QgsProcessingModelChildDependency>();
273 QMetaType::registerEqualsComparator<QgsProcessingFeatureSourceDefinition>();
274 QMetaType::registerEqualsComparator<QgsProperty>();
275 QMetaType::registerEqualsComparator<QgsDateTimeRange>();
276 QMetaType::registerEqualsComparator<QgsDateRange>();
277 qRegisterMetaType<QPainter::CompositionMode>(
"QPainter::CompositionMode" );
278 qRegisterMetaType<QgsDateTimeRange>(
"QgsDateTimeRange" );
283 if ( ABISYM( mRunningFromBuildDir ) )
286 *sPrefixPath() = QString();
287 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
288 setPluginPath( *sBuildOutputPath() +
'/' + QString( QGIS_PLUGIN_SUBDIR ) +
'/' + *sCfgIntDir() );
290 setPluginPath( *sBuildOutputPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
292 setPkgDataPath( *sBuildOutputPath() + QStringLiteral(
"/data" ) );
293 *sLibraryPath() = *sBuildOutputPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
294 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
295 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/' + *sCfgIntDir() +
'/';
297 *sLibexecPath() = *sBuildOutputPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
299 #if defined( HAVE_QUICK )
300 *sQmlImportPath() = *sBuildOutputPath() +
'/' + QGIS_QML_SUBDIR +
'/';
305 char *
prefixPath = getenv(
"QGIS_PREFIX_PATH" );
308 if ( sPrefixPath()->isNull() )
310 #if defined(Q_OS_MACX) || defined(Q_OS_WIN)
312 #elif defined(ANDROID)
314 QDir myDir( QDir::homePath() );
316 QString myPrefix = myDir.absolutePath();
319 QDir myDir( applicationDirPath() );
321 if ( applicationDirPath().contains( QStringLiteral(
"cgi-bin" ) ) )
326 QString myPrefix = myDir.absolutePath();
337 *sConfigPath() = profileFolder +
'/';
341 if ( getenv(
"QGIS_AUTH_DB_DIR_PATH" ) )
347 QMap<QString, QString> systemEnvVarMap;
348 QString passfile( QStringLiteral(
"QGIS_AUTH_PASSWORD_FILE" ) );
350 const auto systemEnvironment = QProcessEnvironment::systemEnvironment().toStringList();
351 for (
const QString &varStr : systemEnvironment )
353 int pos = varStr.indexOf( QLatin1Char(
'=' ) );
356 QString varStrName = varStr.left( pos );
357 QString varStrValue = varStr.mid( pos + 1 );
358 if ( varStrName != passfile )
360 systemEnvVarMap.insert( varStrName, varStrValue );
363 *sSystemEnvVars() = systemEnvVarMap;
370 QString projLib( QDir::cleanPath(
pkgDataPath().append(
"/proj" ) ) );
371 if ( QFile::exists( projLib ) )
373 currentProjSearchPaths.append( projLib );
377 char **newPaths =
new char *[currentProjSearchPaths.length()];
378 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
380 newPaths[i] = CPLStrdup( currentProjSearchPaths.at( i ).toUtf8().constData() );
382 proj_context_set_search_paths(
nullptr, currentProjSearchPaths.count(), newPaths );
383 for (
int i = 0; i < currentProjSearchPaths.count(); ++i )
385 CPLFree( newPaths[i] );
390 QCoreApplication::addLibraryPath(
pluginPath() );
395 ABISYM( sMaxThreads ) = -1;
408 if ( !members()->mStyleModel )
411 ABISYM( mInitialized ) =
true;
416 delete mDataItemProviderRegistry;
417 delete mApplicationMembers;
418 delete mQgisTranslator;
419 delete mQtTranslator;
427 void QgsApplication::invalidateCaches()
439 return qobject_cast<QgsApplication *>( QCoreApplication::instance() );
445 if (
event->type() == QEvent::FileOpen )
448 if ( ABISYM( mFileOpenEventReceiver ) )
451 done =
notify( ABISYM( mFileOpenEventReceiver ),
event );
458 sFileOpenEventList()->append(
static_cast<QFileOpenEvent *
>(
event )->file() );
465 done = QApplication::event(
event );
474 if ( thread() == receiver->thread() )
484 done = QApplication::notify( receiver,
event );
488 qCritical() <<
"Caught unhandled QgsException: " << e.
what();
489 if ( qApp->thread() == QThread::currentThread() )
490 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
492 catch ( std::exception &e )
494 qCritical() <<
"Caught unhandled std::exception: " << e.
what();
495 if ( qApp->thread() == QThread::currentThread() )
496 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
500 qCritical() <<
"Caught unhandled unknown exception";
501 if ( qApp->thread() == QThread::currentThread() )
502 QMessageBox::critical( activeWindow(), tr(
"Exception" ), tr(
"unknown exception" ) );
510 return QgsRuntimeProfiler::threadLocalInstance();
516 ABISYM( mFileOpenEventReceiver ) = receiver;
518 if ( sFileOpenEventList()->count() > 0 )
520 const QStringList fileOpenEventList = *sFileOpenEventList();
521 for (
const QString &file : fileOpenEventList )
523 QFileOpenEvent foe( file );
524 QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
526 sFileOpenEventList()->clear();
533 #if defined(Q_OS_WIN)
534 if ( sPrefixPath()->endsWith(
"/bin" ) )
536 sPrefixPath()->chop( 4 );
539 if ( useDefaultPaths && !ABISYM( mRunningFromBuildDir ) )
541 setPluginPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) );
542 setPkgDataPath( *sPrefixPath() +
'/' + QStringLiteral( QGIS_DATA_SUBDIR ) );
544 *sLibraryPath() = *sPrefixPath() +
'/' + QGIS_LIB_SUBDIR +
'/';
545 *sLibexecPath() = *sPrefixPath() +
'/' + QGIS_LIBEXEC_SUBDIR +
'/';
546 #if defined( HAVE_QUICK )
547 *sQmlImportPath() = *sPrefixPath() +
'/' + QGIS_QML_SUBDIR +
'/';
560 QString mySvgPath =
pkgDataPath + QStringLiteral(
"/svg/" );
563 if ( !sDefaultSvgPaths()->contains( mySvgPath ) )
564 *sDefaultSvgPaths() << mySvgPath;
569 *sDefaultSvgPaths() = pathList;
574 QFileInfo fi( authDbDirPath );
575 if ( fi.exists() && fi.isDir() && fi.isWritable() )
577 *sAuthDbDirPath() = fi.canonicalFilePath() + QDir::separator();
584 if ( ABISYM( mRunningFromBuildDir ) )
586 static bool sOnce =
true;
590 ( void ) blockNotifications;
591 qWarning(
"!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
597 return *sPrefixPath();
601 return *sPluginPath();
606 if ( sPkgDataPath()->isNull() )
609 return *sPkgDataPath();
614 return QStringLiteral(
":/images/themes/default/" );
619 QDir dir( usersThemes );
627 return defaultThemes;
633 return iconsPath() + QStringLiteral(
"qgis-icon-60x60.png" );
638 return ABISYM( sMaxThreads );
645 if ( QFile::exists( path + iconFile ) )
646 return path + iconFile;
654 const QString cacheKey = ( name.startsWith(
'/' ) ? name.mid( 1 ) : name )
655 + ( fillColor.isValid() ? QStringLiteral(
"_%1" ).arg( fillColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() )
656 + ( strokeColor.isValid() ? QStringLiteral(
"_%1" ).arg( strokeColor.name( QColor::HexArgb ).mid( 1 ) ) : QString() );
658 if ( app && app->mIconCache.contains( cacheKey ) )
659 return app->mIconCache.value( cacheKey );
662 const bool colorBased = fillColor.isValid() || strokeColor.isValid();
664 auto iconFromColoredSvg = [ = ](
const QString & path ) -> QIcon
669 const QString
iconPath = sIconCacheDir()->filePath( cacheKey + QStringLiteral(
".svg" ) );
671 if ( f.open( QFile::WriteOnly | QFile::Truncate ) )
673 f.write( svgContent );
678 QgsDebugMsg( QStringLiteral(
"Could not create colorized icon svg at %1" ).arg(
iconPath ) );
682 return QIcon( f.fileName() );
687 if ( QFile::exists( preferredPath ) )
691 icon = iconFromColoredSvg( preferredPath );
695 icon = QIcon( preferredPath );
698 else if ( QFile::exists( defaultPath ) )
704 icon = iconFromColoredSvg( defaultPath );
708 icon = QIcon( defaultPath );
717 app->mIconCache.insert( cacheKey, icon );
724 if ( app && app->mCursorCache.contains( cursor ) )
725 return app->mCursorCache.value( cursor );
736 name = QStringLiteral(
"mZoomIn.svg" );
741 name = QStringLiteral(
"mZoomOut.svg" );
748 name = QStringLiteral(
"mIdentify.svg" );
751 name = QStringLiteral(
"mCrossHair.svg" );
754 name = QStringLiteral(
"mCapturePoint.svg" );
757 name = QStringLiteral(
"mSelect.svg" );
764 name = QStringLiteral(
"mSampler.svg" );
769 Q_ASSERT( ! name.isEmpty( ) );
771 QIcon icon =
getThemeIcon( QStringLiteral(
"cursors" ) + QDir::separator() + name );
774 if ( ! icon.isNull( ) )
778 cursorIcon = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
781 app->mCursorCache.insert( cursor, cursorIcon );
788 const QString preferredPath =
activeThemePath() + QDir::separator() + name;
790 const QString path = QFile::exists( preferredPath ) ? preferredPath : defaultPath;
791 if ( foreColor.isValid() || backColor.isValid() )
793 bool fitsInCache =
false;
794 const QImage image =
svgCache()->
svgAsImage( path, size, backColor, foreColor, 1, 1, fitsInCache );
795 return QPixmap::fromImage( image );
798 return QPixmap( path );
808 static QString appPath;
809 if ( appPath.isNull() )
811 if ( QCoreApplication::instance() )
813 appPath = applicationDirPath();
817 qWarning(
"Application path not initialized" );
821 if ( !appPath.isNull() || getenv(
"QGIS_PREFIX_PATH" ) )
823 QString prefix = getenv(
"QGIS_PREFIX_PATH" ) ? getenv(
"QGIS_PREFIX_PATH" ) : appPath;
828 static const QStringList paths { QStringList() << QString() << QStringLiteral(
"/.." ) << QStringLiteral(
"/bin" ) << QStringLiteral(
"/../../.." ) };
829 for (
const QString &path : paths )
831 f.setFileName( prefix + path +
"/qgisbuildpath.txt" );
835 if ( f.exists() && f.open( QIODevice::ReadOnly ) )
837 ABISYM( mRunningFromBuildDir ) =
true;
838 *sBuildSourcePath() = f.readLine().trimmed();
839 *sBuildOutputPath() = f.readLine().trimmed();
841 QgsDebugMsgLevel( QStringLiteral(
"- source directory: %1" ).arg( sBuildSourcePath()->toUtf8().constData() ), 4 );
842 QgsDebugMsgLevel( QStringLiteral(
"- output directory of the build: %1" ).arg( sBuildOutputPath()->toUtf8().constData() ), 4 );
843 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
844 *sCfgIntDir() = prefix.split(
'/', QString::SkipEmptyParts ).last();
845 qDebug(
"- cfg: %s", sCfgIntDir()->toUtf8().constData() );
851 if ( getenv(
"QGIS_PREFIX_PATH" ) )
857 QDir dir( QDir::homePath() );
862 #if defined(Q_OS_MACX)
864 #elif defined(Q_OS_WIN)
871 if ( appPath.contains( QStringLiteral(
"cgi-bin" ) ) )
881 if ( ABISYM( mRunningFromBuildDir ) )
882 return *sBuildOutputPath() + QStringLiteral(
"/data" );
884 return prefixPath +
'/' + QStringLiteral( QGIS_DATA_SUBDIR );
889 return *sThemeName();
899 qApp->setStyleSheet( QString() );
903 QString path = themes.value(
themeName );
904 QString stylesheetname = path +
"/style.qss";
906 QFile file( stylesheetname );
907 QFile variablesfile( path +
"/variables.qss" );
909 QFileInfo variableInfo( variablesfile );
911 if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
916 QString styledata = file.readAll();
917 styledata.replace( QLatin1String(
"@theme_path" ), path );
919 if ( variableInfo.exists() )
921 QTextStream in( &variablesfile );
922 while ( !in.atEnd() )
924 QString line = in.readLine();
926 if ( line.startsWith(
'@' ) )
928 int index = line.indexOf(
':' );
929 QString name = line.mid( 0, index );
930 QString value = line.mid( index + 1, line.length() );
931 styledata.replace( name, value );
934 variablesfile.close();
942 const static QRegularExpression regex( QStringLiteral(
"(?<=[\\s:])([0-9\\.]+)(?=em)" ) );
943 QRegularExpressionMatch match = regex.match( styledata, index );
944 while ( match.hasMatch() )
946 index = match.capturedStart();
947 styledata.remove( index, match.captured( 0 ).length() );
949 styledata.insert( index, number );
950 index += number.length();
951 match = regex.match( styledata, index );
955 qApp->setStyleSheet( styledata );
957 QFile palettefile( path +
"/palette.txt" );
958 QFileInfo paletteInfo( palettefile );
959 if ( paletteInfo.exists() && palettefile.open( QIODevice::ReadOnly ) )
961 QPalette
pal = qApp->palette();
962 QTextStream in( &palettefile );
963 while ( !in.atEnd() )
965 QString line = in.readLine();
966 QStringList parts = line.split(
':' );
967 if ( parts.count() == 2 )
969 int role = parts.at( 0 ).trimmed().toInt();
971 pal.setColor(
static_cast< QPalette::ColorRole
>( role ), color );
975 qApp->setPalette(
pal );
984 QHash<QString, QString> mapping;
985 mapping.insert( QStringLiteral(
"default" ), QString() );
986 const auto constPaths = paths;
987 for (
const QString &path : constPaths )
990 QFileInfoList styleFiles = folder.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
991 const auto constStyleFiles = styleFiles;
992 for (
const QFileInfo &info : constStyleFiles )
994 QFileInfo styleFile( info.absoluteFilePath() +
"/style.qss" );
995 if ( !styleFile.exists() )
998 QString name = info.baseName();
999 QString path = info.absoluteFilePath();
1000 mapping.insert( name, path );
1008 return pkgDataPath() + QStringLiteral(
"/doc/AUTHORS" );
1013 return pkgDataPath() + QStringLiteral(
"/doc/CONTRIBUTORS" );
1017 return pkgDataPath() + QStringLiteral(
"/doc/developersmap.html" );
1022 return pkgDataPath() + QStringLiteral(
"/doc/SPONSORS" );
1027 return pkgDataPath() + QStringLiteral(
"/doc/DONORS" );
1032 return pkgDataPath() + QStringLiteral(
"/doc/TRANSLATORS" );
1037 return pkgDataPath() + QStringLiteral(
"/doc/LICENSE" );
1042 if ( ABISYM( mRunningFromBuildDir ) )
1043 return *sBuildOutputPath() + QStringLiteral(
"/i18n/" );
1045 return pkgDataPath() + QStringLiteral(
"/i18n/" );
1050 return pkgDataPath() + QStringLiteral(
"/resources/metadata-ISO/" );
1055 return pkgDataPath() + QStringLiteral(
"/resources/qgis.db" );
1060 return *sConfigPath();
1070 return *sAuthDbDirPath() + QStringLiteral(
"qgis-auth.db" );
1075 return QStringLiteral(
":/images/splash/" );
1080 return pkgDataPath() + QStringLiteral(
"/images/icons/" );
1085 if ( ABISYM( mRunningFromBuildDir ) )
1087 QString tempCopy = QDir::tempPath() +
"/srs6.db";
1089 if ( !QFile( tempCopy ).exists() )
1092 if ( !f.copy( tempCopy ) )
1094 qFatal(
"Could not create temporary copy" );
1102 return pkgDataPath() + QStringLiteral(
"/resources/srs.db" );
1109 members()->mSvgPathCacheValid =
false;
1114 static QReadWriteLock lock;
1118 if ( members()->mSvgPathCacheValid )
1120 return members()->mSvgPathCache;
1131 for (
const QString &path : pathList )
1133 if ( !paths.contains( path ) )
1134 paths.append( path );
1136 for (
const QString &path : std::as_const( *sDefaultSvgPaths() ) )
1138 if ( !paths.contains( path ) )
1139 paths.append( path );
1141 members()->mSvgPathCache = paths;
1156 return *sSystemEnvVars();
1166 const thread_local QRegExp regexp( QStringLiteral(
"^[A-Za-z][A-Za-z0-9\\._-]*" ) );
1172 if ( !sUserName()->isEmpty() )
1173 return *sUserName();
1176 TCHAR name [ UNLEN + 1 ];
1177 DWORD size = UNLEN + 1;
1179 if ( GetUserName( ( TCHAR * )name, &size ) )
1181 *sUserName() = QString::fromLocal8Bit( name );
1184 #elif QT_CONFIG(process)
1187 process.start( QStringLiteral(
"whoami" ), QStringList() );
1188 process.waitForFinished();
1189 *sUserName() = process.readAllStandardOutput().trimmed();
1192 if ( !sUserName()->isEmpty() )
1193 return *sUserName();
1196 *sUserName() = qgetenv(
"USER" );
1197 if ( !sUserName()->isEmpty() )
1198 return *sUserName();
1201 *sUserName() = qgetenv(
"USERNAME" );
1202 return *sUserName();
1207 if ( !sUserFullName()->isEmpty() )
1208 return *sUserFullName();
1211 TCHAR name [ UNLEN + 1 ];
1212 DWORD size = UNLEN + 1;
1215 if ( GetUserNameEx( NameDisplay, ( TCHAR * )name, &size ) )
1217 *sUserFullName() = QString::fromLocal8Bit( name );
1221 if ( sUserFullName()->isEmpty() )
1223 #elif defined(Q_OS_ANDROID) || defined(__MINGW32__)
1224 *sUserFullName() = QStringLiteral(
"Not available" );
1226 struct passwd *p = getpwuid( getuid() );
1230 QString gecosName = QString( p->pw_gecos );
1231 *sUserFullName() = gecosName.left( gecosName.indexOf(
',', 0 ) );
1236 return *sUserFullName();
1241 #if defined(Q_OS_ANDROID)
1242 return QLatin1String(
"android" );
1243 #elif defined(Q_OS_MAC)
1244 return QLatin1String(
"osx" );
1245 #elif defined(Q_OS_WIN)
1246 return QLatin1String(
"windows" );
1247 #elif defined(Q_OS_LINUX)
1248 return QStringLiteral(
"linux" );
1249 #elif defined(Q_OS_FREEBSD)
1250 return QStringLiteral(
"freebsd" );
1251 #elif defined(Q_OS_OPENBSD)
1252 return QStringLiteral(
"openbsd" );
1253 #elif defined(Q_OS_NETBSD)
1254 return QStringLiteral(
"netbsd" );
1255 #elif defined(Q_OS_UNIX)
1256 return QLatin1String(
"unix" );
1258 return QLatin1String(
"unknown" );
1264 return *sPlatformName();
1273 if (
locale.startsWith( QLatin1String(
"en" ), Qt::CaseInsensitive ) )
1282 return QLocale().name().left( 2 );
1293 return pkgDataPath() + QStringLiteral(
"/resources/symbology-style.xml" );
1298 return pkgDataPath() + QStringLiteral(
"/resources/themes" );
1303 return pkgDataPath() + QStringLiteral(
"/resources/server/" );
1308 return *sLibraryPath();
1313 return *sLibexecPath();
1318 return *sQmlImportPath();
1323 return ( htonl( 1 ) == 1 ) ?
XDR :
NDR;
1330 init( *sProfilePath() );
1355 if (
auto *lInstance =
instance() )
1357 if ( !lInstance->mAuthManager )
1361 return lInstance->mAuthManager;
1366 if ( !sAuthManager )
1368 return sAuthManager;
1376 QThreadPool::globalInstance()->waitForDone();
1379 if (
auto *lInstance =
instance() )
1380 delete lInstance->mAuthManager;
1382 delete sAuthManager;
1387 QgsApplication::sendPostedEvents(
nullptr, QEvent::DeferredDelete );
1395 if ( QgsProviderRegistry::exists() )
1404 GDALDestroyDriverManager();
1409 QString myEnvironmentVar( getenv(
"QGIS_PREFIX_PATH" ) );
1410 QString myState = tr(
"Application state:\n"
1411 "QGIS_PREFIX_PATH env var:\t\t%1\n"
1413 "Plugin Path:\t\t%3\n"
1414 "Package Data Path:\t%4\n"
1415 "Active Theme Name:\t%5\n"
1416 "Active Theme Path:\t%6\n"
1417 "Default Theme Path:\t%7\n"
1418 "SVG Search Paths:\t%8\n"
1419 "User DB Path:\t%9\n"
1420 "Auth DB Path:\t%10\n" )
1421 .arg( myEnvironmentVar,
1428 svgPaths().join( tr(
"\n\t\t",
"match indentation of application state" ) ),
1441 QColor myColor1( Qt::lightGray );
1442 QColor myColor2 = myColor1;
1443 myColor2 = myColor2.lighter( 110 );
1445 myStyle = QStringLiteral(
".overview{"
1447 " font-weight: bold;"
1450 " background: white;"
1452 " font-family: 'Lato', 'Open Sans', 'Lucida Grande', 'Segoe UI', 'Arial', sans-serif;"
1455 "h1{ background-color: #F6F6F6;"
1457 " font-size: x-large; "
1458 " font-weight: normal;"
1459 " background: none;"
1460 " padding: 0.75em 0 0;"
1462 " line-height: 3em;"
1464 "h2{ background-color: #F6F6F6;"
1466 " font-size: medium; "
1467 " font-weight: normal;"
1468 " background: none;"
1469 " padding: 0.75em 0 0;"
1471 " line-height: 1.1em;"
1473 "h3{ background-color: #F6F6F6;"
1475 " font-weight: bold;"
1476 " font-size: large;"
1477 " text-align: left;"
1478 " border-bottom: 5px solid #DCEB5C;"
1480 "h4{ background-color: #F6F6F6;"
1482 " font-weight: bold;"
1483 " font-size: medium;"
1484 " text-align: left;"
1486 "h5{ background-color: #F6F6F6;"
1488 " font-weight: bold;"
1489 " font-size: small;"
1490 " text-align: left;"
1492 "a{ color: #729FCF;"
1493 " font-family: arial,sans-serif;"
1495 "label{ background-color: #FFFFCC;"
1496 " border: 1px solid black;"
1498 " padding: 0px 3px; "
1499 " font-size: small;"
1502 " font-weight: bold;"
1507 " border-top: 1px solid black;"
1509 ".list-view .highlight {"
1510 " text-align: left;"
1513 " padding-right: 15px;"
1514 " padding-left: 20px;"
1515 " font-weight: bold;"
1517 ".tabular-view .odd-row {"
1518 " background-color: #f9f9f9;"
1521 " font-weight: bold;"
1522 " padding-top:25px;"
1526 switch ( styleSheetType )
1528 case StyleSheetType::Qt:
1529 myStyle += QStringLiteral(
1531 " border-collapse: collapse;"
1534 ".tabular-view th, .tabular-view td { "
1535 " border:1px solid black;"
1539 case StyleSheetType::WebBrowser:
1540 myStyle += QStringLiteral(
1545 "table.tabular-view, table.list-view { "
1546 " border-collapse: collapse;"
1547 " table-layout:fixed;"
1548 " width: 100% !important;"
1553 " line-height: inherit;"
1556 " word-wrap: break-word; "
1557 " vertical-align: top;"
1560 ".list-view th:first-child, .list-view td:first-child {"
1563 ".list-view.highlight { "
1564 " padding-left: inherit; "
1567 ".tabular-view th:first-child, .tabular-view td:first-child { "
1571 ".tabular-view th.strong { "
1572 " background-color: #eee; "
1575 ".tabular-view th, .tabular-view td { "
1576 " border: 1px solid #eee;"
1587 if ( 0 >= OGRGetDriverCount() )
1595 QString aPathUrl = aPath;
1596 QString tPathUrl = targetPath;
1597 #if defined( Q_OS_WIN )
1598 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
1600 aPathUrl.replace(
'\\',
'/' );
1601 if ( aPathUrl.startsWith(
"//" ) )
1604 aPathUrl =
"\\\\" + aPathUrl.mid( 2 );
1607 tPathUrl.replace(
'\\',
'/' );
1608 if ( tPathUrl.startsWith(
"//" ) )
1611 tPathUrl =
"\\\\" + tPathUrl.mid( 2 );
1614 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
1617 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1618 QStringList targetElems = tPathUrl.split(
'/', QString::SkipEmptyParts );
1619 QStringList aPathElems = aPathUrl.split(
'/', QString::SkipEmptyParts );
1621 QStringList targetElems = tPathUrl.split(
'/', Qt::SkipEmptyParts );
1622 QStringList aPathElems = aPathUrl.split(
'/', Qt::SkipEmptyParts );
1625 targetElems.removeAll( QStringLiteral(
"." ) );
1626 aPathElems.removeAll( QStringLiteral(
"." ) );
1630 while ( !aPathElems.isEmpty() &&
1631 !targetElems.isEmpty() &&
1632 aPathElems[0].compare( targetElems[0], cs ) == 0 )
1634 aPathElems.removeFirst();
1635 targetElems.removeFirst();
1645 if ( !targetElems.isEmpty() )
1648 for (
int i = 0; i < targetElems.size(); i++ )
1650 aPathElems.insert( 0, QStringLiteral(
".." ) );
1657 aPathElems.insert( 0, QStringLiteral(
"." ) );
1660 return aPathElems.join( QLatin1Char(
'/' ) );
1666 if ( !rpath.startsWith( QLatin1String(
"./" ) ) && !rpath.startsWith( QLatin1String(
"../" ) ) )
1671 QString rPathUrl = rpath;
1672 QString targetPathUrl = targetPath;
1674 #if defined(Q_OS_WIN)
1675 rPathUrl.replace(
'\\',
'/' );
1676 targetPathUrl.replace(
'\\',
'/' );
1678 bool uncPath = targetPathUrl.startsWith(
"//" );
1681 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1682 QStringList srcElems = rPathUrl.split(
'/', QString::SkipEmptyParts );
1683 QStringList targetElems = targetPathUrl.split(
'/', QString::SkipEmptyParts );
1685 QStringList srcElems = rPathUrl.split(
'/', Qt::SkipEmptyParts );
1686 QStringList targetElems = targetPathUrl.split(
'/', Qt::SkipEmptyParts );
1689 #if defined(Q_OS_WIN)
1692 targetElems.insert( 0,
"" );
1693 targetElems.insert( 0,
"" );
1698 targetElems << srcElems;
1699 targetElems.removeAll( QStringLiteral(
"." ) );
1703 while ( ( pos = targetElems.indexOf( QLatin1String(
".." ) ) ) > 0 )
1706 targetElems.removeAt( pos - 1 );
1707 targetElems.removeAt( pos - 1 );
1710 #if !defined(Q_OS_WIN)
1712 targetElems.prepend( QString() );
1715 return targetElems.join( QLatin1Char(
'/' ) );
1720 return *sBuildSourcePath();
1725 return *sBuildOutputPath();
1728 #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA)
1729 QString QgsApplication::cfgIntDir()
1731 return *sCfgIntDir();
1737 if ( sGdalSkipList()->contains( driver ) || driver.isEmpty() )
1741 *sGdalSkipList() << driver;
1747 if ( !sGdalSkipList()->contains( driver ) )
1751 int myPos = sGdalSkipList()->indexOf( driver );
1754 sGdalSkipList()->removeAt( myPos );
1761 return *sGdalSkipList();
1765 const QStringList &deferredSkippedGdalDrivers )
1770 QgsSettings settings;
1771 settings.setValue( QStringLiteral(
"gdal/skipDrivers" ),
skippedGdalDrivers.join( QLatin1Char(
',' ) ) );
1778 QgsSettings settings;
1779 QString joinedList, delimiter;
1780 if ( settings.contains( QStringLiteral(
"gdal/skipDrivers" ) ) )
1782 joinedList = settings.value( QStringLiteral(
"gdal/skipDrivers" ), QString() ).toString();
1783 delimiter = QStringLiteral(
"," );
1787 joinedList = settings.value( QStringLiteral(
"gdal/skipList" ), QString() ).toString();
1788 delimiter = QStringLiteral(
" " );
1791 if ( !joinedList.isEmpty() )
1793 myList = joinedList.split( delimiter );
1795 *sGdalSkipList() = myList;
1801 return *sDeferredSkippedGdalDrivers();
1806 sGdalSkipList()->removeDuplicates();
1807 QStringList realDisabledDriverList;
1808 for (
const auto &driverName : *sGdalSkipList() )
1810 if ( !sDeferredSkippedGdalDrivers()->contains( driverName ) )
1811 realDisabledDriverList << driverName;
1813 QString myDriverList = realDisabledDriverList.join(
',' );
1814 QgsDebugMsgLevel( QStringLiteral(
"Gdal Skipped driver list set to:" ), 2 );
1816 CPLSetConfigOption(
"GDAL_SKIP", myDriverList.toUtf8() );
1823 QDir myDir( folder );
1824 if ( !myDir.exists() )
1826 myDir.mkpath( folder );
1832 void QgsApplication::copyPath(
const QString &src,
const QString &dst )
1835 if ( ! dir.exists() )
1838 const auto subDirectories = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot );
1839 for (
const QString &d : subDirectories )
1841 QString dst_path = dst + QDir::separator() + d;
1842 dir.mkpath( dst_path );
1843 copyPath( src + QDir::separator() + d, dst_path );
1846 const auto files = dir.entryList( QDir::Files );
1847 for (
const QString &f : files )
1849 QFile::copy( src + QDir::separator() + f, dst + QDir::separator() + f );
1856 QgsSettings settings;
1858 QVariantMap variables;
1861 settings.beginGroup(
"variables" );
1862 QStringList childKeys = settings.childKeys();
1863 for ( QStringList::const_iterator it = childKeys.constBegin(); it != childKeys.constEnd(); ++it )
1866 variables.insert( name, settings.value( name ) );
1874 QgsSettings settings;
1876 QVariantMap::const_iterator it = variables.constBegin();
1877 settings.beginGroup(
"variables" );
1878 settings.remove(
"" );
1879 for ( ; it != variables.constEnd(); ++it )
1881 settings.setValue( it.key(), it.value() );
1890 QgsSettings settings;
1892 settings.setValue( QStringLiteral(
"variables/" ) + name, value );
1899 QFontMetrics fm( ( QFont() ) );
1900 const double scale = 1.1 * standardSize / 24;
1901 int scaledIconSize =
static_cast< int >( std::floor( std::max(
Qgis::UI_SCALE_FACTOR * fm.height() * scale,
static_cast< double >( standardSize ) ) ) );
1902 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
1903 if ( applyDevicePixelRatio && QApplication::desktop() )
1904 scaledIconSize *= QApplication::desktop()->devicePixelRatio();
1906 if ( applyDevicePixelRatio )
1908 if ( QWidget *activeWindow = QApplication::activeWindow() )
1909 scaledIconSize *= ( activeWindow->screen() ? QApplication::activeWindow()->screen()->devicePixelRatio() : 1 );
1912 return scaledIconSize;
1922 *sTranslation() = translation;
1932 ApplicationMembers *appMembers = members();
1933 if ( appMembers->mNullRepresentation.isNull() )
1935 appMembers->mNullRepresentation = QgsSettings().value( QStringLiteral(
"qgis/nullValue" ), QStringLiteral(
"NULL" ) ).toString();
1937 return appMembers->mNullRepresentation;
1942 ApplicationMembers *appMembers = members();
1956 return members()->mActionScopeRegistry;
1965 QDir myDir( myPamPath );
1966 if ( !myDir.exists() )
1968 myDir.mkpath( myPamPath );
1971 #if defined(Q_OS_WIN)
1972 CPLSetConfigOption(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
1976 int myChangeFlag = 0;
1977 setenv(
"GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
1984 if ( !qgisPrivateDbFile.exists() )
1988 QFile masterFile( qgisMasterDbFileName );
1994 bool isDbFileCopied = masterFile.copy( qgisPrivateDbFile.fileName() );
1996 if ( !isDbFileCopied )
2000 *errorMessage = tr(
"[ERROR] Can not make qgis.db private copy" );
2005 QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
2006 if ( !( perms & QFile::WriteOwner ) )
2008 if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
2012 *errorMessage = tr(
"Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
2026 *errorMessage = tr(
"Could not open qgis.db" );
2031 char *errmsg =
nullptr;
2032 int res = sqlite3_exec( database.get(),
"SELECT srs_id FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2033 if ( res != SQLITE_OK )
2035 sqlite3_free( errmsg );
2038 if ( sqlite3_exec( database.get(),
2039 "DROP INDEX IF EXISTS idx_srsauthid;"
2040 "CREATE TABLE tbl_srs ("
2041 "srs_id INTEGER PRIMARY KEY,"
2042 "description text NOT NULL,"
2043 "projection_acronym text NOT NULL,"
2044 "ellipsoid_acronym NOT NULL,"
2045 "parameters text NOT NULL,"
2047 "auth_name varchar,"
2049 "is_geo integer NOT NULL,"
2050 "deprecated boolean,"
2052 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2056 *errorMessage = tr(
"Creation of missing tbl_srs in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2058 sqlite3_free( errmsg );
2065 res = sqlite3_exec( database.get(),
"SELECT wkt FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2066 if ( res != SQLITE_OK )
2069 sqlite3_free( errmsg );
2070 if ( sqlite3_exec( database.get(),
2071 "DROP INDEX IF EXISTS idx_srsauthid;"
2072 "DROP TABLE IF EXISTS tbl_srs_bak;"
2073 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2074 "CREATE TABLE tbl_srs ("
2075 "srs_id INTEGER PRIMARY KEY,"
2076 "description text NOT NULL,"
2077 "projection_acronym text NOT NULL,"
2078 "ellipsoid_acronym NOT NULL,"
2079 "parameters text NOT NULL,"
2081 "auth_name varchar,"
2083 "is_geo integer NOT NULL,"
2084 "deprecated boolean,"
2086 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2087 "INSERT INTO tbl_srs(srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,auth_name,auth_id,is_geo,deprecated) SELECT srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,'','',is_geo,0 FROM tbl_srs_bak;"
2088 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2092 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2094 sqlite3_free( errmsg );
2100 res = sqlite3_exec( database.get(),
"SELECT acronym FROM tbl_projection LIMIT 0",
nullptr,
nullptr, &errmsg );
2101 if ( res != SQLITE_OK )
2103 sqlite3_free( errmsg );
2106 if ( sqlite3_exec( database.get(),
2107 "CREATE TABLE tbl_projection ("
2108 "acronym varchar(20) NOT NULL PRIMARY KEY,"
2109 "name varchar(255) NOT NULL default '',"
2110 "notes varchar(255) NOT NULL default '',"
2111 "parameters varchar(255) NOT NULL default ''"
2112 ")",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2116 *errorMessage = tr(
"Creation of missing tbl_projection in the private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2118 sqlite3_free( errmsg );
2123 res = sqlite3_exec( database.get(),
"SELECT epsg FROM tbl_srs LIMIT 0",
nullptr,
nullptr, &errmsg );
2124 if ( res == SQLITE_OK )
2127 if ( sqlite3_exec( database.get(),
2128 "DROP INDEX IF EXISTS idx_srsauthid;"
2129 "DROP TABLE IF EXISTS tbl_srs_bak;"
2130 "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
2131 "CREATE TABLE tbl_srs ("
2132 "srs_id INTEGER PRIMARY KEY,"
2133 "description text NOT NULL,"
2134 "projection_acronym text NOT NULL,"
2135 "ellipsoid_acronym NOT NULL,"
2136 "parameters text NOT NULL,"
2138 "auth_name varchar,"
2140 "is_geo integer NOT NULL,"
2141 "deprecated boolean,"
2143 "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
2144 "INSERT INTO tbl_srs(srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,auth_name,auth_id,is_geo,deprecated) SELECT srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,'','',is_geo,0 FROM tbl_srs_bak;"
2145 "DROP TABLE tbl_srs_bak",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2149 *errorMessage = tr(
"Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2151 sqlite3_free( errmsg );
2157 sqlite3_free( errmsg );
2160 if ( sqlite3_exec( database.get(),
"DROP VIEW vw_srs",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2162 QgsDebugMsg( QStringLiteral(
"vw_srs didn't exists in private qgis.db: %1" ).arg( errmsg ) );
2165 if ( sqlite3_exec( database.get(),
2166 "CREATE VIEW vw_srs AS"
2168 " a.description AS description"
2169 ",a.srs_id AS srs_id"
2170 ",a.is_geo AS is_geo"
2171 ",coalesce(b.name,a.projection_acronym) AS name"
2172 ",a.parameters AS parameters"
2173 ",a.auth_name AS auth_name"
2174 ",a.auth_id AS auth_id"
2175 ",a.deprecated AS deprecated"
2177 " LEFT OUTER JOIN tbl_projection b ON a.projection_acronym=b.acronym"
2178 " ORDER BY coalesce(b.name,a.projection_acronym),a.description",
nullptr,
nullptr, &errmsg ) != SQLITE_OK )
2182 *errorMessage = tr(
"Update of view in private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
2184 sqlite3_free( errmsg );
2197 if ( maxThreads < 1 || maxThreads > QThread::idealThreadCount() )
2208 QThreadPool::globalInstance()->setMaxThreadCount(
maxThreads );
2209 QgsDebugMsgLevel( QStringLiteral(
"set QThreadPool max thread count to %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ), 2 );
2214 return members()->mTaskManager;
2219 return members()->mSettingsRegistryCore;
2224 return members()->mColorSchemeRegistry;
2229 return members()->mPaintEffectRegistry;
2234 return members()->mRendererRegistry;
2239 return members()->mRasterRendererRegistry;
2244 return members()->mPointCloudRendererRegistry;
2249 if (
auto *lInstance =
instance() )
2251 if ( !
instance()->mDataItemProviderRegistry )
2255 return lInstance->mDataItemProviderRegistry;
2261 if ( !sDataItemProviderRegistry )
2263 return sDataItemProviderRegistry;
2269 return members()->mCrsRegistry;
2274 return members()->mSvgCache;
2279 return members()->mImageCache;
2284 return members()->mSourceCache;
2289 return members()->mNetworkContentFetcherRegistry;
2294 return members()->mValidityCheckRegistry;
2299 return members()->mSymbolLayerRegistry;
2304 return members()->mCalloutRegistry;
2309 return members()->mLayoutItemRegistry;
2314 return members()->mAnnotationItemRegistry;
2319 return members()->mGpsConnectionRegistry;
2324 return members()->mPluginLayerRegistry;
2329 return members()->mClassificationMethodRegistry;
2334 return members()->mBookmarkManager;
2339 return members()->mTileDownloadManager;
2344 return members()->mStyleModel;
2349 return members()->mMessageLog;
2354 return members()->mProcessingRegistry;
2359 return members()->mConnectionRegistry;
2364 return members()->mPageSizeRegistry;
2369 return members()->mAnnotationRegistry;
2374 return members()->mNumericFormatRegistry;
2379 return members()->mFieldFormatterRegistry;
2384 return members()->m3DRendererRegistry;
2389 return members()->m3DSymbolRegistry;
2394 return members()->mScaleBarRendererRegistry;
2399 return members()->mProjectStorageRegistry;
2404 return members()->mLocalizedDataPathRegistry;
2407 QgsApplication::ApplicationMembers::ApplicationMembers()
2411 mSettingsRegistryCore =
new QgsSettingsRegistryCore();
2417 profiler->
start( tr(
"Setup coordinate reference system registry" ) );
2422 profiler->
start( tr(
"Create connection registry" ) );
2427 profiler->
start( tr(
"Setup task manager" ) );
2432 profiler->
start( tr(
"Setup action scope registry" ) );
2437 profiler->
start( tr(
"Setup numeric formats" ) );
2442 profiler->
start( tr(
"Setup field formats" ) );
2447 profiler->
start( tr(
"Setup SVG cache" ) );
2452 profiler->
start( tr(
"Setup image cache" ) );
2457 profiler->
start( tr(
"Setup source cache" ) );
2462 profiler->
start( tr(
"Setup color scheme registry" ) );
2467 profiler->
start( tr(
"Setup paint effect" ) );
2472 profiler->
start( tr(
"Setup symbol layer registry" ) );
2477 profiler->
start( tr(
"Setup callout registry" ) );
2482 profiler->
start( tr(
"Setup renderer registry" ) );
2487 profiler->
start( tr(
"Setup raster renderer registry" ) );
2492 profiler->
start( tr(
"Setup point cloud renderer registry" ) );
2497 profiler->
start( tr(
"Setup GPS registry" ) );
2502 profiler->
start( tr(
"Setup plugin layer registry" ) );
2507 profiler->
start( tr(
"Setup Processing registry" ) );
2513 profiler->
start( tr(
"Setup layout item registry" ) );
2515 mLayoutItemRegistry->populate();
2519 profiler->
start( tr(
"Setup annotation registry" ) );
2520 mAnnotationRegistry =
new QgsAnnotationRegistry();
2524 profiler->
start( tr(
"Setup annotation item registry" ) );
2526 mAnnotationItemRegistry->populate();
2530 profiler->
start( tr(
"Setup 3D symbol registry" ) );
2535 profiler->
start( tr(
"Setup 3D renderer registry" ) );
2540 profiler->
start( tr(
"Setup project storage registry" ) );
2545 profiler->
start( tr(
"Setup network content cache" ) );
2550 profiler->
start( tr(
"Setup layout check registry" ) );
2555 profiler->
start( tr(
"Setup classification registry" ) );
2560 profiler->
start( tr(
"Setup bookmark manager" ) );
2565 profiler->
start( tr(
"Setup tile download manager" ) );
2570 profiler->
start( tr(
"Setup scalebar registry" ) );
2576 QgsApplication::ApplicationMembers::~ApplicationMembers()
2579 delete mTileDownloadManager;
2580 delete mScaleBarRendererRegistry;
2581 delete mValidityCheckRegistry;
2582 delete mActionScopeRegistry;
2583 delete m3DRendererRegistry;
2584 delete m3DSymbolRegistry;
2585 delete mAnnotationRegistry;
2586 delete mColorSchemeRegistry;
2587 delete mFieldFormatterRegistry;
2588 delete mGpsConnectionRegistry;
2590 delete mPaintEffectRegistry;
2591 delete mPluginLayerRegistry;
2592 delete mProcessingRegistry;
2593 delete mProjectStorageRegistry;
2594 delete mPageSizeRegistry;
2595 delete mAnnotationItemRegistry;
2596 delete mLayoutItemRegistry;
2597 delete mPointCloudRendererRegistry;
2598 delete mRasterRendererRegistry;
2599 delete mRendererRegistry;
2602 delete mSourceCache;
2603 delete mCalloutRegistry;
2604 delete mSymbolLayerRegistry;
2605 delete mTaskManager;
2606 delete mNetworkContentFetcherRegistry;
2607 delete mClassificationMethodRegistry;
2608 delete mNumericFormatRegistry;
2609 delete mBookmarkManager;
2610 delete mConnectionRegistry;
2611 delete mLocalizedDataPathRegistry;
2612 delete mCrsRegistry;
2613 delete mSettingsRegistryCore;
2616 QgsApplication::ApplicationMembers *QgsApplication::members()
2618 if (
auto *lInstance =
instance() )
2620 return lInstance->mApplicationMembers;
2624 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
2625 static QMutex sMemberMutex( QMutex::Recursive );
2627 static QRecursiveMutex sMemberMutex;
2629 QMutexLocker lock( &sMemberMutex );
2630 if ( !sApplicationMembers )
2631 sApplicationMembers =
new ApplicationMembers();
2632 return sApplicationMembers;
static const double UI_SCALE_FACTOR
UI scaling factor.
Keeps track of available 3D renderers.
Registry of available 3D symbol classes.
The action scope registry is an application wide registry that contains a list of available action sc...
Registry of available annotation item types.
Extends QApplication to provide access to QGIS specific resources such as theme paths,...
static QString resolvePkgPath()
Calculate the application pkg path.
static int scaleIconSize(int standardSize, bool applyDevicePixelRatio=false)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
static void restoreGdalDriver(const QString &driver)
Sets the GDAL_SKIP environment variable to exclude the specified driver and then calls GDALDriverMana...
static void setCustomVariables(const QVariantMap &customVariables)
Custom expression variables for this application.
static QString i18nPath()
Returns the path to the translation directory.
static QgsAnnotationItemRegistry * annotationItemRegistry()
Returns the application's annotation item registry, used for annotation item types.
static QString osName()
Returns a string name of the operating system QGIS is running on.
static void registerOgrDrivers()
Register OGR drivers ensuring this only happens once.
static QString sponsorsFilePath()
Returns the path to the sponsors file.
endian_t
Constants for endian-ness.
static QString qgisMasterDatabaseFilePath()
Returns the path to the master qgis.db file.
static void skipGdalDriver(const QString &driver)
Sets the GDAL_SKIP environment variable to include the specified driver and then calls GDALDriverMana...
static QString defaultThemePath()
Returns the path to the default theme directory.
static QgsPageSizeRegistry * pageSizeRegistry()
Returns the application's page size registry, used for managing layout page sizes.
static QgsValidityCheckRegistry * validityCheckRegistry()
Returns the application's validity check registry, used for managing validity checks.
static QgsDataItemProviderRegistry * dataItemProviderRegistry()
Returns the application's data item provider registry, which keeps a list of data item providers that...
static QString userStylePath()
Returns the path to user's style.
static QString platform()
Returns the QGIS platform name, e.g., "desktop" or "server".
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers,...
static QgsConnectionRegistry * connectionRegistry()
Returns the application's connection registry, used for managing saved data provider connections.
static void exitQgis()
deletes provider registry and map layer registry
static void setPluginPath(const QString &pluginPath)
Alters plugin path - used by 3rd party apps.
static QPixmap getThemePixmap(const QString &name, const QColor &foreColor=QColor(), const QColor &backColor=QColor(), int size=16)
Helper to get a theme icon as a pixmap.
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
static QVariantMap customVariables()
Custom expression variables for this application.
static QgsPointCloudRendererRegistry * pointCloudRendererRegistry()
Returns the application's point cloud renderer registry, used for managing point cloud layer 2D rende...
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects.
static QString pluginPath()
Returns the path to the application plugin directory.
static void setUITheme(const QString &themeName)
Set the current UI theme used to style the interface.
static bool createDatabase(QString *errorMessage=nullptr)
initialize qgis.db
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
static void init(QString profileFolder=QString())
This method initializes paths etc for QGIS.
static void setThemeName(const QString &themeName)
Set the active theme to the specified theme.
void customVariablesChanged()
Emitted whenever a custom global variable changes.
static QString buildSourcePath()
Returns path to the source directory. Valid only when running from build directory.
static QString buildOutputPath()
Returns path to the build output directory. Valid only when running from build directory.
bool notify(QObject *receiver, QEvent *event) override
Catch exceptions when sending event to receiver.
static int maxThreads()
Gets maximum concurrent thread count.
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes.
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
static QString reportStyleSheet(QgsApplication::StyleSheetType styleSheetType=QgsApplication::StyleSheetType::Qt)
Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet...
static QString pkgDataPath()
Returns the common root path of all application data directories.
static QgsScaleBarRendererRegistry * scaleBarRendererRegistry()
Gets the registry of available scalebar renderers.
static QgsLayoutItemRegistry * layoutItemRegistry()
Returns the application's layout item registry, used for layout item types.
static void setFileOpenEventReceiver(QObject *receiver)
Sets the FileOpen event receiver.
static QgsSymbolLayerRegistry * symbolLayerRegistry()
Returns the application's symbol layer registry, used for managing symbol layers.
static QgsRasterRendererRegistry * rasterRendererRegistry()
Returns the application's raster renderer registry, used for managing raster layer renderers.
static void applyGdalSkippedDrivers()
Apply the skipped drivers list to gdal.
static void setMaxThreads(int maxThreads)
Set maximum concurrent thread count.
static QRegExp shortNameRegExp()
Returns the short name regular expression for line edit validator.
static QgsNumericFormatRegistry * numericFormatRegistry()
Gets the registry of available numeric formats.
static QgsNetworkContentFetcherRegistry * networkContentFetcherRegistry()
Returns the application's network content registry used for fetching temporary files during QGIS sess...
static QgsProjectStorageRegistry * projectStorageRegistry()
Returns registry of available project storage implementations.
static QString licenceFilePath()
Returns the path to the licence file.
static QString libexecPath()
Returns the path with utility executables (help viewer, crssync, ...)
static QStringList skippedGdalDrivers()
Returns the list of gdal drivers that should be skipped (based on GDAL_SKIP environment variable)
StyleSheetType
The StyleSheetType enum represents the stylesheet type that a widget supports.
static QString translatorsFilePath()
Returns the path to the sponsors file.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static void setNullRepresentation(const QString &nullRepresentation)
This string is used to represent the value NULL throughout QGIS.
static QgsGpsConnectionRegistry * gpsConnectionRegistry()
Returns the application's GPS connection registry, used for managing GPS connections.
static QString locale()
Returns the QGIS locale.
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images.
static QStringList svgPaths()
Returns the paths to svg directories.
static void initQgis()
loads providers
static QString showSettings()
Convenience function to get a summary of the paths used in this application instance useful for debug...
bool event(QEvent *event) override
Watch for QFileOpenEvent.
static void setPkgDataPath(const QString &pkgDataPath)
Alters pkg data path - used by 3rd party apps.
static QString absolutePathToRelativePath(const QString &apath, const QString &targetPath)
Converts absolute path to path relative to target.
static QgsRuntimeProfiler * profiler()
Returns the application runtime profiler.
~QgsApplication() override
static QgsLocalizedDataPathRegistry * localizedDataPathRegistry()
Returns the registry of data repositories These are used as paths for basemaps, logos,...
static const char * QGIS_APPLICATION_NAME
static QgsTileDownloadManager * tileDownloadManager()
Returns the application's tile download manager, used for download of map tiles when rendering.
static const char * QGIS_ORGANIZATION_DOMAIN
static QMap< QString, QString > systemEnvVars()
Returns the system environment variables passed to application.
static void setAuthDatabaseDirPath(const QString &authDbDirPath)
Alters authentication data base directory path - used by 3rd party apps.
static QString prefixPath()
Returns the path to the application prefix directory.
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
static QgsMessageLog * messageLog()
Returns the application's message log.
void preNotify(QObject *receiver, QEvent *event, bool *done)
static bool createThemeFolder()
Create the users theme folder.
static QString metadataPath()
Returns the path to the metadata directory.
static QgsActionScopeRegistry * actionScopeRegistry()
Returns the action scope registry.
static QgsCoordinateReferenceSystemRegistry * coordinateReferenceSystemRegistry()
Returns the application's coordinate reference system (CRS) registry, which handles known CRS definit...
static const QgsSettingsEntryBool settingsLocaleOverrideFlag
Settings entry locale override flag.
static const char * QGIS_ORGANIZATION_NAME
static QString contributorsFilePath()
Returns the path to the contributors file.
static const QgsSettingsEntryStringList settingsSearchPathsForSVG
Settings entry search path for SVG.
void collectTranslatableObjects(QgsTranslationContext *translationContext)
Emits the signal to collect all the strings of .qgs to be included in ts file.
static QgsSourceCache * sourceCache()
Returns the application's source cache, used for caching embedded and remote source strings as local ...
static QgsTaskManager * taskManager()
Returns the application's task manager, used for managing application wide background task handling.
static QgsAnnotationRegistry * annotationRegistry()
Returns the application's annotation registry, used for managing annotation types.
static QgsPluginLayerRegistry * pluginLayerRegistry()
Returns the application's plugin layer registry, used for managing plugin layer types.
static QgsClassificationMethodRegistry * classificationMethodRegistry()
Returns the application's classification methods registry, used in graduated renderer.
static QStringList deferredSkippedGdalDrivers()
Returns the list of gdal drivers that have been disabled in the current session, and thus,...
static QString defaultStylePath()
Returns the path to default style (works as a starting point).
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
static QString qmlImportPath()
Returns the path where QML components are installed for QGIS Quick library.
Cursor
The Cursor enum defines constants for QGIS custom cursors.
@ CrossHair
Precisely identify a point on the canvas.
@ Identify
Identify: obtain information about the object.
@ Select
Select a rectangle.
@ CapturePoint
Select and capture a point or a feature.
@ Sampler
Color/Value picker.
static QString qgisAuthDatabaseFilePath()
Returns the path to the user authentication database file: qgis-auth.db.
static QString authorsFilePath()
Returns the path to the authors file.
static QgsBookmarkManager * bookmarkManager()
Returns the application's bookmark manager, used for storing installation-wide bookmarks.
static QString qgisUserDatabaseFilePath()
Returns the path to the user qgis.db file.
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
static QString activeThemePath()
Returns the path to the currently active theme directory.
static QString defaultThemesFolder()
Returns the path to default themes folder from install (works as a starting point).
static void setSkippedGdalDrivers(const QStringList &skippedGdalDrivers, const QStringList &deferredSkippedGdalDrivers)
Sets the list of gdal drivers that should be disabled (skippedGdalDrivers), but excludes for now the ...
static QgsRendererRegistry * rendererRegistry()
Returns the application's renderer registry, used for managing vector layer renderers.
static void setTranslation(const QString &translation)
Set translation.
static QgsCalloutRegistry * calloutRegistry()
Returns the application's callout registry, used for managing callout types.
static void setPrefixPath(const QString &prefixPath, bool useDefaultPaths=false)
Alters prefix path - used by 3rd party apps.
static QgsStyleModel * defaultStyleModel()
Returns a shared QgsStyleModel containing the default style library (see QgsStyle::defaultStyle()).
static QString relativePathToAbsolutePath(const QString &rpath, const QString &targetPath)
Converts path relative to target to an absolute path.
static void setSvgPaths(const QStringList &svgPaths)
Sets the paths to svg directories and invalidates the svg path list cache.
static QString developersMapFilePath()
Returns the path to the developers map file.
static endian_t endian()
Returns whether this machine uses big or little endian.
int maxConcurrentConnectionsPerPool() const
The maximum number of concurrent connections per connections pool.
static void setCustomVariable(const QString &name, const QVariant &value)
Set a single custom expression variable.
void requestForTranslatableObjects(QgsTranslationContext *translationContext)
Emitted when project strings which require translation are being collected for inclusion in a ....
static QString iconsPath()
Returns the path to the icons image directory.
static Qgs3DSymbolRegistry * symbol3DRegistry()
Returns registry of available 3D symbols.
static QHash< QString, QString > uiThemes()
All themes found in ~/.qgis3/themes folder.
static QString splashPath()
Returns the path to the splash screen image directory.
static QString donorsFilePath()
Returns the path to the donors file.
static QString themeName()
Set the active theme to the specified theme.
void nullRepresentationChanged()
This string is used to represent the value NULL throughout QGIS.
static QString srsDatabaseFilePath()
Returns the path to the srs.db file.
static QString userThemesFolder()
Returns the path to user's themes folder.
static void registerGdalDriversFromSettings()
Register gdal drivers, excluding the ones mentioned in "gdal/skipList" setting.
static Qgs3DRendererRegistry * renderer3DRegistry()
Returns registry of available 3D renderers.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
static void setDefaultSvgPaths(const QStringList &pathList)
Alters default svg paths - used by 3rd party apps.
static QString libraryPath()
Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries.
static QStringList layoutTemplatePaths()
Returns the paths to layout template directories.
static QString userFullName()
Returns the user's operating system login account full display name.
static QgsSettingsRegistryCore * settingsRegistryCore()
Returns the application's settings registry, used for managing application settings.
static QString serverResourcesPath()
Returns the path to the server resources directory.
static QString appIconPath()
Gets application icon.
static QString userLoginName()
Returns the user's operating system login account name.
static const QgsSettingsEntryString settingsLocaleUserLocale
Settings entry locale user locale.
Singleton offering an interface to manage the authentication configuration database and to utilize co...
bool init(const QString &pluginPath=QString(), const QString &authDatabasePath=QString())
init initialize QCA, prioritize qca-ossl plugin and optionally set up the authentication database
static QgsAuthManager * instance()
Enforce singleton pattern.
Manages storage of a set of bookmarks.
void initialize(const QString &filePath)
Initializes the bookmark manager.
Registry of available callout classes.
This class manages all known classification methods.
Registry of color schemes.
void addDefaultSchemes()
Adds all default color schemes to this color scheme.
void initStyleScheme()
Initializes the default random style color scheme for the user.
A registry for saved data provider connections, allowing retrieval of saved connections by name and p...
A registry for known coordinate reference system (CRS) definitions, including any user-defined CRSes.
static void invalidateCache(bool disableCache=false)
Clears the internal cache used to initialize QgsCoordinateReferenceSystem objects.
This class keeps a list of data item providers that may add items to the browser tree.
static void invalidateCache(bool disableCache=false)
Clears the internal cache used.
Defines a QGIS exception class.
static void cleanRegisteredFunctions()
Deletes all registered functions whose ownership have been transferred to the expression engine.
A class to register / unregister existing GPS connections such that the information is available to a...
A cache for images derived from raster files.
Registry of available layout item types.
static const QgsSettingsEntryStringList settingsSearchPathForTemplates
Settings entry search path for templates.
A registry class to hold localized data paths which can be used for basemaps, logos,...
Temporarily blocks the application QgsMessageLog (see QgsApplication::messageLog()) from emitting the...
Interface for logging messages from QGIS in GUI independent way.
static QgsNetworkAccessManager * instance(Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
Returns a pointer to the active QgsNetworkAccessManager for the current thread.
Registry for temporary fetched files.
A registry for known page sizes.
Registry of available paint effects.
A registry of plugin layers types.
Registry of 2D renderers for point clouds.
Registry for various processing components, including providers, algorithms and various parameters an...
static QStringList searchPaths()
Returns the current list of Proj file search paths.
Registry of storage backends that QgsProject may use.
static QgsProject * instance()
Returns the QgsProject singleton instance.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Registry for raster renderers.
The QgsReadWriteLocker class is a convenience class that simplifies locking and unlocking QReadWriteL...
void changeMode(Mode mode)
Change the mode of the lock to mode.
Provides a method of recording run time profiles of operations, allowing easy recording of their over...
void end(const QString &group="startup")
End the current profile event.
void start(const QString &name, const QString &group="startup")
Start a profile event with the given name.
The QgsScaleBarRendererRegistry manages registered scalebar renderers.
Scoped object for logging of the runtime for a single operation or group of operations.
A cache for source strings that returns a local file path containing the source content.
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
static void cleanDefaultStyle()
Deletes the default style. Only to be used by QgsApplication::exitQgis()
static QgsStyle * defaultStyle()
Returns default application-wide style.
A cache for images / pictures derived from SVG files.
QImage svgAsImage(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool &fitsInCache, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >())
Returns an SVG drawing as a QImage.
QByteArray svgContent(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >(), bool *isMissingImage=nullptr)
Gets the SVG content corresponding to the given path.
Registry of available symbol layer classes.
static QColor decodeColor(const QString &str)
Task manager for managing a set of long-running QgsTask tasks.
Tile download manager handles downloads of map tiles for the purpose of map rendering.
Used for the collecting of strings from projects for translation and creation of ts files.
User profile manager is used to manager list, and manage user profiles on the users machine.
QgsUserProfile * getProfile(const QString &defaultProfile="default", bool createNew=true, bool initSettings=true)
Returns the profile from the given root profile location.
static QString resolveProfilesFolder(const QString &basePath=QString())
Resolves the profiles folder for the given path.
User profile contains information about the user profile folders on the machine.
const QString folder() const
The base folder for the user profile.
This class keeps a list of QgsAbstractValidityCheck checks which can be used when performing validity...
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
int open(const QString &path)
Opens the database at the specified file path.
QMap< QString, QString > QgsStringMap
#define CONN_POOL_MAX_CONCURRENT_CONNS
QObject * ABISYM(QgsApplication::mFileOpenEventReceiver)
Q_GLOBAL_STATIC_WITH_ARGS(PalPropertyList, palHiddenProperties,({ QgsPalLayerSettings::PositionX, QgsPalLayerSettings::PositionY, QgsPalLayerSettings::Show, QgsPalLayerSettings::LabelRotation, QgsPalLayerSettings::Family, QgsPalLayerSettings::FontStyle, QgsPalLayerSettings::Size, QgsPalLayerSettings::Bold, QgsPalLayerSettings::Italic, QgsPalLayerSettings::Underline, QgsPalLayerSettings::Color, QgsPalLayerSettings::Strikeout, QgsPalLayerSettings::MultiLineAlignment, QgsPalLayerSettings::BufferSize, QgsPalLayerSettings::BufferDraw, QgsPalLayerSettings::BufferColor, QgsPalLayerSettings::LabelDistance, QgsPalLayerSettings::Hali, QgsPalLayerSettings::Vali, QgsPalLayerSettings::ScaleVisibility, QgsPalLayerSettings::MinScale, QgsPalLayerSettings::MaxScale, QgsPalLayerSettings::AlwaysShow, QgsPalLayerSettings::CalloutDraw, QgsPalLayerSettings::LabelAllParts })) QgsAuxiliaryLayer
Q_GLOBAL_STATIC(QReadWriteLock, sDefinitionCacheLock)
#define QgsDebugMsgLevel(str, level)