From 0b2e8e7c735c5db9a2bc274996e2880c4d0daecf Mon Sep 17 00:00:00 2001 From: wonder Date: Sun, 18 Nov 2007 18:08:01 +0000 Subject: [PATCH] - removed PKGDATAPATH and PLUGINPATH definitions: use QgsApplication instead - use QgsApplication to detect data path in help viewer and mapserver export git-svn-id: http://svn.osgeo.org/qgis/trunk@7455 c8812cc2-4d05-0410-92ff-de0c093fc19c --- CMakeLists.txt | 2 -- src/helpviewer/qgshelpviewer.cpp | 24 ++++--------------- tools/mapserver_export/qgsmapserverexport.cpp | 23 ++++++------------ 3 files changed, 11 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12e9e981d6c..d50b9c6bd5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -181,8 +181,6 @@ ELSE (WIN32) IF (UNIX AND NOT APPLE) ADD_DEFINITIONS(-DPREFIX=\\"${CMAKE_INSTALL_PREFIX}\\") - ADD_DEFINITIONS(-DPLUGINPATH=\\"${QGIS_PLUGIN_DIR}\\") - ADD_DEFINITIONS(-DPKGDATAPATH=\\"${QGIS_DATA_DIR}\\") ENDIF (UNIX AND NOT APPLE) ENDIF (WIN32) diff --git a/src/helpviewer/qgshelpviewer.cpp b/src/helpviewer/qgshelpviewer.cpp index 679c0b49b77..7f5a0b3a71c 100644 --- a/src/helpviewer/qgshelpviewer.cpp +++ b/src/helpviewer/qgshelpviewer.cpp @@ -32,6 +32,8 @@ #include "qgshelpviewer.h" +#include "qgsapplication.h" + QgsHelpViewer::QgsHelpViewer(const QString &contextId, QWidget *parent, Qt::WFlags fl) : QDialog(parent, fl) @@ -63,16 +65,7 @@ void QgsHelpViewer::loadContext(const QString &contextId) if(contextId != QString::null) { // set up the path to the help file - QString helpFilesPath = -#ifdef Q_OS_MACX - // remove bin/qgis_help.app/Contents/MacOS to get to share/qgis - qApp->applicationDirPath() + "/../../../../share/qgis" + -#elif WIN32 - qApp->applicationDirPath() + "/share/qgis" -#else - QString(PKGDATAPATH) + -#endif - "/resources/context_help/"; + QString helpFilesPath = QgsApplication::pkgDataPath() + "/resources/context_help/"; /* * determine the locale and create the file name from * the context id @@ -137,16 +130,7 @@ void QgsHelpViewer::loadContextFromSqlite(const QString &contextId) if(contextId != QString::null) { // connect to the database - QString helpDbPath = -#ifdef Q_OS_MACX - // remove bin/qgis_help.app/Contents/MacOS to get to share/qgis - qApp->applicationDirPath() + "/../../../../share/qgis" + -#elif WIN32 - qApp->applicationDirPath() + -#else - QString(PKGDATAPATH) + -#endif - "/resources/qgis_help.db"; + QString helpDbPath = QgsApplication::pkgDataPath() + "/resources/qgis_help.db"; int rc = connectDb(helpDbPath); // get the help content and title from the database diff --git a/tools/mapserver_export/qgsmapserverexport.cpp b/tools/mapserver_export/qgsmapserverexport.cpp index 186c36cb9d3..4acc4572485 100644 --- a/tools/mapserver_export/qgsmapserverexport.cpp +++ b/tools/mapserver_export/qgsmapserverexport.cpp @@ -29,9 +29,12 @@ email : sherman at mrcc.com #include #include #include -#include "../../src/core/qgscontexthelp.h" #include "qgsmapserverexport.h" +// from CORE library +#include "qgsapplication.h" +#include "qgscontexthelp.h" + // constructor QgsMapserverExport::QgsMapserverExport(QWidget * parent, Qt::WFlags fl) @@ -114,21 +117,9 @@ void QgsMapserverExport::apply() //TODO Need to append the path to the qgis python files using the path to the // Python files in the QGIS install directory PyRun_SimpleString("import sys"); - QString prefixPath = QApplication::applicationDirPath(); - // Setup up path to the python script directory based on platform -#ifdef Q_WS_MACX - QString dataPath = prefixPath + "/../../../../share/qgis"; -#elif WIN32 -# ifndef _MSC_VER - QString dataPath = prefixPath + "/share/qgis"; -# else - QString dataPath = prefixPath; -# endif -#else - QString dataPath ( PKGDATAPATH ); -#endif - dataPath = dataPath.trimmed(); - QString scriptDir = dataPath + QDir::separator() + "python"; + + // Setup up path to the python script directory + QString scriptDir = QgsApplication::pkgDataPath() + QDir::separator() + "python"; qDebug("Python scripts directory: " + scriptDir.toLocal8Bit()); //QString curdir = "/home/gsherman/development/qgis_qt_port/tools/mapserver_export"; QString sysCmd = QString("sys.path.append('%1')").arg(scriptDir);