Delete images from a producti first[C when a product is deleted.

Tue, 24 Jan 2023 15:57:13 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 24 Jan 2023 15:57:13 +0100
changeset 473
0d7441b39d41
parent 472
db8ad1c2112b
child 474
18b72c518d0d

Delete images from a producti first[C when a product is deleted.

src/EditProduct.cpp file | annotate | diff | comparison | revisions
translations/bmsapp_en.ts file | annotate | diff | comparison | revisions
translations/bmsapp_nl.ts file | annotate | diff | comparison | revisions
--- a/src/EditProduct.cpp	Mon Jan 23 17:23:10 2023 +0100
+++ b/src/EditProduct.cpp	Tue Jan 24 15:57:13 2023 +0100
@@ -912,6 +912,19 @@
     if (rc == QMessageBox::No)
         return;
 
+    /*
+     * First delete any pictures for this product.
+     */
+    QSqlQuery query;
+    query.prepare("DELETE FROM products_pics WHERE uuid=:uuid");
+    query.bindValue(":uuid", product->uuid);
+    query.exec();
+    if (query.lastError().isValid()) {
+        qWarning() << "on_deleteButton_clicked()" << query.lastError();
+        QMessageBox::warning(this, tr("Database error"), tr("MySQL error: %1\n%2\n%3")
+                .arg(query.lastError().nativeErrorCode()).arg(query.lastError().driverText()).arg(query.lastError().databaseText()));
+    }
+
     DB_product::dele(this, this->recno);
 
     this->close();
--- a/translations/bmsapp_en.ts	Mon Jan 23 17:23:10 2023 +0100
+++ b/translations/bmsapp_en.ts	Tue Jan 24 15:57:13 2023 +0100
@@ -4202,12 +4202,12 @@
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/EditProduct.cpp" line="934"/>
+        <location filename="../src/EditProduct.cpp" line="947"/>
         <source>Product changed</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/EditProduct.cpp" line="934"/>
+        <location filename="../src/EditProduct.cpp" line="947"/>
         <source>The product has been modified. Save changes?</source>
         <translation type="unfinished"></translation>
     </message>
@@ -4332,7 +4332,7 @@
         <location filename="../src/EditProductTab5.cpp" line="399"/>
         <location filename="../src/EditProductTab6.cpp" line="896"/>
         <location filename="../src/EditProductTab7.cpp" line="306"/>
-        <location filename="../src/EditProductTab13.cpp" line="271"/>
+        <location filename="../src/EditProductTab13.cpp" line="277"/>
         <location filename="../src/EditProduct.cpp" line="910"/>
         <source>Delete %1</source>
         <translation type="unfinished"></translation>
@@ -4980,6 +4980,9 @@
     </message>
     <message>
         <location filename="../src/EditProductTab9.cpp" line="645"/>
+        <location filename="../src/EditProductTab13.cpp" line="332"/>
+        <location filename="../src/EditProductTab13.cpp" line="335"/>
+        <location filename="../src/EditProductTab13.cpp" line="358"/>
         <location filename="../src/EditProductExport.cpp" line="37"/>
         <location filename="../src/EditProductExport.cpp" line="40"/>
         <location filename="../src/EditProductExport.cpp" line="264"/>
@@ -5254,52 +5257,73 @@
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/EditProductTab13.cpp" line="153"/>
+        <location filename="../src/EditProductTab13.cpp" line="164"/>
         <source>Open File</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/EditProductTab13.cpp" line="174"/>
+        <location filename="../src/EditProductTab13.cpp" line="180"/>
         <source>Cannot load %1: %2</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
         <location filename="../ui/EditProduct.ui" line="12295"/>
-        <location filename="../src/EditProductTab13.cpp" line="202"/>
+        <location filename="../src/EditProductTab13.cpp" line="208"/>
         <source>Image here</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/EditProductTab13.cpp" line="212"/>
+        <location filename="../src/EditProductTab13.cpp" line="218"/>
         <source>Image type:</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/EditProductTab13.cpp" line="225"/>
+        <location filename="../src/EditProductTab13.cpp" line="231"/>
         <source>Image comment:</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/EditProductTab13.cpp" line="232"/>
+        <location filename="../src/EditProductTab13.cpp" line="238"/>
         <source>The comment for this image.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/EditProductTab13.cpp" line="271"/>
+        <location filename="../src/EditProductTab13.cpp" line="277"/>
         <source>Delete image</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
+        <location filename="../src/EditProductTab13.cpp" line="333"/>
+        <source>Files (*.png)</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/EditProductTab13.cpp" line="335"/>
+        <source>No PNG file selected.</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/EditProductTab13.cpp" line="358"/>
+        <source>Saved %1</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
         <location filename="../src/EditProductTab13.cpp" line="50"/>
-        <location filename="../src/EditProductTab13.cpp" line="257"/>
-        <location filename="../src/EditProductTab13.cpp" line="285"/>
+        <location filename="../src/EditProductTab13.cpp" line="263"/>
+        <location filename="../src/EditProductTab13.cpp" line="291"/>
+        <location filename="../src/EditProductTab13.cpp" line="393"/>
+        <location filename="../src/EditProductTab13.cpp" line="418"/>
+        <location filename="../src/EditProduct.cpp" line="924"/>
         <source>Database error</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
         <location filename="../src/EditProductTab13.cpp" line="50"/>
-        <location filename="../src/EditProductTab13.cpp" line="257"/>
-        <location filename="../src/EditProductTab13.cpp" line="285"/>
+        <location filename="../src/EditProductTab13.cpp" line="263"/>
+        <location filename="../src/EditProductTab13.cpp" line="291"/>
+        <location filename="../src/EditProductTab13.cpp" line="393"/>
+        <location filename="../src/EditProductTab13.cpp" line="418"/>
+        <location filename="../src/EditProduct.cpp" line="924"/>
         <source>MySQL error: %1
 %2
 %3</source>
--- a/translations/bmsapp_nl.ts	Mon Jan 23 17:23:10 2023 +0100
+++ b/translations/bmsapp_nl.ts	Tue Jan 24 15:57:13 2023 +0100
@@ -4640,8 +4640,11 @@
     </message>
     <message>
         <location filename="../src/EditProductTab13.cpp" line="50"/>
-        <location filename="../src/EditProductTab13.cpp" line="257"/>
-        <location filename="../src/EditProductTab13.cpp" line="285"/>
+        <location filename="../src/EditProductTab13.cpp" line="263"/>
+        <location filename="../src/EditProductTab13.cpp" line="291"/>
+        <location filename="../src/EditProductTab13.cpp" line="393"/>
+        <location filename="../src/EditProductTab13.cpp" line="418"/>
+        <location filename="../src/EditProduct.cpp" line="924"/>
         <source>Database error</source>
         <translation>Database fout</translation>
     </message>
@@ -4685,8 +4688,11 @@
     </message>
     <message>
         <location filename="../src/EditProductTab13.cpp" line="50"/>
-        <location filename="../src/EditProductTab13.cpp" line="257"/>
-        <location filename="../src/EditProductTab13.cpp" line="285"/>
+        <location filename="../src/EditProductTab13.cpp" line="263"/>
+        <location filename="../src/EditProductTab13.cpp" line="291"/>
+        <location filename="../src/EditProductTab13.cpp" line="393"/>
+        <location filename="../src/EditProductTab13.cpp" line="418"/>
+        <location filename="../src/EditProduct.cpp" line="924"/>
         <source>MySQL error: %1
 %2
 %3</source>
@@ -4700,12 +4706,12 @@
         <translation>Verwijder product</translation>
     </message>
     <message>
-        <location filename="../src/EditProduct.cpp" line="934"/>
+        <location filename="../src/EditProduct.cpp" line="947"/>
         <source>Product changed</source>
         <translation>Product gewijzigd</translation>
     </message>
     <message>
-        <location filename="../src/EditProduct.cpp" line="934"/>
+        <location filename="../src/EditProduct.cpp" line="947"/>
         <source>The product has been modified. Save changes?</source>
         <translation>Het product is gewijzigd. Wijzigingen opslaan?</translation>
     </message>
@@ -4842,7 +4848,7 @@
         <location filename="../src/EditProductTab5.cpp" line="399"/>
         <location filename="../src/EditProductTab6.cpp" line="896"/>
         <location filename="../src/EditProductTab7.cpp" line="306"/>
-        <location filename="../src/EditProductTab13.cpp" line="271"/>
+        <location filename="../src/EditProductTab13.cpp" line="277"/>
         <location filename="../src/EditProduct.cpp" line="910"/>
         <source>Delete %1</source>
         <translation>Verwijder %1</translation>
@@ -5483,6 +5489,9 @@
     </message>
     <message>
         <location filename="../src/EditProductTab9.cpp" line="645"/>
+        <location filename="../src/EditProductTab13.cpp" line="332"/>
+        <location filename="../src/EditProductTab13.cpp" line="335"/>
+        <location filename="../src/EditProductTab13.cpp" line="358"/>
         <location filename="../src/EditProductExport.cpp" line="37"/>
         <location filename="../src/EditProductExport.cpp" line="40"/>
         <location filename="../src/EditProductExport.cpp" line="264"/>
@@ -5860,41 +5869,56 @@
         <translation>Bevestig dat het proeven gedaan is en opmerkingen ingevuld zijn.</translation>
     </message>
     <message>
-        <location filename="../src/EditProductTab13.cpp" line="153"/>
+        <location filename="../src/EditProductTab13.cpp" line="164"/>
         <source>Open File</source>
         <translation>Open bestand</translation>
     </message>
     <message>
-        <location filename="../src/EditProductTab13.cpp" line="174"/>
+        <location filename="../src/EditProductTab13.cpp" line="180"/>
         <source>Cannot load %1: %2</source>
         <translation>Kan niet laden %1: %2</translation>
     </message>
     <message>
         <location filename="../ui/EditProduct.ui" line="12295"/>
-        <location filename="../src/EditProductTab13.cpp" line="202"/>
+        <location filename="../src/EditProductTab13.cpp" line="208"/>
         <source>Image here</source>
         <translation>Plaatje hier</translation>
     </message>
     <message>
-        <location filename="../src/EditProductTab13.cpp" line="212"/>
+        <location filename="../src/EditProductTab13.cpp" line="218"/>
         <source>Image type:</source>
         <translation>Soort plaatje:</translation>
     </message>
     <message>
-        <location filename="../src/EditProductTab13.cpp" line="225"/>
+        <location filename="../src/EditProductTab13.cpp" line="231"/>
         <source>Image comment:</source>
         <translation>Bijschrift:</translation>
     </message>
     <message>
-        <location filename="../src/EditProductTab13.cpp" line="232"/>
+        <location filename="../src/EditProductTab13.cpp" line="238"/>
         <source>The comment for this image.</source>
         <translation>Het bijschrift of commentaar bij dit plaatje.</translation>
     </message>
     <message>
-        <location filename="../src/EditProductTab13.cpp" line="271"/>
+        <location filename="../src/EditProductTab13.cpp" line="277"/>
         <source>Delete image</source>
         <translation>Wis plaatje</translation>
     </message>
+    <message>
+        <location filename="../src/EditProductTab13.cpp" line="333"/>
+        <source>Files (*.png)</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/EditProductTab13.cpp" line="335"/>
+        <source>No PNG file selected.</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/EditProductTab13.cpp" line="358"/>
+        <source>Saved %1</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>EditProfileFerment</name>

mercurial