@@ -2106,19 +2106,17 @@ void QgisApp::about()
21062106 .arg ( QGis::QGIS_VERSION )
21072107 .arg ( QGis::QGIS_SVN_VERSION );
21082108#ifdef HAVE_POSTGRESQL
2109-
21102109 versionString += tr ( " This copy of QGIS has been built with PostgreSQL support." );
21112110#else
2112-
21132111 versionString += tr ( " This copy of QGIS has been built without PostgreSQL support." );
21142112#endif
2115- #ifdef HAVE_SPATIALITE
21162113
2114+ #ifdef HAVE_SPATIALITE
21172115 versionString += tr ( " \n This copy of QGIS has been built with SpatiaLite support." );
21182116#else
2119-
21202117 versionString += tr ( " \n This copy of QGIS has been built without SpatiaLite support." );
21212118#endif
2119+
21222120 versionString += tr ( " \n This binary was compiled against Qt %1,"
21232121 " and is currently running against Qt %2" )
21242122 .arg ( QT_VERSION_STR )
@@ -2399,16 +2397,16 @@ void QgisApp::loadOGRSublayers( QString layertype, QString uri, QStringList list
23992397}
24002398
24012399/* * This helper checks to see whether the file name appears to be a valid vector file name */
2402- bool QgisApp::isValidVectorFileName ( QString theFileNameQString )
2400+ bool QgisApp::isValidShapeFileName ( QString theFileNameQString )
24032401{
2404- return ( theFileNameQString.toLower (). endsWith ( " .shp" ) );
2402+ return theFileNameQString.endsWith ( " .shp" , Qt::CaseInsensitive );
24052403}
24062404
24072405/* * Overloaded of the above function provided for convenience that takes a qstring pointer */
2408- bool QgisApp::isValidVectorFileName ( QString * theFileNameQString )
2406+ bool QgisApp::isValidShapeFileName ( QString * theFileNameQString )
24092407{
24102408 // dereference and delegate
2411- return isValidVectorFileName ( *theFileNameQString );
2409+ return isValidShapeFileName ( *theFileNameQString );
24122410}
24132411
24142412#ifndef HAVE_POSTGRESQL
@@ -2524,7 +2522,6 @@ void QgisApp::addSpatiaLiteLayer()
25242522 QStringList::Iterator it = tables.begin ();
25252523 while ( it != tables.end () )
25262524 {
2527-
25282525 // normalizing the layer name
25292526 QString layername = *it;
25302527 layername = layername.mid ( 1 );
@@ -2736,13 +2733,28 @@ void QgisApp::newVectorLayer()
27362733 openFileDialog->selectFilter ( lastUsedFilter );
27372734 }
27382735
2739- if ( openFileDialog->exec () != QDialog::Accepted )
2736+ int res;
2737+ while (( res = openFileDialog->exec () ) == QDialog::Accepted )
2738+ {
2739+ fileName = openFileDialog->selectedFiles ().first ();
2740+
2741+ if ( fileformat == " ESRI Shapefile" && !isValidShapeFileName ( fileName ) )
2742+ {
2743+ QMessageBox::information ( this ,
2744+ tr ( " New Shapefile" ),
2745+ tr ( " Shapefiles must end on .shp" ) );
2746+ continue ;
2747+ }
2748+
2749+ break ;
2750+ }
2751+
2752+ if ( res == QDialog::Rejected )
27402753 {
27412754 delete openFileDialog;
27422755 return ;
27432756 }
27442757
2745- fileName = openFileDialog->selectedFiles ().first ();
27462758 enc = openFileDialog->encoding ();
27472759
27482760 // If the file exists, delete it otherwise we'll end up loading that
@@ -2751,9 +2763,6 @@ void QgisApp::newVectorLayer()
27512763 // with a linestring file).
27522764 if ( fileformat == " ESRI Shapefile" )
27532765 {
2754- if ( !fileName.endsWith ( " .shp" , Qt::CaseInsensitive ) )
2755- fileName += " .shp" ;
2756-
27572766 QgsVectorFileWriter::deleteShapeFile ( fileName );
27582767 }
27592768 else
@@ -3505,15 +3514,17 @@ void QgisApp::deleteSelected( QgsMapLayer *layer )
35053514
35063515 if ( !layer )
35073516 {
3508- QMessageBox::information ( this , tr ( " No Layer Selected" ),
3517+ QMessageBox::information ( this ,
3518+ tr ( " No Layer Selected" ),
35093519 tr ( " To delete features, you must select a vector layer in the legend" ) );
35103520 return ;
35113521 }
35123522
35133523 QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer );
35143524 if ( !vlayer )
35153525 {
3516- QMessageBox::information ( this , tr ( " No Vector Layer Selected" ),
3526+ QMessageBox::information ( this ,
3527+ tr ( " No Vector Layer Selected" ),
35173528 tr ( " Deleting features only works on vector layers" ) );
35183529 return ;
35193530 }
@@ -3957,7 +3968,7 @@ void QgisApp::editCut( QgsMapLayer * layerContainingSelection )
39573968 if ( selectionVectorLayer != 0 )
39583969 {
39593970 QgsFeatureList features = selectionVectorLayer->selectedFeatures ();
3960- clipboard ()->replaceWithCopyOf ( selectionVectorLayer->dataProvider ()-> fields (), features );
3971+ clipboard ()->replaceWithCopyOf ( selectionVectorLayer->pendingFields (), features );
39613972 clipboard ()->setCRS ( selectionVectorLayer->srs () );
39623973 selectionVectorLayer->beginEditCommand ( tr ( " Features cut" ) );
39633974 selectionVectorLayer->deleteSelectedFeatures ();
@@ -3986,14 +3997,14 @@ void QgisApp::editCopy( QgsMapLayer * layerContainingSelection )
39863997 if ( selectionVectorLayer != 0 )
39873998 {
39883999 QgsFeatureList features = selectionVectorLayer->selectedFeatures ();
3989- clipboard ()->replaceWithCopyOf ( selectionVectorLayer->dataProvider ()-> fields (), features );
4000+ clipboard ()->replaceWithCopyOf ( selectionVectorLayer->pendingFields (), features );
39904001 clipboard ()->setCRS ( selectionVectorLayer->srs () );
39914002 }
39924003 }
39934004}
39944005
39954006
3996- void QgisApp::editPaste ( QgsMapLayer * destinationLayer )
4007+ void QgisApp::editPaste ( QgsMapLayer *destinationLayer )
39974008{
39984009 if ( mMapCanvas && mMapCanvas ->isDrawing () )
39994010 {
0 commit comments