Skip to content
Permalink
Browse files

Merge pull request #881 from mbernasocchi/android

Various android updates from mbernasocchi
  • Loading branch information
dakcarto committed Sep 10, 2013
2 parents 5f61dd1 + b61b5b0 commit bb002ee1a82a8a783015026c20efb4cc8079802f
@@ -102,9 +102,6 @@ ELSE (ANDROID)
SET (DEFAULT_WITH_QTMOBILITY FALSE)
ENDIF (ANDROID)
SET (WITH_QTMOBILITY ${DEFAULT_WITH_QTMOBILITY} CACHE BOOL "Determines if QtMobility related code should be build (for example internal GPS)")
IF (WITH_QTMOBILITY)
FIND_PACKAGE(QtMobility 1.1.0)
ENDIF (WITH_QTMOBILITY)

SET (WITH_GLOBE FALSE CACHE BOOL "Determines whether Globe plugin should be built")
IF (WITH_GLOBE)
@@ -234,6 +231,10 @@ IF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT
MESSAGE(SEND_ERROR "Some Qt4 modules haven't been found!")
ENDIF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR NOT QT_QTWEBKIT_FOUND)

IF (WITH_QTMOBILITY)
FIND_PACKAGE(QtMobility 1.1.0)
ENDIF (WITH_QTMOBILITY)

IF (ANDROID)
SET (DEFAULT_WITH_TOUCH TRUE)
ELSE (ANDROID)
@@ -605,12 +606,12 @@ IF (GIT_MARKER)
# Get GIT remote and branch
EXECUTE_PROCESS(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${GITCOMMAND} name-rev --name-only HEAD OUTPUT_VARIABLE GIT_LOCAL_BRANCH
COMMAND ${GITCOMMAND} name-rev --name-only HEAD OUTPUT_VARIABLE GIT_LOCAL_BRANCH
)
STRING(STRIP "${GIT_LOCAL_BRANCH}" GIT_LOCAL_BRANCH)
EXECUTE_PROCESS(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${GITCOMMAND} config branch.${GIT_LOCAL_BRANCH}.remote OUTPUT_VARIABLE GIT_REMOTE
COMMAND ${GITCOMMAND} config branch.${GIT_LOCAL_BRANCH}.remote OUTPUT_VARIABLE GIT_REMOTE
)
STRING(STRIP "${GIT_REMOTE}" GIT_REMOTE)
EXECUTE_PROCESS(
@@ -26,10 +26,10 @@

INCLUDE(CMakeFindFrameworks)

if(EXISTS PYTHON_LIBRARY)
if(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}")
# Already in cache, be silent
set(PYTHONLIBRARY_FOUND TRUE)
else(EXISTS PYTHON_LIBRARY)
else(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}")

set(_custom_python_fw FALSE)
if(APPLE AND PYTHON_CUSTOM_FRAMEWORK)
@@ -69,6 +69,7 @@ else(EXISTS PYTHON_LIBRARY)
STRING(REPLACE "\\" "/" PYTHON_SITE_PACKAGES_DIR ${PYTHON_SITE_PACKAGES_DIR})
endif(WIN32)
FIND_LIBRARY(PYTHON_LIBRARY NAMES ${PYTHON_LIBRARY_NAMES} PATHS ${PYTHON_PREFIX}/lib ${PYTHON_PREFIX}/libs NO_DEFAULT_PATH)
set(PYTHON_INCLUDE_PATH ${PYTHON_INCLUDE_PATH} CACHE FILEPATH "Directory holding the python.h include file" FORCE)
set(PYTHONLIBRARY_FOUND TRUE)
endif(python_config)

@@ -109,4 +110,4 @@ else(EXISTS PYTHON_LIBRARY)
endif(PYTHONLIBRARY_FIND_REQUIRED)
endif(PYTHONLIBRARY_FOUND)

endif (EXISTS PYTHON_LIBRARY)
endif (EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}")
@@ -1,4 +1,4 @@
INCLUDE(FindQt4)
#INCLUDE(FindQt4)

set(MOBILITY_CONFIG_MKSPECS_FILE "")
IF(EXISTS "${QT_MKSPECS_DIR}/features/mobilityconfig.prf")
@@ -15,7 +15,7 @@ macro(export_component component)
STRING(TOUPPER ${component} _COMPONENT)
SET(QT_MOBILITY_${_COMPONENT}_FOUND 1)
SET(QT_MOBILITY_${_COMPONENT}_INCLUDE_DIR ${QT_MOBILITY_PARENT_INCLUDE_DIR}/Qt${component})
SET(QT_MOBILITY_${_COMPONENT}_LIBRARY Qt${component})
SET(QT_MOBILITY_${_COMPONENT}_LIBRARY ${QT_LIBRARY_DIR}/libQt${component}.so)
ADD_DEFINITIONS(-DHAVE_QT_MOBILITY_${_COMPONENT})
ENDIF()
ENDIF()
@@ -48,6 +48,10 @@ INCLUDE_DIRECTORIES(
${CMAKE_BINARY_DIR} # qgsconfig.h, qgsversion.h
)

IF(NOT ANDROID)
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} ANDROID)
ENDIF(NOT ANDROID)

IF(NOT WITH_TOUCH)
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_TOUCH)
ENDIF(NOT WITH_TOUCH)
@@ -106,7 +106,9 @@ class QgsComposerScaleBar: QgsComposerItem

/**Returns the x - positions of the segment borders (in item coordinates) and the width
of the segment*/
%If (!ANDROID)
void segmentPositions( QList<QPair<double, double> >& posWidthList ) const;
%End

/**Sets box size suitable to content*/
void adjustBoxSize();
@@ -20,10 +20,12 @@ class QgsQtLocationConnection: QgsGPSConnection
/**Called when the position updated.*/
// void positionUpdated( const QGeoPositionInfo &info );

%If (!ANDROID)
/**Called when the number of satellites in view is updated.*/
void satellitesInViewUpdated( const QList<QGeoSatelliteInfo>& satellites );

/**Called when the number of satellites in use is updated.*/
void satellitesInUseUpdated( const QList<QGeoSatelliteInfo>& satellites );
%End
};
%End
@@ -1,3 +1,4 @@
%Feature ANDROID

class QgsApplication : QApplication
{
@@ -294,6 +295,11 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
* @note added in 2.0 */
static void applyGdalSkippedDrivers();


%If(ANDROID)
bool x11EventFilter ( XEvent * event );
%End

signals:
// void preNotify( QObject * receiver, QEvent * event, bool * done );
};
@@ -38,10 +38,12 @@ class QgsClipper
// feature in x and y. The shapeOpen parameter determines whether
// the function treats the points as a closed shape (polygon), or as
// an open shape (linestring).

%If (!ANDROID)
static void trimFeature( QVector<double>& x,
QVector<double>& y,
bool shapeOpen );

%End
static void trimPolygon( QPolygonF& pts, const QgsRectangle& clipRect );

/**Reads a polyline from WKB and clips it to clipExtent
@@ -374,6 +374,12 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
{
connect( QgsProject::instance(), SIGNAL( writeProject( QDomDocument& ) ), this, SLOT( writeXML( QDomDocument& ) ) );
}

#if defined(ANDROID)
// fix for Qt Ministro hiding app's menubar in favor of native Android menus
menuBar()->setNativeMenuBar( false );
menuBar()->setVisible( true );
#endif
}

QgsComposer::~QgsComposer()
@@ -1097,6 +1097,12 @@ int main( int argc, char *argv[] )
delete mypSplash;

qgis->completeInitialization();

#if defined(ANDROID)
// fix for Qt Ministro hiding app's menubar in favor of native Android menus
qgis->menuBar()->setNativeMenuBar( false );
qgis->menuBar()->setVisible( true );
#endif

int retval = myApp.exec();
delete qgis;
@@ -738,6 +738,10 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
// should come after fileNewBlank to ensure project is properly set up to receive any data source files
QgsApplication::setFileOpenEventReceiver( this );

#ifdef ANDROID
toggleFullScreen();
#endif

} // QgisApp ctor

QgisApp::QgisApp( )
@@ -8851,6 +8855,30 @@ bool QgisApp::addRasterLayers( QStringList const &theFileNameQStringList, bool g
//
///////////////////////////////////////////////////////////////////

#ifdef ANDROID
void QgisApp::keyReleaseEvent(QKeyEvent *event)
{
static bool accepted=true;
if (event->key()==Qt::Key_Close)
{
// do something useful here
int ret = QMessageBox::question(this, tr("Exit QGIS"),
tr("Do you really want to quit QGIS?"),
QMessageBox::Yes | QMessageBox::No);
switch(ret)
{
case QMessageBox::Yes:
this->close();
break;

case QMessageBox::No:
break;
}
event->setAccepted(accepted); // dont't close my Top Level Widget !
accepted=false;// close the app next time when the user press back button
}
}
#endif

void QgisApp::keyPressEvent( QKeyEvent * e )
{
@@ -622,6 +622,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! reimplements widget keyPress event so we can check if cancel was pressed
virtual void keyPressEvent( QKeyEvent * event );

#ifdef ANDROID
//! reimplements widget keyReleaseEvent event so we can check if back was pressed
virtual void keyReleaseEvent( QKeyEvent * event );
#endif

#ifdef Q_OS_WIN
//! reimplements context menu event
virtual void contextMenuEvent( QContextMenuEvent *event );
@@ -45,10 +45,14 @@ class CORE_EXPORT QgsQtLocationConnection: public QgsGPSConnection
*/
void positionUpdated( const QGeoPositionInfo &info );

/**Called when the number of satellites in view is updated.*/
/**Called when the number of satellites in view is updated.
* @note not available in python binding
*/
void satellitesInViewUpdated( const QList<QGeoSatelliteInfo>& satellites );

/**Called when the number of satellites in use is updated.*/
/**Called when the number of satellites in use is updated.
* @note not available in python binding
*/
void satellitesInUseUpdated( const QList<QGeoSatelliteInfo>& satellites );

private:
@@ -139,6 +139,12 @@ void QgsApplication::init( QString customConfigPath )
{
#if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32)
setPrefixPath( applicationDirPath(), true );
#elif defined(ANDROID)
// this is "/data/data/org.qgis.qgis" in android
QDir myDir( QDir::homePath() );
myDir.cdUp();
QString myPrefix = myDir.absolutePath();
setPrefixPath( myPrefix, true );
#else
QDir myDir( applicationDirPath() );
myDir.cdUp();
@@ -26,6 +26,11 @@
* Extends QApplication to provide access to QGIS specific resources such
* as theme paths, database paths etc.
*/

#ifdef ANDROID
typedef void XEvent;
#endif

class CORE_EXPORT QgsApplication: public QApplication
{
Q_OBJECT
@@ -274,6 +279,13 @@ class CORE_EXPORT QgsApplication: public QApplication
* @note added in 2.0 */
static void applyGdalSkippedDrivers();

#ifdef ANDROID
//dummy method to workaround sip generation issue issue
bool x11EventFilter ( XEvent * event ){
return 0;
}
#endif

signals:
//! @note not available in python bindings
void preNotify( QObject * receiver, QEvent * event, bool * done );
@@ -56,7 +56,9 @@ QgsMessageLogViewer::QgsMessageLogViewer( QStatusBar *statusBar, QWidget *parent
mButton->setMaximumWidth( 20 );
mButton->setMaximumHeight( 20 );
mButton->setIcon( icon( "/mIconWarn.png" ) );
#ifndef ANDROID
mButton->setToolTip( tr( "No messages." ) );
#endif
mButton->setCheckable( true );
mButton->hide();
connect( mButton, SIGNAL( toggled( bool ) ), this, SLOT( buttonToggled( bool ) ) );
@@ -108,7 +110,11 @@ void QgsMessageLogViewer::buttonDestroyed()

void QgsMessageLogViewer::logMessage( QString message, QString tag, QgsMessageLog::MessageLevel level )
{
#ifdef ANDROID
mCount++;
#else
mButton->setToolTip( tr( "%1 message(s) logged." ).arg( mCount++ ) );
#endif

if ( !isVisible() && level > QgsMessageLog::INFO )
{
@@ -163,7 +169,11 @@ void QgsMessageLogViewer::closeTab( int index )
{
mCount -= w->rowCount();
if ( mButton )
#ifdef ANDROID
mCount++;
#else
mButton->setToolTip( tr( "%1 message(s) logged." ).arg( mCount++ ) );
#endif
}
tabWidget->removeTab( index );
}

0 comments on commit bb002ee

Please sign in to comment.
You can’t perform that action at this time.