Skip to content
Permalink
Browse files
show failure to create a new shapefile on message bar and point to me…
…ssage log (fixes #6709)
  • Loading branch information
jef-n committed Jun 21, 2014
1 parent d2bc8fb commit 71c15f0639b2e9356b23fc9e7d113c01f10787da
Showing with 18 additions and 7 deletions.
  1. +2 −1 python/gui/qgsnewvectorlayerdialog.sip
  2. +8 −0 src/app/qgisapp.cpp
  3. +6 −5 src/gui/qgsnewvectorlayerdialog.cpp
  4. +2 −1 src/gui/qgsnewvectorlayerdialog.h
@@ -6,7 +6,8 @@ class QgsNewVectorLayerDialog : QDialog

public:

// run the dialog, create the layer. Return file name if the creation was successful
// run the dialog, create the layer.
// @return fileName on success, empty string use aborted, QString::null if creation failed
static QString runAndCreateLayer( QWidget* parent = 0, QString* enc = 0 );

QgsNewVectorLayerDialog( QWidget *parent = 0, Qt::WindowFlags fl = QgisGui::ModalDialogFlags );
@@ -3641,6 +3641,14 @@ void QgisApp::newVectorLayer()
//todo: the last parameter will change accordingly to layer type
addVectorLayers( fileNames, enc, "file" );
}
else if( fileName.isNull() )
{
QLabel *msgLabel = new QLabel( tr( "Layer creation failed. Please check the <a href=\"#messageLog\">message log</a> for further information." ), messageBar() );
msgLabel->setWordWrap( true );
connect( msgLabel, SIGNAL( linkActivated( QString ) ), mLogDock, SLOT( show() ) );
QgsMessageBarItem *item = new QgsMessageBarItem( msgLabel, QgsMessageBar::WARNING );
messageBar()->pushItem( item );
}
}

void QgisApp::newSpatialiteLayer()
@@ -243,7 +243,7 @@ QString QgsNewVectorLayerDialog::runAndCreateLayer( QWidget* parent, QString* pE
QgsNewVectorLayerDialog geomDialog( parent );
if ( geomDialog.exec() == QDialog::Rejected )
{
return QString();
return "";
}

QGis::WkbType geometrytype = geomDialog.selectedType();
@@ -261,7 +261,7 @@ QString QgsNewVectorLayerDialog::runAndCreateLayer( QWidget* parent, QString* pE
QString fileName = QFileDialog::getSaveFileName( 0, tr( "Save layer as..." ), lastUsedDir, filterString );
if ( fileName.isNull() )
{
return fileName;
return "";
}

if ( fileformat == "ESRI Shapefile" && !fileName.endsWith( ".shp", Qt::CaseInsensitive ) )
@@ -290,23 +290,24 @@ QString QgsNewVectorLayerDialog::runAndCreateLayer( QWidget* parent, QString* pE
QgsCoordinateReferenceSystem srs( crsId, QgsCoordinateReferenceSystem::InternalCrsId );
if ( !createEmptyDataSource( fileName, fileformat, enc, geometrytype, attributes, &srs ) )
{
return QString();
return QString::null;
}
}
else
{
QgsDebugMsg( "geometry type not recognised" );
return QString();
return QString::null;
}
}
else
{
QgsDebugMsg( "Resolving newEmptyDataSource(...) failed" );
return QString();
return QString::null;
}
}

if ( pEnc )
*pEnc = enc;

return fileName;
}
@@ -29,7 +29,8 @@ class GUI_EXPORT QgsNewVectorLayerDialog: public QDialog, private Ui::QgsNewVect

public:

// run the dialog, create the layer. Return file name if the creation was successful
// run the dialog, create the layer.
// @return fileName on success, empty string use aborted, QString::null if creation failed
static QString runAndCreateLayer( QWidget* parent = 0, QString* enc = 0 );

QgsNewVectorLayerDialog( QWidget *parent = 0, Qt::WindowFlags fl = QgisGui::ModalDialogFlags );

0 comments on commit 71c15f0

Please sign in to comment.