106 recipe->sparge_source = query.value(39).toInt(); |
106 recipe->sparge_source = query.value(39).toInt(); |
107 recipe->sparge_acid_type = query.value(40).toInt(); |
107 recipe->sparge_acid_type = query.value(40).toInt(); |
108 recipe->sparge_acid_perc = query.value(41).toDouble(); |
108 recipe->sparge_acid_perc = query.value(41).toDouble(); |
109 recipe->sparge_acid_amount = query.value(42).toDouble(); |
109 recipe->sparge_acid_amount = query.value(42).toDouble(); |
110 recipe->mash_ph = query.value(43).toDouble(); |
110 recipe->mash_ph = query.value(43).toDouble(); |
111 recipe->mash_name = query.value(44).toDouble(); |
111 recipe->mash_name = query.value(44).toString(); |
112 recipe->calc_acid = query.value(45).toInt() ? true:false; |
112 recipe->calc_acid = query.value(45).toInt() ? true:false; |
113 |
113 |
114 recipe->w1_name = query.value(46).toString(); |
114 recipe->w1_name = query.value(46).toString(); |
115 recipe->w1_amount = query.value(47).toDouble(); |
115 recipe->w1_amount = query.value(47).toDouble(); |
116 recipe->w1_calcium = query.value(48).toDouble(); |
116 recipe->w1_calcium = query.value(48).toDouble(); |
768 color = round((4.46 * bv * sr) / ui->batch_sizeEdit->value() * colorh); |
769 color = round((4.46 * bv * sr) / ui->batch_sizeEdit->value() * colorh); |
769 } else { |
770 } else { |
770 double cw = colort / ui->batch_sizeEdit->value() * 8.34436; |
771 double cw = colort / ui->batch_sizeEdit->value() * 8.34436; |
771 color = Utils::kw_to_ebc(ui->color_methodEdit->currentIndex(), cw); |
772 color = Utils::kw_to_ebc(ui->color_methodEdit->currentIndex(), cw); |
772 } |
773 } |
773 qDebug() << " color" << ui->est_colorEdit->value() << color; |
774 qDebug() << " color" << ui->est_colorEdit->value() << color << recipe->est_color; |
|
775 recipe->est_color = color; |
774 ui->est_colorEdit->setValue(color); |
776 ui->est_colorEdit->setValue(color); |
775 ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(color)); |
777 ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(color)); |
776 ui->est_color2Edit->setValue(color); |
778 ui->est_color2Edit->setValue(color); |
777 ui->est_color2Edit->setStyleSheet(Utils::ebc_to_style(color)); |
779 ui->est_color2Edit->setStyleSheet(Utils::ebc_to_style(color)); |
778 ui->est_colorShow->setValue(color); |
780 ui->est_colorShow->setValue(color); |
808 if (mashkg > 0 && mashinfuse > 0 && mashtime > 0 && mashtemp > 0) |
810 if (mashkg > 0 && mashinfuse > 0 && mashtime > 0 && mashtemp > 0) |
809 fg = Utils::estimate_fg(psugar, pcara, mashinfuse / mashkg, mashtime, mashtemp, svg, og); |
811 fg = Utils::estimate_fg(psugar, pcara, mashinfuse / mashkg, mashtime, mashtemp, svg, og); |
810 else |
812 else |
811 fg = Utils::estimate_fg(psugar, pcara, 0, 0, 0, svg, og); |
813 fg = Utils::estimate_fg(psugar, pcara, 0, 0, 0, svg, og); |
812 qDebug() << " FG" << ui->est_fgEdit->value() << fg; |
814 qDebug() << " FG" << ui->est_fgEdit->value() << fg; |
|
815 recipe->est_fg = fg; |
813 ui->est_fgEdit->setValue(fg); |
816 ui->est_fgEdit->setValue(fg); |
814 ui->est_fg3Edit->setValue(fg); |
817 ui->est_fg3Edit->setValue(fg); |
815 ui->est_fgShow->setValue(fg); |
818 ui->est_fgShow->setValue(fg); |
816 |
819 |
817 double abv = Utils::abvol(og, fg); |
820 double abv = Utils::abvol(og, fg); |
818 qDebug() << " ABV" << ui->est_abvEdit->value() << abv; |
821 qDebug() << " ABV" << ui->est_abvEdit->value() << abv; |
819 ui->est_abvEdit->setValue(abv); |
822 ui->est_abvEdit->setValue(abv); |
820 ui->est_abv2Edit->setValue(abv); |
823 ui->est_abv2Edit->setValue(abv); |
821 ui->est_abvShow->setValue(abv); |
824 ui->est_abvShow->setValue(abv); |
|
825 recipe->est_abv = abv; |
822 |
826 |
823 /* |
827 /* |
824 * Calculate kilocalories/liter. Formula from brouwhulp. |
828 * Calculate kilocalories/liter. Formula from brouwhulp. |
825 * Take the alcohol and sugar parts and then combine. |
829 * Take the alcohol and sugar parts and then combine. |
826 */ |
830 */ |
910 "st_guide=:st_guide, st_category=:st_category, st_category_number=:st_catnr, st_type=:st_type, " |
914 "st_guide=:st_guide, st_category=:st_category, st_category_number=:st_catnr, st_type=:st_type, " |
911 "st_og_min=:st_og_min, st_og_max=:st_og_max, st_fg_min=:st_fg_min, st_fg_max=:st_fg_max, " |
915 "st_og_min=:st_og_min, st_og_max=:st_og_max, st_fg_min=:st_fg_min, st_fg_max=:st_fg_max, " |
912 "st_ibu_min=:st_ibu_min, st_ibu_max=:st_ibu_max, st_color_min=:st_color_min, st_color_max=:st_color_max, " |
916 "st_ibu_min=:st_ibu_min, st_ibu_max=:st_ibu_max, st_color_min=:st_color_min, st_color_max=:st_color_max, " |
913 "st_carb_min=:st_carb_min, st_carb_max=:st_carb_max, st_abv_min=:st_abv_min, st_abv_max=:st_abv_max, " |
917 "st_carb_min=:st_carb_min, st_carb_max=:st_carb_max, st_abv_min=:st_abv_min, st_abv_max=:st_abv_max, " |
914 "name=:name, notes=:notes, type=:type, batch_size=:batch_size, boil_size=:boil_size, " |
918 "name=:name, notes=:notes, type=:type, batch_size=:batch_size, boil_size=:boil_size, " |
915 "boil_time=:boil_time, efficiency=:efficiency, sparge_temp=:sparge_temp, sparge_ph=:sparge_ph, " |
919 "boil_time=:boil_time, efficiency=:efficiency, est_og=:est_og, est_fg=:est_fg, est_abv=:est_abv, " |
|
920 "est_color=:est_color, color_method=:color_method, est_ibu=:est_ibu, ibu_method=:ibu_method, " |
|
921 "est_carb=:est_carb, sparge_temp=:sparge_temp, sparge_ph=:sparge_ph, " |
916 "sparge_volume=:sparge_volume, sparge_source=:sparge_source, sparge_acid_type=:sparge_acid_type, " |
922 "sparge_volume=:sparge_volume, sparge_source=:sparge_source, sparge_acid_type=:sparge_acid_type, " |
917 "sparge_acid_perc=:sparge_acid_perc, sparge_acid_amount=:sparge_acid_amount, mash_ph=:mash_ph, " |
923 "sparge_acid_perc=:sparge_acid_perc, sparge_acid_amount=:sparge_acid_amount, mash_ph=:mash_ph, " |
918 "mash_name=:mash_name, calc_acid=:calc_acid, " |
924 "mash_name=:mash_name, calc_acid=:calc_acid, " |
919 "w1_name=:w1_name, w1_amount=:w1_amount, w1_calcium=:w1_calcium, w1_sulfate=:w1_sulfate, " |
925 "w1_name=:w1_name, w1_amount=:w1_amount, w1_calcium=:w1_calcium, w1_sulfate=:w1_sulfate, " |
920 "w1_chloride=:w1_chloride, w1_sodium=:w1_sodium, w1_magnesium=:w1_magnesium, " |
926 "w1_chloride=:w1_chloride, w1_sodium=:w1_sodium, w1_magnesium=:w1_magnesium, " |
935 "st_guide=:st_guide, st_category=:st_category, st_category_number=:st_catnr, st_type=:st_type, " |
941 "st_guide=:st_guide, st_category=:st_category, st_category_number=:st_catnr, st_type=:st_type, " |
936 "st_og_min=:st_og_min, st_og_max=:st_og_max, st_fg_min=:st_fg_min, st_fg_max=:st_fg_max, " |
942 "st_og_min=:st_og_min, st_og_max=:st_og_max, st_fg_min=:st_fg_min, st_fg_max=:st_fg_max, " |
937 "st_ibu_min=:st_ibu_min, st_ibu_max=:st_ibu_max, st_color_min=:st_color_min, st_color_max=:st_color_max, " |
943 "st_ibu_min=:st_ibu_min, st_ibu_max=:st_ibu_max, st_color_min=:st_color_min, st_color_max=:st_color_max, " |
938 "st_carb_min=:st_carb_min, st_carb_max=:st_carb_max, st_abv_min=:st_abv_min, st_abv_max=:st_abv_max, " |
944 "st_carb_min=:st_carb_min, st_carb_max=:st_carb_max, st_abv_min=:st_abv_min, st_abv_max=:st_abv_max, " |
939 "name=:name, notes=:notes, type=:type, batch_size=:batch_size, boil_size=:boil_size, " |
945 "name=:name, notes=:notes, type=:type, batch_size=:batch_size, boil_size=:boil_size, " |
940 "boil_time=:boil_time, efficiency=:efficiency, sparge_temp=:sparge_temp, sparge_ph=:sparge_ph, " |
946 "boil_time=:boil_time, efficiency=:efficiency, est_og=:est_og, est_fg=:est_fg, est_abv=:est_abv, " |
|
947 "est_color=:est_color, color_method=:color_method, est_ibu=:est_ibu, ibu_method=:ibu_method, " |
|
948 "est_carb=:est_carb, sparge_temp=:sparge_temp, sparge_ph=:sparge_ph, " |
941 "sparge_volume=:sparge_volume, sparge_source=:sparge_source, sparge_acid_type=:sparge_acid_type, " |
949 "sparge_volume=:sparge_volume, sparge_source=:sparge_source, sparge_acid_type=:sparge_acid_type, " |
942 "sparge_acid_perc=:sparge_acid_perc, sparge_acid_amount=:sparge_acid_amount, mash_ph=:mash_ph, " |
950 "sparge_acid_perc=:sparge_acid_perc, sparge_acid_amount=:sparge_acid_amount, mash_ph=:mash_ph, " |
943 "mash_name=:mash_name, calc_acid=:calc_acid, " |
951 "mash_name=:mash_name, calc_acid=:calc_acid, " |
944 "w1_name=:w1_name, w1_amount=:w1_amount, w1_calcium=:w1_calcium, w1_sulfate=:w1_sulfate, " |
952 "w1_name=:w1_name, w1_amount=:w1_amount, w1_calcium=:w1_calcium, w1_sulfate=:w1_sulfate, " |
945 "w1_chloride=:w1_chloride, w1_sodium=:w1_sodium, w1_magnesium=:w1_magnesium, " |
953 "w1_chloride=:w1_chloride, w1_sodium=:w1_sodium, w1_magnesium=:w1_magnesium, " |
1430 |
1438 |
1431 this->ignoreChanges = false; |
1439 this->ignoreChanges = false; |
1432 is_changed(); |
1440 is_changed(); |
1433 } |
1441 } |
1434 |
1442 |
|
1443 void EditRecipe::ferment_to100_changed(bool val) |
|
1444 { |
|
1445 qDebug() << "ferment_to100_changed()" << recipe->fermentables_row << val; |
|
1446 } |
|
1447 |
|
1448 void EditRecipe::ferment_select_changed(int val) |
|
1449 { |
|
1450 QSqlQuery query; |
|
1451 bool instock = instockEdit->isChecked(); |
|
1452 QString w; |
|
1453 QTableWidgetItem *item; |
|
1454 |
|
1455 if (val < 1) |
|
1456 return; |
|
1457 |
|
1458 qDebug() << "ferment_select_changed()" << recipe->fermentables_row << val << instock; |
|
1459 |
|
1460 /* |
|
1461 * Search the fermentable pointed by the index and instock flag. |
|
1462 */ |
|
1463 QString sql = "SELECT name,origin,supplier,cost,type,yield,color,coarse_fine_diff,moisture,diastatic_power,protein,dissolved_protein,max_in_batch," |
|
1464 "graintype,recommend_mash,add_after_boil,di_ph,acid_to_ph_57 FROM inventory_fermentables "; |
|
1465 if (instock) |
|
1466 sql.append("WHERE inventory > 0 "); |
|
1467 sql.append("ORDER BY supplier,name"); |
|
1468 query.prepare(sql); |
|
1469 query.exec(); |
|
1470 query.first(); |
|
1471 for (int i = 0; i < (val - 1); i++) { |
|
1472 query.next(); |
|
1473 } |
|
1474 qDebug() << "found" << query.value(2).toString() << query.value(0).toString(); |
|
1475 |
|
1476 /* |
|
1477 * Replace the fermentable record contents |
|
1478 */ |
|
1479 this->ignoreChanges = true; |
|
1480 recipe->fermentables[recipe->fermentables_row].f_name = query.value(0).toString(); |
|
1481 recipe->fermentables[recipe->fermentables_row].f_origin = query.value(1).toString(); |
|
1482 recipe->fermentables[recipe->fermentables_row].f_supplier = query.value(2).toString(); |
|
1483 recipe->fermentables[recipe->fermentables_row].f_cost = query.value(3).toDouble(); |
|
1484 recipe->fermentables[recipe->fermentables_row].f_type = query.value(4).toInt(); |
|
1485 recipe->fermentables[recipe->fermentables_row].f_yield = query.value(5).toDouble(); |
|
1486 recipe->fermentables[recipe->fermentables_row].f_color = query.value(6).toDouble(); |
|
1487 recipe->fermentables[recipe->fermentables_row].f_coarse_fine_diff = query.value(7).toDouble(); |
|
1488 recipe->fermentables[recipe->fermentables_row].f_moisture = query.value(8).toDouble(); |
|
1489 recipe->fermentables[recipe->fermentables_row].f_diastatic_power = query.value(9).toDouble(); |
|
1490 recipe->fermentables[recipe->fermentables_row].f_protein = query.value(10).toDouble(); |
|
1491 recipe->fermentables[recipe->fermentables_row].f_dissolved_protein = query.value(11).toDouble(); |
|
1492 recipe->fermentables[recipe->fermentables_row].f_max_in_batch = query.value(12).toDouble(); |
|
1493 recipe->fermentables[recipe->fermentables_row].f_graintype = query.value(13).toInt(); |
|
1494 recipe->fermentables[recipe->fermentables_row].f_recommend_mash = query.value(14).toInt() ? true:false; |
|
1495 recipe->fermentables[recipe->fermentables_row].f_add_after_boil = query.value(15).toInt() ? true:false; |
|
1496 recipe->fermentables[recipe->fermentables_row].f_di_ph = query.value(16).toDouble(); |
|
1497 recipe->fermentables[recipe->fermentables_row].f_acid_to_ph_57 = query.value(17).toDouble(); |
|
1498 |
|
1499 /* |
|
1500 * Update the visible fields |
|
1501 */ |
|
1502 nameEdit->setText(recipe->fermentables.at(recipe->fermentables_row).f_name); |
|
1503 supplierEdit->setText(recipe->fermentables.at(recipe->fermentables_row).f_supplier); |
|
1504 maxEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_max_in_batch); |
|
1505 |
|
1506 ui->fermentablesTable->setItem(recipe->fermentables_row, 0, new QTableWidgetItem(recipe->fermentables.at(recipe->fermentables_row).f_supplier)); |
|
1507 ui->fermentablesTable->setItem(recipe->fermentables_row, 1, new QTableWidgetItem(recipe->fermentables.at(recipe->fermentables_row).f_name)); |
|
1508 |
|
1509 w = QString("%1").arg(recipe->fermentables.at(recipe->fermentables_row).f_color, 1, 'f', 0, '0'); |
|
1510 item = new QTableWidgetItem(w); |
|
1511 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
1512 ui->fermentablesTable->setItem(recipe->fermentables_row, 2, item); |
|
1513 |
|
1514 item = new QTableWidgetItem(f_types[recipe->fermentables.at(recipe->fermentables_row).f_type]); |
|
1515 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
|
1516 ui->fermentablesTable->setItem(recipe->fermentables_row, 3, item); |
|
1517 |
|
1518 item = new QTableWidgetItem(f_graintypes[recipe->fermentables.at(recipe->fermentables_row).f_graintype]); |
|
1519 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
|
1520 ui->fermentablesTable->setItem(recipe->fermentables_row, 4, item); |
|
1521 |
|
1522 item = new QTableWidgetItem(QString("%1%").arg(recipe->fermentables.at(recipe->fermentables_row).f_yield, 2, 'f', 1, '0')); |
|
1523 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
1524 ui->fermentablesTable->setItem(recipe->fermentables_row, 6, item); |
|
1525 |
|
1526 this->ignoreChanges = false; |
|
1527 calcFermentables(); |
|
1528 is_changed(); |
|
1529 } |
|
1530 |
|
1531 void EditRecipe::ferment_instock_changed(bool val) |
|
1532 { |
|
1533 QSqlQuery query; |
|
1534 |
|
1535 qDebug() << "ferment_instock_changed()" << recipe->fermentables_row << val; |
|
1536 |
|
1537 this->selectEdit->setCurrentIndex(-1); |
|
1538 this->selectEdit->clear(); |
|
1539 QString sql = "SELECT supplier,name,color,inventory FROM inventory_fermentables "; |
|
1540 if (val) |
|
1541 sql.append("WHERE inventory > 0 "); |
|
1542 sql.append("ORDER BY supplier,name"); |
|
1543 query.prepare(sql); |
|
1544 query.exec(); |
|
1545 query.first(); |
|
1546 this->selectEdit->addItem(""); // Start with empty value |
|
1547 for (int i = 0; i < query.size(); i++) { |
|
1548 this->selectEdit->addItem(query.value(0).toString()+" - "+query.value(1).toString()+" ("+query.value(2).toString()+" EBC) "+ |
|
1549 QString("%1 kg").arg(query.value(3).toDouble(), 4, 'f', 3, '0')); |
|
1550 query.next(); |
|
1551 } |
|
1552 } |
|
1553 |
|
1554 void EditRecipe::ferment_added_changed(int val) |
|
1555 { |
|
1556 qDebug() << "ferment_added_changed()" << recipe->fermentables_row << val; |
|
1557 } |
|
1558 |
1435 |
1559 |
1436 void EditRecipe::on_editFermentRow_clicked() |
1560 void EditRecipe::on_editFermentRow_clicked() |
1437 { |
1561 { |
|
1562 QSqlQuery query; |
|
1563 |
1438 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
1564 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
1439 recipe->fermentables_row = pb->objectName().toInt(); |
1565 recipe->fermentables_row = pb->objectName().toInt(); |
1440 qDebug() << "Edit fermentable row" << recipe->fermentables_row; |
1566 qDebug() << "Edit fermentable row" << recipe->fermentables_row; |
1441 Fermentables backup = recipe->fermentables.at(recipe->fermentables_row); |
1567 Fermentables backup = recipe->fermentables.at(recipe->fermentables_row); |
1442 |
1568 |
1485 selectLabel->setGeometry(QRect(10, 70, 141, 20)); |
1611 selectLabel->setGeometry(QRect(10, 70, 141, 20)); |
1486 selectLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
1612 selectLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
1487 QLabel *instockLabel = new QLabel(dialog); |
1613 QLabel *instockLabel = new QLabel(dialog); |
1488 instockLabel->setObjectName(QString::fromUtf8("instockLabel")); |
1614 instockLabel->setObjectName(QString::fromUtf8("instockLabel")); |
1489 instockLabel->setText(tr("In stock:")); |
1615 instockLabel->setText(tr("In stock:")); |
1490 instockLabel->setGeometry(QRect(420, 70, 121, 20)); |
1616 instockLabel->setGeometry(QRect(525, 70, 121, 20)); |
1491 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
1617 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
1492 QLabel *maxLabel = new QLabel(dialog); |
1618 QLabel *maxLabel = new QLabel(dialog); |
1493 maxLabel->setObjectName(QString::fromUtf8("maxLabel")); |
1619 maxLabel->setObjectName(QString::fromUtf8("maxLabel")); |
1494 maxLabel->setText(tr("Max in batch:")); |
1620 maxLabel->setText(tr("Max in batch:")); |
1495 maxLabel->setGeometry(QRect(420, 130, 121, 20)); |
1621 maxLabel->setGeometry(QRect(420, 130, 121, 20)); |
1496 maxLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
1622 maxLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
1497 |
1623 |
1498 selectEdit = new QComboBox(dialog); |
1624 selectEdit = new QComboBox(dialog); |
1499 selectEdit->setObjectName(QString::fromUtf8("selectEdit")); |
1625 selectEdit->setObjectName(QString::fromUtf8("selectEdit")); |
1500 selectEdit->setGeometry(QRect(160, 70, 251, 23)); |
1626 selectEdit->setGeometry(QRect(160, 70, 371, 23)); |
|
1627 |
1501 nameEdit = new QLineEdit(dialog); |
1628 nameEdit = new QLineEdit(dialog); |
1502 nameEdit->setObjectName(QString::fromUtf8("nameEdit")); |
1629 nameEdit->setObjectName(QString::fromUtf8("nameEdit")); |
1503 nameEdit->setText(recipe->fermentables.at(recipe->fermentables_row).f_name); |
1630 nameEdit->setText(recipe->fermentables.at(recipe->fermentables_row).f_name); |
1504 nameEdit->setGeometry(QRect(160, 10, 511, 23)); |
1631 nameEdit->setGeometry(QRect(160, 10, 511, 23)); |
1505 nameEdit->setReadOnly(true); |
1632 nameEdit->setReadOnly(true); |
1516 amountEdit->setDecimals(3); |
1643 amountEdit->setDecimals(3); |
1517 amountEdit->setReadOnly(recipe->fermentables_use100); |
1644 amountEdit->setReadOnly(recipe->fermentables_use100); |
1518 amountEdit->setMaximum(100000.0); |
1645 amountEdit->setMaximum(100000.0); |
1519 amountEdit->setSingleStep(0.0010); |
1646 amountEdit->setSingleStep(0.0010); |
1520 amountEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_amount); |
1647 amountEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_amount); |
1521 connect(amountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::ferment_amount_changed); |
|
1522 |
1648 |
1523 pctEdit = new QDoubleSpinBox(dialog); |
1649 pctEdit = new QDoubleSpinBox(dialog); |
1524 pctEdit->setObjectName(QString::fromUtf8("pctEdit")); |
1650 pctEdit->setObjectName(QString::fromUtf8("pctEdit")); |
1525 pctEdit->setGeometry(QRect(160, 130, 121, 24)); |
1651 pctEdit->setGeometry(QRect(160, 130, 121, 24)); |
1526 pctEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
1652 pctEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
1555 to100Edit->setGeometry(QRect(160, 160, 85, 21)); |
1680 to100Edit->setGeometry(QRect(160, 160, 85, 21)); |
1556 to100Edit->setChecked(recipe->fermentables.at(recipe->fermentables_row).f_adjust_to_total_100); |
1681 to100Edit->setChecked(recipe->fermentables.at(recipe->fermentables_row).f_adjust_to_total_100); |
1557 |
1682 |
1558 instockEdit = new QCheckBox(dialog); |
1683 instockEdit = new QCheckBox(dialog); |
1559 instockEdit->setObjectName(QString::fromUtf8("instockEdit")); |
1684 instockEdit->setObjectName(QString::fromUtf8("instockEdit")); |
1560 instockEdit->setGeometry(QRect(550, 70, 85, 21)); |
1685 instockEdit->setGeometry(QRect(655, 70, 85, 21)); |
|
1686 instockEdit->setChecked(true); |
1561 |
1687 |
1562 maxEdit = new QDoubleSpinBox(dialog); |
1688 maxEdit = new QDoubleSpinBox(dialog); |
1563 maxEdit->setObjectName(QString::fromUtf8("maxEdit")); |
1689 maxEdit->setObjectName(QString::fromUtf8("maxEdit")); |
1564 maxEdit->setGeometry(QRect(550, 130, 121, 24)); |
1690 maxEdit->setGeometry(QRect(550, 130, 121, 24)); |
1565 maxEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
1691 maxEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
1566 maxEdit->setReadOnly(true); |
1692 maxEdit->setReadOnly(true); |
1567 maxEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); |
1693 maxEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); |
1568 maxEdit->setDecimals(1); |
1694 maxEdit->setDecimals(1); |
1569 maxEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_max_in_batch); |
1695 maxEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_max_in_batch); |
1570 |
1696 |
|
1697 ferment_instock_changed(true); |
|
1698 |
|
1699 connect(selectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::ferment_select_changed); |
|
1700 connect(amountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::ferment_amount_changed); |
|
1701 connect(pctEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::ferment_pct_changed); |
|
1702 connect(addedEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::ferment_added_changed); |
|
1703 connect(to100Edit, &QCheckBox::stateChanged, this, &EditRecipe::ferment_to100_changed); |
|
1704 connect(instockEdit, &QCheckBox::stateChanged, this, &EditRecipe::ferment_instock_changed); |
1571 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); |
1705 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); |
1572 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); |
1706 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); |
|
1707 |
|
1708 dialog->setModal(true); |
1573 dialog->exec(); |
1709 dialog->exec(); |
1574 if (dialog->result() == QDialog::Rejected) { |
1710 if (dialog->result() == QDialog::Rejected) { |
1575 qDebug() << "rejected"; |
1711 qDebug() << "reject and rollback"; |
1576 // restore fermentbackup |
1712 recipe->fermentables[recipe->fermentables_row] = backup; |
1577 // recalculate percentages |
1713 /* |
1578 } else { |
1714 * Recalculate the percentages |
1579 qDebug() << "accepted"; |
1715 */ |
1580 } |
1716 double total = 0; |
1581 |
1717 for (int i = 0; i < recipe->fermentables.size(); i++) |
1582 // disconnect |
1718 if (recipe->fermentables.at(i).f_added < 4) // Only before bottle/kegging |
|
1719 total += recipe->fermentables.at(i).f_amount; |
|
1720 for (int i = 0; i < recipe->fermentables.size(); i++) { |
|
1721 if (recipe->fermentables.at(i).f_added < 4) { |
|
1722 recipe->fermentables[i].f_percentage = recipe->fermentables.at(i).f_amount / total * 100; |
|
1723 } |
|
1724 } |
|
1725 } |
|
1726 |
|
1727 disconnect(selectEdit, nullptr, nullptr, nullptr); |
|
1728 disconnect(amountEdit, nullptr, nullptr, nullptr); |
|
1729 disconnect(pctEdit, nullptr, nullptr, nullptr); |
|
1730 disconnect(addedEdit, nullptr, nullptr, nullptr); |
|
1731 disconnect(to100Edit, nullptr, nullptr, nullptr); |
|
1732 disconnect(instockEdit, nullptr, nullptr, nullptr); |
|
1733 disconnect(buttonBox, nullptr, nullptr, nullptr); |
|
1734 |
1583 emit refreshAll(); |
1735 emit refreshAll(); |
1584 } |
1736 } |
1585 |
1737 |
1586 |
1738 |
1587 void EditRecipe::on_quitButton_clicked() |
1739 void EditRecipe::on_quitButton_clicked() |