mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
show failure to create a new shapefile on message bar and point to message log (fixes #6709)
This commit is contained in:
parent
d2bc8fb40a
commit
71c15f0639
@ -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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user