Skip to content

Commit bb002ee

Browse files
committedSep 10, 2013
Merge pull request #881 from mbernasocchi/android
Various android updates from mbernasocchi
2 parents 5f61dd1 + b61b5b0 commit bb002ee

16 files changed

+108
-13
lines changed
 

‎CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ ELSE (ANDROID)
102102
SET (DEFAULT_WITH_QTMOBILITY FALSE)
103103
ENDIF (ANDROID)
104104
SET (WITH_QTMOBILITY ${DEFAULT_WITH_QTMOBILITY} CACHE BOOL "Determines if QtMobility related code should be build (for example internal GPS)")
105-
IF (WITH_QTMOBILITY)
106-
FIND_PACKAGE(QtMobility 1.1.0)
107-
ENDIF (WITH_QTMOBILITY)
108105

109106
SET (WITH_GLOBE FALSE CACHE BOOL "Determines whether Globe plugin should be built")
110107
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
234231
MESSAGE(SEND_ERROR "Some Qt4 modules haven't been found!")
235232
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)
236233

234+
IF (WITH_QTMOBILITY)
235+
FIND_PACKAGE(QtMobility 1.1.0)
236+
ENDIF (WITH_QTMOBILITY)
237+
237238
IF (ANDROID)
238239
SET (DEFAULT_WITH_TOUCH TRUE)
239240
ELSE (ANDROID)
@@ -605,12 +606,12 @@ IF (GIT_MARKER)
605606
# Get GIT remote and branch
606607
EXECUTE_PROCESS(
607608
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
608-
COMMAND ${GITCOMMAND} name-rev --name-only HEAD OUTPUT_VARIABLE GIT_LOCAL_BRANCH
609+
COMMAND ${GITCOMMAND} name-rev --name-only HEAD OUTPUT_VARIABLE GIT_LOCAL_BRANCH
609610
)
610611
STRING(STRIP "${GIT_LOCAL_BRANCH}" GIT_LOCAL_BRANCH)
611612
EXECUTE_PROCESS(
612613
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
613-
COMMAND ${GITCOMMAND} config branch.${GIT_LOCAL_BRANCH}.remote OUTPUT_VARIABLE GIT_REMOTE
614+
COMMAND ${GITCOMMAND} config branch.${GIT_LOCAL_BRANCH}.remote OUTPUT_VARIABLE GIT_REMOTE
614615
)
615616
STRING(STRIP "${GIT_REMOTE}" GIT_REMOTE)
616617
EXECUTE_PROCESS(

‎cmake/FindPythonLibrary.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
INCLUDE(CMakeFindFrameworks)
2828

29-
if(EXISTS PYTHON_LIBRARY)
29+
if(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}")
3030
# Already in cache, be silent
3131
set(PYTHONLIBRARY_FOUND TRUE)
32-
else(EXISTS PYTHON_LIBRARY)
32+
else(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}")
3333

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

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

112-
endif (EXISTS PYTHON_LIBRARY)
113+
endif (EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}")

‎cmake/FindQtMobility.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
INCLUDE(FindQt4)
1+
#INCLUDE(FindQt4)
22

33
set(MOBILITY_CONFIG_MKSPECS_FILE "")
44
IF(EXISTS "${QT_MKSPECS_DIR}/features/mobilityconfig.prf")
@@ -15,7 +15,7 @@ macro(export_component component)
1515
STRING(TOUPPER ${component} _COMPONENT)
1616
SET(QT_MOBILITY_${_COMPONENT}_FOUND 1)
1717
SET(QT_MOBILITY_${_COMPONENT}_INCLUDE_DIR ${QT_MOBILITY_PARENT_INCLUDE_DIR}/Qt${component})
18-
SET(QT_MOBILITY_${_COMPONENT}_LIBRARY Qt${component})
18+
SET(QT_MOBILITY_${_COMPONENT}_LIBRARY ${QT_LIBRARY_DIR}/libQt${component}.so)
1919
ADD_DEFINITIONS(-DHAVE_QT_MOBILITY_${_COMPONENT})
2020
ENDIF()
2121
ENDIF()

‎python/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ INCLUDE_DIRECTORIES(
4848
${CMAKE_BINARY_DIR} # qgsconfig.h, qgsversion.h
4949
)
5050

51+
IF(NOT ANDROID)
52+
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} ANDROID)
53+
ENDIF(NOT ANDROID)
54+
5155
IF(NOT WITH_TOUCH)
5256
SET(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_TOUCH)
5357
ENDIF(NOT WITH_TOUCH)

‎python/core/composer/qgscomposerscalebar.sip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ class QgsComposerScaleBar: QgsComposerItem
106106

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

111113
/**Sets box size suitable to content*/
112114
void adjustBoxSize();

‎python/core/gps/qgsqtlocationconnection.sip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ class QgsQtLocationConnection: QgsGPSConnection
2020
/**Called when the position updated.*/
2121
// void positionUpdated( const QGeoPositionInfo &info );
2222

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

2627
/**Called when the number of satellites in use is updated.*/
2728
void satellitesInUseUpdated( const QList<QGeoSatelliteInfo>& satellites );
29+
%End
2830
};
2931
%End

‎python/core/qgsapplication.sip

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
%Feature ANDROID
12

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

298+
299+
%If(ANDROID)
300+
bool x11EventFilter ( XEvent * event );
301+
%End
302+
297303
signals:
298304
// void preNotify( QObject * receiver, QEvent * event, bool * done );
299305
};

‎python/core/qgsclipper.sip

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ class QgsClipper
3838
// feature in x and y. The shapeOpen parameter determines whether
3939
// the function treats the points as a closed shape (polygon), or as
4040
// an open shape (linestring).
41+
42+
%If (!ANDROID)
4143
static void trimFeature( QVector<double>& x,
4244
QVector<double>& y,
4345
bool shapeOpen );
44-
46+
%End
4547
static void trimPolygon( QPolygonF& pts, const QgsRectangle& clipRect );
4648

4749
/**Reads a polyline from WKB and clips it to clipExtent

‎src/app/composer/qgscomposer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,12 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
374374
{
375375
connect( QgsProject::instance(), SIGNAL( writeProject( QDomDocument& ) ), this, SLOT( writeXML( QDomDocument& ) ) );
376376
}
377+
378+
#if defined(ANDROID)
379+
// fix for Qt Ministro hiding app's menubar in favor of native Android menus
380+
menuBar()->setNativeMenuBar( false );
381+
menuBar()->setVisible( true );
382+
#endif
377383
}
378384

379385
QgsComposer::~QgsComposer()

‎src/app/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,12 @@ int main( int argc, char *argv[] )
10971097
delete mypSplash;
10981098

10991099
qgis->completeInitialization();
1100+
1101+
#if defined(ANDROID)
1102+
// fix for Qt Ministro hiding app's menubar in favor of native Android menus
1103+
qgis->menuBar()->setNativeMenuBar( false );
1104+
qgis->menuBar()->setVisible( true );
1105+
#endif
11001106

11011107
int retval = myApp.exec();
11021108
delete qgis;

‎src/app/qgisapp.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,10 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
738738
// should come after fileNewBlank to ensure project is properly set up to receive any data source files
739739
QgsApplication::setFileOpenEventReceiver( this );
740740

741+
#ifdef ANDROID
742+
toggleFullScreen();
743+
#endif
744+
741745
} // QgisApp ctor
742746

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

8858+
#ifdef ANDROID
8859+
void QgisApp::keyReleaseEvent(QKeyEvent *event)
8860+
{
8861+
static bool accepted=true;
8862+
if (event->key()==Qt::Key_Close)
8863+
{
8864+
// do something useful here
8865+
int ret = QMessageBox::question(this, tr("Exit QGIS"),
8866+
tr("Do you really want to quit QGIS?"),
8867+
QMessageBox::Yes | QMessageBox::No);
8868+
switch(ret)
8869+
{
8870+
case QMessageBox::Yes:
8871+
this->close();
8872+
break;
8873+
8874+
case QMessageBox::No:
8875+
break;
8876+
}
8877+
event->setAccepted(accepted); // dont't close my Top Level Widget !
8878+
accepted=false;// close the app next time when the user press back button
8879+
}
8880+
}
8881+
#endif
88548882

88558883
void QgisApp::keyPressEvent( QKeyEvent * e )
88568884
{

‎src/app/qgisapp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
622622
//! reimplements widget keyPress event so we can check if cancel was pressed
623623
virtual void keyPressEvent( QKeyEvent * event );
624624

625+
#ifdef ANDROID
626+
//! reimplements widget keyReleaseEvent event so we can check if back was pressed
627+
virtual void keyReleaseEvent( QKeyEvent * event );
628+
#endif
629+
625630
#ifdef Q_OS_WIN
626631
//! reimplements context menu event
627632
virtual void contextMenuEvent( QContextMenuEvent *event );

‎src/core/gps/qgsqtlocationconnection.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ class CORE_EXPORT QgsQtLocationConnection: public QgsGPSConnection
4545
*/
4646
void positionUpdated( const QGeoPositionInfo &info );
4747

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

51-
/**Called when the number of satellites in use is updated.*/
53+
/**Called when the number of satellites in use is updated.
54+
* @note not available in python binding
55+
*/
5256
void satellitesInUseUpdated( const QList<QGeoSatelliteInfo>& satellites );
5357

5458
private:

‎src/core/qgsapplication.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ void QgsApplication::init( QString customConfigPath )
139139
{
140140
#if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32)
141141
setPrefixPath( applicationDirPath(), true );
142+
#elif defined(ANDROID)
143+
// this is "/data/data/org.qgis.qgis" in android
144+
QDir myDir( QDir::homePath() );
145+
myDir.cdUp();
146+
QString myPrefix = myDir.absolutePath();
147+
setPrefixPath( myPrefix, true );
142148
#else
143149
QDir myDir( applicationDirPath() );
144150
myDir.cdUp();

‎src/core/qgsapplication.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
* Extends QApplication to provide access to QGIS specific resources such
2727
* as theme paths, database paths etc.
2828
*/
29+
30+
#ifdef ANDROID
31+
typedef void XEvent;
32+
#endif
33+
2934
class CORE_EXPORT QgsApplication: public QApplication
3035
{
3136
Q_OBJECT
@@ -274,6 +279,13 @@ class CORE_EXPORT QgsApplication: public QApplication
274279
* @note added in 2.0 */
275280
static void applyGdalSkippedDrivers();
276281

282+
#ifdef ANDROID
283+
//dummy method to workaround sip generation issue issue
284+
bool x11EventFilter ( XEvent * event ){
285+
return 0;
286+
}
287+
#endif
288+
277289
signals:
278290
//! @note not available in python bindings
279291
void preNotify( QObject * receiver, QEvent * event, bool * done );

‎src/gui/qgsmessagelogviewer.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ QgsMessageLogViewer::QgsMessageLogViewer( QStatusBar *statusBar, QWidget *parent
5656
mButton->setMaximumWidth( 20 );
5757
mButton->setMaximumHeight( 20 );
5858
mButton->setIcon( icon( "/mIconWarn.png" ) );
59+
#ifndef ANDROID
5960
mButton->setToolTip( tr( "No messages." ) );
61+
#endif
6062
mButton->setCheckable( true );
6163
mButton->hide();
6264
connect( mButton, SIGNAL( toggled( bool ) ), this, SLOT( buttonToggled( bool ) ) );
@@ -108,7 +110,11 @@ void QgsMessageLogViewer::buttonDestroyed()
108110

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

113119
if ( !isVisible() && level > QgsMessageLog::INFO )
114120
{
@@ -163,7 +169,11 @@ void QgsMessageLogViewer::closeTab( int index )
163169
{
164170
mCount -= w->rowCount();
165171
if ( mButton )
172+
#ifdef ANDROID
173+
mCount++;
174+
#else
166175
mButton->setToolTip( tr( "%1 message(s) logged." ).arg( mCount++ ) );
176+
#endif
167177
}
168178
tabWidget->removeTab( index );
169179
}

0 commit comments

Comments
 (0)
Please sign in to comment.