141
141
#include " qgspluginmetadata.h"
142
142
#include " qgspluginregistry.h"
143
143
#include " qgspoint.h"
144
- #include " qgsprojectbadlayerguihandler .h"
144
+ #include " qgshandlebadlayers .h"
145
145
#include " qgsproject.h"
146
146
#include " qgsprojectproperties.h"
147
147
#include " qgsproviderregistry.h"
@@ -506,7 +506,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
506
506
QgsRasterLayer::buildSupportedRasterFileFilter ( mRasterFileFilter );
507
507
508
508
// set handler for missing layers (will be owned by QgsProject)
509
- QgsProject::instance ()->setBadLayerHandler ( new QgsProjectBadLayerGuiHandler () );
509
+ QgsProject::instance ()->setBadLayerHandler ( new QgsHandleBadLayersHandler () );
510
510
511
511
#if 0
512
512
// Set the background color for toolbox and overview as they default to
@@ -1125,6 +1125,12 @@ void QgisApp::createActions()
1125
1125
connect ( mActionRemoveLayer , SIGNAL ( triggered () ), this , SLOT ( removeLayer () ) );
1126
1126
mActionRemoveLayer ->setEnabled ( false );
1127
1127
1128
+ mActionSetLayerCRS = new QAction ( getThemeIcon ( " mActionSetLayerCRS.png" ), tr ( " Set CRS of Layer(s)" ), this );
1129
+ shortcuts->registerAction ( mActionSetLayerCRS , tr ( " Ctrl+Shift+C" , " Set CRS of Layer(s)" ) );
1130
+ mActionSetLayerCRS ->setStatusTip ( tr ( " Set CRS of Layer(s)" ) );
1131
+ connect ( mActionSetLayerCRS , SIGNAL ( triggered () ), this , SLOT ( setLayerCRS () ) );
1132
+ mActionSetLayerCRS ->setEnabled ( false );
1133
+
1128
1134
mActionTileScale = new QAction ( getThemeIcon ( " mActionTileScale.png" ), tr ( " Tile scale slider" ), this );
1129
1135
shortcuts->registerAction ( mActionTileScale , tr ( " " , " Tile scale slider" ) );
1130
1136
mActionTileScale ->setStatusTip ( tr ( " Show tile scale slider" ) );
@@ -1249,6 +1255,14 @@ void QgisApp::createActions()
1249
1255
#endif
1250
1256
mActionHelpContents ->setStatusTip ( tr ( " Help Documentation" ) );
1251
1257
connect ( mActionHelpContents , SIGNAL ( triggered () ), this , SLOT ( helpContents () ) );
1258
+ mActionHelpContents ->setEnabled ( QFileInfo ( QgsApplication::pkgDataPath () + " /doc/index.html" ).exists () );
1259
+
1260
+ #ifdef WITH_APIDOC
1261
+ mActionHelpAPI = new QAction ( getThemeIcon ( " mActionHelpAPI.png" ), tr ( " API documentation" ), this );
1262
+ connect ( mActionHelpAPI , SIGNAL ( triggered () ), this , SLOT ( apiDocumentation () ) );
1263
+ mActionHelpAPI ->setEnabled ( QFileInfo ( QgsApplication::pkgDataPath () + " /doc/api/index.html" ).exists () );
1264
+ #endif
1265
+
1252
1266
1253
1267
mActionQgisHomePage = new QAction ( getThemeIcon ( " mActionQgisHomePage.png" ), tr ( " QGIS Home Page" ), this );
1254
1268
#ifndef Q_WS_MAC
@@ -1609,6 +1623,7 @@ void QgisApp::createMenus()
1609
1623
mLayerMenu ->addAction ( mActionLayerSaveAs );
1610
1624
mLayerMenu ->addAction ( mActionLayerSelectionSaveAs );
1611
1625
mLayerMenu ->addAction ( mActionRemoveLayer );
1626
+ mLayerMenu ->addAction ( mActionSetLayerCRS );
1612
1627
mLayerMenu ->addAction ( mActionLayerProperties );
1613
1628
mLayerMenu ->addAction ( mActionLayerSubsetString );
1614
1629
mActionLayerSeparator2 = mLayerMenu ->addSeparator ();
@@ -1684,6 +1699,9 @@ void QgisApp::createMenus()
1684
1699
mHelpMenu = menuBar ()->addMenu ( tr ( " &Help" ) );
1685
1700
1686
1701
mHelpMenu ->addAction ( mActionHelpContents );
1702
+ #ifdef WITH_APIDOC
1703
+ mHelpMenu ->addAction ( mActionHelpAPI );
1704
+ #endif
1687
1705
mActionHelpSeparator1 = mHelpMenu ->addSeparator ();
1688
1706
1689
1707
mHelpMenu ->addAction ( mActionQgisHomePage );
@@ -1730,6 +1748,7 @@ void QgisApp::createToolBars()
1730
1748
mLayerToolBar ->addAction ( mActionAddWmsLayer );
1731
1749
mLayerToolBar ->addAction ( mActionNewVectorLayer );
1732
1750
mLayerToolBar ->addAction ( mActionRemoveLayer );
1751
+ mLayerToolBar ->addAction ( mActionSetLayerCRS );
1733
1752
// commented out for QGIS 1.4 by Tim
1734
1753
// mLayerToolBar->addAction( mActionAddToOverview );
1735
1754
// mLayerToolBar->addAction( mActionShowAllLayers );
@@ -1898,6 +1917,9 @@ void QgisApp::createToolBars()
1898
1917
mHelpToolBar = addToolBar ( tr ( " Help" ) );
1899
1918
mHelpToolBar ->setObjectName ( " Help" );
1900
1919
mHelpToolBar ->addAction ( mActionHelpContents );
1920
+ #ifdef WITH_APIDOC
1921
+ mHelpToolBar ->addAction ( mActionHelpAPI );
1922
+ #endif
1901
1923
mHelpToolBar ->addAction ( QWhatsThis::createAction () );
1902
1924
mToolbarMenu ->addAction ( mHelpToolBar ->toggleViewAction () );
1903
1925
@@ -2108,6 +2130,7 @@ void QgisApp::setTheme( QString theThemeName )
2108
2130
mActionAddPgLayer ->setIcon ( getThemeIcon ( " /mActionAddLayer.png" ) );
2109
2131
mActionAddSpatiaLiteLayer ->setIcon ( getThemeIcon ( " /mActionAddSpatiaLiteLayer.png" ) );
2110
2132
mActionRemoveLayer ->setIcon ( getThemeIcon ( " /mActionRemoveLayer.png" ) );
2133
+ mActionSetLayerCRS ->setIcon ( getThemeIcon ( " /mActionSetLayerCRS.png" ) );
2111
2134
mActionNewVectorLayer ->setIcon ( getThemeIcon ( " /mActionNewVectorLayer.png" ) );
2112
2135
mActionAddAllToOverview ->setIcon ( getThemeIcon ( " /mActionAddAllToOverview.png" ) );
2113
2136
mActionHideAllLayers ->setIcon ( getThemeIcon ( " /mActionHideAllLayers.png" ) );
@@ -2120,6 +2143,9 @@ void QgisApp::setTheme( QString theThemeName )
2120
2143
mActionOptions ->setIcon ( getThemeIcon ( " /mActionOptions.png" ) );
2121
2144
mActionConfigureShortcuts ->setIcon ( getThemeIcon ( " /mActionOptions.png" ) );
2122
2145
mActionHelpContents ->setIcon ( getThemeIcon ( " /mActionHelpContents.png" ) );
2146
+ #ifdef WITH_APIDOC
2147
+ mActionHelpAPI ->setIcon ( getThemeIcon ( " /mActionHelpApi.png" ) );
2148
+ #endif
2123
2149
mActionLocalHistogramStretch ->setIcon ( getThemeIcon ( " /mActionLocalHistogramStretch.png" ) );
2124
2150
mActionQgisHomePage ->setIcon ( getThemeIcon ( " /mActionQgisHomePage.png" ) );
2125
2151
mActionAbout ->setIcon ( getThemeIcon ( " /mActionHelpAbout.png" ) );
@@ -4107,7 +4133,7 @@ void QgisApp::saveAsVectorFileGeneral( bool saveOnlySelection )
4107
4133
}
4108
4134
else
4109
4135
{
4110
- destCRS = vlayer->srs ();
4136
+ destCRS = vlayer->crs ();
4111
4137
}
4112
4138
}
4113
4139
else
@@ -4812,7 +4838,7 @@ void QgisApp::editCut( QgsMapLayer * layerContainingSelection )
4812
4838
{
4813
4839
QgsFeatureList features = selectionVectorLayer->selectedFeatures ();
4814
4840
clipboard ()->replaceWithCopyOf ( selectionVectorLayer->pendingFields (), features );
4815
- clipboard ()->setCRS ( selectionVectorLayer->srs () );
4841
+ clipboard ()->setCRS ( selectionVectorLayer->crs () );
4816
4842
selectionVectorLayer->beginEditCommand ( tr ( " Features cut" ) );
4817
4843
selectionVectorLayer->deleteSelectedFeatures ();
4818
4844
selectionVectorLayer->endEditCommand ();
@@ -4839,7 +4865,7 @@ void QgisApp::editCopy( QgsMapLayer * layerContainingSelection )
4839
4865
{
4840
4866
QgsFeatureList features = selectionVectorLayer->selectedFeatures ();
4841
4867
clipboard ()->replaceWithCopyOf ( selectionVectorLayer->pendingFields (), features );
4842
- clipboard ()->setCRS ( selectionVectorLayer->srs () );
4868
+ clipboard ()->setCRS ( selectionVectorLayer->crs () );
4843
4869
}
4844
4870
}
4845
4871
}
@@ -4865,7 +4891,7 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
4865
4891
QgsFeatureList features;
4866
4892
if ( mMapCanvas ->mapRenderer ()->hasCrsTransformEnabled () )
4867
4893
{
4868
- features = clipboard ()->transformedCopyOf ( pasteVectorLayer->srs () );
4894
+ features = clipboard ()->transformedCopyOf ( pasteVectorLayer->crs () );
4869
4895
}
4870
4896
else
4871
4897
{
@@ -5233,6 +5259,34 @@ void QgisApp::removeLayer()
5233
5259
mMapCanvas ->refresh ();
5234
5260
}
5235
5261
5262
+ void QgisApp::setLayerCRS ()
5263
+ {
5264
+ if ( mMapCanvas && mMapCanvas ->isDrawing () )
5265
+ {
5266
+ return ;
5267
+ }
5268
+
5269
+ if ( !mMapLegend )
5270
+ {
5271
+ return ;
5272
+ }
5273
+
5274
+ QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector ( this );
5275
+ mySelector->setMessage ();
5276
+ if ( mySelector->exec () )
5277
+ {
5278
+ QgsCoordinateReferenceSystem crs ( mySelector->selectedCrsId (), QgsCoordinateReferenceSystem::InternalCrsId );
5279
+ mMapLegend ->setCRSForSelectedLayers ( crs );
5280
+ mMapCanvas ->refresh ();
5281
+ }
5282
+ else
5283
+ {
5284
+ QApplication::restoreOverrideCursor ();
5285
+ }
5286
+
5287
+ delete mySelector;
5288
+ }
5289
+
5236
5290
void QgisApp::showGpsTool ()
5237
5291
{
5238
5292
if ( !mpGpsWidget )
@@ -5550,7 +5604,7 @@ void QgisApp::options()
5550
5604
myRenderer->setProjectionsEnabled ( false );
5551
5605
}
5552
5606
mMapCanvas ->refresh ();
5553
- }
5607
+ }
5554
5608
5555
5609
delete optionsDialog;
5556
5610
}
@@ -5602,6 +5656,11 @@ void QgisApp::helpContents()
5602
5656
openURL ( " index.html" );
5603
5657
}
5604
5658
5659
+ void QgisApp::apiDocumentation ()
5660
+ {
5661
+ openURL ( " api/index.html" );
5662
+ }
5663
+
5605
5664
void QgisApp::helpQgisHomePage ()
5606
5665
{
5607
5666
openURL ( " http://qgis.org" , false );
@@ -6283,6 +6342,7 @@ void QgisApp::selectionChanged( QgsMapLayer *layer )
6283
6342
void QgisApp::legendLayerSelectionChanged ( void )
6284
6343
{
6285
6344
mActionRemoveLayer ->setEnabled ( mMapLegend && mMapLegend ->selectedLayers ().size () > 0 );
6345
+ mActionSetLayerCRS ->setEnabled ( mMapLegend && mMapLegend ->selectedLayers ().size () > 0 );
6286
6346
}
6287
6347
6288
6348
void QgisApp::activateDeactivateLayerRelatedActions ( QgsMapLayer* layer )
0 commit comments