Set yeastpack dropdown on yeast edit row start.

Thu, 02 Feb 2023 15:50:15 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 02 Feb 2023 15:50:15 +0100
changeset 484
ebf7ef31da35
parent 483
eb0a5f132ea9
child 485
83b5c2b3c414

Set yeastpack dropdown on yeast edit row start.

src/EditProductTab6.cpp file | annotate | diff | comparison | revisions
--- a/src/EditProductTab6.cpp	Thu Feb 02 15:23:18 2023 +0100
+++ b/src/EditProductTab6.cpp	Thu Feb 02 15:50:15 2023 +0100
@@ -1364,19 +1364,22 @@
     yeast_instock_changed(true);
     yeast_load_packages(product->yeasts.at(product->yeasts_row).laboratory, product->yeasts.at(product->yeasts_row).form);
 
-    int index = -1;
+    /*
+     * Try to set the yeastpack dropdown to the selected entry if set.
+     */
+    int index = 0;
     if (! product->yeasts.at(product->yeasts_row).yp_uuid.isNull() && (product->yeasts.at(product->yeasts_row).yp_uuid.length() == 36)) {
 	query.prepare("SELECT * FROM inventory_yeastpack WHERE laboratory=:laboratory AND form=:form AND valid='1' ORDER BY laboratory,package");
 	query.bindValue(":laboratory", product->yeasts.at(product->yeasts_row).laboratory);
 	query.bindValue(":form", product->yeasts.at(product->yeasts_row).form);
-	qDebug() << "  search" << product->yeasts.at(product->yeasts_row).laboratory << product->yeasts.at(product->yeasts_row).form;
 	query.exec();
 	while (query.next()) {
 	    index++;
-	    if (query.value("uuid").toString() == product->yeasts.at(product->yeasts_row).yp_uuid)
+	    if (query.value("uuid").toString() == product->yeasts.at(product->yeasts_row).yp_uuid) {
+		this->ypackageEdit->setCurrentIndex(index);
 		break;
+	    }
 	}
-	qDebug() << "  result" << index << (query.value("uuid").toString() == product->yeasts.at(product->yeasts_row).yp_uuid);
     }
 
     connect(yselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::yeast_select_changed);

mercurial