Skip to content

Commit

Permalink
fix #2763
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13600 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 30, 2010
1 parent 5ee6a71 commit 83d33b3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 32 deletions.
40 changes: 11 additions & 29 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2990,33 +2990,24 @@ void QgisApp::newVectorLayer()
std::list<std::pair<QString, QString> > attributes;
geomDialog.attributes( attributes );

bool haveLastUsedFilter = false; // by default, there is no last
// used filter
QString enc;
QString fileName;

QSettings settings; // where we keep last used filter in
// persistent state

haveLastUsedFilter = settings.contains( "/UI/lastVectorFileFilter" );
QString lastUsedFilter = settings.value( "/UI/lastVectorFileFilter",
QVariant( QString::null ) ).toString();

QString lastUsedDir = settings.value( "/UI/lastVectorFileFilterDir",
"." ).toString();
QSettings settings;
QString lastUsedDir = settings.value( "/UI/lastVectorFileFilterDir", "." ).toString();

QgsDebugMsg( "Saving vector file dialog without filters: " );

QgsEncodingFileDialog* openFileDialog = new QgsEncodingFileDialog( this,
tr( "Save As" ), lastUsedDir, "", QString( "" ) );
QgsEncodingFileDialog* openFileDialog =
new QgsEncodingFileDialog( this, tr( "Save As" ), lastUsedDir, "", QString( "" ) );

// allow for selection of more than one file
openFileDialog->setFileMode( QFileDialog::AnyFile );
openFileDialog->setAcceptMode( QFileDialog::AcceptSave );
openFileDialog->setConfirmOverwrite( true );

if ( haveLastUsedFilter ) // set the filter to the last one used
if ( settings.contains( "/UI/lastVectorFileFilter" ) )
{
QString lastUsedFilter = settings.value( "/UI/lastVectorFileFilter", QVariant( QString::null ) ).toString();
openFileDialog->selectFilter( lastUsedFilter );
}

Expand All @@ -3026,23 +3017,14 @@ void QgisApp::newVectorLayer()
return;
}

enc = openFileDialog->encoding();
fileName = openFileDialog->selectedFiles().first();

// If the file exists, delete it otherwise we'll end up loading that
// file, which can cause problems (e.g., if the file contains
// linestrings, but we're wanting to create points, we'll end up
// with a linestring file).
if ( fileformat == "ESRI Shapefile" )
{
QgsVectorFileWriter::deleteShapeFile( fileName );
}
else
{
QFile::remove( fileName );
}
if( fileformat == "ESRI Shapefile" && !fileName.endsWith( ".shp", Qt::CaseInsensitive ) )
fileName += ".shp";

settings.setValue( "/UI/lastVectorFileFilter", openFileDialog->selectedFilter() );
enc = openFileDialog->encoding();

settings.setValue( "/UI/lastVectorFileFilter", openFileDialog->selectedFilter() );
settings.setValue( "/UI/lastVectorFileFilterDir", openFileDialog->directory().absolutePath() );

delete openFileDialog;
Expand Down
7 changes: 7 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ email : sherman at mrcc.com
#include "qgsgeometry.h"
#include "qgslogger.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsvectorfilewriter.h"

static const QString TEXT_PROVIDER_KEY = "ogr";
static const QString TEXT_PROVIDER_DESCRIPTION =
Expand Down Expand Up @@ -1575,6 +1576,12 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
}
fieldNames << name;
}

QgsVectorFileWriter::deleteShapeFile( uri );
}
else
{
QFile::remove( uri );
}

OGRDataSourceH dataSource;
Expand Down
3 changes: 0 additions & 3 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ email : a.furieri@lqt.it
#include <qgsrectangle.h>
#include <qgscoordinatereferencesystem.h>

#include "qgsprovidercountcalcevent.h"
#include "qgsproviderextentcalcevent.h"

#include "qgsspatialiteprovider.h"

#include "qgslogger.h"
Expand Down

0 comments on commit 83d33b3

Please sign in to comment.