Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/qgis/Quantum-GIS into android
Browse files Browse the repository at this point in the history
  • Loading branch information
mbernasocchi committed Jul 29, 2011
2 parents bfb5f2c + f3d5387 commit 5676b3b
Show file tree
Hide file tree
Showing 37 changed files with 1,173 additions and 136 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Expand Up @@ -378,6 +378,16 @@ SET (QGIS_DATA_DIR ${QGIS_DATA_SUBDIR})
SET (QGIS_PLUGIN_DIR ${QGIS_PLUGIN_SUBDIR})
SET (QGIS_INCLUDE_DIR ${QGIS_INCLUDE_SUBDIR})

# set the default locations where the targets (executables, libraries) will land when compiled
# this is to allow running qgis from the source tree without having to actually do a "make install"
SET (QGIS_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output)
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_BIN_SUBDIR})
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_LIB_SUBDIR})

# write a marker with source directory path into the output's bin directory
# if run from the build directory QGIS will detect it and alter the paths
FILE(WRITE ${QGIS_OUTPUT_DIRECTORY}/${QGIS_BIN_SUBDIR}/source_path.txt "${CMAKE_SOURCE_DIR}")

# manual page - makes sense only on unix systems
IF (UNIX AND NOT APPLE)
SET (DEFAULT_MANUAL_SUBDIR man)
Expand Down
4 changes: 3 additions & 1 deletion i18n/CMakeLists.txt
Expand Up @@ -6,7 +6,7 @@ MACRO(ADD_TRANSLATION_FILES _sources )
GET_FILENAME_COMPONENT(_in ${_current_FILE} ABSOLUTE)
GET_FILENAME_COMPONENT(_basename ${_current_FILE} NAME_WE)

SET(_out ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.qm)
SET(_out ${QGIS_OUTPUT_DIRECTORY}/i18n/${_basename}.qm)

ADD_CUSTOM_COMMAND(
OUTPUT ${_out}
Expand All @@ -19,6 +19,8 @@ MACRO(ADD_TRANSLATION_FILES _sources )
ENDFOREACH (_current_FILE)
ENDMACRO(ADD_TRANSLATION_FILES)

# make sure the output directory exists
file(MAKE_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/i18n)

FILE (GLOB TS_FILES *.ts)

Expand Down
2 changes: 2 additions & 0 deletions images/images.qrc
Expand Up @@ -348,6 +348,8 @@
<file>themes/gis/plugins/wfs.png</file>
<file>splash/splash.png</file>
<file>north_arrows/default.png</file>
<file>themes/default/locked.png</file>
<file>themes/default/unlocked.png</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
11 changes: 11 additions & 0 deletions python/CMakeLists.txt
@@ -1,5 +1,9 @@
ADD_SUBDIRECTORY(plugins)


SET (PYTHON_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/python)
SET (QGIS_PYTHON_OUTPUT_DIRECTORY ${PYTHON_OUTPUT_DIRECTORY}/qgis)

IF (WITH_INTERNAL_SPATIALITE)
ADD_SUBDIRECTORY(pyspatialite)

Expand All @@ -9,6 +13,12 @@ IF (WITH_INTERNAL_SPATIALITE)
)
ENDIF (WITH_INTERNAL_SPATIALITE)


SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QGIS_PYTHON_OUTPUT_DIRECTORY})
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_PYTHON_OUTPUT_DIRECTORY})
file(COPY __init__.py utils.py console.py DESTINATION ${QGIS_PYTHON_OUTPUT_DIRECTORY})


INCLUDE_DIRECTORIES(
${PYTHON_INCLUDE_PATH}
${SIP_INCLUDE_DIR}
Expand Down Expand Up @@ -49,6 +59,7 @@ IF(NOT PYQT4_VERSION_NUM LESS 264194) # 0x040802
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} QSETTYPE_CONVERSION)
ENDIF(NOT PYQT4_VERSION_NUM LESS 264194)


# core module
FILE(GLOB sip_files_core core/*.sip)
SET(SIP_EXTRA_FILES_DEPEND ${sip_files_core})
Expand Down
25 changes: 25 additions & 0 deletions python/core/qgsapplication.sip
Expand Up @@ -185,6 +185,14 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
//! Returns the path to default style (works as a starting point). Added in QGIS 1.4
static const QString defaultStyleV2Path();

//! Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries
//! @note Added in 2.0
static const QString libraryPath();

//! Returns the path with utility executables (help viewer, crssync, ...)
//! @note Added in 2.0
static const QString libexecPath();

//! Alters prefix path - used by 3rd party apps
static void setPrefixPath(const QString thePrefixPath, bool useDefaultPaths = FALSE);

Expand Down Expand Up @@ -235,5 +243,22 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
*/
static void registerOgrDrivers();

/**Converts absolute path to path relative to target
@note: this method was added in version 1.6*/
static QString absolutePathToRelativePath( QString apath, QString targetPath );
/**Converts path relative to target to an absolute path
@note: this method was added in version 1.6*/
static QString relativePathToAbsolutePath( QString rpath, QString targetPath );

/** Indicates whether running from build directory (not installed)
@note added in 2.0 */
static bool isRunningFromBuildDir();
/** Returns path to the source directory. Valid only when running from build directory
@note added in 2.0 */
static QString buildSourcePath();
/** Returns path to the build output directory. Valid only when running from build directory
@note added in 2.0 */
static QString buildOutputPath();

};

16 changes: 16 additions & 0 deletions python/pyspatialite/CMakeLists.txt
@@ -1,3 +1,7 @@
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PYTHON_OUTPUT_DIRECTORY}/pyspatialite)
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PYTHON_OUTPUT_DIRECTORY}/pyspatialite)


INCLUDE_DIRECTORIES(
../../src/core/spatialite/headers
../../src/core/spatialite/headers/spatialite
Expand Down Expand Up @@ -49,6 +53,18 @@ IF (WIN32)
SET_TARGET_PROPERTIES(pyspatialite PROPERTIES SUFFIX ".pyd")
ENDIF (WIN32)

FOREACH(file
lib/__init__.py
lib/dbapi2.py
lib/dump.py
)
ADD_CUSTOM_COMMAND(TARGET pyspatialite
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${file} ${PYTHON_OUTPUT_DIRECTORY}/pyspatialite/${file}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
ENDFOREACH(file)

INSTALL(TARGETS pyspatialite DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/pyspatialite")
INSTALL(FILES
lib/__init__.py
Expand Down
15 changes: 0 additions & 15 deletions src/app/main.cpp
Expand Up @@ -479,21 +479,6 @@ int main( int argc, char *argv[] )
QApplication::setStyle( new QPlastiqueStyle );
#endif

// Check to see if qgis was started from the source directory.
// This is done by checking whether qgis binary is in 'src/app'
// directory. If running from there, exit gracefully.
// (QGIS might work incorrectly when run from the sources)
QString appDir = qApp->applicationDirPath();

if ( appDir.endsWith( "/src/app" ) )
{
QMessageBox::critical( 0, "QGIS Not Installed",
"You appear to be running QGIS from the source directory.\n"
"You must install QGIS using make install and run it from the "
"installed directory." );
exit( 1 );
}

QString i18nPath = QgsApplication::i18nPath();

/* Translation file for QGIS.
Expand Down
35 changes: 19 additions & 16 deletions src/app/qgisapp.cpp
Expand Up @@ -668,23 +668,26 @@ void QgisApp::dropEvent( QDropEvent *event )
QByteArray encodedData = event->mimeData()->data( "application/x-vnd.qgis.qgis.uri" );
QDataStream stream( &encodedData, QIODevice::ReadOnly );
QString xUri; // extended uri: layer_type:provider_key:uri
stream >> xUri;
QgsDebugMsg( xUri );
QRegExp rx( "^([^:]+):([^:]+):([^:]+):(.+)" );
if ( rx.indexIn( xUri ) != -1 )
while ( !stream.atEnd() )
{
QString layerType = rx.cap( 1 );
QString providerKey = rx.cap( 2 );
QString name = rx.cap( 3 );
QString uri = rx.cap( 4 );
QgsDebugMsg( "type: " + layerType + " key: " + providerKey + " name: " + name + " uri: " + uri );
if ( layerType == "vector" )
stream >> xUri;
QgsDebugMsg( xUri );
QRegExp rx( "^([^:]+):([^:]+):([^:]+):(.+)" );
if ( rx.indexIn( xUri ) != -1 )
{
addVectorLayer( uri, name, providerKey );
}
else if ( layerType == "raster" )
{
addRasterLayer( uri, name, providerKey, QStringList(), QStringList(), QString(), QString() );
QString layerType = rx.cap( 1 );
QString providerKey = rx.cap( 2 );
QString name = rx.cap( 3 );
QString uri = rx.cap( 4 );
QgsDebugMsg( "type: " + layerType + " key: " + providerKey + " name: " + name + " uri: " + uri );
if ( layerType == "vector" )
{
addVectorLayer( uri, name, providerKey );
}
else if ( layerType == "raster" )
{
addRasterLayer( uri, name, providerKey, QStringList(), QStringList(), QString(), QString() );
}
}
}
}
Expand Down Expand Up @@ -4616,7 +4619,7 @@ void QgisApp::loadPythonSupport()
{
QString pythonlibName( "qgispython" );
#if defined(Q_WS_MAC) || defined(Q_OS_LINUX)
pythonlibName.prepend( QgsApplication::prefixPath() + "/" + QGIS_LIB_SUBDIR + "/" );
pythonlibName.prepend( QgsApplication::libraryPath() );
#endif
#ifdef __MINGW32__
pythonlibName.prepend( "lib" );
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgsbrowserdockwidget.cpp
Expand Up @@ -15,6 +15,9 @@ QgsBrowserDockWidget::QgsBrowserDockWidget( QWidget * parent ) :
setWindowTitle( tr( "Browser" ) );

mBrowserView = new QTreeView( this );
mBrowserView->setDragEnabled( true );
mBrowserView->setDragDropMode( QTreeView::DragOnly );
mBrowserView->setSelectionMode( QAbstractItemView::ExtendedSelection );
setWidget( mBrowserView );

//connect( mBrowserView, SIGNAL( clicked( const QModelIndex& ) ), this, SLOT( itemClicked( const QModelIndex& ) ) );
Expand Down
86 changes: 71 additions & 15 deletions src/core/qgsapplication.cpp
Expand Up @@ -40,9 +40,14 @@ QStringList QgsApplication::mFileOpenEventList;
QString QgsApplication::mPrefixPath;
QString QgsApplication::mPluginPath;
QString QgsApplication::mPkgDataPath;
QString QgsApplication::mLibraryPath;
QString QgsApplication::mLibexecPath;
QString QgsApplication::mThemeName;
QStringList QgsApplication::mDefaultSvgPaths;
QString QgsApplication::mConfigPath = QDir::homePath() + QString( "/.qgis/" );
bool QgsApplication::mRunningFromBuildDir = false;
QString QgsApplication::mBuildSourcePath;
QString QgsApplication::mBuildOutputPath;

/*!
\class QgsApplication
Expand All @@ -60,14 +65,46 @@ QString QgsApplication::mConfigPath = QDir::homePath() + QString( "/.qgis/" );
QgsApplication::QgsApplication( int & argc, char ** argv, bool GUIenabled, QString customConfigPath )
: QApplication( argc, argv, GUIenabled )
{
// check if QGIS is run from build directory (not the install directory)
QDir appDir( applicationDirPath() );
if ( appDir.exists( "source_path.txt" ) )
{
QFile f( applicationDirPath() + "/source_path.txt" );
if ( f.open( QIODevice::ReadOnly ) )
{
mRunningFromBuildDir = true;
mBuildSourcePath = f.readAll();
#if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32)
setPrefixPath( applicationDirPath(), true );
mBuildOutputPath = applicationDirPath();
#else
QDir myDir( applicationDirPath() );
myDir.cdUp();
QString myPrefix = myDir.absolutePath();
setPrefixPath( myPrefix, true );
mBuildOutputPath = applicationDirPath() + "/.."; // on linux
#endif
qDebug( "Running from build directory!" );
qDebug( "- source directory: %s", mBuildSourcePath.toAscii().data() );
qDebug( "- output directory of the build: %s", mBuildOutputPath.toAscii().data() );
}
}

if ( mRunningFromBuildDir )
{
// we run from source directory - not installed to destination (specified prefix)
mPrefixPath = QString(); // set invalid path
setPluginPath( mBuildOutputPath + "/" + QString( QGIS_PLUGIN_SUBDIR ) );
setPkgDataPath( mBuildSourcePath ); // directly source path - used for: doc, resources, svg
mLibraryPath = mBuildOutputPath + "/" + QGIS_LIB_SUBDIR + "/";
mLibexecPath = mBuildOutputPath + "/" + QGIS_LIBEXEC_SUBDIR + "/";
}
else
{
#if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32)
setPrefixPath( applicationDirPath(), true );
#else
QDir myDir( applicationDirPath() );
myDir.cdUp();
QString myPrefix = myDir.absolutePath();
setPrefixPath( myPrefix, true );
#endif
}

if ( !customConfigPath.isEmpty() )
{
Expand Down Expand Up @@ -170,6 +207,8 @@ void QgsApplication::setPrefixPath( const QString thePrefixPath, bool useDefault
setPluginPath( mPrefixPath + "/" + QString( QGIS_PLUGIN_SUBDIR ) );
setPkgDataPath( mPrefixPath + "/" + QString( QGIS_DATA_SUBDIR ) );
}
mLibraryPath = mPrefixPath + "/" + QGIS_LIB_SUBDIR + "/";
mLibexecPath = mPrefixPath + "/" + QGIS_LIBEXEC_SUBDIR + "/";
}

void QgsApplication::setPluginPath( const QString thePluginPath )
Expand All @@ -180,10 +219,10 @@ void QgsApplication::setPluginPath( const QString thePluginPath )
void QgsApplication::setPkgDataPath( const QString thePkgDataPath )
{
mPkgDataPath = thePkgDataPath;
QString svgPath = mPkgDataPath + QString( "/svg/" );
QString mySvgPath = svgPath();
// avoid duplicate entries
if ( !mDefaultSvgPaths.contains( svgPath ) )
mDefaultSvgPaths << svgPath;
if ( !mDefaultSvgPaths.contains( mySvgPath ) )
mDefaultSvgPaths << mySvgPath;
}

void QgsApplication::setDefaultSvgPaths( const QStringList& pathList )
Expand All @@ -193,6 +232,11 @@ void QgsApplication::setDefaultSvgPaths( const QStringList& pathList )

const QString QgsApplication::prefixPath()
{
if ( mRunningFromBuildDir )
{
qWarning( "!!! prefix path was requested, but it is not valid - we do not run from installed path !!!" );
}

return mPrefixPath;
}
const QString QgsApplication::pluginPath()
Expand Down Expand Up @@ -285,12 +329,10 @@ const QString QgsApplication::translatorsFilePath()
{
return mPkgDataPath + QString( "/doc/TRANSLATORS" );
}
/*!
Returns the path to the developer image directory.
*/

const QString QgsApplication::developerPath()
{
return mPkgDataPath + QString( "/images/developers/" );
return QString(); // developer images are no longer shipped!
}

/*!
Expand All @@ -302,7 +344,7 @@ const QString QgsApplication::helpAppPath()
#ifdef Q_OS_MACX
helpAppPath = applicationDirPath() + "/bin/qgis_help.app/Contents/MacOS";
#else
helpAppPath = prefixPath() + "/" QGIS_LIBEXEC_SUBDIR;
helpAppPath = libexecPath();
#endif
helpAppPath += "/qgis_help";
return helpAppPath;
Expand All @@ -312,7 +354,10 @@ const QString QgsApplication::helpAppPath()
*/
const QString QgsApplication::i18nPath()
{
return mPkgDataPath + QString( "/i18n/" );
if ( mRunningFromBuildDir )
return mBuildOutputPath + QString( "/i18n" );
else
return mPkgDataPath + QString( "/i18n/" );
}

/*!
Expand Down Expand Up @@ -386,7 +431,8 @@ const QStringList QgsApplication::svgPaths()
*/
const QString QgsApplication::svgPath()
{
return mPkgDataPath + QString( "/svg/" );
QString svgSubDir( mRunningFromBuildDir ? "/images/svg/" : "/svg/" );
return mPkgDataPath + svgSubDir;
}

const QString QgsApplication::userStyleV2Path()
Expand All @@ -399,6 +445,16 @@ const QString QgsApplication::defaultStyleV2Path()
return mPkgDataPath + QString( "/resources/symbology-ng-style.xml" );
}

const QString QgsApplication::libraryPath()
{
return mLibraryPath;
}

const QString QgsApplication::libexecPath()
{
return mLibexecPath;
}

QgsApplication::endian_t QgsApplication::endian()
{
return ( htonl( 1 ) == 1 ) ? XDR : NDR ;
Expand Down

0 comments on commit 5676b3b

Please sign in to comment.