diff -r baf666307ebb -r 51aea8b798f0 src/ProdOnTree.cpp --- a/src/ProdOnTree.cpp Sat May 21 21:44:24 2022 +0200 +++ b/src/ProdOnTree.cpp Sun May 22 10:22:22 2022 +0200 @@ -242,8 +242,8 @@ connect(openButton, SIGNAL(clicked()), this, SLOT(on_openButton_clicked())); connect(this, SIGNAL(setStatus(QString)), parent, SLOT(statusMsg(QString))); - treeWidget->setColumnCount(4); - treeWidget->setHeaderLabels({ tr("Guide"), tr("Group"), tr("Style"), tr("Product") }); + treeWidget->setColumnCount(5); + treeWidget->setHeaderLabels({ tr("Guide"), tr("Group"), tr("Style"), tr("Code"), tr("Product") }); treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents); treeWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); @@ -298,7 +298,7 @@ query3.exec(); while (query3.next()) { name = new QTreeWidgetItem(QStringList({ "", "", "", - query3.value(2).toString() + " - " + query3.value(0).toString(), query3.value(1).toString() })); + query3.value(2).toString(), query3.value(0).toString(), query3.value(1).toString() })); st_name->addChild( name ); } } @@ -335,7 +335,7 @@ * Fill in basic details of the selected recipe. */ QSqlQuery query; - query.prepare("SELECT batch_size,boil_size,boil_time,efficiency,est_og,est_fg,est_abv,est_color,color_method,est_ibu,ibu_method,est_carb,notes,name " + query.prepare("SELECT batch_size,boil_size,boil_time,efficiency,est_og,est_fg,est_abv,est_color,color_method,est_ibu,ibu_method,est_carb,notes,name,code " "FROM products WHERE record=:record"); query.bindValue(":record", record); query.exec(); @@ -355,7 +355,7 @@ ibumethodEdit->setText(i_method[query.value(10).toInt()]); co2Edit->setValue(query.value(11).toDouble()); remarksEdit->setPlainText(query.value(12).toString()); - recipeBox->setTitle(query.value(13).toString()); + recipeBox->setTitle(query.value(14).toString() + " - " + query.value(13).toString()); recipeBox->setEnabled(true); } else { qDebug() << "Error getting product record" << record; @@ -405,15 +405,16 @@ } else { item->setExpanded(true); } - } else if (col == 3) { + } else if ((col == 3) || (col == 4)) { /* * if a recipe name is selected then: - * item column 3 contains the recipe name, - * item column 4 contains the recipe record number. + * item column 3 contains the product code, + * item column 4 contains the product name, + * item column 5 contains the product record number. */ - if (item->text(4).toInt() > 0) { - if (record != item->text(4).toInt()) { - record = item->text(4).toInt(); + if (item->text(5).toInt() > 0) { + if (record != item->text(5).toInt()) { + record = item->text(5).toInt(); showRecipe(); } } @@ -423,8 +424,8 @@ void ProdOnTree::on_item_doubleclicked(QTreeWidgetItem *item, int col) { - if ((col == 3) && (item->text(4).toInt() > 0)) { - edit(item->text(4).toInt()); + if (((col == 3) || (col == 4)) && (item->text(5).toInt() > 0)) { + edit(item->text(5).toInt()); } }