@@ -258,6 +258,10 @@ extern "C"
258
258
#include < windows.h>
259
259
#endif
260
260
261
+ #ifdef HAVE_TOUCH
262
+ #include " qgsmaptooltouch.h"
263
+ #endif
264
+
261
265
class QTreeWidgetItem ;
262
266
263
267
@@ -626,7 +630,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
626
630
// request notification of FileOpen events (double clicking a file icon in Mac OS X Finder)
627
631
QgsApplication::setFileOpenEventReceiver ( this );
628
632
629
- #ifdef ANDROID
633
+ #ifdef HAVE_TOUCH
630
634
// add reacting to long click in android
631
635
grabGesture ( Qt::TapAndHoldGesture );
632
636
#endif
@@ -646,6 +650,9 @@ QgisApp::~QgisApp()
646
650
delete mMapTools .mZoomIn ;
647
651
delete mMapTools .mZoomOut ;
648
652
delete mMapTools .mPan ;
653
+ #ifdef HAVE_TOUCH
654
+ delete mMapTools .mTouch ;
655
+ #endif
649
656
delete mMapTools .mIdentify ;
650
657
delete mMapTools .mFeatureAction ;
651
658
delete mMapTools .mMeasureDist ;
@@ -741,8 +748,8 @@ bool QgisApp::event( QEvent * event )
741
748
openFile ( foe->file () );
742
749
done = true ;
743
750
}
744
- #ifdef ANDROID
745
- else if ( event->type () == QEvent::Gesture )
751
+ #ifdef HAVE_TOUCH
752
+ else if (event->type () == QEvent::Gesture )
746
753
{
747
754
done = gestureEvent ( static_cast <QGestureEvent*>( event ) );
748
755
}
@@ -820,6 +827,9 @@ void QgisApp::createActions()
820
827
821
828
// View Menu Items
822
829
830
+ #ifdef HAVE_TOUCH
831
+ connect ( mActionTouch , SIGNAL ( triggered () ), this , SLOT ( touch () ) );
832
+ #endif
823
833
connect ( mActionPan , SIGNAL ( triggered () ), this , SLOT ( pan () ) );
824
834
connect ( mActionPanToSelected , SIGNAL ( triggered () ), this , SLOT ( panToSelected () ) );
825
835
connect ( mActionZoomIn , SIGNAL ( triggered () ), this , SLOT ( zoomIn () ) );
@@ -1009,6 +1019,9 @@ void QgisApp::createActionGroups()
1009
1019
//
1010
1020
// Map Tool Group
1011
1021
mMapToolGroup = new QActionGroup ( this );
1022
+ #ifdef HAVE_TOUCH
1023
+ mMapToolGroup ->addAction ( mActionTouch );
1024
+ #endif
1012
1025
mMapToolGroup ->addAction ( mActionPan );
1013
1026
mMapToolGroup ->addAction ( mActionZoomIn );
1014
1027
mMapToolGroup ->addAction ( mActionZoomOut );
@@ -1529,6 +1542,9 @@ void QgisApp::setTheme( QString theThemeName )
1529
1542
mActionZoomOut ->setIcon ( getThemeIcon ( " /mActionZoomOut.png" ) );
1530
1543
mActionZoomFullExtent ->setIcon ( getThemeIcon ( " /mActionZoomFullExtent.png" ) );
1531
1544
mActionZoomToSelected ->setIcon ( getThemeIcon ( " /mActionZoomToSelected.png" ) );
1545
+ #ifdef HAVE_TOUCH
1546
+ mActionTouch ->setIcon ( getThemeIcon ( " /mActionTouch.png" ) );
1547
+ #endif
1532
1548
mActionPan ->setIcon ( getThemeIcon ( " /mActionPan.png" ) );
1533
1549
mActionZoomLast ->setIcon ( getThemeIcon ( " /mActionZoomLast.png" ) );
1534
1550
mActionZoomNext ->setIcon ( getThemeIcon ( " /mActionZoomNext.png" ) );
@@ -1660,6 +1676,10 @@ void QgisApp::createCanvasTools()
1660
1676
mMapTools .mZoomOut ->setAction ( mActionZoomOut );
1661
1677
mMapTools .mPan = new QgsMapToolPan ( mMapCanvas );
1662
1678
mMapTools .mPan ->setAction ( mActionPan );
1679
+ #ifdef HAVE_TOUCH
1680
+ mMapTools .mTouch = new QgsMapToolTouch ( mMapCanvas );
1681
+ mMapTools .mTouch ->setAction ( mActionTouch );
1682
+ #endif
1663
1683
mMapTools .mIdentify = new QgsMapToolIdentify ( mMapCanvas );
1664
1684
mMapTools .mIdentify ->setAction ( mActionIdentify );
1665
1685
mMapTools .mFeatureAction = new QgsMapToolFeatureAction ( mMapCanvas );
@@ -1725,6 +1745,9 @@ void QgisApp::createCanvasTools()
1725
1745
mMapTools .mChangeLabelProperties ->setAction ( mActionChangeLabelProperties );
1726
1746
// ensure that non edit tool is initialised or we will get crashes in some situations
1727
1747
mNonEditMapTool = mMapTools .mPan ;
1748
+ // #ifdef HAVE_TOUCH
1749
+ // mNonEditMapTool = mMapTools.mTouch;
1750
+ // #endif
1728
1751
}
1729
1752
1730
1753
void QgisApp::createOverview ()
@@ -2275,10 +2298,11 @@ bool QgisApp::addVectorLayers( QStringList const & theLayerQStringList, const QS
2275
2298
// present a dialog to choose GDAL raster sublayers
2276
2299
void QgisApp::askUserForGDALSublayers ( QgsRasterLayer *layer )
2277
2300
{
2278
- if ( !layer || layer-> subLayers (). size () < 1 )
2301
+ if ( !layer )
2279
2302
return ;
2280
2303
2281
2304
QStringList sublayers = layer->subLayers ();
2305
+
2282
2306
QgsDebugMsg ( " sublayers:\n " + sublayers.join ( " \n " ) + " \n " );
2283
2307
2284
2308
// if promptLayers=Load all, load all sublayers without prompting
@@ -2303,7 +2327,16 @@ void QgisApp::askUserForGDALSublayers( QgsRasterLayer *layer )
2303
2327
2304
2328
if ( chooseSublayersDialog.exec () )
2305
2329
{
2306
- loadGDALSublayers ( layer->source (), chooseSublayersDialog.getSelection () );
2330
+ foreach ( QString path, chooseSublayersDialog.getSelection () )
2331
+ {
2332
+ QString name = path;
2333
+ name.replace ( layer->source (), QFileInfo ( layer->source () ).completeBaseName () );
2334
+ QgsRasterLayer *rlayer = new QgsRasterLayer ( path, name );
2335
+ if ( rlayer && rlayer->isValid () )
2336
+ {
2337
+ addRasterLayer ( rlayer );
2338
+ }
2339
+ }
2307
2340
}
2308
2341
}
2309
2342
@@ -2316,9 +2349,11 @@ bool QgisApp::shouldAskUserForGDALSublayers( QgsRasterLayer *layer )
2316
2349
2317
2350
QSettings settings;
2318
2351
int promptLayers = settings.value ( " /qgis/promptForRasterSublayers" , 1 ).toInt ();
2352
+ // 0 = always -> always ask (if there are existing sublayers)
2353
+ // 1 = if needed -> ask if layer has no bands, but has sublayers
2354
+ // 2 = never
2319
2355
2320
- // return true if promptLayers=Always or if promptLayers!=Never and there are no bands
2321
- return promptLayers == 0 || ( promptLayers != 2 && layer->bandCount () == 0 );
2356
+ return promptLayers == 0 || ( promptLayers == 1 && layer->bandCount () == 0 );
2322
2357
}
2323
2358
2324
2359
// This method will load with GDAL the layers in parameter.
@@ -2732,6 +2767,10 @@ void QgisApp::fileNew( bool thePromptToSaveFlag )
2732
2767
// set the initial map tool
2733
2768
mMapCanvas ->setMapTool ( mMapTools .mPan );
2734
2769
mNonEditMapTool = mMapTools .mPan ; // signals are not yet setup to catch this
2770
+ #ifdef HAVE_TOUCH
2771
+ mMapCanvas ->setMapTool ( mMapTools .mTouch );
2772
+ mNonEditMapTool = mMapTools .mTouch ; // signals are not yet setup to catch this
2773
+ #endif
2735
2774
} // QgisApp::fileNew(bool thePromptToSaveFlag)
2736
2775
2737
2776
@@ -2821,11 +2860,7 @@ void QgisApp::fileOpen()
2821
2860
deletePrintComposers ();
2822
2861
removeAnnotationItems ();
2823
2862
// clear out any stuff from previous project
2824
-
2825
- // avoid multiple canvas redraws during loading of project files
2826
- bool bkRenderFlag = mMapCanvas ->renderFlag ();
2827
- mMapCanvas ->setRenderFlag ( false );
2828
-
2863
+ mMapCanvas ->freeze ( true );
2829
2864
removeAllLayers ();
2830
2865
2831
2866
QgsProject::instance ()->setFileName ( fullPath );
@@ -2835,7 +2870,8 @@ void QgisApp::fileOpen()
2835
2870
QMessageBox::critical ( this ,
2836
2871
tr ( " QGIS Project Read Error" ),
2837
2872
QgsProject::instance ()->error () );
2838
- mMapCanvas ->setRenderFlag ( bkRenderFlag );
2873
+ mMapCanvas ->freeze ( false );
2874
+ mMapCanvas ->refresh ();
2839
2875
return ;
2840
2876
}
2841
2877
@@ -2847,7 +2883,8 @@ void QgisApp::fileOpen()
2847
2883
// add this to the list of recently used project files
2848
2884
saveRecentProjectPath ( fullPath, settings );
2849
2885
2850
- mMapCanvas ->setRenderFlag ( bkRenderFlag );
2886
+ mMapCanvas ->freeze ( false );
2887
+ mMapCanvas ->refresh ();
2851
2888
}
2852
2889
2853
2890
} // QgisApp::fileOpen
@@ -2859,8 +2896,7 @@ void QgisApp::fileOpen()
2859
2896
*/
2860
2897
bool QgisApp::addProject ( QString projectFile )
2861
2898
{
2862
- bool bkRenderFlag = mMapCanvas ->renderFlag ();
2863
- mMapCanvas ->setRenderFlag ( false );
2899
+ mMapCanvas ->freeze ( true );
2864
2900
2865
2901
QApplication::setOverrideCursor ( Qt::WaitCursor );
2866
2902
@@ -2878,7 +2914,8 @@ bool QgisApp::addProject( QString projectFile )
2878
2914
2879
2915
QApplication::restoreOverrideCursor ();
2880
2916
2881
- mMapCanvas ->setRenderFlag ( bkRenderFlag );
2917
+ mMapCanvas ->freeze ( false );
2918
+ mMapCanvas ->refresh ();
2882
2919
return false ;
2883
2920
}
2884
2921
@@ -2914,7 +2951,8 @@ bool QgisApp::addProject( QString projectFile )
2914
2951
2915
2952
QApplication::restoreOverrideCursor ();
2916
2953
2917
- mMapCanvas ->setRenderFlag ( bkRenderFlag );
2954
+ mMapCanvas ->freeze ( false );
2955
+ mMapCanvas ->refresh ();
2918
2956
return true ;
2919
2957
} // QgisApp::addProject(QString projectFile)
2920
2958
@@ -3362,6 +3400,13 @@ void QgisApp::pan()
3362
3400
mMapCanvas ->setMapTool ( mMapTools .mPan );
3363
3401
}
3364
3402
3403
+ #ifdef HAVE_TOUCH
3404
+ void QgisApp::touch ()
3405
+ {
3406
+ mMapCanvas ->setMapTool ( mMapTools .mTouch );
3407
+ }
3408
+ #endif
3409
+
3365
3410
void QgisApp::zoomFull ()
3366
3411
{
3367
3412
mMapCanvas ->zoomToFullExtent ();
@@ -7361,8 +7406,8 @@ QMenu* QgisApp::createPopupMenu()
7361
7406
return menu;
7362
7407
}
7363
7408
7364
- #ifdef ANDROID
7365
- bool QgisApp::gestureEvent ( QGestureEvent *event )
7409
+ #ifdef HAVE_TOUCH
7410
+ bool QgisApp::gestureEvent (QGestureEvent *event)
7366
7411
{
7367
7412
if ( QGesture *tapAndHold = event->gesture ( Qt::TapAndHoldGesture ) )
7368
7413
{
0 commit comments