show failure to create a new shapefile on message bar and point to message log (fixes #6709)

This commit is contained in:
Juergen E. Fischer 2014-06-21 21:53:16 +02:00
parent d2bc8fb40a
commit 71c15f0639
4 changed files with 18 additions and 7 deletions

View File

@ -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 );

View File

@ -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()

View File

@ -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;
}

View File

@ -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 );