76 |
76 |
77 item = new QTableWidgetItem(misc_uses[recipe->miscs.at(i).m_use_use]); |
77 item = new QTableWidgetItem(misc_uses[recipe->miscs.at(i).m_use_use]); |
78 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
78 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
79 ui->miscsTable->setItem(i, 2, item); |
79 ui->miscsTable->setItem(i, 2, item); |
80 |
80 |
81 if (recipe->miscs.at(i).m_use_use == 2) { // Boil |
81 if (recipe->miscs.at(i).m_use_use == MISC_USES_BOIL) { |
82 item = new QTableWidgetItem(QString("%1 min.").arg(recipe->miscs.at(i).m_time, 1, 'f', 0, '0')); |
82 item = new QTableWidgetItem(QString("%1 min.").arg(recipe->miscs.at(i).m_time, 1, 'f', 0, '0')); |
83 } else if (recipe->miscs.at(i).m_use_use == 3 || recipe->miscs.at(i).m_use_use == 4) { // Primary or secondary |
83 } else if (recipe->miscs.at(i).m_use_use == MISC_USES_PRIMARY || recipe->miscs.at(i).m_use_use == MISC_USES_SECONDARY) { |
84 item = new QTableWidgetItem(QString("%1 days.").arg(recipe->miscs.at(i).m_time / 1440, 1, 'f', 0, '0')); |
84 item = new QTableWidgetItem(QString("%1 days.").arg(recipe->miscs.at(i).m_time / 1440, 1, 'f', 0, '0')); |
85 } else { |
85 } else { |
86 item = new QTableWidgetItem(QString("")); |
86 item = new QTableWidgetItem(QString("")); |
87 } |
87 } |
88 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
88 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
97 |
97 |
98 /* |
98 /* |
99 * Add the Delete and Edit row buttons. |
99 * Add the Delete and Edit row buttons. |
100 * Not for water agents, these are set on the water tab. |
100 * Not for water agents, these are set on the water tab. |
101 */ |
101 */ |
102 if (recipe->miscs.at(i).m_type == 4) { |
102 if (recipe->miscs.at(i).m_type == MISC_TYPES_WATER_AGENT) { |
103 ui->miscsTable->removeCellWidget(i, 5); |
103 ui->miscsTable->removeCellWidget(i, 5); |
104 ui->miscsTable->removeCellWidget(i, 6); |
104 ui->miscsTable->removeCellWidget(i, 6); |
|
105 item = new QTableWidgetItem(""); |
|
106 item->setToolTip(tr("Edit this from the water tab")); |
|
107 ui->miscsTable->setItem(i, 5, item); |
|
108 item = new QTableWidgetItem(""); |
|
109 item->setToolTip(tr("Edit this from the water tab")); |
|
110 ui->miscsTable->setItem(i, 6, item); |
105 } else { |
111 } else { |
|
112 if (ui->miscsTable->item(i, 5)) { |
|
113 ui->miscsTable->takeItem(i, 5); /* to remove the old tooltip */ |
|
114 } |
|
115 if (ui->miscsTable->item(i, 6)) { |
|
116 ui->miscsTable->takeItem(i, 6); |
|
117 } |
106 pWidget = new QWidget(); |
118 pWidget = new QWidget(); |
107 QPushButton* btn_dele = new QPushButton(); |
119 QPushButton* btn_dele = new QPushButton(); |
108 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
120 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
109 btn_dele->setText(tr("Delete")); |
121 btn_dele->setText(tr("Delete")); |
110 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteMiscRow_clicked())); |
122 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteMiscRow_clicked())); |
127 } |
139 } |
128 |
140 |
129 /* |
141 /* |
130 * Update the water agents. |
142 * Update the water agents. |
131 */ |
143 */ |
132 if (recipe->miscs.at(i).m_type == 4) { |
144 if (recipe->miscs.at(i).m_type == MISC_TYPES_WATER_AGENT) { |
133 if (recipe->miscs.at(i).m_name == "CaCl2") { |
145 if (recipe->miscs.at(i).m_name == "CaCl2") { |
134 ui->bs_cacl2Edit->setValue(recipe->miscs.at(i).m_amount * 1000.0); |
146 ui->bs_cacl2Edit->setValue(recipe->miscs.at(i).m_amount * 1000.0); |
135 } else if (recipe->miscs.at(i).m_name == "CaSO4") { |
147 } else if (recipe->miscs.at(i).m_name == "CaSO4") { |
136 ui->bs_caso4Edit->setValue(recipe->miscs.at(i).m_amount * 1000.0); |
148 ui->bs_caso4Edit->setValue(recipe->miscs.at(i).m_amount * 1000.0); |
137 } else if (recipe->miscs.at(i).m_name == "MgSO4") { |
149 } else if (recipe->miscs.at(i).m_name == "MgSO4") { |
320 { |
332 { |
321 QTableWidgetItem *item; |
333 QTableWidgetItem *item; |
322 |
334 |
323 qDebug() << "misc_time_changed()" << recipe->miscs_row << val; |
335 qDebug() << "misc_time_changed()" << recipe->miscs_row << val; |
324 |
336 |
325 if (recipe->miscs.at(recipe->miscs_row).m_use_use == 2) { // Boil |
337 if (recipe->miscs.at(recipe->miscs_row).m_use_use == MISC_USES_BOIL) { |
326 recipe->miscs[recipe->miscs_row].m_time = val; |
338 recipe->miscs[recipe->miscs_row].m_time = val; |
327 item = new QTableWidgetItem(QString("%1 min.").arg(val, 1, 'f', 0, '0')); |
339 item = new QTableWidgetItem(QString("%1 min.").arg(val, 1, 'f', 0, '0')); |
328 } else if (recipe->miscs.at(recipe->miscs_row).m_use_use == 3 || recipe->miscs.at(recipe->miscs_row).m_use_use == 4) { // Primary or secondary |
340 } else if (recipe->miscs.at(recipe->miscs_row).m_use_use == MISC_USES_PRIMARY || |
|
341 recipe->miscs.at(recipe->miscs_row).m_use_use == MISC_USES_SECONDARY) { |
329 recipe->miscs[recipe->miscs_row].m_time = val * 1440; |
342 recipe->miscs[recipe->miscs_row].m_time = val * 1440; |
330 item = new QTableWidgetItem(QString("%1 days.").arg(val, 1, 'f', 0, '0')); |
343 item = new QTableWidgetItem(QString("%1 days.").arg(val, 1, 'f', 0, '0')); |
331 } else { |
344 } else { |
332 item = new QTableWidgetItem(QString("")); |
345 item = new QTableWidgetItem(QString("")); |
333 } |
346 } |
417 item = new QTableWidgetItem(QString("%1 ml").arg(recipe->miscs.at(recipe->miscs_row).m_amount * 1000.0, 3, 'f', 2, '0')); |
430 item = new QTableWidgetItem(QString("%1 ml").arg(recipe->miscs.at(recipe->miscs_row).m_amount * 1000.0, 3, 'f', 2, '0')); |
418 } |
431 } |
419 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
432 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
420 ui->miscsTable->setItem(recipe->miscs_row, 4, item); |
433 ui->miscsTable->setItem(recipe->miscs_row, 4, item); |
421 |
434 |
|
435 qDebug() << "before" << recipe->miscs_row; |
422 is_changed(); |
436 is_changed(); |
423 emit refreshAll(); |
437 refreshMiscs(); |
|
438 /* |
|
439 * The order of the list is changed, lookup the item we just added. |
|
440 */ |
|
441 for (int i = 0; i < recipe->miscs.size(); i++) { |
|
442 if ((recipe->miscs.at(i).m_name == query.value(0).toString()) && |
|
443 (recipe->miscs.at(i).m_type == query.value(1).toInt()) && |
|
444 (recipe->miscs.at(i).m_use_use == query.value(2).toInt())) { |
|
445 recipe->miscs_row = i; |
|
446 break; |
|
447 } |
|
448 } |
|
449 qDebug() << "after" << recipe->miscs_row; |
424 } |
450 } |
425 |
451 |
426 |
452 |
427 void EditRecipe::misc_instock_changed(bool val) |
453 void EditRecipe::misc_instock_changed(bool val) |
428 { |
454 { |
456 recipe->miscs[recipe->miscs_row].m_use_use = val; |
482 recipe->miscs[recipe->miscs_row].m_use_use = val; |
457 item = new QTableWidgetItem(misc_uses[val]); |
483 item = new QTableWidgetItem(misc_uses[val]); |
458 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
484 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
459 ui->miscsTable->setItem(recipe->miscs_row, 2, item); |
485 ui->miscsTable->setItem(recipe->miscs_row, 2, item); |
460 |
486 |
461 if (val == 3 || val == 4) { // Fermentation stages |
487 if (val == MISC_USES_PRIMARY || val == MISC_USES_SECONDARY) { |
462 recipe->miscs[recipe->miscs_row].m_time = mtimeEdit->value() * 1440; |
488 recipe->miscs[recipe->miscs_row].m_time = mtimeEdit->value() * 1440; |
463 mtimeEdit->setReadOnly(false); |
489 mtimeEdit->setReadOnly(false); |
464 mtimeLabel->setText(tr("Time in days:")); |
490 mtimeLabel->setText(tr("Time in days:")); |
465 item = new QTableWidgetItem(QString("%1 days.").arg(recipe->miscs.at(recipe->miscs_row).m_time / 1440, 1, 'f', 0, '0')); |
491 item = new QTableWidgetItem(QString("%1 days.").arg(recipe->miscs.at(recipe->miscs_row).m_time / 1440, 1, 'f', 0, '0')); |
466 } else if (val == 2) { // Boil |
492 } else if (val == MISC_USES_BOIL) { |
467 recipe->miscs[recipe->miscs_row].m_time = mtimeEdit->value(); |
493 recipe->miscs[recipe->miscs_row].m_time = mtimeEdit->value(); |
468 mtimeEdit->setReadOnly(false); |
494 mtimeEdit->setReadOnly(false); |
469 mtimeLabel->setText(tr("Time in minutes:")); |
495 mtimeLabel->setText(tr("Time in minutes:")); |
470 item = new QTableWidgetItem(QString("%1 min.").arg(recipe->miscs.at(recipe->miscs_row).m_time, 1, 'f', 0, '0')); |
496 item = new QTableWidgetItem(QString("%1 min.").arg(recipe->miscs.at(recipe->miscs_row).m_time, 1, 'f', 0, '0')); |
471 } else { |
497 } else { |
652 recipe->miscs[i].m_amount = amount; |
678 recipe->miscs[i].m_amount = amount; |
653 |
679 |
654 /* |
680 /* |
655 * Update the water agents. |
681 * Update the water agents. |
656 */ |
682 */ |
657 if (recipe->miscs.at(i).m_type == 4) { |
683 if (recipe->miscs.at(i).m_type == MISC_TYPES_WATER_AGENT) { |
658 if (recipe->miscs.at(i).m_name == "CaCl2") { |
684 if (recipe->miscs.at(i).m_name == "CaCl2") { |
659 ui->bs_cacl2Edit->setValue(recipe->miscs.at(i).m_amount * 1000.0); |
685 ui->bs_cacl2Edit->setValue(recipe->miscs.at(i).m_amount * 1000.0); |
660 } else if (recipe->miscs.at(i).m_name == "CaSO4") { |
686 } else if (recipe->miscs.at(i).m_name == "CaSO4") { |
661 ui->bs_caso4Edit->setValue(recipe->miscs.at(i).m_amount * 1000.0); |
687 ui->bs_caso4Edit->setValue(recipe->miscs.at(i).m_amount * 1000.0); |
662 } else if (recipe->miscs.at(i).m_name == "MgSO4") { |
688 } else if (recipe->miscs.at(i).m_name == "MgSO4") { |