23 #include <QFileOpenEvent>
24 #include <QMessageBox>
29 #include <netinet/in.h>
34 #include "qgsconfig.h"
38 QObject *
ABISYM( QgsApplication::mFileOpenEventReceiver );
39 QStringList
ABISYM( QgsApplication::mFileOpenEventList );
40 QString
ABISYM( QgsApplication::mPrefixPath );
41 QString
ABISYM( QgsApplication::mPluginPath );
42 QString
ABISYM( QgsApplication::mPkgDataPath );
43 QString
ABISYM( QgsApplication::mThemeName );
44 QStringList
ABISYM( QgsApplication::mDefaultSvgPaths );
45 QString
ABISYM( QgsApplication::mConfigPath ) = QDir::homePath() + QString(
"/.qgis/" );
61 : QApplication( argc, argv, GUIenabled )
63 #if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32)
66 QDir myDir( applicationDirPath() );
68 QString myPrefix = myDir.absolutePath();
72 if ( !customConfigPath.isEmpty() )
74 ABISYM( mConfigPath ) = customConfigPath +
"/";
87 if ( event->type() == QEvent::FileOpen )
90 if (
ABISYM( mFileOpenEventReceiver ) )
93 done =
notify(
ABISYM( mFileOpenEventReceiver ), event );
100 ABISYM( mFileOpenEventList ).append( static_cast<QFileOpenEvent *>( event )->file() );
122 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.
what() );
124 catch ( std::exception & e )
126 QMessageBox::critical( activeWindow(), tr(
"Exception" ), e.what() );
130 QMessageBox::critical( activeWindow(), tr(
"Exception" ), tr(
"unknown exception" ) );
138 ABISYM( mFileOpenEventReceiver ) = receiver;
140 if (
ABISYM( mFileOpenEventList ).count() > 0 )
142 QStringListIterator i(
ABISYM( mFileOpenEventList ) );
143 while ( i.hasNext() )
145 QFileOpenEvent foe( i.next() );
146 QgsApplication::sendEvent(
ABISYM( mFileOpenEventReceiver ), &foe );
148 ABISYM( mFileOpenEventList ).clear();
154 ABISYM( mPrefixPath ) = thePrefixPath;
155 #if defined(_MSC_VER)
156 if (
ABISYM( mPrefixPath ).endsWith(
"/bin" ) )
158 ABISYM( mPrefixPath ).chop( 4 );
161 if ( useDefaultPaths )
170 ABISYM( mPluginPath ) = thePluginPath;
175 ABISYM( mPkgDataPath ) = thePkgDataPath;
176 QString
svgPath =
ABISYM( mPkgDataPath ) + QString(
"/svg/" );
178 if ( !
ABISYM( mDefaultSvgPaths ).contains( svgPath ) )
184 ABISYM( mDefaultSvgPaths ) = pathList;
189 return ABISYM( mPrefixPath );
193 return ABISYM( mPluginPath );
197 return ABISYM( mPkgDataPath );
201 return ":/images/themes/default/";
205 return ":/images/themes/" +
ABISYM( mThemeName ) +
"/";
213 if ( QFile::exists( path + iconFile ) )
214 return path + iconFile;
225 QString myPath =
":/images/themes/" + theThemeName +
"/";
227 if ( QFile::exists( myPath ) )
229 ABISYM( mThemeName ) = theThemeName;
233 ABISYM( mThemeName ) =
"default";
241 return ABISYM( mThemeName );
248 return ABISYM( mPkgDataPath ) + QString(
"/doc/AUTHORS" );
255 return ABISYM( mPkgDataPath ) + QString(
"/doc/CONTRIBUTORS" );
262 return ABISYM( mPkgDataPath ) + QString(
"/doc/SPONSORS" );
270 return ABISYM( mPkgDataPath ) + QString(
"/doc/DONORS" );
279 return ABISYM( mPkgDataPath ) + QString(
"/doc/TRANSLATORS" );
286 return ABISYM( mPkgDataPath ) + QString(
"/images/developers/" );
296 helpAppPath = applicationDirPath() +
"/bin/qgis_help.app/Contents/MacOS";
298 helpAppPath =
prefixPath() +
"/" QGIS_LIBEXEC_SUBDIR;
300 helpAppPath +=
"/qgis_help";
308 return ABISYM( mPkgDataPath ) + QString(
"/i18n/" );
316 return ABISYM( mPkgDataPath ) + QString(
"/resources/qgis.db" );
324 return ABISYM( mConfigPath );
340 return ABISYM( mPkgDataPath ) + QString(
"/images/splash/" );
348 return ABISYM( mPkgDataPath ) + QString(
"/images/icons/" );
355 return ABISYM( mPkgDataPath ) + QString(
"/resources/srs.db" );
366 QStringList myPathList;
367 QString myPaths = settings.value(
"svg/searchPathsForSVG",
"" ).toString();
368 if ( !myPaths.isEmpty() )
370 myPathList = myPaths.split(
"|" );
373 myPathList <<
ABISYM( mDefaultSvgPaths );
382 return ABISYM( mPkgDataPath ) + QString(
"/svg/" );
392 return ABISYM( mPkgDataPath ) + QString(
"/resources/symbology-ng-style.xml" );
397 return ( htonl( 1 ) == 1 ) ?
XDR :
NDR ;
417 QString myState = QString(
"Application state:\n"
420 "Package Data Path : %3\n"
421 "Active Theme Name : %4\n"
422 "Active Theme Path : %5\n"
423 "Default Theme Path : %6\n"
424 "SVG Search Paths : %7\n"
425 "User DB Path : %8\n" )
426 .arg(
ABISYM( mPrefixPath ) )
427 .arg(
ABISYM( mPluginPath ) )
428 .arg(
ABISYM( mPkgDataPath ) )
443 QColor myColor1 = palette().highlight().color();
444 QColor myColor2 = myColor1;
445 myColor2 = myColor2.lighter( 110 );
447 myStyle =
".glossy{ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, "
448 "stop: 0 " + myColor1.name() +
","
449 "stop: 0.1 " + myColor2.name() +
","
450 "stop: 0.5 " + myColor1.name() +
","
451 "stop: 0.9 " + myColor2.name() +
","
452 "stop: 1 " + myColor1.name() +
");"
456 "padding-bottom: 8px;"
457 "border: 1px solid #6c6c6c;"
459 ".overview{ font: 1.82em; font-weight: bold;}"
460 "body{ background: white;"
462 " font-family: arial,sans-serif;"
464 "h2{ background-color: #F6F6F6;"
466 " font-size: medium; "
467 " font-weight: normal;"
468 " font-family: luxi serif, georgia, times new roman, times, serif;"
470 " padding: 0.75em 0 0;"
472 " line-height: 1.1em;"
474 "h3{ background-color: #F6F6F6;"
476 " font-family: luxi serif, georgia, times new roman, times, serif;"
477 " font-weight: bold;"
479 " text-align: right;"
480 " border-bottom: 5px solid #DCEB5C;"
482 "h4{ background-color: #F6F6F6;"
484 " font-family: luxi serif, georgia, times new roman, times, serif;"
485 " font-weight: bold;"
486 " font-size: medium;"
487 " text-align: right;"
489 "h5{ background-color: #F6F6F6;"
491 " font-family: luxi serif, georgia, times new roman, times, serif;"
492 " font-weight: bold;"
494 " text-align: right;"
497 " font-family: arial,sans-serif;"
500 "label{ background-color: #FFFFCC;"
501 " border: 1px solid black;"
503 " padding: 0px 3px; "
511 if ( 0 >= OGRGetDriverCount() )
519 #if defined( Q_OS_WIN )
520 const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
522 aPath.replace(
"\\",
"/" );
523 if ( aPath.startsWith(
"//" ) )
526 aPath =
"\\\\" + aPath.mid( 2 );
529 targetPath.replace(
"\\",
"/" );
530 if ( targetPath.startsWith(
"//" ) )
533 targetPath =
"\\\\" + targetPath.mid( 2 );
536 const Qt::CaseSensitivity cs = Qt::CaseSensitive;
539 QStringList targetElems = targetPath.split(
"/", QString::SkipEmptyParts );
540 QStringList aPathElems = aPath.split(
"/", QString::SkipEmptyParts );
542 targetElems.removeAll(
"." );
543 aPathElems.removeAll(
"." );
547 while ( aPathElems.size() > 0 &&
548 targetElems.size() > 0 &&
549 aPathElems[0].compare( targetElems[0], cs ) == 0 )
551 aPathElems.removeFirst();
552 targetElems.removeFirst();
562 if ( targetElems.size() > 0 )
565 for (
int i = 0; i < targetElems.size(); i++ )
567 aPathElems.insert( 0,
".." );
574 aPathElems.insert( 0,
"." );
577 return aPathElems.join(
"/" );
583 if ( !rpath.startsWith(
"./" ) && !rpath.startsWith(
"../" ) )
588 #if defined(Q_OS_WIN)
589 rpath.replace(
"\\",
"/" );
590 targetPath.replace(
"\\",
"/" );
592 bool uncPath = targetPath.startsWith(
"//" );
595 QStringList srcElems = rpath.split(
"/", QString::SkipEmptyParts );
596 QStringList targetElems = targetPath.split(
"/", QString::SkipEmptyParts );
598 #if defined(Q_OS_WIN)
601 targetElems.insert( 0,
"" );
602 targetElems.insert( 0,
"" );
607 targetElems << srcElems;
608 targetElems.removeAll(
"." );
612 while (( pos = targetElems.indexOf(
".." ) ) > 0 )
615 targetElems.removeAt( pos - 1 );
616 targetElems.removeAt( pos - 1 );
619 #if !defined(Q_OS_WIN)
621 targetElems.prepend(
"" );
624 return targetElems.join(
"/" );