diff -r d1d208a857b0 -r 242a68fa7186 src/EditProductTab3.cpp --- a/src/EditProductTab3.cpp Mon Jun 13 15:47:16 2022 +0200 +++ b/src/EditProductTab3.cpp Mon Jun 13 16:47:52 2022 +0200 @@ -21,17 +21,17 @@ bool EditProduct::ferment_sort_test(const Fermentables &D1, const Fermentables &D2) { - if (D1.f_added > D2.f_added) + if (D1.added > D2.added) return false; - if (D1.f_added < D2.f_added) + if (D1.added < D2.added) return true; - return (D1.f_amount >= D2.f_amount) && (D1.f_color < D2.f_color); + return (D1.amount >= D2.amount) && (D1.color < D2.color); } void EditProduct::to100Fermentables(int row) { - if (product->fermentables.at(row).f_adjust_to_total_100) { + if (product->fermentables.at(row).adjust_to_total_100) { QWidget *pWidget = new QWidget(); QLabel *label = new QLabel; label->setPixmap(QPixmap(":icons/silk/tick.png")); @@ -79,42 +79,42 @@ for (int i = 0; i < product->fermentables.size(); i++) { - ui->fermentablesTable->setItem(i, 0, new QTableWidgetItem(product->fermentables.at(i).f_supplier)); - ui->fermentablesTable->setItem(i, 1, new QTableWidgetItem(product->fermentables.at(i).f_name)); + ui->fermentablesTable->setItem(i, 0, new QTableWidgetItem(product->fermentables.at(i).supplier)); + ui->fermentablesTable->setItem(i, 1, new QTableWidgetItem(product->fermentables.at(i).name)); - w = QString("%1").arg(product->fermentables.at(i).f_color, 1, 'f', 0, '0'); + w = QString("%1").arg(product->fermentables.at(i).color, 1, 'f', 0, '0'); item = new QTableWidgetItem(w); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->fermentablesTable->setItem(i, 2, item); - item = new QTableWidgetItem(fermentable_types[product->fermentables.at(i).f_type]); + item = new QTableWidgetItem(fermentable_types[product->fermentables.at(i).type]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->fermentablesTable->setItem(i, 3, item); - item = new QTableWidgetItem(fermentable_graintypes[product->fermentables.at(i).f_graintype]); + item = new QTableWidgetItem(fermentable_graintypes[product->fermentables.at(i).graintype]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->fermentablesTable->setItem(i, 4, item); - item = new QTableWidgetItem(fermentable_added[product->fermentables.at(i).f_added]); + item = new QTableWidgetItem(fermentable_added[product->fermentables.at(i).added]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->fermentablesTable->setItem(i, 5, item); - item = new QTableWidgetItem(QString("%1%").arg(product->fermentables.at(i).f_yield, 2, 'f', 1, '0')); + item = new QTableWidgetItem(QString("%1%").arg(product->fermentables.at(i).yield, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->fermentablesTable->setItem(i, 6, item); - item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables.at(i).f_amount, 4, 'f', 3, '0')); + item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables.at(i).amount, 4, 'f', 3, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->fermentablesTable->setItem(i, 7, item); - item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables.at(i).f_inventory, 4, 'f', 3, '0')); + item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables.at(i).inventory, 4, 'f', 3, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - if (product->fermentables.at(i).f_inventory < product->fermentables.at(i).f_amount) + if (product->fermentables.at(i).inventory < product->fermentables.at(i).amount) item->setForeground(QBrush(QColor(Qt::red))); ui->fermentablesTable->setItem(i, 8, item); - if (product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) { - item = new QTableWidgetItem(QString("%1%").arg(product->fermentables.at(i).f_percentage, 2, 'f', 1, '0')); + if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) { + item = new QTableWidgetItem(QString("%1%").arg(product->fermentables.at(i).percentage, 2, 'f', 1, '0')); } else { item = new QTableWidgetItem(QString("")); // Blank for bottling and kegging. } @@ -124,7 +124,7 @@ to100Fermentables(i); /* Add the Delete row button */ - if (product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) { + if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) { pWidget = new QWidget(); QPushButton* btn_dele = new QPushButton(); btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ @@ -243,45 +243,45 @@ product->fermentables_ok = true; product->mashs_kg = 0; for (i = 0; i < product->fermentables.size(); i++) { - if (product->fermentables.at(i).f_type == FERMENTABLE_TYPE_SUGAR && product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) - psugar += product->fermentables.at(i).f_percentage; - if (product->fermentables.at(i).f_graintype == FERMENTABLE_GRAINTYPE_CRYSTAL && product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) - pcara += product->fermentables.at(i).f_percentage; - d = product->fermentables.at(i).f_amount * (product->fermentables.at(i).f_yield / 100) * (1 - product->fermentables.at(i).f_moisture / 100); - if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_MASH) { + if (product->fermentables.at(i).type == FERMENTABLE_TYPE_SUGAR && product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) + psugar += product->fermentables.at(i).percentage; + if (product->fermentables.at(i).graintype == FERMENTABLE_GRAINTYPE_CRYSTAL && product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) + pcara += product->fermentables.at(i).percentage; + d = product->fermentables.at(i).amount * (product->fermentables.at(i).yield / 100) * (1 - product->fermentables.at(i).moisture / 100); + if (product->fermentables.at(i).added == FERMENTABLE_ADDED_MASH) { if (mvol > 0) { // If mash volume is known - mvol += product->fermentables.at(i).f_amount * product->fermentables.at(i).f_moisture / 100; + mvol += product->fermentables.at(i).amount * product->fermentables.at(i).moisture / 100; s += d; } d = product->efficiency / 100 * d; sugarsm += d; - product->mashs_kg += product->fermentables.at(i).f_amount; + product->mashs_kg += product->fermentables.at(i).amount; } - if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_MASH || product->fermentables.at(i).f_added == FERMENTABLE_ADDED_BOIL) + if (product->fermentables.at(i).added == FERMENTABLE_ADDED_MASH || product->fermentables.at(i).added == FERMENTABLE_ADDED_BOIL) sugarsf += d; - if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_FERMENTATION || product->fermentables.at(i).f_added == FERMENTABLE_ADDED_LAGERING) { - x = (product->fermentables.at(i).f_yield / 100) * (1 - product->fermentables.at(i).f_moisture / 100); - addedS += product->fermentables.at(i).f_amount * x; - addedmass += product->fermentables.at(i).f_amount; - vol += (x * sugardensity + (1 - x) * 1) * product->fermentables.at(i).f_amount; + if (product->fermentables.at(i).added == FERMENTABLE_ADDED_FERMENTATION || product->fermentables.at(i).added == FERMENTABLE_ADDED_LAGERING) { + x = (product->fermentables.at(i).yield / 100) * (1 - product->fermentables.at(i).moisture / 100); + addedS += product->fermentables.at(i).amount * x; + addedmass += product->fermentables.at(i).amount; + vol += (x * sugardensity + (1 - x) * 1) * product->fermentables.at(i).amount; } - if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_MASH && - (product->fermentables.at(i).f_type == FERMENTABLE_TYPE_GRAIN || product->fermentables.at(i).f_type == FERMENTABLE_TYPE_ADJUCT) && - product->fermentables.at(i).f_color < 50) { - lintner += product->fermentables.at(i).f_diastatic_power * product->fermentables.at(i).f_amount; + if (product->fermentables.at(i).added == FERMENTABLE_ADDED_MASH && + (product->fermentables.at(i).type == FERMENTABLE_TYPE_GRAIN || product->fermentables.at(i).type == FERMENTABLE_TYPE_ADJUCT) && + product->fermentables.at(i).color < 50) { + lintner += product->fermentables.at(i).diastatic_power * product->fermentables.at(i).amount; } - if (product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) { - colort += product->fermentables.at(i).f_amount * Utils::ebc_to_srm(product->fermentables.at(i).f_color); - colorh += product->fermentables.at(i).f_amount * product->fermentables.at(i).f_color * Utils::get_kt(product->fermentables.at(i).f_color); - colorn += (product->fermentables.at(i).f_percentage / 100) * product->fermentables.at(i).f_color; // For 8.6 Pt wort. + if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) { + colort += product->fermentables.at(i).amount * Utils::ebc_to_srm(product->fermentables.at(i).color); + colorh += product->fermentables.at(i).amount * product->fermentables.at(i).color * Utils::get_kt(product->fermentables.at(i).color); + colorn += (product->fermentables.at(i).percentage / 100) * product->fermentables.at(i).color; // For 8.6 Pt wort. } /* Check supplies */ - if ((((product->inventory_reduced <= PROD_STAGE_BREW) && (product->fermentables.at(i).f_added <= FERMENTABLE_ADDED_BOIL)) || - ((product->inventory_reduced <= PROD_STAGE_PRIMARY) && (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_FERMENTATION)) || - ((product->inventory_reduced <= PROD_STAGE_TERTIARY) && (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_LAGERING)) || - ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_BOTTLE)) || - ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_KEGS))) && - product->fermentables.at(i).f_inventory < product->fermentables.at(i).f_amount) { + if ((((product->inventory_reduced <= PROD_STAGE_BREW) && (product->fermentables.at(i).added <= FERMENTABLE_ADDED_BOIL)) || + ((product->inventory_reduced <= PROD_STAGE_PRIMARY) && (product->fermentables.at(i).added == FERMENTABLE_ADDED_FERMENTATION)) || + ((product->inventory_reduced <= PROD_STAGE_TERTIARY) && (product->fermentables.at(i).added == FERMENTABLE_ADDED_LAGERING)) || + ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->fermentables.at(i).added == FERMENTABLE_ADDED_BOTTLE)) || + ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->fermentables.at(i).added == FERMENTABLE_ADDED_KEGS))) && + product->fermentables.at(i).inventory < product->fermentables.at(i).amount) { product->fermentables_ok = false; } } @@ -454,10 +454,10 @@ // Bottle priming double priming_total = 0; for (i = 0; i < product->fermentables.size(); i++) { - if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_BOTTLE) { - priming_total += ((product->fermentables.at(i).f_yield / 100) * (1 - product->fermentables.at(i).f_moisture / 100)) * - product->fermentables.at(i).f_amount; - qDebug() << " priming" << product->fermentables.at(i).f_amount << "total" << priming_total; + if (product->fermentables.at(i).added == FERMENTABLE_ADDED_BOTTLE) { + priming_total += ((product->fermentables.at(i).yield / 100) * (1 - product->fermentables.at(i).moisture / 100)) * + product->fermentables.at(i).amount; + qDebug() << " priming" << product->fermentables.at(i).amount << "total" << priming_total; } } double grl = priming_total * 1000.0 * (1 / product->batch_size); @@ -484,11 +484,11 @@ double sug = Utils::sg_to_plato(og) * product->batch_size * og / 100.0; // total amount of sugars in kg. for (i = 0; i < product->fermentables.size(); i++) { - if (product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) { - d = product->fermentables.at(i).f_percentage / 100.0 * - (product->fermentables.at(i).f_yield / 100.0) * - (1 - product->fermentables.at(i).f_moisture / 100.0); - if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_MASH) + if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) { + d = product->fermentables.at(i).percentage / 100.0 * + (product->fermentables.at(i).yield / 100.0) * + (1 - product->fermentables.at(i).moisture / 100.0); + if (product->fermentables.at(i).added == FERMENTABLE_ADDED_MASH) d = efficiency / 100.0 * d; tot += d; } @@ -498,8 +498,8 @@ if (totmass) { for (i = 0; i < product->fermentables.size(); i++) { - amount = round(product->fermentables.at(i).f_percentage * 10.0 * totmass) / 1000.0; - product->fermentables[i].f_amount = amount; + amount = round(product->fermentables.at(i).percentage * 10.0 * totmass) / 1000.0; + product->fermentables[i].amount = amount; } } } @@ -578,32 +578,32 @@ qDebug() << "Add fermentable row"; for (int i = 0; i < product->fermentables.size(); i++) { - if (product->fermentables.at(i).f_amount == 0 && product->fermentables.at(i).f_color == 0) + if (product->fermentables.at(i).amount == 0 && product->fermentables.at(i).color == 0) return; // Add only one at a time. } - newf.f_name = "Select one"; - newf.f_origin = ""; - newf.f_supplier = ""; - newf.f_amount = 0; - newf.f_cost = 0; - newf.f_type = FERMENTABLE_TYPE_GRAIN; - newf.f_yield = 0; - newf.f_color = 0; - newf.f_coarse_fine_diff = 0; - newf.f_moisture = 0; - newf.f_diastatic_power = 0; - newf.f_protein = 0; - newf.f_dissolved_protein = 0; - newf.f_max_in_batch = 100; - newf.f_graintype = FERMENTABLE_GRAINTYPE_BASE; - newf.f_added = FERMENTABLE_ADDED_MASH; - newf.f_recommend_mash = true; - newf.f_add_after_boil = false; - newf.f_adjust_to_total_100 = false; - newf.f_percentage = 0; - newf.f_di_ph = 0; - newf.f_acid_to_ph_57 = 0; + newf.name = "Select one"; + newf.origin = ""; + newf.supplier = ""; + newf.amount = 0; + newf.cost = 0; + newf.type = FERMENTABLE_TYPE_GRAIN; + newf.yield = 0; + newf.color = 0; + newf.coarse_fine_diff = 0; + newf.moisture = 0; + newf.diastatic_power = 0; + newf.protein = 0; + newf.dissolved_protein = 0; + newf.max_in_batch = 100; + newf.graintype = FERMENTABLE_GRAINTYPE_BASE; + newf.added = FERMENTABLE_ADDED_MASH; + newf.recommend_mash = true; + newf.add_after_boil = false; + newf.adjust_to_total_100 = false; + newf.percentage = 0; + newf.di_ph = 0; + newf.acid_to_ph_57 = 0; product->fermentables.append(newf); emit refreshAll(); @@ -622,7 +622,7 @@ if (product->fermentables.size() < 1) return; - int rc = QMessageBox::warning(this, tr("Delete fermentable"), tr("Delete %1").arg(product->fermentables.at(row).f_name), + int rc = QMessageBox::warning(this, tr("Delete fermentable"), tr("Delete %1").arg(product->fermentables.at(row).name), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (rc == QMessageBox::No) return; @@ -634,11 +634,11 @@ */ double total = 0; for (int i = 0; i < product->fermentables.size(); i++) - if (product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging - total += product->fermentables.at(i).f_amount; + if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging + total += product->fermentables.at(i).amount; for (int i = 0; i < product->fermentables.size(); i++) - if (product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) - product->fermentables[i].f_percentage = product->fermentables.at(i).f_amount / total * 100; + if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) + product->fermentables[i].percentage = product->fermentables.at(i).amount / total * 100; is_changed(); emit refreshAll(); @@ -650,26 +650,26 @@ QTableWidgetItem *item; double total = 0, perc; - if (product->fermentables_use100 && product->fermentables.at(product->fermentables_row).f_added < FERMENTABLE_ADDED_BOTTLE) + if (product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < FERMENTABLE_ADDED_BOTTLE) return; qDebug() << "ferment_amount_changed()" << product->fermentables_row << val; - product->fermentables[product->fermentables_row].f_amount = val; + product->fermentables[product->fermentables_row].amount = val; item = new QTableWidgetItem(QString("%1 Kg").arg(val, 4, 'f', 3, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->fermentablesTable->setItem(product->fermentables_row, 7, item); for (int i = 0; i < product->fermentables.size(); i++) - if (product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging - total += product->fermentables.at(i).f_amount; + if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging + total += product->fermentables.at(i).amount; /* * Recalculate the percentages */ for (int i = 0; i < product->fermentables.size(); i++) { - if (product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) { - perc = product->fermentables.at(i).f_amount / total * 100; - product->fermentables[i].f_percentage = perc; + if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) { + perc = product->fermentables.at(i).amount / total * 100; + product->fermentables[i].percentage = perc; item = new QTableWidgetItem(QString("%1%").arg(perc, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->fermentablesTable->setItem(i, 8, item); @@ -695,35 +695,35 @@ * this is not the entry to be adjusted to 100. */ for (int i = 0; i < product->fermentables.size(); i++) { - if (product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging - total += product->fermentables.at(i).f_amount; - if (product->fermentables.at(i).f_adjust_to_total_100) + if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging + total += product->fermentables.at(i).amount; + if (product->fermentables.at(i).adjust_to_total_100) row100 = i; } - double oldperc = product->fermentables.at(product->fermentables_row).f_percentage; + double oldperc = product->fermentables.at(product->fermentables_row).percentage; double diffp = val - oldperc; double diffw = (diffp / 100) * total; qDebug() << "row100" << row100 << "total" << total << "diff kg" << diffw << "diff %" << diffp; - product->fermentables[product->fermentables_row].f_percentage += diffp; - product->fermentables[product->fermentables_row].f_amount += diffw; - product->fermentables[row100].f_percentage -= diffp; - product->fermentables[row100].f_amount -= diffw; + product->fermentables[product->fermentables_row].percentage += diffp; + product->fermentables[product->fermentables_row].amount += diffw; + product->fermentables[row100].percentage -= diffp; + product->fermentables[row100].amount -= diffw; - item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables[product->fermentables_row].f_amount, 4, 'f', 3, '0')); + item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables[product->fermentables_row].amount, 4, 'f', 3, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->fermentablesTable->setItem(product->fermentables_row, 7, item); - this->famountEdit->setValue(product->fermentables[product->fermentables_row].f_amount); + this->famountEdit->setValue(product->fermentables[product->fermentables_row].amount); - item = new QTableWidgetItem(QString("%1%").arg(product->fermentables[product->fermentables_row].f_percentage, 2, 'f', 1, '0')); + item = new QTableWidgetItem(QString("%1%").arg(product->fermentables[product->fermentables_row].percentage, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->fermentablesTable->setItem(product->fermentables_row, 8, item); - item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables[row100].f_amount, 4, 'f', 3, '0')); + item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables[row100].amount, 4, 'f', 3, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->fermentablesTable->setItem(row100, 7, item); - item = new QTableWidgetItem(QString("%1%").arg(product->fermentables[row100].f_percentage, 2, 'f', 1, '0')); + item = new QTableWidgetItem(QString("%1%").arg(product->fermentables[row100].percentage, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->fermentablesTable->setItem(row100, 8, item); @@ -735,9 +735,9 @@ { qDebug() << "ferment_to100_changed()" << product->fermentables_row << val << product->fermentables_use100; - if (product->fermentables.at(product->fermentables_row).f_added >= FERMENTABLE_ADDED_BOTTLE) { + if (product->fermentables.at(product->fermentables_row).added >= FERMENTABLE_ADDED_BOTTLE) { const QSignalBlocker blocker1(to100Edit); - product->fermentables[product->fermentables_row].f_adjust_to_total_100 = false; + product->fermentables[product->fermentables_row].adjust_to_total_100 = false; to100Edit->setChecked(false); return; } @@ -751,21 +751,21 @@ if (! product->fermentables_use100 && val) { /* Scenario 1. */ product->fermentables_use100 = true; - product->fermentables[product->fermentables_row].f_adjust_to_total_100 = true; + product->fermentables[product->fermentables_row].adjust_to_total_100 = true; pctEdit->setReadOnly(false); famountEdit->setReadOnly(true); - } else if (product->fermentables_use100 && product->fermentables[product->fermentables_row].f_adjust_to_total_100 && ! val) { + } else if (product->fermentables_use100 && product->fermentables[product->fermentables_row].adjust_to_total_100 && ! val) { /* Scenario 2. */ - product->fermentables[product->fermentables_row].f_adjust_to_total_100 = false; + product->fermentables[product->fermentables_row].adjust_to_total_100 = false; product->fermentables_use100 = false; pctEdit->setReadOnly(true); famountEdit->setReadOnly(false); - } else if (product->fermentables_use100 && ! product->fermentables[product->fermentables_row].f_adjust_to_total_100 && val) { + } else if (product->fermentables_use100 && ! product->fermentables[product->fermentables_row].adjust_to_total_100 && val) { /* Scenario 3. */ for (int i = 0; i < product->fermentables.size(); i++) { - product->fermentables[i].f_adjust_to_total_100 = false; + product->fermentables[i].adjust_to_total_100 = false; } - product->fermentables[product->fermentables_row].f_adjust_to_total_100 = true; + product->fermentables[product->fermentables_row].adjust_to_total_100 = true; } else { qDebug() << "bug"; return; @@ -808,56 +808,56 @@ /* * Replace the fermentable record contents */ - product->fermentables[product->fermentables_row].f_name = query.value(0).toString(); - product->fermentables[product->fermentables_row].f_origin = query.value(1).toString(); - product->fermentables[product->fermentables_row].f_supplier = query.value(2).toString(); - product->fermentables[product->fermentables_row].f_cost = query.value(3).toDouble(); - product->fermentables[product->fermentables_row].f_type = query.value(4).toInt(); - product->fermentables[product->fermentables_row].f_yield = query.value(5).toDouble(); - product->fermentables[product->fermentables_row].f_color = query.value(6).toDouble(); - product->fermentables[product->fermentables_row].f_coarse_fine_diff = query.value(7).toDouble(); - product->fermentables[product->fermentables_row].f_moisture = query.value(8).toDouble(); - product->fermentables[product->fermentables_row].f_diastatic_power = query.value(9).toDouble(); - product->fermentables[product->fermentables_row].f_protein = query.value(10).toDouble(); - product->fermentables[product->fermentables_row].f_dissolved_protein = query.value(11).toDouble(); - product->fermentables[product->fermentables_row].f_max_in_batch = query.value(12).toDouble(); - product->fermentables[product->fermentables_row].f_graintype = query.value(13).toInt(); - product->fermentables[product->fermentables_row].f_recommend_mash = query.value(14).toInt() ? true:false; - product->fermentables[product->fermentables_row].f_add_after_boil = query.value(15).toInt() ? true:false; - product->fermentables[product->fermentables_row].f_di_ph = query.value(16).toDouble(); - product->fermentables[product->fermentables_row].f_acid_to_ph_57 = query.value(17).toDouble(); - product->fermentables[product->fermentables_row].f_inventory = query.value(18).toDouble(); + product->fermentables[product->fermentables_row].name = query.value(0).toString(); + product->fermentables[product->fermentables_row].origin = query.value(1).toString(); + product->fermentables[product->fermentables_row].supplier = query.value(2).toString(); + product->fermentables[product->fermentables_row].cost = query.value(3).toDouble(); + product->fermentables[product->fermentables_row].type = query.value(4).toInt(); + product->fermentables[product->fermentables_row].yield = query.value(5).toDouble(); + product->fermentables[product->fermentables_row].color = query.value(6).toDouble(); + product->fermentables[product->fermentables_row].coarse_fine_diff = query.value(7).toDouble(); + product->fermentables[product->fermentables_row].moisture = query.value(8).toDouble(); + product->fermentables[product->fermentables_row].diastatic_power = query.value(9).toDouble(); + product->fermentables[product->fermentables_row].protein = query.value(10).toDouble(); + product->fermentables[product->fermentables_row].dissolved_protein = query.value(11).toDouble(); + product->fermentables[product->fermentables_row].max_in_batch = query.value(12).toDouble(); + product->fermentables[product->fermentables_row].graintype = query.value(13).toInt(); + product->fermentables[product->fermentables_row].recommend_mash = query.value(14).toInt() ? true:false; + product->fermentables[product->fermentables_row].add_after_boil = query.value(15).toInt() ? true:false; + product->fermentables[product->fermentables_row].di_ph = query.value(16).toDouble(); + product->fermentables[product->fermentables_row].acid_to_ph_57 = query.value(17).toDouble(); + product->fermentables[product->fermentables_row].inventory = query.value(18).toDouble(); /* * Update the visible fields */ - fnameEdit->setText(product->fermentables.at(product->fermentables_row).f_name); - fsupplierEdit->setText(product->fermentables.at(product->fermentables_row).f_supplier); - fmaxEdit->setValue(product->fermentables.at(product->fermentables_row).f_max_in_batch); + fnameEdit->setText(product->fermentables.at(product->fermentables_row).name); + fsupplierEdit->setText(product->fermentables.at(product->fermentables_row).supplier); + fmaxEdit->setValue(product->fermentables.at(product->fermentables_row).max_in_batch); - ui->fermentablesTable->setItem(product->fermentables_row, 0, new QTableWidgetItem(product->fermentables.at(product->fermentables_row).f_supplier)); - ui->fermentablesTable->setItem(product->fermentables_row, 1, new QTableWidgetItem(product->fermentables.at(product->fermentables_row).f_name)); + ui->fermentablesTable->setItem(product->fermentables_row, 0, new QTableWidgetItem(product->fermentables.at(product->fermentables_row).supplier)); + ui->fermentablesTable->setItem(product->fermentables_row, 1, new QTableWidgetItem(product->fermentables.at(product->fermentables_row).name)); - w = QString("%1").arg(product->fermentables.at(product->fermentables_row).f_color, 1, 'f', 0, '0'); + w = QString("%1").arg(product->fermentables.at(product->fermentables_row).color, 1, 'f', 0, '0'); item = new QTableWidgetItem(w); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->fermentablesTable->setItem(product->fermentables_row, 2, item); - item = new QTableWidgetItem(fermentable_types[product->fermentables.at(product->fermentables_row).f_type]); + item = new QTableWidgetItem(fermentable_types[product->fermentables.at(product->fermentables_row).type]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->fermentablesTable->setItem(product->fermentables_row, 3, item); - item = new QTableWidgetItem(fermentable_graintypes[product->fermentables.at(product->fermentables_row).f_graintype]); + item = new QTableWidgetItem(fermentable_graintypes[product->fermentables.at(product->fermentables_row).graintype]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->fermentablesTable->setItem(product->fermentables_row, 4, item); - item = new QTableWidgetItem(QString("%1%").arg(product->fermentables.at(product->fermentables_row).f_yield, 2, 'f', 1, '0')); + item = new QTableWidgetItem(QString("%1%").arg(product->fermentables.at(product->fermentables_row).yield, 2, 'f', 1, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); ui->fermentablesTable->setItem(product->fermentables_row, 6, item); - item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables.at(product->fermentables_row).f_inventory, 4, 'f', 3, '0')); + item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables.at(product->fermentables_row).inventory, 4, 'f', 3, '0')); item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - if (product->fermentables.at(product->fermentables_row).f_inventory < product->fermentables.at(product->fermentables_row).f_amount) + if (product->fermentables.at(product->fermentables_row).inventory < product->fermentables.at(product->fermentables_row).amount) item->setForeground(QBrush(QColor(Qt::red))); ui->fermentablesTable->setItem(product->fermentables_row, 8, item); @@ -894,21 +894,21 @@ { qDebug() << "ferment_added_changed()" << product->fermentables_row << val; - product->fermentables[product->fermentables_row].f_added = val; + product->fermentables[product->fermentables_row].added = val; QTableWidgetItem *item = new QTableWidgetItem(fermentable_added[val]); item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); ui->fermentablesTable->setItem(product->fermentables_row, 5, item); - famountEdit->setReadOnly(product->fermentables_use100 && product->fermentables.at(product->fermentables_row).f_added < FERMENTABLE_ADDED_BOTTLE); - pctEdit->setReadOnly(! (product->fermentables_use100 && product->fermentables.at(product->fermentables_row).f_added < FERMENTABLE_ADDED_BOTTLE)); + famountEdit->setReadOnly(product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < FERMENTABLE_ADDED_BOTTLE); + pctEdit->setReadOnly(! (product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < FERMENTABLE_ADDED_BOTTLE)); double total = 0; for (int i = 0; i < product->fermentables.size(); i++) - if (product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging - total += product->fermentables.at(i).f_amount; + if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging + total += product->fermentables.at(i).amount; for (int i = 0; i < product->fermentables.size(); i++) - if (product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) - product->fermentables[i].f_percentage = product->fermentables.at(i).f_amount / total * 100; + if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) + product->fermentables[i].percentage = product->fermentables.at(i).amount / total * 100; is_changed(); emit refreshAll(); @@ -988,12 +988,12 @@ fnameEdit = new QLineEdit(dialog); fnameEdit->setObjectName(QString::fromUtf8("fnameEdit")); - fnameEdit->setText(product->fermentables.at(product->fermentables_row).f_name); + fnameEdit->setText(product->fermentables.at(product->fermentables_row).name); fnameEdit->setGeometry(QRect(160, 10, 511, 23)); fnameEdit->setReadOnly(true); fsupplierEdit = new QLineEdit(dialog); fsupplierEdit->setObjectName(QString::fromUtf8("fsupplierEdit")); - fsupplierEdit->setText(product->fermentables.at(product->fermentables_row).f_supplier); + fsupplierEdit->setText(product->fermentables.at(product->fermentables_row).supplier); fsupplierEdit->setGeometry(QRect(160, 40, 511, 23)); fsupplierEdit->setReadOnly(true); famountEdit = new QDoubleSpinBox(dialog); @@ -1002,10 +1002,10 @@ famountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); famountEdit->setAccelerated(true); famountEdit->setDecimals(3); - famountEdit->setReadOnly(product->fermentables_use100 && product->fermentables.at(product->fermentables_row).f_added < 4); + famountEdit->setReadOnly(product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < 4); famountEdit->setMaximum(100000.0); famountEdit->setSingleStep(0.0010); - famountEdit->setValue(product->fermentables.at(product->fermentables_row).f_amount); + famountEdit->setValue(product->fermentables.at(product->fermentables_row).amount); pctEdit = new QDoubleSpinBox(dialog); pctEdit->setObjectName(QString::fromUtf8("pctEdit")); @@ -1013,8 +1013,8 @@ pctEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); pctEdit->setAccelerated(true); pctEdit->setDecimals(1); - if (product->fermentables_use100 && product->fermentables.at(product->fermentables_row).f_added < FERMENTABLE_ADDED_BOTTLE) { - if (product->fermentables.at(product->fermentables_row).f_adjust_to_total_100) + if (product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < FERMENTABLE_ADDED_BOTTLE) { + if (product->fermentables.at(product->fermentables_row).adjust_to_total_100) pctEdit->setReadOnly(true); else pctEdit->setReadOnly(false); @@ -1023,7 +1023,7 @@ } pctEdit->setMaximum(100.0); pctEdit->setSingleStep(0.1); - pctEdit->setValue(product->fermentables.at(product->fermentables_row).f_percentage); + pctEdit->setValue(product->fermentables.at(product->fermentables_row).percentage); faddedEdit = new QComboBox(dialog); faddedEdit->setObjectName(QString::fromUtf8("faddedEdit")); @@ -1032,12 +1032,12 @@ faddedEdit->addItem(tr("Boil")); faddedEdit->addItem(tr("Fermentation")); faddedEdit->addItem(tr("Lagering")); - faddedEdit->setCurrentIndex(product->fermentables.at(product->fermentables_row).f_added); + faddedEdit->setCurrentIndex(product->fermentables.at(product->fermentables_row).added); to100Edit = new QCheckBox(dialog); to100Edit->setObjectName(QString::fromUtf8("to100Edit")); to100Edit->setGeometry(QRect(160, 160, 85, 21)); - to100Edit->setChecked(product->fermentables.at(product->fermentables_row).f_adjust_to_total_100); + to100Edit->setChecked(product->fermentables.at(product->fermentables_row).adjust_to_total_100); finstockEdit = new QCheckBox(dialog); finstockEdit->setObjectName(QString::fromUtf8("instockEdit")); @@ -1051,7 +1051,7 @@ fmaxEdit->setReadOnly(true); fmaxEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); fmaxEdit->setDecimals(1); - fmaxEdit->setValue(product->fermentables.at(product->fermentables_row).f_max_in_batch); + fmaxEdit->setValue(product->fermentables.at(product->fermentables_row).max_in_batch); ferment_instock_changed(true); @@ -1074,14 +1074,14 @@ */ double total = 0; for (int i = 0; i < product->fermentables.size(); i++) - if (product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging - total += product->fermentables.at(i).f_amount; + if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging + total += product->fermentables.at(i).amount; product->fermentables_use100 = false; for (int i = 0; i < product->fermentables.size(); i++) { - if (product->fermentables.at(i).f_adjust_to_total_100) + if (product->fermentables.at(i).adjust_to_total_100) product->fermentables_use100 = true; - if (product->fermentables.at(i).f_added < FERMENTABLE_ADDED_BOTTLE) { - product->fermentables[i].f_percentage = product->fermentables.at(i).f_amount / total * 100; + if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) { + product->fermentables[i].percentage = product->fermentables.at(i).amount / total * 100; } } }