Mon, 13 Jun 2022 15:47:16 +0200
Member names for hops normalized.
--- a/src/EditProductExport.cpp Mon Jun 13 12:26:27 2022 +0200 +++ b/src/EditProductExport.cpp Mon Jun 13 15:47:16 2022 +0200 @@ -124,16 +124,16 @@ for (int i = 0; i < product->hops.size(); i++) { xmlWriter->writeStartElement("HOP"); xmlWriter->writeTextElement("VERSION", "1"); - xmlWriter->writeTextElement("NAME", product->hops.at(i).h_name); - xmlWriter->writeTextElement("ALPHA", QString::number(product->hops.at(i).h_alpha, 'f', 1)); - xmlWriter->writeTextElement("AMOUNT", QString::number(product->hops.at(i).h_amount, 'f', 4)); - xmlWriter->writeTextElement("USE", hop_use[product->hops.at(i).h_useat]); - xmlWriter->writeTextElement("TIME", QString::number(product->hops.at(i).h_time, 'f', 0)); - xmlWriter->writeTextElement("TYPE", hop_types[product->hops.at(i).h_type]); - xmlWriter->writeTextElement("FORM", hop_forms[product->hops.at(i).h_form]); - xmlWriter->writeTextElement("BETA", QString::number(product->hops.at(i).h_beta, 'f', 1)); - xmlWriter->writeTextElement("HSI", QString::number(product->hops.at(i).h_hsi, 'f', 1)); - xmlWriter->writeTextElement("ORIGIN", product->hops.at(i).h_origin); + xmlWriter->writeTextElement("NAME", product->hops.at(i).name); + xmlWriter->writeTextElement("ALPHA", QString::number(product->hops.at(i).alpha, 'f', 1)); + xmlWriter->writeTextElement("AMOUNT", QString::number(product->hops.at(i).amount, 'f', 4)); + xmlWriter->writeTextElement("USE", hop_use[product->hops.at(i).useat]); + xmlWriter->writeTextElement("TIME", QString::number(product->hops.at(i).time, 'f', 0)); + xmlWriter->writeTextElement("TYPE", hop_types[product->hops.at(i).type]); + xmlWriter->writeTextElement("FORM", hop_forms[product->hops.at(i).form]); + xmlWriter->writeTextElement("BETA", QString::number(product->hops.at(i).beta, 'f', 1)); + xmlWriter->writeTextElement("HSI", QString::number(product->hops.at(i).hsi, 'f', 1)); + xmlWriter->writeTextElement("ORIGIN", product->hops.at(i).origin); xmlWriter->writeEndElement(); } xmlWriter->writeEndElement(); // HOPS @@ -471,20 +471,20 @@ memo.append("[tabular]\n"); memo.append("[head]Hop[/head][head]Vorm[/head][head]Alpha[/head][head]IBU[/head][head]Gram[/head][head]Toevoegen moment[/head]\n"); for (int i = 0; i < product->hops.size(); i++) { - double ibu = Utils::toIBU(product->hops.at(i).h_useat, product->hops.at(i).h_form, product->preboil_sg, product->batch_size, - product->hops.at(i).h_amount, product->hops.at(i).h_time, product->hops.at(i).h_alpha, product->ibu_method, + double ibu = Utils::toIBU(product->hops.at(i).useat, product->hops.at(i).form, product->preboil_sg, product->batch_size, + product->hops.at(i).amount, product->hops.at(i).time, product->hops.at(i).alpha, product->ibu_method, product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); - memo.append("[row][data]" + product->hops.at(i).h_name + " (" + product->hops.at(i).h_origin + ")[/data]"); - memo.append("[data]" + hop_forms[product->hops.at(i).h_form] + "[/data]"); - memo.append("[data]" + QString::number(product->hops.at(i).h_alpha, 'f', 1) + "[/data]"); + memo.append("[row][data]" + product->hops.at(i).name + " (" + product->hops.at(i).origin + ")[/data]"); + memo.append("[data]" + hop_forms[product->hops.at(i).form] + "[/data]"); + memo.append("[data]" + QString::number(product->hops.at(i).alpha, 'f', 1) + "[/data]"); memo.append("[data]" + QString::number(ibu, 'f', 1) + "[/data]"); - memo.append("[data]" + QString::number(product->hops.at(i).h_amount * 1000, 'f', 2) + "[/data]"); - if (product->hops.at(i).h_useat == HOP_USEAT_BOIL || product->hops.at(i).h_useat == HOP_USEAT_WHIRLPOOL) - memo.append("[data]" + hop_use[product->hops.at(i).h_useat] + " " + QString::number(product->hops.at(i).h_time) + " minuten[/data][/row]\n"); - else if (product->hops.at(i).h_useat == HOP_USEAT_DRY_HOP) - memo.append("[data]" + hop_use[product->hops.at(i).h_useat] + " " + QString::number(product->hops.at(i).h_time / 1440) + " dagen[/data][/row]\n"); + memo.append("[data]" + QString::number(product->hops.at(i).amount * 1000, 'f', 2) + "[/data]"); + if (product->hops.at(i).useat == HOP_USEAT_BOIL || product->hops.at(i).useat == HOP_USEAT_WHIRLPOOL) + memo.append("[data]" + hop_use[product->hops.at(i).useat] + " " + QString::number(product->hops.at(i).time) + " minuten[/data][/row]\n"); + else if (product->hops.at(i).useat == HOP_USEAT_DRY_HOP) + memo.append("[data]" + hop_use[product->hops.at(i).useat] + " " + QString::number(product->hops.at(i).time / 1440) + " dagen[/data][/row]\n"); else - memo.append("[data]" + hop_use[product->hops.at(i).h_useat] + "[/data][/row]\n"); + memo.append("[data]" + hop_use[product->hops.at(i).useat] + "[/data][/row]\n"); } memo.append("[/tabular]\n\n"); @@ -929,7 +929,7 @@ sp->fermentables[j].f_amount = round(sp->fermentables.at(j).f_amount * factor * 100000) / 100000; } for (int j = 0; j < sp->hops.size(); j++) { - sp->hops[j].h_amount = round(sp->hops.at(j).h_amount * factor * 100000) / 100000; + sp->hops[j].amount = round(sp->hops.at(j).amount * factor * 100000) / 100000; } for (int j = 0; j < sp->miscs.size(); j++) { sp->miscs[j].amount = round(sp->miscs.at(j).amount * factor * 100000) / 100000; @@ -986,7 +986,7 @@ sp->fermentables[j].f_amount = round(sp->fermentables.at(j).f_amount * factor * 100000) / 100000; } for (int j = 0; j < sp->hops.size(); j++) { - sp->hops[j].h_amount = round(sp->hops.at(j).h_amount * factor * 100000) / 100000; + sp->hops[j].amount = round(sp->hops.at(j).amount * factor * 100000) / 100000; } for (int j = 0; j < sp->miscs.size(); j++) { sp->miscs[j].amount = round(sp->miscs.at(j).amount * factor * 100000) / 100000;
--- a/src/EditProductTab4.cpp Mon Jun 13 12:26:27 2022 +0200 +++ b/src/EditProductTab4.cpp Mon Jun 13 15:47:16 2022 +0200 @@ -21,17 +21,17 @@ bool EditProduct::hop_sort_test(const Hops &D1, const Hops &D2) { - if (D1.h_useat > D2.h_useat) + if (D1.useat > D2.useat) return false; - if (D1.h_useat < D2.h_useat) + if (D1.useat < D2.useat) return true; /* Same useat moments, test time. */ - if (D1.h_time < D2.h_time) + if (D1.time < D2.time) return false; - if (D1.h_time > D2.h_time) + if (D1.time > D2.time) return true; /* Finally consider the amounts */ - return (D1.h_amount > D2.h_amount); + return (D1.amount > D2.amount); } @@ -67,57 +67,57 @@ for (int i = 0; i < product->hops.size(); i++) { - ui->hopsTable->setItem(i, 0, new QTableWidgetItem(product->hops.at(i).h_origin)); - ui->hopsTable->setItem(i, 1, new QTableWidgetItem(product->hops.at(i).h_name)); + ui->hopsTable->setItem(i, 0, new QTableWidgetItem(product->hops.at(i).origin)); + ui->hopsTable->setItem(i, 1, new QTableWidgetItem(product->hops.at(i).name)); - item = new QTableWidgetItem(hop_types[product->hops.at(i).h_type]); + item = new QTableWidgetItem(hop_types[product->hops.at(i).type]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->hopsTable->setItem(i, 2, item); - item = new QTableWidgetItem(hop_forms[product->hops.at(i).h_form]); + item = new QTableWidgetItem(hop_forms[product->hops.at(i).form]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->hopsTable->setItem(i, 3, item); - item = new QTableWidgetItem(QString("%1%").arg(product->hops.at(i).h_alpha, 2, 'f', 1, '0')); + item = new QTableWidgetItem(QString("%1%").arg(product->hops.at(i).alpha, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(i, 4, item); - item = new QTableWidgetItem(hop_useat[product->hops.at(i).h_useat]); + item = new QTableWidgetItem(hop_useat[product->hops.at(i).useat]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->hopsTable->setItem(i, 5, item); - if (product->hops.at(i).h_useat == 2 || product->hops.at(i).h_useat == 4) { // Boil or whirlpool - item = new QTableWidgetItem(QString("%1 min.").arg(product->hops.at(i).h_time, 1, 'f', 0, '0')); - } else if (product->hops.at(i).h_useat == 5) { // Dry-hop - item = new QTableWidgetItem(QString("%1 days.").arg(product->hops.at(i).h_time / 1440, 1, 'f', 0, '0')); + if (product->hops.at(i).useat == 2 || product->hops.at(i).useat == 4) { // Boil or whirlpool + item = new QTableWidgetItem(QString("%1 min.").arg(product->hops.at(i).time, 1, 'f', 0, '0')); + } else if (product->hops.at(i).useat == 5) { // Dry-hop + item = new QTableWidgetItem(QString("%1 days.").arg(product->hops.at(i).time / 1440, 1, 'f', 0, '0')); } else { item = new QTableWidgetItem(QString("")); } item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(i, 6, item); - double ibu = Utils::toIBU(product->hops.at(i).h_useat, product->hops.at(i).h_form, product->preboil_sg, product->batch_size, - product->hops.at(i).h_amount, product->hops.at(i).h_time, product->hops.at(i).h_alpha, product->ibu_method, + double ibu = Utils::toIBU(product->hops.at(i).useat, product->hops.at(i).form, product->preboil_sg, product->batch_size, + product->hops.at(i).amount, product->hops.at(i).time, product->hops.at(i).alpha, product->ibu_method, product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(i, 7, item); - if (product->hops.at(i).h_amount < 1.0) { - item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(i).h_amount * 1000.0, 2, 'f', 1, '0')); + if (product->hops.at(i).amount < 1.0) { + item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(i).amount * 1000.0, 2, 'f', 1, '0')); } else { - item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).h_amount, 4, 'f', 3, '0')); + item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).amount, 4, 'f', 3, '0')); } item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(i, 8, item); - if (product->hops.at(i).h_inventory < 1.0) { - item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(i).h_inventory * 1000.0, 2, 'f', 1, '0')); + if (product->hops.at(i).inventory < 1.0) { + item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(i).inventory * 1000.0, 2, 'f', 1, '0')); } else { - item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).h_inventory, 4, 'f', 3, '0')); + item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).inventory, 4, 'f', 3, '0')); } item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - if (product->hops.at(i).h_inventory < product->hops.at(i).h_amount) + if (product->hops.at(i).inventory < product->hops.at(i).amount) item->setForeground(QBrush(QColor(Qt::red))); ui->hopsTable->setItem(i, 9, item); @@ -234,20 +234,20 @@ product->hops_ok = true; for (int i = 0; i < product->hops.size(); i++) { - ibus += Utils::toIBU(product->hops.at(i).h_useat, product->hops.at(i).h_form, product->preboil_sg, - product->batch_size, product->hops.at(i).h_amount, - product->hops.at(i).h_time, product->hops.at(i).h_alpha, product->ibu_method, + ibus += Utils::toIBU(product->hops.at(i).useat, product->hops.at(i).form, product->preboil_sg, + product->batch_size, product->hops.at(i).amount, + product->hops.at(i).time, product->hops.at(i).alpha, product->ibu_method, product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); - ferm_ibus += Utils::toIBU(product->hops.at(i).h_useat, product->hops.at(i).h_form, product->preboil_sg, - product->brew_fermenter_volume + product->brew_fermenter_tcloss, product->hops.at(i).h_amount, - product->hops.at(i).h_time, product->hops.at(i).h_alpha, product->ibu_method, + ferm_ibus += Utils::toIBU(product->hops.at(i).useat, product->hops.at(i).form, product->preboil_sg, + product->brew_fermenter_volume + product->brew_fermenter_tcloss, product->hops.at(i).amount, + product->hops.at(i).time, product->hops.at(i).alpha, product->ibu_method, product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); - hop_flavour += Utils::hopFlavourContribution(product->hops.at(i).h_time, product->batch_size, product->hops.at(i).h_useat, product->hops.at(i).h_amount); - hop_aroma += Utils::hopAromaContribution(product->hops.at(i).h_time, product->batch_size, product->hops.at(i).h_useat, product->hops.at(i).h_amount); - if ((((product->inventory_reduced <= PROD_STAGE_BREW) && (product->hops.at(i).h_useat <= HOP_USEAT_WHIRLPOOL)) || - ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->hops.at(i).h_useat == HOP_USEAT_DRY_HOP))) && - (product->hops.at(i).h_inventory < product->hops.at(i).h_amount)) + hop_flavour += Utils::hopFlavourContribution(product->hops.at(i).time, product->batch_size, product->hops.at(i).useat, product->hops.at(i).amount); + hop_aroma += Utils::hopAromaContribution(product->hops.at(i).time, product->batch_size, product->hops.at(i).useat, product->hops.at(i).amount); + if ((((product->inventory_reduced <= PROD_STAGE_BREW) && (product->hops.at(i).useat <= HOP_USEAT_WHIRLPOOL)) || + ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->hops.at(i).useat == HOP_USEAT_DRY_HOP))) && + (product->hops.at(i).inventory < product->hops.at(i).amount)) product->hops_ok = false; } @@ -278,27 +278,27 @@ qDebug() << "Add hop row"; for (int i = 0; i < product->hops.size(); i++) { - if (product->hops.at(i).h_amount == 0 && product->hops.at(i).h_alpha == 0) + if (product->hops.at(i).amount == 0 && product->hops.at(i).alpha == 0) return; // Add only one at a time. } - newh.h_name = "Select one"; - newh.h_origin = ""; - newh.h_amount = 0; - newh.h_cost = 0; - newh.h_type = HOP_TYPE_BITTERING; - newh.h_form = HOP_FORMS_PELLET; - newh.h_useat = HOP_USEAT_BOIL; - newh.h_time = 0; - newh.h_alpha = 0; - newh.h_beta = 0; - newh.h_hsi = 0; - newh.h_humulene = 0; - newh.h_caryophyllene = 0; - newh.h_cohumulone = 0; - newh.h_myrcene = 0; - newh.h_total_oil = 0; - newh.h_inventory = 0; + newh.name = "Select one"; + newh.origin = ""; + newh.amount = 0; + newh.cost = 0; + newh.type = HOP_TYPE_BITTERING; + newh.form = HOP_FORMS_PELLET; + newh.useat = HOP_USEAT_BOIL; + newh.time = 0; + newh.alpha = 0; + newh.beta = 0; + newh.hsi = 0; + newh.humulene = 0; + newh.caryophyllene = 0; + newh.cohumulone = 0; + newh.myrcene = 0; + newh.total_oil = 0; + newh.inventory = 0; product->hops.append(newh); emit refreshAll(); @@ -314,7 +314,7 @@ int row = pb->objectName().toInt(); qDebug() << "Delete hop row" << row << product->hops.size(); - int rc = QMessageBox::warning(this, tr("Delete hop"), tr("Delete %1").arg(product->hops.at(row).h_name), + int rc = QMessageBox::warning(this, tr("Delete hop"), tr("Delete %1").arg(product->hops.at(row).name), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (rc == QMessageBox::No) return; @@ -331,14 +331,14 @@ qDebug() << "hop_amount_changed()" << product->hops_row << val; - product->hops[product->hops_row].h_amount = val / 1000.0; + product->hops[product->hops_row].amount = val / 1000.0; item = new QTableWidgetItem(QString("%1 gr").arg(val, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(product->hops_row, 8, item); - double ibu = Utils::toIBU(product->hops.at(product->hops_row).h_useat, product->hops.at(product->hops_row).h_form, product->preboil_sg, - product->batch_size, product->hops.at(product->hops_row).h_amount, product->hops.at(product->hops_row).h_time, - product->hops.at(product->hops_row).h_alpha, product->ibu_method, + double ibu = Utils::toIBU(product->hops.at(product->hops_row).useat, product->hops.at(product->hops_row).form, product->preboil_sg, + product->batch_size, product->hops.at(product->hops_row).amount, product->hops.at(product->hops_row).time, + product->hops.at(product->hops_row).alpha, product->ibu_method, product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); ibuEdit->setValue(ibu); @@ -357,22 +357,22 @@ qDebug() << "hop_time_changed()" << product->hops_row << val; - if (product->hops.at(product->hops_row).h_useat == HOP_USEAT_BOIL || product->hops.at(product->hops_row).h_useat == HOP_USEAT_WHIRLPOOL) { + if (product->hops.at(product->hops_row).useat == HOP_USEAT_BOIL || product->hops.at(product->hops_row).useat == HOP_USEAT_WHIRLPOOL) { item = new QTableWidgetItem(QString("%1 min.").arg(val, 1, 'f', 0, '0')); - product->hops[product->hops_row].h_time = val; - } else if (product->hops.at(product->hops_row).h_useat == HOP_USEAT_DRY_HOP) { + product->hops[product->hops_row].time = val; + } else if (product->hops.at(product->hops_row).useat == HOP_USEAT_DRY_HOP) { item = new QTableWidgetItem(QString("%1 days.").arg(val, 1, 'f', 0, '0')); - product->hops[product->hops_row].h_time = val * 1440; + product->hops[product->hops_row].time = val * 1440; } else { item = new QTableWidgetItem(QString("")); - product->hops[product->hops_row].h_time = val; + product->hops[product->hops_row].time = val; } item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(product->hops_row, 6, item); - double ibu = Utils::toIBU(product->hops.at(product->hops_row).h_useat, product->hops.at(product->hops_row).h_form, product->preboil_sg, - product->batch_size, product->hops.at(product->hops_row).h_amount, product->hops.at(product->hops_row).h_time, - product->hops.at(product->hops_row).h_alpha, product->ibu_method, + double ibu = Utils::toIBU(product->hops.at(product->hops_row).useat, product->hops.at(product->hops_row).form, product->preboil_sg, + product->batch_size, product->hops.at(product->hops_row).amount, product->hops.at(product->hops_row).time, + product->hops.at(product->hops_row).alpha, product->ibu_method, product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); ibuEdit->setValue(ibu); @@ -414,45 +414,45 @@ /* * Replace the hop record contents */ - product->hops[product->hops_row].h_name = query.value(0).toString(); - product->hops[product->hops_row].h_origin = query.value(1).toString(); - product->hops[product->hops_row].h_alpha = query.value(2).toDouble(); - product->hops[product->hops_row].h_beta = query.value(3).toDouble(); - product->hops[product->hops_row].h_humulene = query.value(4).toDouble(); - product->hops[product->hops_row].h_caryophyllene = query.value(5).toDouble(); - product->hops[product->hops_row].h_cohumulone = query.value(6).toDouble(); - product->hops[product->hops_row].h_myrcene = query.value(7).toDouble(); - product->hops[product->hops_row].h_hsi = query.value(8).toDouble(); - product->hops[product->hops_row].h_total_oil = query.value(9).toDouble(); - product->hops[product->hops_row].h_type = query.value(10).toInt(); - product->hops[product->hops_row].h_form = query.value(11).toInt(); - product->hops[product->hops_row].h_cost = query.value(12).toDouble(); - product->hops[product->hops_row].h_inventory = query.value(13).toDouble(); + product->hops[product->hops_row].name = query.value(0).toString(); + product->hops[product->hops_row].origin = query.value(1).toString(); + product->hops[product->hops_row].alpha = query.value(2).toDouble(); + product->hops[product->hops_row].beta = query.value(3).toDouble(); + product->hops[product->hops_row].humulene = query.value(4).toDouble(); + product->hops[product->hops_row].caryophyllene = query.value(5).toDouble(); + product->hops[product->hops_row].cohumulone = query.value(6).toDouble(); + product->hops[product->hops_row].myrcene = query.value(7).toDouble(); + product->hops[product->hops_row].hsi = query.value(8).toDouble(); + product->hops[product->hops_row].total_oil = query.value(9).toDouble(); + product->hops[product->hops_row].type = query.value(10).toInt(); + product->hops[product->hops_row].form = query.value(11).toInt(); + product->hops[product->hops_row].cost = query.value(12).toDouble(); + product->hops[product->hops_row].inventory = query.value(13).toDouble(); /* * Update the visible fields */ - hnameEdit->setText(product->hops.at(product->hops_row).h_name); - horiginEdit->setText(product->hops.at(product->hops_row).h_origin); + hnameEdit->setText(product->hops.at(product->hops_row).name); + horiginEdit->setText(product->hops.at(product->hops_row).origin); - double ibu = Utils::toIBU(product->hops.at(product->hops_row).h_useat, product->hops.at(product->hops_row).h_form, product->preboil_sg, - product->batch_size, product->hops.at(product->hops_row).h_amount, product->hops.at(product->hops_row).h_time, - product->hops.at(product->hops_row).h_alpha, product->ibu_method, + double ibu = Utils::toIBU(product->hops.at(product->hops_row).useat, product->hops.at(product->hops_row).form, product->preboil_sg, + product->batch_size, product->hops.at(product->hops_row).amount, product->hops.at(product->hops_row).time, + product->hops.at(product->hops_row).alpha, product->ibu_method, product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); ibuEdit->setValue(ibu); - ui->hopsTable->setItem(product->hops_row, 0, new QTableWidgetItem(product->hops.at(product->hops_row).h_origin)); - ui->hopsTable->setItem(product->hops_row, 1, new QTableWidgetItem(product->hops.at(product->hops_row).h_name)); + ui->hopsTable->setItem(product->hops_row, 0, new QTableWidgetItem(product->hops.at(product->hops_row).origin)); + ui->hopsTable->setItem(product->hops_row, 1, new QTableWidgetItem(product->hops.at(product->hops_row).name)); - item = new QTableWidgetItem(hop_types[product->hops.at(product->hops_row).h_type]); + item = new QTableWidgetItem(hop_types[product->hops.at(product->hops_row).type]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->hopsTable->setItem(product->hops_row, 2, item); - item = new QTableWidgetItem(hop_forms[product->hops.at(product->hops_row).h_form]); + item = new QTableWidgetItem(hop_forms[product->hops.at(product->hops_row).form]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->hopsTable->setItem(product->hops_row, 3, item); - item = new QTableWidgetItem(QString("%1%").arg(product->hops.at(product->hops_row).h_alpha, 2, 'f', 1, '0')); + item = new QTableWidgetItem(QString("%1%").arg(product->hops.at(product->hops_row).alpha, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(product->hops_row, 4, item); @@ -460,13 +460,13 @@ item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(product->hops_row, 7, item); - if (product->hops.at(product->hops_row).h_inventory < 1.0) { - item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(product->hops_row).h_inventory * 1000.0, 2, 'f', 1, '0')); + if (product->hops.at(product->hops_row).inventory < 1.0) { + item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(product->hops_row).inventory * 1000.0, 2, 'f', 1, '0')); } else { - item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(product->hops_row).h_inventory, 4, 'f', 3, '0')); + item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(product->hops_row).inventory, 4, 'f', 3, '0')); } item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - if (product->hops.at(product->hops_row).h_inventory < product->hops.at(product->hops_row).h_amount) + if (product->hops.at(product->hops_row).inventory < product->hops.at(product->hops_row).amount) item->setForeground(QBrush(QColor(Qt::red))); ui->hopsTable->setItem(product->hops_row, 9, item); @@ -503,18 +503,18 @@ { qDebug() << "hop_useat_changed()" << product->hops_row << val; - product->hops[product->hops_row].h_useat = val; + product->hops[product->hops_row].useat = val; QTableWidgetItem *item = new QTableWidgetItem(hop_useat[val]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->hopsTable->setItem(product->hops_row, 5, item); if (val == HOP_USEAT_BOIL || val == HOP_USEAT_WHIRLPOOL) { htimeLabel->setText(tr("Time in minutes:")); - htimeEdit->setValue(product->hops.at(product->hops_row).h_time); + htimeEdit->setValue(product->hops.at(product->hops_row).time); htimeEdit->setReadOnly(false); } else if (val == HOP_USEAT_DRY_HOP) { htimeLabel->setText(tr("Time in days:")); - htimeEdit->setValue(product->hops.at(product->hops_row).h_time / 1440); + htimeEdit->setValue(product->hops.at(product->hops_row).time / 1440); htimeEdit->setReadOnly(false); } else { htimeLabel->setText(""); @@ -565,9 +565,9 @@ amountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); htimeLabel = new QLabel(dialog); htimeLabel->setObjectName(QString::fromUtf8("htimeLabel")); - if (product->hops.at(product->hops_row).h_useat == 5) // Dry-hop + if (product->hops.at(product->hops_row).useat == 5) // Dry-hop htimeLabel->setText(tr("Time in days:")); - else if (product->hops.at(product->hops_row).h_useat == 2 || product->hops.at(product->hops_row).h_useat == 4) // Boil or whirlpool + else if (product->hops.at(product->hops_row).useat == 2 || product->hops.at(product->hops_row).useat == 4) // Boil or whirlpool htimeLabel->setText(tr("Time in minutes:")); else htimeLabel->setText(""); @@ -601,12 +601,12 @@ hnameEdit = new QLineEdit(dialog); hnameEdit->setObjectName(QString::fromUtf8("hnameEdit")); - hnameEdit->setText(product->hops.at(product->hops_row).h_name); + hnameEdit->setText(product->hops.at(product->hops_row).name); hnameEdit->setGeometry(QRect(160, 10, 511, 23)); hnameEdit->setReadOnly(true); horiginEdit = new QLineEdit(dialog); horiginEdit->setObjectName(QString::fromUtf8("horiginEdit")); - horiginEdit->setText(product->hops.at(product->hops_row).h_origin); + horiginEdit->setText(product->hops.at(product->hops_row).origin); horiginEdit->setGeometry(QRect(160, 40, 511, 23)); horiginEdit->setReadOnly(true); hamountEdit = new QDoubleSpinBox(dialog); @@ -617,18 +617,18 @@ hamountEdit->setDecimals(1); hamountEdit->setMaximum(1000000.0); hamountEdit->setSingleStep(0.5); - hamountEdit->setValue(product->hops.at(product->hops_row).h_amount * 1000.0); + hamountEdit->setValue(product->hops.at(product->hops_row).amount * 1000.0); htimeEdit = new QSpinBox(dialog); htimeEdit->setObjectName(QString::fromUtf8("htimeEdit")); htimeEdit->setGeometry(QRect(160, 130, 121, 24)); htimeEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); htimeEdit->setAccelerated(true); htimeEdit->setMaximum(10000.0); - if (product->hops.at(product->hops_row).h_useat == HOP_USEAT_BOIL || product->hops.at(product->hops_row).h_useat == HOP_USEAT_WHIRLPOOL) { - htimeEdit->setValue(product->hops.at(product->hops_row).h_time); + if (product->hops.at(product->hops_row).useat == HOP_USEAT_BOIL || product->hops.at(product->hops_row).useat == HOP_USEAT_WHIRLPOOL) { + htimeEdit->setValue(product->hops.at(product->hops_row).time); htimeEdit->setReadOnly(false); - } else if (product->hops.at(product->hops_row).h_useat == HOP_USEAT_DRY_HOP) { - htimeEdit->setValue(product->hops.at(product->hops_row).h_time / 1440); + } else if (product->hops.at(product->hops_row).useat == HOP_USEAT_DRY_HOP) { + htimeEdit->setValue(product->hops.at(product->hops_row).time / 1440); htimeEdit->setReadOnly(false); } else { htimeEdit->setReadOnly(true); @@ -642,7 +642,7 @@ useatEdit->addItem(tr("Aroma")); useatEdit->addItem(tr("Whirlpool")); useatEdit->addItem(tr("Dry hop")); - useatEdit->setCurrentIndex(product->hops.at(product->hops_row).h_useat); + useatEdit->setCurrentIndex(product->hops.at(product->hops_row).useat); hinstockEdit = new QCheckBox(dialog); hinstockEdit->setObjectName(QString::fromUtf8("hinstockEdit")); @@ -656,9 +656,9 @@ ibuEdit->setReadOnly(true); ibuEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); ibuEdit->setDecimals(1); - double ibu = Utils::toIBU(product->hops.at(product->hops_row).h_useat, product->hops.at(product->hops_row).h_form, product->preboil_sg, - product->batch_size, product->hops.at(product->hops_row).h_amount, product->hops.at(product->hops_row).h_time, - product->hops.at(product->hops_row).h_alpha, product->ibu_method, + double ibu = Utils::toIBU(product->hops.at(product->hops_row).useat, product->hops.at(product->hops_row).form, product->preboil_sg, + product->batch_size, product->hops.at(product->hops_row).amount, product->hops.at(product->hops_row).time, + product->hops.at(product->hops_row).alpha, product->ibu_method, product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); ibuEdit->setValue(ibu); @@ -679,11 +679,11 @@ product->hops[product->hops_row] = backup; } else { /* Clear time if hop is not used for boil, whirlpool or dry-hop. */ - if (! (product->hops.at(product->hops_row).h_useat == HOP_USEAT_BOIL || - product->hops.at(product->hops_row).h_useat == HOP_USEAT_WHIRLPOOL || - product->hops.at(product->hops_row).h_useat == HOP_USEAT_DRY_HOP)) { - if (product->hops.at(product->hops_row).h_time) { - product->hops[product->hops_row].h_time = 0; + if (! (product->hops.at(product->hops_row).useat == HOP_USEAT_BOIL || + product->hops.at(product->hops_row).useat == HOP_USEAT_WHIRLPOOL || + product->hops.at(product->hops_row).useat == HOP_USEAT_DRY_HOP)) { + if (product->hops.at(product->hops_row).time) { + product->hops[product->hops_row].time = 0; is_changed(); } } @@ -708,8 +708,8 @@ return; for (int i = 0; i < product->hops.size(); i++) { - amount = product->hops.at(i).h_amount * factor; - product->hops[i].h_amount = amount; + amount = product->hops.at(i).amount * factor; + product->hops[i].amount = amount; } }
--- a/src/EditRecipeExport.cpp Mon Jun 13 12:26:27 2022 +0200 +++ b/src/EditRecipeExport.cpp Mon Jun 13 15:47:16 2022 +0200 @@ -116,16 +116,16 @@ for (int i = 0; i < recipe->hops.size(); i++) { xmlWriter->writeStartElement("HOP"); xmlWriter->writeTextElement("VERSION", "1"); - xmlWriter->writeTextElement("NAME", recipe->hops.at(i).h_name); - xmlWriter->writeTextElement("ALPHA", QString::number(recipe->hops.at(i).h_alpha, 'f', 1)); - xmlWriter->writeTextElement("AMOUNT", QString::number(recipe->hops.at(i).h_amount, 'f', 4)); - xmlWriter->writeTextElement("USE", hop_use[recipe->hops.at(i).h_useat]); - xmlWriter->writeTextElement("TIME", QString::number(recipe->hops.at(i).h_time, 'f', 0)); - xmlWriter->writeTextElement("TYPE", hop_types[recipe->hops.at(i).h_type]); - xmlWriter->writeTextElement("FORM", hop_forms[recipe->hops.at(i).h_form]); - xmlWriter->writeTextElement("BETA", QString::number(recipe->hops.at(i).h_beta, 'f', 1)); - xmlWriter->writeTextElement("HSI", QString::number(recipe->hops.at(i).h_hsi, 'f', 1)); - xmlWriter->writeTextElement("ORIGIN", recipe->hops.at(i).h_origin); + xmlWriter->writeTextElement("NAME", recipe->hops.at(i).name); + xmlWriter->writeTextElement("ALPHA", QString::number(recipe->hops.at(i).alpha, 'f', 1)); + xmlWriter->writeTextElement("AMOUNT", QString::number(recipe->hops.at(i).amount, 'f', 4)); + xmlWriter->writeTextElement("USE", hop_use[recipe->hops.at(i).useat]); + xmlWriter->writeTextElement("TIME", QString::number(recipe->hops.at(i).time, 'f', 0)); + xmlWriter->writeTextElement("TYPE", hop_types[recipe->hops.at(i).type]); + xmlWriter->writeTextElement("FORM", hop_forms[recipe->hops.at(i).form]); + xmlWriter->writeTextElement("BETA", QString::number(recipe->hops.at(i).beta, 'f', 1)); + xmlWriter->writeTextElement("HSI", QString::number(recipe->hops.at(i).hsi, 'f', 1)); + xmlWriter->writeTextElement("ORIGIN", recipe->hops.at(i).origin); xmlWriter->writeEndElement(); } xmlWriter->writeEndElement(); // HOPS @@ -281,7 +281,7 @@ void EditRecipe::copyProduct() { - Product *p = new Product; + Product *p = new Product(); p->record = -1; p->name = recipe->name + QString(" [duplicate]"); @@ -289,7 +289,7 @@ p->birth = QDate::currentDate(); p->stage = p->inventory_reduced = PROD_STAGE_PLAN; p->notes = recipe->notes; - p->log_brew = p->log_fermentation = p->log_ispindel = p->log_co2pressure = p->locked = false; +// p->log_brew = p->log_fermentation = p->log_ispindel = p->log_co2pressure = p->locked = false; p->st_name = recipe->st_name; p->st_letter = recipe->st_letter; @@ -313,14 +313,14 @@ p->eq_name = QString("Not yet set"); p->eq_notes = QString(""); p->eq_tun_specific_heat = 0.11; - p->eq_tun_material = 0; +// p->eq_tun_material = 0; p->eq_tun_volume = p->eq_tun_height = 20; p->eq_tun_weight = 2; - p->eq_top_up_water = 0; +// p->eq_top_up_water = 0; p->eq_trub_chiller_loss = 0.5; p->eq_evap_rate = 1.8; p->eq_calc_boil_volume = true; - p->eq_top_up_kettle = 0; +// p->eq_top_up_kettle = 0; p->eq_hop_utilization = 100; p->eq_lauter_volume = p->eq_lauter_height = p->eq_kettle_volume = p->eq_kettle_height = p->eq_mash_volume = 20; p->eq_lauter_deadspace = 0.5; @@ -339,30 +339,30 @@ p->est_abv = recipe->est_abv; p->brew_date_start = p->brew_date_end = QDateTime(); - p->brew_mash_ph = p->brew_mash_sg = p->brew_mash_efficiency = 0; - p->brew_sparge_temperature = p->brew_sparge_volume = p->brew_sparge_est = p->brew_sparge_ph = 0; - p->brew_preboil_volume = p->brew_preboil_sg = p->brew_preboil_ph = p->brew_preboil_efficiency = 0; - p->brew_aboil_volume = p->brew_aboil_sg = p->brew_aboil_ph = p->brew_aboil_efficiency = 0; - p->brew_cooling_method = p->brew_cooling_time = 0; +// p->brew_mash_ph = p->brew_mash_sg = p->brew_mash_efficiency = 0; +// p->brew_sparge_temperature = p->brew_sparge_volume = p->brew_sparge_est = p->brew_sparge_ph = 0; +// p->brew_preboil_volume = p->brew_preboil_sg = p->brew_preboil_ph = p->brew_preboil_efficiency = 0; + // p->brew_aboil_volume = p->brew_aboil_sg = p->brew_aboil_ph = p->brew_aboil_efficiency = 0; + // p->brew_cooling_method = p->brew_cooling_time = 0; p->brew_cooling_to = 20; - p->brew_whirlpool9 = p->brew_whirlpool7 = p->brew_whirlpool6 = p->brew_whirlpool2 = 0; - p->brew_fermenter_volume = p->brew_fermenter_extrawater = p->brew_fermenter_tcloss = 0; - p->brew_aeration_time = p->brew_aeration_speed = p->brew_aeration_type = 0; - p->brew_fermenter_sg = p->brew_fermenter_ibu = p->brew_fermenter_color = 0; +// p->brew_whirlpool9 = p->brew_whirlpool7 = p->brew_whirlpool6 = p->brew_whirlpool2 = 0; +// p->brew_fermenter_volume = p->brew_fermenter_extrawater = p->brew_fermenter_tcloss = 0; +// p->brew_aeration_time = p->brew_aeration_speed = p->brew_aeration_type = 0; +// p->brew_fermenter_sg = p->brew_fermenter_ibu = p->brew_fermenter_color = 0; - p->og = p->fg = 0; - p->primary_start_temp = p->primary_max_temp = p->primary_end_temp = p->primary_end_sg = 0; +// p->og = p->fg = 0; +// p->primary_start_temp = p->primary_max_temp = p->primary_end_temp = p->primary_end_sg = 0; p->primary_end_date = p->secondary_end_date = QDate(); - p->secondary_temp = p->secondary_end_sg = p->tertiary_temp = 0; +// p->secondary_temp = p->secondary_end_sg = p->tertiary_temp = 0; p->package_date = QDate(); - p->package_volume = p->package_infuse_amount = p->package_infuse_abv = p->package_abv = p->package_ph = 0; +// p->package_volume = p->package_infuse_amount = p->package_infuse_abv = p->package_abv = p->package_ph = 0; p->package_infuse_notes = ""; - p->bottle_amount = p->bottle_carbonation = p->bottle_priming_amount = p->bottle_carbonation_temp = 0; - p->keg_amount = p->keg_carbonation = p->keg_priming_amount = p->keg_carbonation_temp = 0; - p->keg_pressure = 0; - p->bottle_priming_water = p->keg_priming_water = 0; - p->bottle_priming_sugar = p->keg_priming_sugar = 0; - p->taste_rate = 0; +// p->bottle_amount = p->bottle_carbonation = p->bottle_priming_amount = p->bottle_carbonation_temp = 0; +// p->keg_amount = p->keg_carbonation = p->keg_priming_amount = p->keg_carbonation_temp = 0; +// p->keg_pressure = 0; +// p->bottle_priming_water = p->keg_priming_water = 0; +// p->bottle_priming_sugar = p->keg_priming_sugar = 0; +// p->taste_rate = 0; p->taste_date = QDate(); p->taste_notes = p->taste_color = p->taste_transparency = p->taste_head = ""; p->taste_aroma = p->taste_taste = p->taste_mouthfeel = p->taste_aftertaste = ""; @@ -416,13 +416,13 @@ p->wa_base_name = recipe->wa_base_name; p->starter_enable = false; - p->starter_type = p->prop_type[0] = p->prop_type[1] = p->prop_type[2] = p->prop_type[3] = 0; +// p->starter_type = p->prop_type[0] = p->prop_type[1] = p->prop_type[2] = p->prop_type[3] = 0; p->starter_viability = 100; p->starter_sg = 1.037; p->yeast_prod_date = QDate(); - p->yeast_pitchrate = p->prop_volume[0] = p->prop_volume[1] = p->prop_volume[2] = p->prop_volume[3] = 0; - p->divide_type = p->divide_parts = p->divide_part = 0; - p->divide_size = 0; +// p->yeast_pitchrate = p->prop_volume[0] = p->prop_volume[1] = p->prop_volume[2] = p->prop_volume[3] = 0; +// p->divide_type = p->divide_parts = p->divide_part = 0; +// p->divide_size = 0; p->divide_factor = 1; p->fermentables = recipe->fermentables; @@ -488,20 +488,20 @@ memo.append("[tabular]\n"); memo.append("[head]Hop[/head][head]Vorm[/head][head]Alpha[/head][head]IBU[/head][head]Gram[/head][head]Toevoegen moment[/head]\n"); for (int i = 0; i < recipe->hops.size(); i++) { - double ibu = Utils::toIBU(recipe->hops.at(i).h_useat, recipe->hops.at(i).h_form, recipe->preboil_sg, recipe->batch_size, - recipe->hops.at(i).h_amount, recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, recipe->ibu_method, - 0, recipe->hops.at(i).h_time, 0, recipe->boil_time); - memo.append("[row][data]" + recipe->hops.at(i).h_name + " (" + recipe->hops.at(i).h_origin + ")[/data]"); - memo.append("[data]" + hop_forms[recipe->hops.at(i).h_form] + "[/data]"); - memo.append("[data]" + QString::number(recipe->hops.at(i).h_alpha, 'f', 1) + "[/data]"); + double ibu = Utils::toIBU(recipe->hops.at(i).useat, recipe->hops.at(i).form, recipe->preboil_sg, recipe->batch_size, + recipe->hops.at(i).amount, recipe->hops.at(i).time, recipe->hops.at(i).alpha, recipe->ibu_method, + 0, recipe->hops.at(i).time, 0, recipe->boil_time); + memo.append("[row][data]" + recipe->hops.at(i).name + " (" + recipe->hops.at(i).origin + ")[/data]"); + memo.append("[data]" + hop_forms[recipe->hops.at(i).form] + "[/data]"); + memo.append("[data]" + QString::number(recipe->hops.at(i).alpha, 'f', 1) + "[/data]"); memo.append("[data]" + QString::number(ibu, 'f', 1) + "[/data]"); - memo.append("[data]" + QString::number(recipe->hops.at(i).h_amount * 1000, 'f', 2) + "[/data]"); - if (recipe->hops.at(i).h_useat == HOP_USEAT_BOIL || recipe->hops.at(i).h_useat == HOP_USEAT_WHIRLPOOL) - memo.append("[data]" + hop_use[recipe->hops.at(i).h_useat] + " " + QString::number(recipe->hops.at(i).h_time) + " minuten[/data][/row]\n"); - else if (recipe->hops.at(i).h_useat == HOP_USEAT_DRY_HOP) - memo.append("[data]" + hop_use[recipe->hops.at(i).h_useat] + " " + QString::number(recipe->hops.at(i).h_time / 1440) + " dagen[/data][/row]\n"); + memo.append("[data]" + QString::number(recipe->hops.at(i).amount * 1000, 'f', 2) + "[/data]"); + if (recipe->hops.at(i).useat == HOP_USEAT_BOIL || recipe->hops.at(i).useat == HOP_USEAT_WHIRLPOOL) + memo.append("[data]" + hop_use[recipe->hops.at(i).useat] + " " + QString::number(recipe->hops.at(i).time) + " minuten[/data][/row]\n"); + else if (recipe->hops.at(i).useat == HOP_USEAT_DRY_HOP) + memo.append("[data]" + hop_use[recipe->hops.at(i).useat] + " " + QString::number(recipe->hops.at(i).time / 1440) + " dagen[/data][/row]\n"); else - memo.append("[data]" + hop_use[recipe->hops.at(i).h_useat] + "[/data][/row]\n"); + memo.append("[data]" + hop_use[recipe->hops.at(i).useat] + "[/data][/row]\n"); } memo.append("[/tabular]\n\n");
--- a/src/EditRecipeTab3.cpp Mon Jun 13 12:26:27 2022 +0200 +++ b/src/EditRecipeTab3.cpp Mon Jun 13 15:47:16 2022 +0200 @@ -21,17 +21,17 @@ bool EditRecipe::hop_sort_test(const Hops &D1, const Hops &D2) { - if (D1.h_useat > D2.h_useat) + if (D1.useat > D2.useat) return false; - if (D1.h_useat < D2.h_useat) + if (D1.useat < D2.useat) return true; /* Same useat moments, test time. */ - if (D1.h_time < D2.h_time) + if (D1.time < D2.time) return false; - if (D1.h_time > D2.h_time) + if (D1.time > D2.time) return true; /* Finally consider the amounts */ - return (D1.h_amount > D2.h_amount); + return (D1.amount > D2.amount); } @@ -66,46 +66,46 @@ for (int i = 0; i < recipe->hops.size(); i++) { - ui->hopsTable->setItem(i, 0, new QTableWidgetItem(recipe->hops.at(i).h_origin)); - ui->hopsTable->setItem(i, 1, new QTableWidgetItem(recipe->hops.at(i).h_name)); + ui->hopsTable->setItem(i, 0, new QTableWidgetItem(recipe->hops.at(i).origin)); + ui->hopsTable->setItem(i, 1, new QTableWidgetItem(recipe->hops.at(i).name)); - item = new QTableWidgetItem(hop_types[recipe->hops.at(i).h_type]); + item = new QTableWidgetItem(hop_types[recipe->hops.at(i).type]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->hopsTable->setItem(i, 2, item); - item = new QTableWidgetItem(hop_forms[recipe->hops.at(i).h_form]); + item = new QTableWidgetItem(hop_forms[recipe->hops.at(i).form]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->hopsTable->setItem(i, 3, item); - item = new QTableWidgetItem(QString("%1%").arg(recipe->hops.at(i).h_alpha, 2, 'f', 1, '0')); + item = new QTableWidgetItem(QString("%1%").arg(recipe->hops.at(i).alpha, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(i, 4, item); - item = new QTableWidgetItem(hop_useat[recipe->hops.at(i).h_useat]); + item = new QTableWidgetItem(hop_useat[recipe->hops.at(i).useat]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->hopsTable->setItem(i, 5, item); - if (recipe->hops.at(i).h_useat == 2 || recipe->hops.at(i).h_useat == 4) { // Boil or whirlpool - item = new QTableWidgetItem(QString("%1 min.").arg(recipe->hops.at(i).h_time, 1, 'f', 0, '0')); - } else if (recipe->hops.at(i).h_useat == 5) { // Dry-hop - item = new QTableWidgetItem(QString("%1 days.").arg(recipe->hops.at(i).h_time / 1440, 1, 'f', 0, '0')); + if (recipe->hops.at(i).useat == 2 || recipe->hops.at(i).useat == 4) { // Boil or whirlpool + item = new QTableWidgetItem(QString("%1 min.").arg(recipe->hops.at(i).time, 1, 'f', 0, '0')); + } else if (recipe->hops.at(i).useat == 5) { // Dry-hop + item = new QTableWidgetItem(QString("%1 days.").arg(recipe->hops.at(i).time / 1440, 1, 'f', 0, '0')); } else { item = new QTableWidgetItem(QString("")); } item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(i, 6, item); - double ibu = Utils::toIBU(recipe->hops.at(i).h_useat, recipe->hops.at(i).h_form, recipe->preboil_sg, recipe->batch_size, recipe->hops.at(i).h_amount, - recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, recipe->ibu_method, 0, recipe->hops.at(i).h_time, + double ibu = Utils::toIBU(recipe->hops.at(i).useat, recipe->hops.at(i).form, recipe->preboil_sg, recipe->batch_size, recipe->hops.at(i).amount, + recipe->hops.at(i).time, recipe->hops.at(i).alpha, recipe->ibu_method, 0, recipe->hops.at(i).time, 0, recipe->boil_time); item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(i, 7, item); - if (recipe->hops.at(i).h_amount < 1.0) { - item = new QTableWidgetItem(QString("%1 gr").arg(recipe->hops.at(i).h_amount * 1000.0, 2, 'f', 1, '0')); + if (recipe->hops.at(i).amount < 1.0) { + item = new QTableWidgetItem(QString("%1 gr").arg(recipe->hops.at(i).amount * 1000.0, 2, 'f', 1, '0')); } else { - item = new QTableWidgetItem(QString("%1 kg").arg(recipe->hops.at(i).h_amount, 4, 'f', 3, '0')); + item = new QTableWidgetItem(QString("%1 kg").arg(recipe->hops.at(i).amount, 4, 'f', 3, '0')); } item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(i, 8, item); @@ -222,11 +222,11 @@ for (int i = 0; i < recipe->hops.size(); i++) { - ibus += Utils::toIBU(recipe->hops.at(i).h_useat, recipe->hops.at(i).h_form, recipe->preboil_sg, recipe->batch_size, recipe->hops.at(i).h_amount, - recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, recipe->ibu_method, 0, recipe->hops.at(i).h_time, + ibus += Utils::toIBU(recipe->hops.at(i).useat, recipe->hops.at(i).form, recipe->preboil_sg, recipe->batch_size, recipe->hops.at(i).amount, + recipe->hops.at(i).time, recipe->hops.at(i).alpha, recipe->ibu_method, 0, recipe->hops.at(i).time, 0, recipe->boil_time); - hop_flavour += Utils::hopFlavourContribution(recipe->hops.at(i).h_time, recipe->batch_size, recipe->hops.at(i).h_useat, recipe->hops.at(i).h_amount); - hop_aroma += Utils::hopAromaContribution(recipe->hops.at(i).h_time, recipe->batch_size, recipe->hops.at(i).h_useat, recipe->hops.at(i).h_amount); + hop_flavour += Utils::hopFlavourContribution(recipe->hops.at(i).time, recipe->batch_size, recipe->hops.at(i).useat, recipe->hops.at(i).amount); + hop_aroma += Utils::hopAromaContribution(recipe->hops.at(i).time, recipe->batch_size, recipe->hops.at(i).useat, recipe->hops.at(i).amount); } hop_flavour = round(hop_flavour * 1000.0 / 5.0) / 10; @@ -253,26 +253,26 @@ qDebug() << "Add hop row"; for (int i = 0; i < recipe->hops.size(); i++) { - if (recipe->hops.at(i).h_amount == 0 && recipe->hops.at(i).h_alpha == 0) + if (recipe->hops.at(i).amount == 0 && recipe->hops.at(i).alpha == 0) return; // Add only one at a time. } - newh.h_name = "Select one"; - newh.h_origin = ""; - newh.h_amount = 0; - newh.h_cost = 0; - newh.h_type = 0; - newh.h_form = 0; - newh.h_useat = 2; - newh.h_time = 0; - newh.h_alpha = 0; - newh.h_beta = 0; - newh.h_hsi = 0; - newh.h_humulene = 0; - newh.h_caryophyllene = 0; - newh.h_cohumulone = 0; - newh.h_myrcene = 0; - newh.h_total_oil = 0; + newh.name = "Select one"; + newh.origin = ""; + newh.amount = 0; + newh.cost = 0; + newh.type = 0; + newh.form = 0; + newh.useat = 2; + newh.time = 0; + newh.alpha = 0; + newh.beta = 0; + newh.hsi = 0; + newh.humulene = 0; + newh.caryophyllene = 0; + newh.cohumulone = 0; + newh.myrcene = 0; + newh.total_oil = 0; recipe->hops.append(newh); emit refreshAll(); @@ -288,7 +288,7 @@ int row = pb->objectName().toInt(); qDebug() << "Delete hop row" << row << recipe->hops.size(); - int rc = QMessageBox::warning(this, tr("Delete hop"), tr("Delete %1").arg(recipe->hops.at(row).h_name), + int rc = QMessageBox::warning(this, tr("Delete hop"), tr("Delete %1").arg(recipe->hops.at(row).name), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (rc == QMessageBox::No) return; @@ -303,14 +303,14 @@ { QTableWidgetItem *item; - recipe->hops[recipe->hops_row].h_amount = val / 1000.0; + recipe->hops[recipe->hops_row].amount = val / 1000.0; item = new QTableWidgetItem(QString("%1 gr").arg(val, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(recipe->hops_row, 8, item); - double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg, - recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time, - recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, + double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, + recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time, + recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).time, 0, recipe->boil_time); ibuEdit->setValue(ibu); @@ -327,14 +327,14 @@ { QTableWidgetItem *item; - recipe->hops[recipe->hops_row].h_alpha = val; + recipe->hops[recipe->hops_row].alpha = val; item = new QTableWidgetItem(QString("%1%").arg(val, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(recipe->hops_row, 4, item); - double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg, - recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time, - recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, + double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, + recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time, + recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).time, 0, recipe->boil_time); ibuEdit->setValue(ibu); @@ -351,22 +351,22 @@ { QTableWidgetItem *item; - if (recipe->hops.at(recipe->hops_row).h_useat == 2 || recipe->hops.at(recipe->hops_row).h_useat == 4) { // Boil or whirlpool + if (recipe->hops.at(recipe->hops_row).useat == 2 || recipe->hops.at(recipe->hops_row).useat == 4) { // Boil or whirlpool item = new QTableWidgetItem(QString("%1 min.").arg(val, 1, 'f', 0, '0')); - recipe->hops[recipe->hops_row].h_time = val; - } else if (recipe->hops.at(recipe->hops_row).h_useat == 5) { // Dry-hop + recipe->hops[recipe->hops_row].time = val; + } else if (recipe->hops.at(recipe->hops_row).useat == 5) { // Dry-hop item = new QTableWidgetItem(QString("%1 days.").arg(val, 1, 'f', 0, '0')); - recipe->hops[recipe->hops_row].h_time = val * 1440; + recipe->hops[recipe->hops_row].time = val * 1440; } else { item = new QTableWidgetItem(QString("")); - recipe->hops[recipe->hops_row].h_time = val; + recipe->hops[recipe->hops_row].time = val; } item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(recipe->hops_row, 6, item); - double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg, - recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time, - recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, + double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, + recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time, + recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).time, 0, recipe->boil_time); ibuEdit->setValue(ibu); @@ -406,44 +406,44 @@ /* * Replace the hop record contents */ - recipe->hops[recipe->hops_row].h_name = query.value(0).toString(); - recipe->hops[recipe->hops_row].h_origin = query.value(1).toString(); - recipe->hops[recipe->hops_row].h_alpha = query.value(2).toDouble(); - recipe->hops[recipe->hops_row].h_beta = query.value(3).toDouble(); - recipe->hops[recipe->hops_row].h_humulene = query.value(4).toDouble(); - recipe->hops[recipe->hops_row].h_caryophyllene = query.value(5).toDouble(); - recipe->hops[recipe->hops_row].h_cohumulone = query.value(6).toDouble(); - recipe->hops[recipe->hops_row].h_myrcene = query.value(7).toDouble(); - recipe->hops[recipe->hops_row].h_hsi = query.value(8).toDouble(); - recipe->hops[recipe->hops_row].h_total_oil = query.value(9).toDouble(); - recipe->hops[recipe->hops_row].h_type = query.value(10).toInt(); - recipe->hops[recipe->hops_row].h_form = query.value(11).toInt(); - recipe->hops[recipe->hops_row].h_cost = query.value(12).toDouble(); + recipe->hops[recipe->hops_row].name = query.value(0).toString(); + recipe->hops[recipe->hops_row].origin = query.value(1).toString(); + recipe->hops[recipe->hops_row].alpha = query.value(2).toDouble(); + recipe->hops[recipe->hops_row].beta = query.value(3).toDouble(); + recipe->hops[recipe->hops_row].humulene = query.value(4).toDouble(); + recipe->hops[recipe->hops_row].caryophyllene = query.value(5).toDouble(); + recipe->hops[recipe->hops_row].cohumulone = query.value(6).toDouble(); + recipe->hops[recipe->hops_row].myrcene = query.value(7).toDouble(); + recipe->hops[recipe->hops_row].hsi = query.value(8).toDouble(); + recipe->hops[recipe->hops_row].total_oil = query.value(9).toDouble(); + recipe->hops[recipe->hops_row].type = query.value(10).toInt(); + recipe->hops[recipe->hops_row].form = query.value(11).toInt(); + recipe->hops[recipe->hops_row].cost = query.value(12).toDouble(); /* * Update the visible fields */ - hnameEdit->setText(recipe->hops.at(recipe->hops_row).h_name); - horiginEdit->setText(recipe->hops.at(recipe->hops_row).h_origin); + hnameEdit->setText(recipe->hops.at(recipe->hops_row).name); + horiginEdit->setText(recipe->hops.at(recipe->hops_row).origin); - double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg, - recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time, - recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, + double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, + recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time, + recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).time, 0, recipe->boil_time); ibuEdit->setValue(ibu); - ui->hopsTable->setItem(recipe->hops_row, 0, new QTableWidgetItem(recipe->hops.at(recipe->hops_row).h_origin)); - ui->hopsTable->setItem(recipe->hops_row, 1, new QTableWidgetItem(recipe->hops.at(recipe->hops_row).h_name)); + ui->hopsTable->setItem(recipe->hops_row, 0, new QTableWidgetItem(recipe->hops.at(recipe->hops_row).origin)); + ui->hopsTable->setItem(recipe->hops_row, 1, new QTableWidgetItem(recipe->hops.at(recipe->hops_row).name)); - item = new QTableWidgetItem(hop_types[recipe->hops.at(recipe->hops_row).h_type]); + item = new QTableWidgetItem(hop_types[recipe->hops.at(recipe->hops_row).type]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->hopsTable->setItem(recipe->hops_row, 2, item); - item = new QTableWidgetItem(hop_forms[recipe->hops.at(recipe->hops_row).h_form]); + item = new QTableWidgetItem(hop_forms[recipe->hops.at(recipe->hops_row).form]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->hopsTable->setItem(recipe->hops_row, 3, item); - item = new QTableWidgetItem(QString("%1%").arg(recipe->hops.at(recipe->hops_row).h_alpha, 2, 'f', 1, '0')); + item = new QTableWidgetItem(QString("%1%").arg(recipe->hops.at(recipe->hops_row).alpha, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->hopsTable->setItem(recipe->hops_row, 4, item); @@ -480,18 +480,18 @@ void EditRecipe::hop_useat_changed(int val) { - recipe->hops[recipe->hops_row].h_useat = val; + recipe->hops[recipe->hops_row].useat = val; QTableWidgetItem *item = new QTableWidgetItem(hop_useat[val]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->hopsTable->setItem(recipe->hops_row, 5, item); if (val == 2 || val == 4) { // Boil or whirlpool htimeLabel->setText(tr("Time in minutes:")); - htimeEdit->setValue(recipe->hops.at(recipe->hops_row).h_time); + htimeEdit->setValue(recipe->hops.at(recipe->hops_row).time); htimeEdit->setReadOnly(false); } else if (val == 5) { // Dry-hop htimeLabel->setText(tr("Time in days:")); - htimeEdit->setValue(recipe->hops.at(recipe->hops_row).h_time / 1440); + htimeEdit->setValue(recipe->hops.at(recipe->hops_row).time / 1440); htimeEdit->setReadOnly(false); } else { htimeLabel->setText(""); @@ -506,14 +506,14 @@ void EditRecipe::hop_form_changed(int val) { - recipe->hops[recipe->hops_row].h_form = val; + recipe->hops[recipe->hops_row].form = val; QTableWidgetItem *item = new QTableWidgetItem(hop_forms[val]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->hopsTable->setItem(recipe->hops_row, 3, item); - double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg, - recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time, - recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, + double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, + recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time, + recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).time, 0, recipe->boil_time); ibuEdit->setValue(ibu); @@ -569,9 +569,9 @@ alphaLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); htimeLabel = new QLabel(dialog); htimeLabel->setObjectName(QString::fromUtf8("htimeLabel")); - if (recipe->hops.at(recipe->hops_row).h_useat == 5) // Dry-hop + if (recipe->hops.at(recipe->hops_row).useat == 5) // Dry-hop htimeLabel->setText(tr("Time in days:")); - else if (recipe->hops.at(recipe->hops_row).h_useat == 2 || recipe->hops.at(recipe->hops_row).h_useat == 4) // Boil or whirlpool + else if (recipe->hops.at(recipe->hops_row).useat == 2 || recipe->hops.at(recipe->hops_row).useat == 4) // Boil or whirlpool htimeLabel->setText(tr("Time in minutes:")); else htimeLabel->setText(""); @@ -610,12 +610,12 @@ hnameEdit = new QLineEdit(dialog); hnameEdit->setObjectName(QString::fromUtf8("hnameEdit")); - hnameEdit->setText(recipe->hops.at(recipe->hops_row).h_name); + hnameEdit->setText(recipe->hops.at(recipe->hops_row).name); hnameEdit->setGeometry(QRect(160, 10, 511, 23)); hnameEdit->setReadOnly(true); horiginEdit = new QLineEdit(dialog); horiginEdit->setObjectName(QString::fromUtf8("horiginEdit")); - horiginEdit->setText(recipe->hops.at(recipe->hops_row).h_origin); + horiginEdit->setText(recipe->hops.at(recipe->hops_row).origin); horiginEdit->setGeometry(QRect(160, 40, 511, 23)); horiginEdit->setReadOnly(true); hamountEdit = new QDoubleSpinBox(dialog); @@ -626,7 +626,7 @@ hamountEdit->setDecimals(1); hamountEdit->setMaximum(1000000.0); hamountEdit->setSingleStep(0.5); - hamountEdit->setValue(recipe->hops.at(recipe->hops_row).h_amount * 1000.0); + hamountEdit->setValue(recipe->hops.at(recipe->hops_row).amount * 1000.0); halphaEdit = new QDoubleSpinBox(dialog); halphaEdit->setObjectName(QString::fromUtf8("halphaEdit")); halphaEdit->setGeometry(QRect(550, 100, 121, 24)); @@ -635,18 +635,18 @@ halphaEdit->setDecimals(1); halphaEdit->setMaximum(100.0); halphaEdit->setSingleStep(0.1); - halphaEdit->setValue(recipe->hops.at(recipe->hops_row).h_alpha); + halphaEdit->setValue(recipe->hops.at(recipe->hops_row).alpha); htimeEdit = new QSpinBox(dialog); htimeEdit->setObjectName(QString::fromUtf8("htimeEdit")); htimeEdit->setGeometry(QRect(160, 130, 121, 24)); htimeEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); htimeEdit->setAccelerated(true); htimeEdit->setMaximum(10000.0); - if (recipe->hops.at(recipe->hops_row).h_useat == 2 || recipe->hops.at(recipe->hops_row).h_useat == 4) { // Boil or whirlpool - htimeEdit->setValue(recipe->hops.at(recipe->hops_row).h_time); + if (recipe->hops.at(recipe->hops_row).useat == 2 || recipe->hops.at(recipe->hops_row).useat == 4) { // Boil or whirlpool + htimeEdit->setValue(recipe->hops.at(recipe->hops_row).time); htimeEdit->setReadOnly(false); - } else if (recipe->hops.at(recipe->hops_row).h_useat == 5){ // Dry-hop - htimeEdit->setValue(recipe->hops.at(recipe->hops_row).h_time / 1440); + } else if (recipe->hops.at(recipe->hops_row).useat == 5){ // Dry-hop + htimeEdit->setValue(recipe->hops.at(recipe->hops_row).time / 1440); htimeEdit->setReadOnly(false); } else { htimeEdit->setReadOnly(true); @@ -660,7 +660,7 @@ useatEdit->addItem(tr("Aroma")); useatEdit->addItem(tr("Whirlpool")); useatEdit->addItem(tr("Dry hop")); - useatEdit->setCurrentIndex(recipe->hops.at(recipe->hops_row).h_useat); + useatEdit->setCurrentIndex(recipe->hops.at(recipe->hops_row).useat); hformEdit = new QComboBox(dialog); hformEdit->setObjectName(QString::fromUtf8("formEdit")); @@ -670,7 +670,7 @@ hformEdit->addItem(tr("Leaf")); hformEdit->addItem(tr("Wet leaf")); hformEdit->addItem(tr("Cryo")); - hformEdit->setCurrentIndex(recipe->hops.at(recipe->hops_row).h_form); + hformEdit->setCurrentIndex(recipe->hops.at(recipe->hops_row).form); hinstockEdit = new QCheckBox(dialog); hinstockEdit->setObjectName(QString::fromUtf8("hinstockEdit")); @@ -684,9 +684,9 @@ ibuEdit->setReadOnly(true); ibuEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); ibuEdit->setDecimals(1); - double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg, - recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time, - recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, + double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, + recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time, + recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).time, 0, recipe->boil_time); ibuEdit->setValue(ibu); @@ -709,11 +709,11 @@ recipe->hops[recipe->hops_row] = backup; } else { /* Clear time if hop is not used for boil, whirlpool or dry-hop. */ - if (! (recipe->hops.at(recipe->hops_row).h_useat == 2 || - recipe->hops.at(recipe->hops_row).h_useat == 4 || - recipe->hops.at(recipe->hops_row).h_useat == 5)) { - if (recipe->hops.at(recipe->hops_row).h_time) { - recipe->hops[recipe->hops_row].h_time = 0; + if (! (recipe->hops.at(recipe->hops_row).useat == 2 || + recipe->hops.at(recipe->hops_row).useat == 4 || + recipe->hops.at(recipe->hops_row).useat == 5)) { + if (recipe->hops.at(recipe->hops_row).time) { + recipe->hops[recipe->hops_row].time = 0; is_changed(); } } @@ -740,8 +740,8 @@ return; for (int i = 0; i < recipe->hops.size(); i++) { - amount = recipe->hops.at(i).h_amount * factor; - recipe->hops[i].h_amount = amount; + amount = recipe->hops.at(i).amount * factor; + recipe->hops[i].amount = amount; } }
--- a/src/ImportXML.cpp Mon Jun 13 12:26:27 2022 +0200 +++ b/src/ImportXML.cpp Mon Jun 13 15:47:16 2022 +0200 @@ -505,7 +505,7 @@ */ total++; Hops *h = new Hops(); - h->h_notes = h->h_origin = h->h_substitutes = ""; + h->notes = h->origin = h->substitutes = ""; while (xml->readNext()) { if (xml->atEnd()) @@ -515,20 +515,20 @@ "humulene=:humulene, caryophyllene=:cary, cohumulone=:cohumulone, myrcene=:myrcene, " "hsi=:hsi, type=:type, form=:form, notes=:notes, origin=:origin, substitutes=:substitutes, " "total_oil=:oil, uuid = :uuid"); - query.bindValue(":name", h->h_name); - query.bindValue(":alpha", QString("%1").arg(h->h_alpha, 2, 'f', 1, '0')); - query.bindValue(":beta", QString("%1").arg(h->h_beta, 2, 'f', 1, '0')); - query.bindValue(":humulene", QString("%1").arg(h->h_humulene, 2, 'f', 1, '0')); - query.bindValue(":cary", QString("%1").arg(h->h_caryophyllene, 2, 'f', 1, '0')); - query.bindValue(":cohumulone", QString("%1").arg(h->h_cohumulone, 2, 'f', 1, '0')); - query.bindValue(":myrcene", QString("%1").arg(h->h_myrcene, 2, 'f', 1, '0')); - query.bindValue(":hsi", QString("%1").arg(h->h_hsi, 2, 'f', 1, '0')); - query.bindValue(":type", h->h_type); - query.bindValue(":form", h->h_form); - query.bindValue(":notes", h->h_notes); - query.bindValue(":origin", h->h_origin); - query.bindValue(":substitutes", h->h_substitutes); - query.bindValue(":oil", QString("%1").arg(h->h_total_oil, 2, 'f', 1, '0')); + query.bindValue(":name", h->name); + query.bindValue(":alpha", QString("%1").arg(h->alpha, 2, 'f', 1, '0')); + query.bindValue(":beta", QString("%1").arg(h->beta, 2, 'f', 1, '0')); + query.bindValue(":humulene", QString("%1").arg(h->humulene, 2, 'f', 1, '0')); + query.bindValue(":cary", QString("%1").arg(h->caryophyllene, 2, 'f', 1, '0')); + query.bindValue(":cohumulone", QString("%1").arg(h->cohumulone, 2, 'f', 1, '0')); + query.bindValue(":myrcene", QString("%1").arg(h->myrcene, 2, 'f', 1, '0')); + query.bindValue(":hsi", QString("%1").arg(h->hsi, 2, 'f', 1, '0')); + query.bindValue(":type", h->type); + query.bindValue(":form", h->form); + query.bindValue(":notes", h->notes); + query.bindValue(":origin", h->origin); + query.bindValue(":substitutes", h->substitutes); + query.bindValue(":oil", QString("%1").arg(h->total_oil, 2, 'f', 1, '0')); query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); query.exec(); if (query.lastError().isValid()) { @@ -544,64 +544,64 @@ (xml->name() == "COST") || (xml->name() == "INVENTORY"))) { // Ignore. } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NAME")) { - h->h_name = xml->readElementText(); + h->name = xml->readElementText(); } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ORIGIN")) { - h->h_origin = xml->readElementText(); + h->origin = xml->readElementText(); } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "NOTES")) { - h->h_notes = xml->readElementText(); + h->notes = xml->readElementText(); } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "FORM")) { QString temp = xml->readElementText(); if (temp == "Plug") - h->h_form = 1; + h->form = 1; else if (temp == "Leaf") - h->h_form = 2; + h->form = 2; else if (temp == "Leaf wet") - h->h_form = 3; + h->form = 3; else if (temp == "Cryo") - h->h_form = 4; + h->form = 4; else - h->h_form = 0; + h->form = 0; } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "ALPHA")) { - h->h_alpha = xml->readElementText().toDouble(); + h->alpha = xml->readElementText().toDouble(); } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TYPE")) { QString temp = xml->readElementText(); if (temp == "Aroma") - h->h_type = 1; + h->type = 1; else if (temp == "Both") - h->h_type = 2; + h->type = 2; else - h->h_type = 0; + h->type = 0; } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "USE")) { QString temp = xml->readElementText(); if (temp == "First wort") - h->h_useat = 1; + h->useat = 1; else if (temp == "Boil") - h->h_useat = 2; + h->useat = 2; else if (temp == "Aroma") - h->h_useat = 3; + h->useat = 3; else if (temp == "Whirlpool") - h->h_useat = 4; + h->useat = 4; else if (temp == "Dry hop") - h->h_useat = 5; + h->useat = 5; else - h->h_useat = 0; + h->useat = 0; } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "BETA")) { - h->h_beta = xml->readElementText().toDouble(); + h->beta = xml->readElementText().toDouble(); } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HSI")) { - h->h_hsi = xml->readElementText().toDouble(); + h->hsi = xml->readElementText().toDouble(); } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "SUBSTITUTES")) { - h->h_substitutes = xml->readElementText(); + h->substitutes = xml->readElementText(); } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "HUMULENE")) { - h->h_humulene = xml->readElementText().toDouble(); + h->humulene = xml->readElementText().toDouble(); } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && ((xml->name() == "CARYOPHYLLENE") || (xml->name() == "CAROPHYLLENE"))) { - h->h_caryophyllene = xml->readElementText().toDouble(); + h->caryophyllene = xml->readElementText().toDouble(); } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "COHUMULONE")) { - h->h_cohumulone = xml->readElementText().toDouble(); + h->cohumulone = xml->readElementText().toDouble(); } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "MYRCENE")) { - h->h_myrcene = xml->readElementText().toDouble(); + h->myrcene = xml->readElementText().toDouble(); } else if ((xml->tokenType() == QXmlStreamReader::StartElement) && (xml->name() == "TOTAL_OIL")) { - h->h_total_oil = xml->readElementText().toDouble(); + h->total_oil = xml->readElementText().toDouble(); } else { if (xml->tokenType() == QXmlStreamReader::StartElement) qDebug() << "2 " << xml->tokenType() << xml->name();
--- a/src/PrinterDialog.cpp Mon Jun 13 12:26:27 2022 +0200 +++ b/src/PrinterDialog.cpp Mon Jun 13 15:47:16 2022 +0200 @@ -435,29 +435,29 @@ double cost_hops = 0; for (int i = 0; i < recipe->hops.size(); i++) { - double cost = recipe->hops.at(i).h_amount * recipe->hops.at(i).h_cost; + double cost = recipe->hops.at(i).amount * recipe->hops.at(i).cost; cost_hops += cost; - double ibu = Utils::toIBU(recipe->hops.at(i).h_useat, recipe->hops.at(i).h_form, recipe->preboil_sg, recipe->batch_size, - recipe->hops.at(i).h_amount, recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, - recipe->ibu_method, 0, recipe->hops.at(i).h_time, 0, recipe->boil_time); + double ibu = Utils::toIBU(recipe->hops.at(i).useat, recipe->hops.at(i).form, recipe->preboil_sg, recipe->batch_size, + recipe->hops.at(i).amount, recipe->hops.at(i).time, recipe->hops.at(i).alpha, + recipe->ibu_method, 0, recipe->hops.at(i).time, 0, recipe->boil_time); - if (recipe->hops.at(i).h_useat == 2 || recipe->hops.at(i).h_useat == 4) // Boil or Whirlpool - use = hop_useat[recipe->hops.at(i).h_useat] + QString(" %1 min").arg(recipe->hops.at(i).h_time); - else if (recipe->hops.at(i).h_useat == 5) // Dryhop - use = hop_useat[recipe->hops.at(i).h_useat] + QString(" %1 days").arg(recipe->hops.at(i).h_time / 1440); + if (recipe->hops.at(i).useat == 2 || recipe->hops.at(i).useat == 4) // Boil or Whirlpool + use = hop_useat[recipe->hops.at(i).useat] + QString(" %1 min").arg(recipe->hops.at(i).time); + else if (recipe->hops.at(i).useat == 5) // Dryhop + use = hop_useat[recipe->hops.at(i).useat] + QString(" %1 days").arg(recipe->hops.at(i).time / 1440); else - use = hop_useat[recipe->hops.at(i).h_useat]; + use = hop_useat[recipe->hops.at(i).useat]; - if (recipe->hops.at(i).h_amount > 1) - amount = QString("%1 kg").arg(recipe->hops.at(i).h_amount, 1, 'f', 3); + if (recipe->hops.at(i).amount > 1) + amount = QString("%1 kg").arg(recipe->hops.at(i).amount, 1, 'f', 3); else - amount = QString("%1 gr").arg(recipe->hops.at(i).h_amount * 1000, 1, 'f', 1); + amount = QString("%1 gr").arg(recipe->hops.at(i).amount * 1000, 1, 'f', 1); painter.fillRect( 20, y, 715, 20, h_line); - painter.drawText( 20, y+4, 260, 20, Qt::AlignLeft, recipe->hops.at(i).h_name + " (" + recipe->hops.at(i).h_origin + ")"); - painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(recipe->hops.at(i).h_alpha, 1, 'f', 1)); + painter.drawText( 20, y+4, 260, 20, Qt::AlignLeft, recipe->hops.at(i).name + " (" + recipe->hops.at(i).origin + ")"); + painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(recipe->hops.at(i).alpha, 1, 'f', 1)); painter.drawText(360, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(ibu, 1, 'f', 1)); - painter.drawText(435, y+4, 80, 20, Qt::AlignLeft, hop_forms[recipe->hops.at(i).h_form]); + painter.drawText(435, y+4, 80, 20, Qt::AlignLeft, hop_forms[recipe->hops.at(i).form]); painter.drawText(520, y+4, 80, 20, Qt::AlignLeft, use); painter.drawText(605, y+4, 60, 20, Qt::AlignRight, amount); painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost, 1, 'f', 3)); @@ -835,29 +835,29 @@ double cost_hops = 0; for (int i = 0; i < product->hops.size(); i++) { - double cost = product->hops.at(i).h_amount * product->hops.at(i).h_cost; + double cost = product->hops.at(i).amount * product->hops.at(i).cost; cost_hops += cost; - double ibu = Utils::toIBU(product->hops.at(i).h_useat, product->hops.at(i).h_form, product->preboil_sg, product->batch_size, - product->hops.at(i).h_amount, product->hops.at(i).h_time, product->hops.at(i).h_alpha, + double ibu = Utils::toIBU(product->hops.at(i).useat, product->hops.at(i).form, product->preboil_sg, product->batch_size, + product->hops.at(i).amount, product->hops.at(i).time, product->hops.at(i).alpha, product->ibu_method, product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); - if (product->hops.at(i).h_useat == 2 || product->hops.at(i).h_useat == 4) // Boil or Whirlpool - use = hop_useat[product->hops.at(i).h_useat] + QString(" %1 min").arg(product->hops.at(i).h_time); - else if (product->hops.at(i).h_useat == 5) // Dryhop - use = hop_useat[product->hops.at(i).h_useat] + QString(" %1 days").arg(product->hops.at(i).h_time / 1440); + if (product->hops.at(i).useat == 2 || product->hops.at(i).useat == 4) // Boil or Whirlpool + use = hop_useat[product->hops.at(i).useat] + QString(" %1 min").arg(product->hops.at(i).time); + else if (product->hops.at(i).useat == 5) // Dryhop + use = hop_useat[product->hops.at(i).useat] + QString(" %1 days").arg(product->hops.at(i).time / 1440); else - use = hop_useat[product->hops.at(i).h_useat]; + use = hop_useat[product->hops.at(i).useat]; - if (product->hops.at(i).h_amount > 1) - amount = QString("%1 kg").arg(product->hops.at(i).h_amount, 1, 'f', 3); + if (product->hops.at(i).amount > 1) + amount = QString("%1 kg").arg(product->hops.at(i).amount, 1, 'f', 3); else - amount = QString("%1 gr").arg(product->hops.at(i).h_amount * 1000, 1, 'f', 1); + amount = QString("%1 gr").arg(product->hops.at(i).amount * 1000, 1, 'f', 1); painter.fillRect( 20, y, 715, 20, h_line); - painter.drawText( 20, y+4, 260, 20, Qt::AlignLeft, product->hops.at(i).h_name + " (" + product->hops.at(i).h_origin + ")"); - painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(product->hops.at(i).h_alpha, 1, 'f', 1)); + painter.drawText( 20, y+4, 260, 20, Qt::AlignLeft, product->hops.at(i).name + " (" + product->hops.at(i).origin + ")"); + painter.drawText(285, y+4, 70, 20, Qt::AlignRight, QString("%1%").arg(product->hops.at(i).alpha, 1, 'f', 1)); painter.drawText(360, y+4, 70, 20, Qt::AlignRight, QString("%1").arg(ibu, 1, 'f', 1)); - painter.drawText(435, y+4, 80, 20, Qt::AlignLeft, hop_forms[product->hops.at(i).h_form]); + painter.drawText(435, y+4, 80, 20, Qt::AlignLeft, hop_forms[product->hops.at(i).form]); painter.drawText(520, y+4, 80, 20, Qt::AlignLeft, use); painter.drawText(605, y+4, 60, 20, Qt::AlignRight, amount); painter.drawText(670, y+4, 60, 20, Qt::AlignRight, QString("%1 €").arg(cost, 1, 'f', 3)); @@ -1638,9 +1638,9 @@ checkLine(&painter, &y, QString(tr("Add brouwzouten"))); checkLine(&painter, &y, QString(tr("Add malts and dough-in"))); for (int j = 0; j < product->hops.size(); j++) { - if (product->hops.at(j).h_useat == HOP_USEAT_MASH) { - checkLine(&painter, &y, QString(tr("Add %1 gram `%2` hop")).arg(product->hops.at(j).h_amount * 1000 * factor, 1, 'f', 1) - .arg(product->hops.at(j).h_name)); + if (product->hops.at(j).useat == HOP_USEAT_MASH) { + checkLine(&painter, &y, QString(tr("Add %1 gram `%2` hop")).arg(product->hops.at(j).amount * 1000 * factor, 1, 'f', 1) + .arg(product->hops.at(j).name)); } } for (int j = 0; j < product->miscs.size(); j++) { @@ -1708,9 +1708,9 @@ checkInput(&painter, &y, QString(tr("Target SG in boil kettle: ")) + strDensity(product->preboil_sg), QString(tr("SG"))); checkInput(&painter, &y, "", QString(tr("pH"))); for (int i = 0; i < product->hops.size(); i++) { - if (product->hops.at(i).h_useat == HOP_USEAT_FWH) { - checkLine(&painter, &y, QString(tr("Add %1 gr `%2` hop after sparge")).arg(product->hops.at(i).h_amount * 1000 * factor, 1, 'f', 1) - .arg(product->hops.at(i).h_name)); + if (product->hops.at(i).useat == HOP_USEAT_FWH) { + checkLine(&painter, &y, QString(tr("Add %1 gr `%2` hop after sparge")).arg(product->hops.at(i).amount * 1000 * factor, 1, 'f', 1) + .arg(product->hops.at(i).name)); } } @@ -1729,7 +1729,7 @@ lines++; } for (int i = 0; i < product->hops.size(); i++) { - if (product->hops.at(i).h_useat == HOP_USEAT_BOIL || product->hops.at(i).h_useat == HOP_USEAT_AROMA) + if (product->hops.at(i).useat == HOP_USEAT_BOIL || product->hops.at(i).useat == HOP_USEAT_AROMA) lines++; } for (int i = 0; i < product->miscs.size(); i++) { @@ -1760,13 +1760,13 @@ checkLine(&painter, &y, QString(tr("Place emersion chiller at 10 minutes before end of boil"))); } for (int j = 0; j < product->hops.size(); j++) { - if ((product->hops.at(j).h_useat == HOP_USEAT_BOIL || product->hops.at(j).h_useat == HOP_USEAT_AROMA) && product->hops.at(j).h_time == i) { + if ((product->hops.at(j).useat == HOP_USEAT_BOIL || product->hops.at(j).useat == HOP_USEAT_AROMA) && product->hops.at(j).time == i) { if (i == 0) - checkLine(&painter, &y, QString(tr("%1 gr `%2` at flameout")).arg(product->hops.at(j).h_amount * 1000 * factor, 1, 'f', 2) - .arg(product->hops.at(j).h_name)); + checkLine(&painter, &y, QString(tr("%1 gr `%2` at flameout")).arg(product->hops.at(j).amount * 1000 * factor, 1, 'f', 2) + .arg(product->hops.at(j).name)); else checkLine(&painter, &y, QString(tr("%1 gr `%2` at %3 minutes before end of boil")) - .arg(product->hops.at(j).h_amount * 1000 * factor, 1, 'f', 2).arg(product->hops.at(j).h_name).arg(i)); + .arg(product->hops.at(j).amount * 1000 * factor, 1, 'f', 2).arg(product->hops.at(j).name).arg(i)); } } for (int j = 0; j < product->miscs.size(); j++) { @@ -1804,7 +1804,7 @@ if (product->brew_whirlpool2) lines++; for (int i = 0; i < product->hops.size(); i++) { - if (product->hops.at(i).h_useat == HOP_USEAT_WHIRLPOOL) + if (product->hops.at(i).useat == HOP_USEAT_WHIRLPOOL) lines++; } if ((y + (lines * 20)) > painter.device()->height()) { @@ -1823,10 +1823,10 @@ if (product->brew_whirlpool6 > 0) checkLine(&painter, &y, QString(tr("Wirlpool for %1 minutes. Keep temp between 60 and 66°C")).arg(product->brew_whirlpool6, 1, 'f', 0)); for (int i = 0; i < product->hops.size(); i++) { - if (product->hops.at(i).h_useat == HOP_USEAT_WHIRLPOOL) + if (product->hops.at(i).useat == HOP_USEAT_WHIRLPOOL) checkLine(&painter, &y, QString(tr("%1 gr `%2` for %3 minutes in the whirlpool")) - .arg(product->hops.at(i).h_amount * 1000 * factor, 1, 'f', 1).arg(product->hops.at(i).h_name) - .arg(product->hops.at(i).h_time)); + .arg(product->hops.at(i).amount * 1000 * factor, 1, 'f', 1).arg(product->hops.at(i).name) + .arg(product->hops.at(i).time)); } checkLine(&painter, &y, QString(tr("Cool to %1°C")).arg(product->brew_cooling_to, 1, 'f', 1)); if (product->brew_whirlpool2 > 0) @@ -1979,7 +1979,7 @@ if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_LAGERING) lines++; for (int i = 0; i < product->hops.size(); i++) - if (product->hops.at(i).h_useat == HOP_USEAT_DRY_HOP) + if (product->hops.at(i).useat == HOP_USEAT_DRY_HOP) lines++; for (int i = 0; i < product->miscs.size(); i++) if (product->miscs.at(i).use_use == MISC_USES_SECONDARY) @@ -2003,9 +2003,9 @@ .arg(product->fermentables.at(i).f_name)); } for (int i = 0; i < product->hops.size(); i++) { - if (product->hops.at(i).h_useat == HOP_USEAT_DRY_HOP) { - checkLine(&painter, &y, QString(tr("Add %1 gram `%2` for %3 days")).arg(product->hops.at(i).h_amount * 1000 * factor, 1, 'f', 1) - .arg(product->hops.at(i).h_name).arg(product->hops.at(i).h_time / 1440)); + if (product->hops.at(i).useat == HOP_USEAT_DRY_HOP) { + checkLine(&painter, &y, QString(tr("Add %1 gram `%2` for %3 days")).arg(product->hops.at(i).amount * 1000 * factor, 1, 'f', 1) + .arg(product->hops.at(i).name).arg(product->hops.at(i).time / 1440)); } } for (int i = 0; i < product->yeasts.size(); i++) {
--- a/src/database/db_product.cpp Mon Jun 13 12:26:27 2022 +0200 +++ b/src/database/db_product.cpp Mon Jun 13 15:47:16 2022 +0200 @@ -346,32 +346,32 @@ for (int i = 0; i < hops.array().size(); i++) { QJsonObject obj = hops.array().at(i).toObject(); Hops h; - h.h_avail = false; - h.h_inventory = 0; - h.h_name = obj["h_name"].toString(); - h.h_origin = obj["h_origin"].toString(); - h.h_amount = obj["h_amount"].toDouble(); - h.h_cost = obj["h_cost"].toDouble(); - h.h_type = obj["h_type"].toInt(); - h.h_form = obj["h_form"].toInt(); - h.h_useat = obj["h_useat"].toInt(); - h.h_time = obj["h_time"].toInt(); - h.h_alpha = obj["h_alpha"].toDouble(); - h.h_beta = obj["h_beta"].toDouble(); - h.h_hsi = obj["h_hsi"].toDouble(); - h.h_humulene = obj["h_humulene"].toDouble(); - h.h_caryophyllene = obj["h_caryophyllene"].toDouble(); - h.h_cohumulone = obj["h_cohumulone"].toDouble(); - h.h_myrcene = obj["h_myrcene"].toDouble(); - h.h_total_oil = obj["h_total_oil"].toDouble(); + h.avail = false; + h.inventory = 0; + h.name = obj["h_name"].toString(); + h.origin = obj["h_origin"].toString(); + h.amount = obj["h_amount"].toDouble(); + h.cost = obj["h_cost"].toDouble(); + h.type = obj["h_type"].toInt(); + h.form = obj["h_form"].toInt(); + h.useat = obj["h_useat"].toInt(); + h.time = obj["h_time"].toInt(); + h.alpha = obj["h_alpha"].toDouble(); + h.beta = obj["h_beta"].toDouble(); + h.hsi = obj["h_hsi"].toDouble(); + h.humulene = obj["h_humulene"].toDouble(); + h.caryophyllene = obj["h_caryophyllene"].toDouble(); + h.cohumulone = obj["h_cohumulone"].toDouble(); + h.myrcene = obj["h_myrcene"].toDouble(); + h.total_oil = obj["h_total_oil"].toDouble(); /* Check and update inventory */ yquery.prepare("SELECT inventory FROM inventory_hops WHERE name=:name AND origin=:origin"); - yquery.bindValue(":name", h.h_name); - yquery.bindValue(":origin", h.h_origin); + yquery.bindValue(":name", h.name); + yquery.bindValue(":origin", h.origin); yquery.exec(); if (yquery.first()) { - h.h_avail = true; - h.h_inventory = yquery.value(0).toDouble(); + h.avail = true; + h.inventory = yquery.value(0).toDouble(); } prod->hops.append(h); } @@ -875,22 +875,22 @@ QJsonArray array; for (int i = 0; i < prod->hops.size(); i++) { QJsonObject obj; - obj.insert("h_name", prod->hops.at(i).h_name); - obj.insert("h_origin", prod->hops.at(i).h_origin); - obj.insert("h_amount", round(prod->hops.at(i).h_amount * 100000) / 100000); - obj.insert("h_cost", round(prod->hops.at(i).h_cost * 100) / 100); - obj.insert("h_type", prod->hops.at(i).h_type); - obj.insert("h_form", prod->hops.at(i).h_form); - obj.insert("h_useat", prod->hops.at(i).h_useat); - obj.insert("h_time", round(prod->hops.at(i).h_time)); - obj.insert("h_alpha", round(prod->hops.at(i).h_alpha * 100) / 100); - obj.insert("h_beta", round(prod->hops.at(i).h_beta * 100) / 100); - obj.insert("h_hsi", round(prod->hops.at(i).h_hsi * 100) / 100); - obj.insert("h_humulene", round(prod->hops.at(i).h_humulene * 100) / 100); - obj.insert("h_caryophyllene", round(prod->hops.at(i).h_caryophyllene * 100) / 100); - obj.insert("h_cohumulone", round(prod->hops.at(i).h_cohumulone * 100) / 100); - obj.insert("h_myrcene", round(prod->hops.at(i).h_myrcene * 100) / 100); - obj.insert("h_total_oil", round(prod->hops.at(i).h_total_oil * 100) / 100); + obj.insert("h_name", prod->hops.at(i).name); + obj.insert("h_origin", prod->hops.at(i).origin); + obj.insert("h_amount", round(prod->hops.at(i).amount * 100000) / 100000); + obj.insert("h_cost", round(prod->hops.at(i).cost * 100) / 100); + obj.insert("h_type", prod->hops.at(i).type); + obj.insert("h_form", prod->hops.at(i).form); + obj.insert("h_useat", prod->hops.at(i).useat); + obj.insert("h_time", round(prod->hops.at(i).time)); + obj.insert("h_alpha", round(prod->hops.at(i).alpha * 100) / 100); + obj.insert("h_beta", round(prod->hops.at(i).beta * 100) / 100); + obj.insert("h_hsi", round(prod->hops.at(i).hsi * 100) / 100); + obj.insert("h_humulene", round(prod->hops.at(i).humulene * 100) / 100); + obj.insert("h_caryophyllene", round(prod->hops.at(i).caryophyllene * 100) / 100); + obj.insert("h_cohumulone", round(prod->hops.at(i).cohumulone * 100) / 100); + obj.insert("h_myrcene", round(prod->hops.at(i).myrcene * 100) / 100); + obj.insert("h_total_oil", round(prod->hops.at(i).total_oil * 100) / 100); // qDebug() << "hops_Json" << i << obj; array.append(obj); /* Append this object */ }
--- a/src/database/db_recipe.cpp Mon Jun 13 12:26:27 2022 +0200 +++ b/src/database/db_recipe.cpp Mon Jun 13 15:47:16 2022 +0200 @@ -193,22 +193,22 @@ for (int i = 0; i < hops.array().size(); i++) { QJsonObject obj = hops.array().at(i).toObject(); Hops h; - h.h_name = obj["h_name"].toString(); - h.h_origin = obj["h_origin"].toString(); - h.h_amount = obj["h_amount"].toDouble(); - h.h_cost = obj["h_cost"].toDouble(); - h.h_type = obj["h_type"].toInt(); - h.h_form = obj["h_form"].toInt(); - h.h_useat = obj["h_useat"].toInt(); - h.h_time = obj["h_time"].toInt(); - h.h_alpha = obj["h_alpha"].toDouble(); - h.h_beta = obj["h_beta"].toDouble(); - h.h_hsi = obj["h_hsi"].toDouble(); - h.h_humulene = obj["h_humulene"].toDouble(); - h.h_caryophyllene = obj["h_caryophyllene"].toDouble(); - h.h_cohumulone = obj["h_cohumulone"].toDouble(); - h.h_myrcene = obj["h_myrcene"].toDouble(); - h.h_total_oil = obj["h_total_oil"].toDouble(); + h.name = obj["h_name"].toString(); + h.origin = obj["h_origin"].toString(); + h.amount = obj["h_amount"].toDouble(); + h.cost = obj["h_cost"].toDouble(); + h.type = obj["h_type"].toInt(); + h.form = obj["h_form"].toInt(); + h.useat = obj["h_useat"].toInt(); + h.time = obj["h_time"].toInt(); + h.alpha = obj["h_alpha"].toDouble(); + h.beta = obj["h_beta"].toDouble(); + h.hsi = obj["h_hsi"].toDouble(); + h.humulene = obj["h_humulene"].toDouble(); + h.caryophyllene = obj["h_caryophyllene"].toDouble(); + h.cohumulone = obj["h_cohumulone"].toDouble(); + h.myrcene = obj["h_myrcene"].toDouble(); + h.total_oil = obj["h_total_oil"].toDouble(); reci->hops.append(h); } } @@ -520,22 +520,22 @@ QJsonArray array; for (int i = 0; i < reci->hops.size(); i++) { QJsonObject obj; - obj.insert("h_name", reci->hops.at(i).h_name); - obj.insert("h_origin", reci->hops.at(i).h_origin); - obj.insert("h_amount", round(reci->hops.at(i).h_amount * 10000) / 10000); - obj.insert("h_cost", round(reci->hops.at(i).h_cost * 100) / 100); - obj.insert("h_type", reci->hops.at(i).h_type); - obj.insert("h_form", reci->hops.at(i).h_form); - obj.insert("h_useat", reci->hops.at(i).h_useat); - obj.insert("h_time", round(reci->hops.at(i).h_time)); - obj.insert("h_alpha", round(reci->hops.at(i).h_alpha * 100) / 100); - obj.insert("h_beta", round(reci->hops.at(i).h_beta * 100) / 100); - obj.insert("h_hsi", round(reci->hops.at(i).h_hsi * 100) / 100); - obj.insert("h_humulene", round(reci->hops.at(i).h_humulene * 100) / 100); - obj.insert("h_caryophyllene", round(reci->hops.at(i).h_caryophyllene * 100) / 100); - obj.insert("h_cohumulone", round(reci->hops.at(i).h_cohumulone * 100) / 100); - obj.insert("h_myrcene", round(reci->hops.at(i).h_myrcene * 100) / 100); - obj.insert("h_total_oil", round(reci->hops.at(i).h_total_oil * 100) / 100); + obj.insert("h_name", reci->hops.at(i).name); + obj.insert("h_origin", reci->hops.at(i).origin); + obj.insert("h_amount", round(reci->hops.at(i).amount * 10000) / 10000); + obj.insert("h_cost", round(reci->hops.at(i).cost * 100) / 100); + obj.insert("h_type", reci->hops.at(i).type); + obj.insert("h_form", reci->hops.at(i).form); + obj.insert("h_useat", reci->hops.at(i).useat); + obj.insert("h_time", round(reci->hops.at(i).time)); + obj.insert("h_alpha", round(reci->hops.at(i).alpha * 100) / 100); + obj.insert("h_beta", round(reci->hops.at(i).beta * 100) / 100); + obj.insert("h_hsi", round(reci->hops.at(i).hsi * 100) / 100); + obj.insert("h_humulene", round(reci->hops.at(i).humulene * 100) / 100); + obj.insert("h_caryophyllene", round(reci->hops.at(i).caryophyllene * 100) / 100); + obj.insert("h_cohumulone", round(reci->hops.at(i).cohumulone * 100) / 100); + obj.insert("h_myrcene", round(reci->hops.at(i).myrcene * 100) / 100); + obj.insert("h_total_oil", round(reci->hops.at(i).total_oil * 100) / 100); array.append(obj); /* Append this object */ } QJsonDocument doc;
--- a/src/global.h Mon Jun 13 12:26:27 2022 +0200 +++ b/src/global.h Mon Jun 13 15:47:16 2022 +0200 @@ -54,56 +54,56 @@ */ struct Fermentables { - QString f_name; - QString f_origin; - QString f_supplier; - QString f_notes; - double f_amount; - double f_cost; - int f_type; - double f_yield; - double f_color; - double f_coarse_fine_diff; - double f_moisture; - double f_diastatic_power; - double f_protein; - double f_dissolved_protein; - double f_max_in_batch; - int f_graintype; - int f_added; - bool f_recommend_mash; - bool f_add_after_boil; - bool f_adjust_to_total_100; - double f_percentage; - double f_di_ph; - double f_acid_to_ph_57; - double f_inventory; ///< In product, current inventory. - bool f_avail; ///< Product available in database. + QString name; + QString origin; + QString supplier; + QString notes; + double amount; + double cost; + int type; + double yield; + double color; + double coarse_fine_diff; + double moisture; + double diastatic_power; + double protein; + double dissolved_protein; + double max_in_batch; + int graintype; + int added; + bool recommend_mash; + bool add_after_boil; + bool adjust_to_total_100; + double percentage; + double di_ph; + double acid_to_ph_57; + double inventory; ///< In product, current inventory. + bool avail; ///< Product available in database. }; struct Hops { - QString h_name; - QString h_origin; - QString h_notes; - QString h_substitutes; - double h_amount; - double h_cost; - int h_type; - int h_form; - int h_useat; - double h_time; - double h_alpha; - double h_beta; - double h_hsi; - double h_humulene; - double h_caryophyllene; - double h_cohumulone; - double h_myrcene; - double h_total_oil; - double h_inventory; ///< In product, current inventory. - bool h_avail; ///< Product available in database. + QString name; + QString origin; + QString notes; + QString substitutes; + double amount; + double cost; + int type; + int form; + int useat; + double time; + double alpha; + double beta; + double hsi; + double humulene; + double caryophyllene; + double cohumulone; + double myrcene; + double total_oil; + double inventory; ///< In product, current inventory. + bool avail; ///< Product available in database. };