From 0240c8bab89232055bf84b12c9cff5c76ecbe698 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 12 Sep 2024 23:48:08 +0200 Subject: [PATCH] [GUI] Save as vector layer dialog: add hints about using TARGET_ARCGIS_VERSION=ARCGIS_PRO_3_2_OR_LATER when needed Fixes #58690 --- src/gui/ogr/qgsvectorlayersaveasdialog.cpp | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/gui/ogr/qgsvectorlayersaveasdialog.cpp b/src/gui/ogr/qgsvectorlayersaveasdialog.cpp index f55e1e84e24e..485339738b47 100644 --- a/src/gui/ogr/qgsvectorlayersaveasdialog.cpp +++ b/src/gui/ogr/qgsvectorlayersaveasdialog.cpp @@ -308,6 +308,57 @@ QList > QgsVectorLayerSaveAsDialog::createControls( c void QgsVectorLayerSaveAsDialog::accept() { +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,9,0) + if ( format() == QLatin1String( "OpenFileGDB" ) ) + { + // The OpenFileGDB driver supports 64-bit integer fields starting with GDAL 3.9, + // if selecting the TARGET_ARCGIS_VERSION=ARCGIS_PRO_3_2_OR_LATER option + bool targetAll = true; + for ( const QString &layerOption : layerOptions() ) + { + if ( layerOption == QLatin1String( "TARGET_ARCGIS_VERSION=ARCGIS_PRO_3_2_OR_LATER" ) ) + { + targetAll = false; + } + } + if ( targetAll ) + { + for ( int i = 0; i < mLayer->fields().size(); ++i ) + { + QgsField fld = mLayer->fields().at( i ); + if ( fld.type() == QMetaType::Type::LongLong ) + { + if ( QMessageBox::question( this, + tr( "Save Vector Layer As" ), + tr( "The layer contains at least one 64-bit integer field, which, with the current settings, can only be exported as a Real field. It could be exported as a 64-bit integer field if the TARGET_ARCGIS_VERSION layer option is set to ARCGIS_PRO_3_2_OR_LATER. Do you want to continue and export it as a Real field?" ) ) != QMessageBox::Yes ) + { + return; + } + break; + } + } + } + } + else if ( format() == QLatin1String( "FileGDB" ) ) + { + // The FileGDB driver based on the ESRI SDK doesn't support 64-bit integers + for ( int i = 0; i < mLayer->fields().size(); ++i ) + { + QgsField fld = mLayer->fields().at( i ); + if ( fld.type() == QMetaType::Type::LongLong ) + { + if ( QMessageBox::question( this, + tr( "Save Vector Layer As" ), + tr( "The layer contains at least one 64-bit integer field, which cannot be exported as such when using this output driver. 64-bit integer fields could be supported by selecting the %1 format and setting its TARGET_ARCGIS_VERSION layer option to ARCGIS_PRO_3_2_OR_LATER. Do you want to continue and export it as a Real field?" ).arg( tr( "ESRI File Geodatabase" ) ) ) != QMessageBox::Yes ) + { + return; + } + break; + } + } + } +#endif + if ( QFile::exists( fileName() ) ) { QgsVectorFileWriter::EditionCapabilities caps =