-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn that layers will be lost when overwriting container vector file #34817
Conversation
I wouldn't vouch for removing this option, the only thing that I would do is add a dialog asking for confirmation. |
To me, it's the very first message which is problematic. I think we should have a radio button on top of the dialog, letting the choice between: "create/overwrite GPGK" and "add layer to existing GPKG". That would remove any confusion, and bonus, you won't get a warning when you select an existing file in the dialog. |
No, it does not. It just saves the new layer in the existing geopackage. Imagine the exact equivalent to the Overwrite File option when saving for example a spreadsheet: An ideal solution for me would be to be able to browse the geopackage contents like it was a folder, in the file selection dialog. Then the user would already be aware of the geopackage contents and in a better position to decide the name of the layer to choose or if he wants to delete the geopackage and all it's contents. But that is probably too much work. |
-1 to remove a feature here. If wording is not clear enough, we can update that. I personally use file overwrite quite often. Not offering this option also means ppl might end up adding a layer to a preexisting gpkg without realizing it, and potentially share sensitive data by mistake. |
This may already be happening, since the dialog appears only on layer collision, not on filename collision. |
Is this an OSX thing? In my build this does not pop up, neither with the New Geopackage Layer
|
I'm with @nirvn here, I'm -1 to removing the option and think we just need extra confirmation/warning prompts instead. |
Added a warning with the layers that the user is about to say goodbye to. It should not spawn when the file has only one layer (ie Overwrite file and overwrite layer will have the same effect) so the user does not get used to it and clicks OK without thinking. It only spawns when other layers are going to be deleted.
|
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
@uclaros what happens when the layer list is too big, does the ok gets out of the screen or can there be a text box with a scroll bar in that case? |
This is a generic
with a list that long, you're probably looking for the cancel button though! |
This reverts commit a5df7fc242e7633af989ac2e970b5b9ddbcbfe55.
…ing that layers will be lost
df5ac4e
to
ac67589
Compare
@uclaros I like that! (off topic: why are your layers named .shp? 😄 ) |
@nyalldawson They were merged in a geopackage with some ad-hoc ogr2ogr bash script but didn't bother to trim the extension! Apparently Greece still lives in the age of .shp and .mdb! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Just some minor cleanups left...
{ | ||
if ( QMessageBox::question( this, | ||
tr( "Save Vector Layer As" ), | ||
tr( "The existing layer has different fields. Do you want to add the missing fields to the layer?" ) ) == QMessageBox::Yes ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tr( "The existing layer has different fields. Do you want to add the missing fields to the layer?" ) ) == QMessageBox::Yes ) | |
tr( "The existing layer has additional fields. Do you want to add the missing fields to the layer?" ) ) == QMessageBox::Yes ) |
} | ||
else if ( mActionOnExistingFile == QgsVectorFileWriter::CreateOrOverwriteFile ) | ||
{ | ||
const QList<QgsOgrDbLayerInfo *> subLayers = QgsOgrLayerItem::subLayers( filename(), format() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is leaked - the entries need to be deleted
else if ( mActionOnExistingFile == QgsVectorFileWriter::CreateOrOverwriteFile ) | ||
{ | ||
const QList<QgsOgrDbLayerInfo *> subLayers = QgsOgrLayerItem::subLayers( filename(), format() ); | ||
QStringList layerList = QStringList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QStringList layerList = QStringList(); | |
QStringList layerList; |
{ | ||
const QList<QgsOgrDbLayerInfo *> subLayers = QgsOgrLayerItem::subLayers( filename(), format() ); | ||
QStringList layerList = QStringList(); | ||
for ( const auto layer : subLayers ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for ( const auto layer : subLayers ) | |
for ( const QgsOgrDbLayerInfo* layer : subLayers ) |
layerList.sort( Qt::CaseInsensitive ); | ||
QMessageBox msgBox; | ||
msgBox.setIcon( QMessageBox::Warning ); | ||
msgBox.setWindowTitle( tr( "Overwrite file" ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msgBox.setWindowTitle( tr( "Overwrite file" ) ); | |
msgBox.setWindowTitle( tr( "Overwrite File" ) ); |
(I think we should backport this to LTR) |
@uclaros nice UI improvement on the dialog! |
Description
Removed the dangerous option to delete the whole container file (geopackage, spatialite etc) when it contains a layer with the same name as the one the user is trying to save.
Fixes #32823