00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "qgsapplication.h"
00017 #include "qgslogger.h"
00018 #include "qgsmaplayerregistry.h"
00019 #include "qgsproviderregistry.h"
00020 #include "qgsexception.h"
00021 #include "qgsgeometry.h"
00022
00023 #include <QDir>
00024 #include <QFile>
00025 #include <QFileOpenEvent>
00026 #include <QMessageBox>
00027 #include <QPalette>
00028 #include <QSettings>
00029
00030 #ifndef Q_WS_WIN
00031 #include <netinet/in.h>
00032 #else
00033 #include <winsock.h>
00034 #endif
00035
00036 #include "qgsconfig.h"
00037
00038 #include <gdal.h>
00039 #include <ogr_api.h>
00040 #include <cpl_conv.h>
00041
00042 QObject * ABISYM( QgsApplication::mFileOpenEventReceiver );
00043 QStringList ABISYM( QgsApplication::mFileOpenEventList );
00044 QString ABISYM( QgsApplication::mPrefixPath );
00045 QString ABISYM( QgsApplication::mPluginPath );
00046 QString ABISYM( QgsApplication::mPkgDataPath );
00047 QString ABISYM( QgsApplication::mLibraryPath );
00048 QString ABISYM( QgsApplication::mLibexecPath );
00049 QString ABISYM( QgsApplication::mThemeName );
00050 QStringList ABISYM( QgsApplication::mDefaultSvgPaths );
00051 QString ABISYM( QgsApplication::mConfigPath );
00052 bool ABISYM( QgsApplication::mRunningFromBuildDir ) = false;
00053 QString ABISYM( QgsApplication::mBuildSourcePath );
00054 #ifdef _MSC_VER
00055 QString ABISYM( QgsApplication::mCfgIntDir );
00056 #endif
00057 QString ABISYM( QgsApplication::mBuildOutputPath );
00058 QStringList ABISYM( QgsApplication::mGdalSkipList );
00059
00073 QgsApplication::QgsApplication( int & argc, char ** argv, bool GUIenabled, QString customConfigPath )
00074 : QApplication( argc, argv, GUIenabled )
00075 {
00076 init( customConfigPath );
00077 }
00078 void QgsApplication::init( QString customConfigPath )
00079 {
00080 if ( customConfigPath.isEmpty() )
00081 {
00082 customConfigPath = QDir::homePath() + QString( "/.qgis/" );
00083 }
00084 qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );
00085
00086
00087 QDir appDir( applicationDirPath() );
00088 #ifndef _MSC_VER
00089 #define SOURCE_PATH "source_path.txt"
00090 #else
00091 #define SOURCE_PATH "../source_path.txt"
00092 #endif
00093 if ( appDir.exists( SOURCE_PATH ) )
00094 {
00095 QFile f( applicationDirPath() + "/" + SOURCE_PATH );
00096 if ( f.open( QIODevice::ReadOnly ) )
00097 {
00098 ABISYM( mRunningFromBuildDir ) = true;
00099 ABISYM( mBuildSourcePath ) = f.readAll();
00100 #if _MSC_VER
00101 QStringList elems = applicationDirPath().split( "/", QString::SkipEmptyParts );
00102 ABISYM( mCfgIntDir ) = elems.last();
00103 ABISYM( mBuildOutputPath ) = applicationDirPath() + "/../..";
00104 #elif defined(Q_WS_MACX)
00105 ABISYM( mBuildOutputPath ) = applicationDirPath();
00106 #else
00107 ABISYM( mBuildOutputPath ) = applicationDirPath() + "/..";
00108 #endif
00109 qDebug( "Running from build directory!" );
00110 qDebug( "- source directory: %s", ABISYM( mBuildSourcePath ).toAscii().data() );
00111 qDebug( "- output directory of the build: %s", ABISYM( mBuildOutputPath ).toAscii().data() );
00112 }
00113 }
00114
00115 if ( ABISYM( mRunningFromBuildDir ) )
00116 {
00117
00118 ABISYM( mPrefixPath ) = QString();
00119 #ifdef _MSC_VER
00120 setPluginPath( ABISYM( mBuildOutputPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) + "/" + ABISYM( mCfgIntDir ) );
00121 #else
00122 setPluginPath( ABISYM( mBuildOutputPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) );
00123 #endif
00124 setPkgDataPath( ABISYM( mBuildSourcePath ) );
00125 ABISYM( mLibraryPath ) = ABISYM( mBuildOutputPath ) + "/" + QGIS_LIB_SUBDIR + "/";
00126 ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) + "/" + QGIS_LIBEXEC_SUBDIR + "/";
00127 }
00128 else
00129 {
00130 #if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32)
00131 setPrefixPath( applicationDirPath(), true );
00132 #else
00133 QDir myDir( applicationDirPath() );
00134 myDir.cdUp();
00135 QString myPrefix = myDir.absolutePath();
00136 setPrefixPath( myPrefix, true );
00137 #endif
00138 }
00139
00140 if ( !customConfigPath.isEmpty() )
00141 {
00142 ABISYM( mConfigPath ) = customConfigPath + "/";
00143 }
00144
00145 ABISYM( mDefaultSvgPaths ) << qgisSettingsDirPath() + QString( "svg/" );
00146
00147
00148
00149
00150 QString myPamPath = qgisSettingsDirPath() + QString( "gdal_pam/" );
00151 QDir myDir( myPamPath );
00152 if ( !myDir.exists() )
00153 {
00154 myDir.mkpath( myPamPath );
00155 }
00156
00157
00158 #if defined(Q_WS_WIN32) || defined(WIN32)
00159 CPLSetConfigOption( "GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
00160 #else
00161
00162
00163 int myChangeFlag = 0;
00164 setenv( "GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag );
00165 #endif
00166 }
00167
00168 QgsApplication::~QgsApplication()
00169 {
00170 }
00171
00172 bool QgsApplication::event( QEvent * event )
00173 {
00174 bool done = false;
00175 if ( event->type() == QEvent::FileOpen )
00176 {
00177
00178 if ( ABISYM( mFileOpenEventReceiver ) )
00179 {
00180
00181 done = notify( ABISYM( mFileOpenEventReceiver ), event );
00182 }
00183 else
00184 {
00185
00186
00187
00188 ABISYM( mFileOpenEventList ).append( static_cast<QFileOpenEvent *>( event )->file() );
00189 done = true;
00190 }
00191 }
00192 else
00193 {
00194
00195 done = QApplication::event( event );
00196 }
00197 return done;
00198 }
00199
00200 bool QgsApplication::notify( QObject * receiver, QEvent * event )
00201 {
00202 bool done = false;
00203 emit preNotify( receiver, event, &done );
00204
00205 if ( done )
00206 return true;
00207
00208
00209 done = true;
00210 try
00211 {
00212 done = QApplication::notify( receiver, event );
00213 }
00214 catch ( QgsException & e )
00215 {
00216 QMessageBox::critical( activeWindow(), tr( "Exception" ), e.what() );
00217 }
00218 catch ( std::exception & e )
00219 {
00220 QMessageBox::critical( activeWindow(), tr( "Exception" ), e.what() );
00221 }
00222 catch ( ... )
00223 {
00224 QMessageBox::critical( activeWindow(), tr( "Exception" ), tr( "unknown exception" ) );
00225 }
00226
00227 return done;
00228 }
00229
00230 void QgsApplication::setFileOpenEventReceiver( QObject * receiver )
00231 {
00232
00233 ABISYM( mFileOpenEventReceiver ) = receiver;
00234
00235 if ( ABISYM( mFileOpenEventList ).count() > 0 )
00236 {
00237 QStringListIterator i( ABISYM( mFileOpenEventList ) );
00238 while ( i.hasNext() )
00239 {
00240 QFileOpenEvent foe( i.next() );
00241 QgsApplication::sendEvent( ABISYM( mFileOpenEventReceiver ), &foe );
00242 }
00243 ABISYM( mFileOpenEventList ).clear();
00244 }
00245 }
00246
00247 void QgsApplication::setPrefixPath( const QString thePrefixPath, bool useDefaultPaths )
00248 {
00249 ABISYM( mPrefixPath ) = thePrefixPath;
00250 #if defined(_MSC_VER)
00251 if ( ABISYM( mPrefixPath ).endsWith( "/bin" ) )
00252 {
00253 ABISYM( mPrefixPath ).chop( 4 );
00254 }
00255 #endif
00256 if ( useDefaultPaths )
00257 {
00258 setPluginPath( ABISYM( mPrefixPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) );
00259 setPkgDataPath( ABISYM( mPrefixPath ) + "/" + QString( QGIS_DATA_SUBDIR ) );
00260 }
00261 ABISYM( mLibraryPath ) = ABISYM( mPrefixPath ) + "/" + QGIS_LIB_SUBDIR + "/";
00262 ABISYM( mLibexecPath ) = ABISYM( mPrefixPath ) + "/" + QGIS_LIBEXEC_SUBDIR + "/";
00263 }
00264
00265 void QgsApplication::setPluginPath( const QString thePluginPath )
00266 {
00267 ABISYM( mPluginPath ) = thePluginPath;
00268 }
00269
00270 void QgsApplication::setPkgDataPath( const QString thePkgDataPath )
00271 {
00272 ABISYM( mPkgDataPath ) = thePkgDataPath;
00273 QString mySvgPath = thePkgDataPath + ( ABISYM( mRunningFromBuildDir ) ? "/images/svg/" : "/svg/" );
00274
00275 if ( !ABISYM( mDefaultSvgPaths ).contains( mySvgPath ) )
00276 ABISYM( mDefaultSvgPaths ) << mySvgPath;
00277 }
00278
00279 void QgsApplication::setDefaultSvgPaths( const QStringList& pathList )
00280 {
00281 ABISYM( mDefaultSvgPaths ) = pathList;
00282 }
00283
00284 const QString QgsApplication::prefixPath()
00285 {
00286 if ( ABISYM( mRunningFromBuildDir ) )
00287 {
00288 qWarning( "!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
00289 }
00290
00291 return ABISYM( mPrefixPath );
00292 }
00293 const QString QgsApplication::pluginPath()
00294 {
00295 return ABISYM( mPluginPath );
00296 }
00297 const QString QgsApplication::pkgDataPath()
00298 {
00299 return ABISYM( mPkgDataPath );
00300 }
00301 const QString QgsApplication::defaultThemePath()
00302 {
00303 return ":/images/themes/default/";
00304 }
00305 const QString QgsApplication::activeThemePath()
00306 {
00307 return ":/images/themes/" + themeName() + "/";
00308 }
00309
00310
00311 QString QgsApplication::iconPath( QString iconFile )
00312 {
00313
00314 QString path = activeThemePath();
00315 if ( QFile::exists( path + iconFile ) )
00316 return path + iconFile;
00317
00318
00319 return defaultThemePath() + iconFile;
00320 }
00321
00325 void QgsApplication::setThemeName( const QString theThemeName )
00326 {
00327 QString myPath = ":/images/themes/" + theThemeName + "/";
00328
00329 if ( QFile::exists( myPath ) )
00330 {
00331 ABISYM( mThemeName ) = theThemeName;
00332 }
00333 else
00334 {
00335 ABISYM( mThemeName ) = "default";
00336 }
00337 }
00341 const QString QgsApplication::themeName()
00342 {
00343 return ABISYM( mThemeName );
00344 }
00348 const QString QgsApplication::authorsFilePath()
00349 {
00350 return ABISYM( mPkgDataPath ) + QString( "/doc/AUTHORS" );
00351 }
00355 const QString QgsApplication::contributorsFilePath()
00356 {
00357 return ABISYM( mPkgDataPath ) + QString( "/doc/CONTRIBUTORS" );
00358 }
00362 const QString QgsApplication::sponsorsFilePath()
00363 {
00364 return ABISYM( mPkgDataPath ) + QString( "/doc/SPONSORS" );
00365 }
00366
00370 const QString QgsApplication::donorsFilePath()
00371 {
00372 return ABISYM( mPkgDataPath ) + QString( "/doc/DONORS" );
00373 }
00374
00379 const QString QgsApplication::translatorsFilePath()
00380 {
00381 return ABISYM( mPkgDataPath ) + QString( "/doc/TRANSLATORS" );
00382 }
00383
00384 const QString QgsApplication::developerPath()
00385 {
00386 return QString();
00387 }
00388
00392 const QString QgsApplication::helpAppPath()
00393 {
00394 QString helpAppPath;
00395 #ifdef Q_OS_MACX
00396 helpAppPath = applicationDirPath() + "/bin/qgis_help.app/Contents/MacOS";
00397 #else
00398 helpAppPath = libexecPath();
00399 #endif
00400 helpAppPath += "/qgis_help";
00401 return helpAppPath;
00402 }
00406 const QString QgsApplication::i18nPath()
00407 {
00408 if ( ABISYM( mRunningFromBuildDir ) )
00409 return ABISYM( mBuildOutputPath ) + QString( "/i18n" );
00410 else
00411 return ABISYM( mPkgDataPath ) + QString( "/i18n/" );
00412 }
00413
00417 const QString QgsApplication::qgisMasterDbFilePath()
00418 {
00419 return ABISYM( mPkgDataPath ) + QString( "/resources/qgis.db" );
00420 }
00421
00425 const QString QgsApplication::qgisSettingsDirPath()
00426 {
00427 return ABISYM( mConfigPath );
00428 }
00429
00433 const QString QgsApplication::qgisUserDbFilePath()
00434 {
00435 return qgisSettingsDirPath() + QString( "qgis.db" );
00436 }
00437
00441 const QString QgsApplication::splashPath()
00442 {
00443 return QString( ":/images/splash/" );
00444 }
00445
00449 const QString QgsApplication::iconsPath()
00450 {
00451 return ABISYM( mPkgDataPath ) + QString( "/images/icons/" );
00452 }
00456 const QString QgsApplication::srsDbFilePath()
00457 {
00458 if ( ABISYM( mRunningFromBuildDir ) )
00459 {
00460 QString tempCopy = QDir::tempPath() + "/srs.db";
00461
00462 if ( !QFile( tempCopy ).exists() )
00463 {
00464 QFile f( ABISYM( mPkgDataPath ) + "/resources/srs.db" );
00465 if ( !f.copy( tempCopy ) )
00466 {
00467 qFatal( "Could not create temporary copy" );
00468 }
00469 }
00470
00471 return tempCopy;
00472 }
00473 else
00474 {
00475 return ABISYM( mPkgDataPath ) + QString( "/resources/srs.db" );
00476 }
00477 }
00478
00482 const QStringList QgsApplication::svgPaths()
00483 {
00484
00485
00486 QSettings settings;
00487 QStringList myPathList;
00488 QString myPaths = settings.value( "svg/searchPathsForSVG", "" ).toString();
00489 if ( !myPaths.isEmpty() )
00490 {
00491 myPathList = myPaths.split( "|" );
00492 }
00493
00494 myPathList << ABISYM( mDefaultSvgPaths );
00495 return myPathList;
00496 }
00497
00501 const QString QgsApplication::svgPath()
00502 {
00503 QString svgSubDir( ABISYM( mRunningFromBuildDir ) ? "/images/svg/" : "/svg/" );
00504 return ABISYM( mPkgDataPath ) + svgSubDir;
00505 }
00506
00507 const QString QgsApplication::userStyleV2Path()
00508 {
00509 return qgisSettingsDirPath() + QString( "symbology-ng-style.xml" );
00510 }
00511
00512 const QString QgsApplication::defaultStyleV2Path()
00513 {
00514 return ABISYM( mPkgDataPath ) + QString( "/resources/symbology-ng-style.xml" );
00515 }
00516
00517 const QString QgsApplication::libraryPath()
00518 {
00519 return ABISYM( mLibraryPath );
00520 }
00521
00522 const QString QgsApplication::libexecPath()
00523 {
00524 return ABISYM( mLibexecPath );
00525 }
00526
00527 QgsApplication::endian_t QgsApplication::endian()
00528 {
00529 return ( htonl( 1 ) == 1 ) ? XDR : NDR ;
00530 }
00531
00532 void QgsApplication::initQgis()
00533 {
00534
00535 QgsProviderRegistry::instance( pluginPath() );
00536
00537
00538 QgsMapLayerRegistry::instance();
00539 }
00540
00541 void QgsApplication::exitQgis()
00542 {
00543 delete QgsMapLayerRegistry::instance();
00544 delete QgsProviderRegistry::instance();
00545 }
00546
00547 QString QgsApplication::showSettings()
00548 {
00549 QString myState = tr( "Application state:\n"
00550 "Prefix:\t\t%1\n"
00551 "Plugin Path:\t\t%2\n"
00552 "Package Data Path:\t%3\n"
00553 "Active Theme Name:\t%4\n"
00554 "Active Theme Path:\t%5\n"
00555 "Default Theme Path:\t%6\n"
00556 "SVG Search Paths:\t%7\n"
00557 "User DB Path:\t%8\n" )
00558 .arg( prefixPath() )
00559 .arg( pluginPath() )
00560 .arg( pkgDataPath() )
00561 .arg( themeName() )
00562 .arg( activeThemePath() )
00563 .arg( defaultThemePath() )
00564 .arg( svgPaths().join( tr( "\n\t\t", "match indentation of application state" ) ) )
00565 .arg( qgisMasterDbFilePath() );
00566 return myState;
00567 }
00568
00569 QString QgsApplication::reportStyleSheet()
00570 {
00571
00572
00573
00574
00575 QColor myColor1 = palette().highlight().color();
00576 QColor myColor2 = myColor1;
00577 myColor2 = myColor2.lighter( 110 );
00578 QString myStyle;
00579 myStyle = "p.glossy{ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
00580 "stop: 0 " + myColor1.name() + ","
00581 "stop: 0.1 " + myColor2.name() + ","
00582 "stop: 0.5 " + myColor1.name() + ","
00583 "stop: 0.9 " + myColor2.name() + ","
00584 "stop: 1 " + myColor1.name() + ");"
00585 "color: white;"
00586 "padding-left: 4px;"
00587 "padding-top: 20px;"
00588 "padding-bottom: 8px;"
00589 "border: 1px solid #6c6c6c;"
00590 "}"
00591 "th.glossy{ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
00592 "stop: 0 " + myColor1.name() + ","
00593 "stop: 0.1 " + myColor2.name() + ","
00594 "stop: 0.5 " + myColor1.name() + ","
00595 "stop: 0.9 " + myColor2.name() + ","
00596 "stop: 1 " + myColor1.name() + ");"
00597 "color: white;"
00598 "border: 1px solid #6c6c6c;"
00599 "}"
00600 ".overview{ font: 1.82em; font-weight: bold;}"
00601 "body{ background: white;"
00602 " color: black;"
00603 " font-family: arial,sans-serif;"
00604 "}"
00605 "h1{ background-color: #F6F6F6;"
00606 " color: #8FB171; "
00607 " font-size: x-large; "
00608 " font-weight: normal;"
00609 " font-family: luxi serif, georgia, times new roman, times, serif;"
00610 " background: none;"
00611 " padding: 0.75em 0 0;"
00612 " margin: 0;"
00613 " line-height: 3em;"
00614 "}"
00615 "h2{ background-color: #F6F6F6;"
00616 " color: #8FB171; "
00617 " font-size: medium; "
00618 " font-weight: normal;"
00619 " font-family: luxi serif, georgia, times new roman, times, serif;"
00620 " background: none;"
00621 " padding: 0.75em 0 0;"
00622 " margin: 0;"
00623 " line-height: 1.1em;"
00624 "}"
00625 "h3{ background-color: #F6F6F6;"
00626 " color: #729FCF;"
00627 " font-family: luxi serif, georgia, times new roman, times, serif;"
00628 " font-weight: bold;"
00629 " font-size: large;"
00630 " text-align: right;"
00631 " border-bottom: 5px solid #DCEB5C;"
00632 "}"
00633 "h4{ background-color: #F6F6F6;"
00634 " color: #729FCF;"
00635 " font-family: luxi serif, georgia, times new roman, times, serif;"
00636 " font-weight: bold;"
00637 " font-size: medium;"
00638 " text-align: right;"
00639 "}"
00640 "h5{ background-color: #F6F6F6;"
00641 " color: #729FCF;"
00642 " font-family: luxi serif, georgia, times new roman, times, serif;"
00643 " font-weight: bold;"
00644 " font-size: small;"
00645 " text-align: right;"
00646 "}"
00647 "a{ color: #729FCF;"
00648 " font-family: arial,sans-serif;"
00649 " font-size: small;"
00650 "}"
00651 "label{ background-color: #FFFFCC;"
00652 " border: 1px solid black;"
00653 " margin: 1px;"
00654 " padding: 0px 3px; "
00655 " font-size: small;"
00656 "}";
00657 return myStyle;
00658 }
00659
00660 void QgsApplication::registerOgrDrivers()
00661 {
00662 if ( 0 >= OGRGetDriverCount() )
00663 {
00664 OGRRegisterAll();
00665 }
00666 }
00667
00668 QString QgsApplication::absolutePathToRelativePath( QString aPath, QString targetPath )
00669 {
00670 #if defined( Q_OS_WIN )
00671 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
00672
00673 aPath.replace( "\\", "/" );
00674 if ( aPath.startsWith( "//" ) )
00675 {
00676
00677 aPath = "\\\\" + aPath.mid( 2 );
00678 }
00679
00680 targetPath.replace( "\\", "/" );
00681 if ( targetPath.startsWith( "//" ) )
00682 {
00683
00684 targetPath = "\\\\" + targetPath.mid( 2 );
00685 }
00686 #else
00687 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
00688 #endif
00689
00690 QStringList targetElems = targetPath.split( "/", QString::SkipEmptyParts );
00691 QStringList aPathElems = aPath.split( "/", QString::SkipEmptyParts );
00692
00693 targetElems.removeAll( "." );
00694 aPathElems.removeAll( "." );
00695
00696
00697 int n = 0;
00698 while ( aPathElems.size() > 0 &&
00699 targetElems.size() > 0 &&
00700 aPathElems[0].compare( targetElems[0], cs ) == 0 )
00701 {
00702 aPathElems.removeFirst();
00703 targetElems.removeFirst();
00704 n++;
00705 }
00706
00707 if ( n == 0 )
00708 {
00709
00710 return aPath;
00711 }
00712
00713 if ( targetElems.size() > 0 )
00714 {
00715
00716 for ( int i = 0; i < targetElems.size(); i++ )
00717 {
00718 aPathElems.insert( 0, ".." );
00719 }
00720 }
00721 else
00722 {
00723
00724
00725 aPathElems.insert( 0, "." );
00726 }
00727
00728 return aPathElems.join( "/" );
00729 }
00730
00731 QString QgsApplication::relativePathToAbsolutePath( QString rpath, QString targetPath )
00732 {
00733
00734 if ( !rpath.startsWith( "./" ) && !rpath.startsWith( "../" ) )
00735 {
00736 return rpath;
00737 }
00738
00739 #if defined(Q_OS_WIN)
00740 rpath.replace( "\\", "/" );
00741 targetPath.replace( "\\", "/" );
00742
00743 bool uncPath = targetPath.startsWith( "//" );
00744 #endif
00745
00746 QStringList srcElems = rpath.split( "/", QString::SkipEmptyParts );
00747 QStringList targetElems = targetPath.split( "/", QString::SkipEmptyParts );
00748
00749 #if defined(Q_OS_WIN)
00750 if ( uncPath )
00751 {
00752 targetElems.insert( 0, "" );
00753 targetElems.insert( 0, "" );
00754 }
00755 #endif
00756
00757
00758 targetElems << srcElems;
00759 targetElems.removeAll( "." );
00760
00761
00762 int pos;
00763 while (( pos = targetElems.indexOf( ".." ) ) > 0 )
00764 {
00765
00766 targetElems.removeAt( pos - 1 );
00767 targetElems.removeAt( pos - 1 );
00768 }
00769
00770 #if !defined(Q_OS_WIN)
00771
00772 targetElems.prepend( "" );
00773 #endif
00774
00775 return targetElems.join( "/" );
00776 }
00777
00778 void QgsApplication::skipGdalDriver( QString theDriver )
00779 {
00780 if ( ABISYM( mGdalSkipList ).contains( theDriver ) || theDriver.isEmpty() )
00781 {
00782 return;
00783 }
00784 ABISYM( mGdalSkipList ) << theDriver;
00785 applyGdalSkippedDrivers();
00786 }
00787
00788 void QgsApplication::restoreGdalDriver( QString theDriver )
00789 {
00790 if ( !ABISYM( mGdalSkipList ).contains( theDriver ) )
00791 {
00792 return;
00793 }
00794 int myPos = ABISYM( mGdalSkipList ).indexOf( theDriver );
00795 if ( myPos >= 0 )
00796 {
00797 ABISYM( mGdalSkipList ).removeAt( myPos );
00798 }
00799 applyGdalSkippedDrivers();
00800 }
00801
00802 void QgsApplication::applyGdalSkippedDrivers()
00803 {
00804 ABISYM( mGdalSkipList ).removeDuplicates();
00805 QString myDriverList = ABISYM( mGdalSkipList ).join( " " );
00806 QgsDebugMsg( "Gdal Skipped driver list set to:" );
00807 QgsDebugMsg( myDriverList );
00808 CPLSetConfigOption( "GDAL_SKIP", myDriverList.toUtf8() );
00809 GDALAllRegister();
00810 }