65 ui->hopsTable->verticalHeader()->hide(); |
65 ui->hopsTable->verticalHeader()->hide(); |
66 ui->hopsTable->setRowCount(product->hops.size()); |
66 ui->hopsTable->setRowCount(product->hops.size()); |
67 |
67 |
68 for (int i = 0; i < product->hops.size(); i++) { |
68 for (int i = 0; i < product->hops.size(); i++) { |
69 |
69 |
70 ui->hopsTable->setItem(i, 0, new QTableWidgetItem(product->hops.at(i).h_origin)); |
70 ui->hopsTable->setItem(i, 0, new QTableWidgetItem(product->hops.at(i).origin)); |
71 ui->hopsTable->setItem(i, 1, new QTableWidgetItem(product->hops.at(i).h_name)); |
71 ui->hopsTable->setItem(i, 1, new QTableWidgetItem(product->hops.at(i).name)); |
72 |
72 |
73 item = new QTableWidgetItem(hop_types[product->hops.at(i).h_type]); |
73 item = new QTableWidgetItem(hop_types[product->hops.at(i).type]); |
74 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
74 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
75 ui->hopsTable->setItem(i, 2, item); |
75 ui->hopsTable->setItem(i, 2, item); |
76 |
76 |
77 item = new QTableWidgetItem(hop_forms[product->hops.at(i).h_form]); |
77 item = new QTableWidgetItem(hop_forms[product->hops.at(i).form]); |
78 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
78 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
79 ui->hopsTable->setItem(i, 3, item); |
79 ui->hopsTable->setItem(i, 3, item); |
80 |
80 |
81 item = new QTableWidgetItem(QString("%1%").arg(product->hops.at(i).h_alpha, 2, 'f', 1, '0')); |
81 item = new QTableWidgetItem(QString("%1%").arg(product->hops.at(i).alpha, 2, 'f', 1, '0')); |
82 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
82 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
83 ui->hopsTable->setItem(i, 4, item); |
83 ui->hopsTable->setItem(i, 4, item); |
84 |
84 |
85 item = new QTableWidgetItem(hop_useat[product->hops.at(i).h_useat]); |
85 item = new QTableWidgetItem(hop_useat[product->hops.at(i).useat]); |
86 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
86 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
87 ui->hopsTable->setItem(i, 5, item); |
87 ui->hopsTable->setItem(i, 5, item); |
88 |
88 |
89 if (product->hops.at(i).h_useat == 2 || product->hops.at(i).h_useat == 4) { // Boil or whirlpool |
89 if (product->hops.at(i).useat == 2 || product->hops.at(i).useat == 4) { // Boil or whirlpool |
90 item = new QTableWidgetItem(QString("%1 min.").arg(product->hops.at(i).h_time, 1, 'f', 0, '0')); |
90 item = new QTableWidgetItem(QString("%1 min.").arg(product->hops.at(i).time, 1, 'f', 0, '0')); |
91 } else if (product->hops.at(i).h_useat == 5) { // Dry-hop |
91 } else if (product->hops.at(i).useat == 5) { // Dry-hop |
92 item = new QTableWidgetItem(QString("%1 days.").arg(product->hops.at(i).h_time / 1440, 1, 'f', 0, '0')); |
92 item = new QTableWidgetItem(QString("%1 days.").arg(product->hops.at(i).time / 1440, 1, 'f', 0, '0')); |
93 } else { |
93 } else { |
94 item = new QTableWidgetItem(QString("")); |
94 item = new QTableWidgetItem(QString("")); |
95 } |
95 } |
96 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
96 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
97 ui->hopsTable->setItem(i, 6, item); |
97 ui->hopsTable->setItem(i, 6, item); |
98 |
98 |
99 double ibu = Utils::toIBU(product->hops.at(i).h_useat, product->hops.at(i).h_form, product->preboil_sg, product->batch_size, |
99 double ibu = Utils::toIBU(product->hops.at(i).useat, product->hops.at(i).form, product->preboil_sg, product->batch_size, |
100 product->hops.at(i).h_amount, product->hops.at(i).h_time, product->hops.at(i).h_alpha, product->ibu_method, |
100 product->hops.at(i).amount, product->hops.at(i).time, product->hops.at(i).alpha, product->ibu_method, |
101 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); |
101 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); |
102 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); |
102 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); |
103 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
103 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
104 ui->hopsTable->setItem(i, 7, item); |
104 ui->hopsTable->setItem(i, 7, item); |
105 |
105 |
106 if (product->hops.at(i).h_amount < 1.0) { |
106 if (product->hops.at(i).amount < 1.0) { |
107 item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(i).h_amount * 1000.0, 2, 'f', 1, '0')); |
107 item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(i).amount * 1000.0, 2, 'f', 1, '0')); |
108 } else { |
108 } else { |
109 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).h_amount, 4, 'f', 3, '0')); |
109 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).amount, 4, 'f', 3, '0')); |
110 } |
110 } |
111 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
111 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
112 ui->hopsTable->setItem(i, 8, item); |
112 ui->hopsTable->setItem(i, 8, item); |
113 |
113 |
114 if (product->hops.at(i).h_inventory < 1.0) { |
114 if (product->hops.at(i).inventory < 1.0) { |
115 item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(i).h_inventory * 1000.0, 2, 'f', 1, '0')); |
115 item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(i).inventory * 1000.0, 2, 'f', 1, '0')); |
116 } else { |
116 } else { |
117 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).h_inventory, 4, 'f', 3, '0')); |
117 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).inventory, 4, 'f', 3, '0')); |
118 } |
118 } |
119 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
119 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
120 if (product->hops.at(i).h_inventory < product->hops.at(i).h_amount) |
120 if (product->hops.at(i).inventory < product->hops.at(i).amount) |
121 item->setForeground(QBrush(QColor(Qt::red))); |
121 item->setForeground(QBrush(QColor(Qt::red))); |
122 ui->hopsTable->setItem(i, 9, item); |
122 ui->hopsTable->setItem(i, 9, item); |
123 |
123 |
124 /* Add the Delete row button */ |
124 /* Add the Delete row button */ |
125 pWidget = new QWidget(); |
125 pWidget = new QWidget(); |
232 double hop_flavour = 0, hop_aroma = 0, ibus = 0, ferm_ibus = 0; |
232 double hop_flavour = 0, hop_aroma = 0, ibus = 0, ferm_ibus = 0; |
233 |
233 |
234 product->hops_ok = true; |
234 product->hops_ok = true; |
235 for (int i = 0; i < product->hops.size(); i++) { |
235 for (int i = 0; i < product->hops.size(); i++) { |
236 |
236 |
237 ibus += Utils::toIBU(product->hops.at(i).h_useat, product->hops.at(i).h_form, product->preboil_sg, |
237 ibus += Utils::toIBU(product->hops.at(i).useat, product->hops.at(i).form, product->preboil_sg, |
238 product->batch_size, product->hops.at(i).h_amount, |
238 product->batch_size, product->hops.at(i).amount, |
239 product->hops.at(i).h_time, product->hops.at(i).h_alpha, product->ibu_method, |
239 product->hops.at(i).time, product->hops.at(i).alpha, product->ibu_method, |
240 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); |
240 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); |
241 ferm_ibus += Utils::toIBU(product->hops.at(i).h_useat, product->hops.at(i).h_form, product->preboil_sg, |
241 ferm_ibus += Utils::toIBU(product->hops.at(i).useat, product->hops.at(i).form, product->preboil_sg, |
242 product->brew_fermenter_volume + product->brew_fermenter_tcloss, product->hops.at(i).h_amount, |
242 product->brew_fermenter_volume + product->brew_fermenter_tcloss, product->hops.at(i).amount, |
243 product->hops.at(i).h_time, product->hops.at(i).h_alpha, product->ibu_method, |
243 product->hops.at(i).time, product->hops.at(i).alpha, product->ibu_method, |
244 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); |
244 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); |
245 |
245 |
246 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); |
246 hop_flavour += Utils::hopFlavourContribution(product->hops.at(i).time, product->batch_size, product->hops.at(i).useat, product->hops.at(i).amount); |
247 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); |
247 hop_aroma += Utils::hopAromaContribution(product->hops.at(i).time, product->batch_size, product->hops.at(i).useat, product->hops.at(i).amount); |
248 if ((((product->inventory_reduced <= PROD_STAGE_BREW) && (product->hops.at(i).h_useat <= HOP_USEAT_WHIRLPOOL)) || |
248 if ((((product->inventory_reduced <= PROD_STAGE_BREW) && (product->hops.at(i).useat <= HOP_USEAT_WHIRLPOOL)) || |
249 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->hops.at(i).h_useat == HOP_USEAT_DRY_HOP))) && |
249 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->hops.at(i).useat == HOP_USEAT_DRY_HOP))) && |
250 (product->hops.at(i).h_inventory < product->hops.at(i).h_amount)) |
250 (product->hops.at(i).inventory < product->hops.at(i).amount)) |
251 product->hops_ok = false; |
251 product->hops_ok = false; |
252 } |
252 } |
253 |
253 |
254 hop_flavour = round(hop_flavour * 1000.0 / 5.0) / 10; |
254 hop_flavour = round(hop_flavour * 1000.0 / 5.0) / 10; |
255 hop_aroma = round(hop_aroma * 1000.0 / 6.0) / 10; |
255 hop_aroma = round(hop_aroma * 1000.0 / 6.0) / 10; |
329 { |
329 { |
330 QTableWidgetItem *item; |
330 QTableWidgetItem *item; |
331 |
331 |
332 qDebug() << "hop_amount_changed()" << product->hops_row << val; |
332 qDebug() << "hop_amount_changed()" << product->hops_row << val; |
333 |
333 |
334 product->hops[product->hops_row].h_amount = val / 1000.0; |
334 product->hops[product->hops_row].amount = val / 1000.0; |
335 item = new QTableWidgetItem(QString("%1 gr").arg(val, 2, 'f', 1, '0')); |
335 item = new QTableWidgetItem(QString("%1 gr").arg(val, 2, 'f', 1, '0')); |
336 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
336 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
337 ui->hopsTable->setItem(product->hops_row, 8, item); |
337 ui->hopsTable->setItem(product->hops_row, 8, item); |
338 |
338 |
339 double ibu = Utils::toIBU(product->hops.at(product->hops_row).h_useat, product->hops.at(product->hops_row).h_form, product->preboil_sg, |
339 double ibu = Utils::toIBU(product->hops.at(product->hops_row).useat, product->hops.at(product->hops_row).form, product->preboil_sg, |
340 product->batch_size, product->hops.at(product->hops_row).h_amount, product->hops.at(product->hops_row).h_time, |
340 product->batch_size, product->hops.at(product->hops_row).amount, product->hops.at(product->hops_row).time, |
341 product->hops.at(product->hops_row).h_alpha, product->ibu_method, |
341 product->hops.at(product->hops_row).alpha, product->ibu_method, |
342 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); |
342 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); |
343 |
343 |
344 ibuEdit->setValue(ibu); |
344 ibuEdit->setValue(ibu); |
345 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); |
345 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); |
346 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
346 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
355 { |
355 { |
356 QTableWidgetItem *item; |
356 QTableWidgetItem *item; |
357 |
357 |
358 qDebug() << "hop_time_changed()" << product->hops_row << val; |
358 qDebug() << "hop_time_changed()" << product->hops_row << val; |
359 |
359 |
360 if (product->hops.at(product->hops_row).h_useat == HOP_USEAT_BOIL || product->hops.at(product->hops_row).h_useat == HOP_USEAT_WHIRLPOOL) { |
360 if (product->hops.at(product->hops_row).useat == HOP_USEAT_BOIL || product->hops.at(product->hops_row).useat == HOP_USEAT_WHIRLPOOL) { |
361 item = new QTableWidgetItem(QString("%1 min.").arg(val, 1, 'f', 0, '0')); |
361 item = new QTableWidgetItem(QString("%1 min.").arg(val, 1, 'f', 0, '0')); |
362 product->hops[product->hops_row].h_time = val; |
362 product->hops[product->hops_row].time = val; |
363 } else if (product->hops.at(product->hops_row).h_useat == HOP_USEAT_DRY_HOP) { |
363 } else if (product->hops.at(product->hops_row).useat == HOP_USEAT_DRY_HOP) { |
364 item = new QTableWidgetItem(QString("%1 days.").arg(val, 1, 'f', 0, '0')); |
364 item = new QTableWidgetItem(QString("%1 days.").arg(val, 1, 'f', 0, '0')); |
365 product->hops[product->hops_row].h_time = val * 1440; |
365 product->hops[product->hops_row].time = val * 1440; |
366 } else { |
366 } else { |
367 item = new QTableWidgetItem(QString("")); |
367 item = new QTableWidgetItem(QString("")); |
368 product->hops[product->hops_row].h_time = val; |
368 product->hops[product->hops_row].time = val; |
369 } |
369 } |
370 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
370 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
371 ui->hopsTable->setItem(product->hops_row, 6, item); |
371 ui->hopsTable->setItem(product->hops_row, 6, item); |
372 |
372 |
373 double ibu = Utils::toIBU(product->hops.at(product->hops_row).h_useat, product->hops.at(product->hops_row).h_form, product->preboil_sg, |
373 double ibu = Utils::toIBU(product->hops.at(product->hops_row).useat, product->hops.at(product->hops_row).form, product->preboil_sg, |
374 product->batch_size, product->hops.at(product->hops_row).h_amount, product->hops.at(product->hops_row).h_time, |
374 product->batch_size, product->hops.at(product->hops_row).amount, product->hops.at(product->hops_row).time, |
375 product->hops.at(product->hops_row).h_alpha, product->ibu_method, |
375 product->hops.at(product->hops_row).alpha, product->ibu_method, |
376 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); |
376 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); |
377 |
377 |
378 ibuEdit->setValue(ibu); |
378 ibuEdit->setValue(ibu); |
379 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); |
379 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); |
380 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
380 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
412 } |
412 } |
413 |
413 |
414 /* |
414 /* |
415 * Replace the hop record contents |
415 * Replace the hop record contents |
416 */ |
416 */ |
417 product->hops[product->hops_row].h_name = query.value(0).toString(); |
417 product->hops[product->hops_row].name = query.value(0).toString(); |
418 product->hops[product->hops_row].h_origin = query.value(1).toString(); |
418 product->hops[product->hops_row].origin = query.value(1).toString(); |
419 product->hops[product->hops_row].h_alpha = query.value(2).toDouble(); |
419 product->hops[product->hops_row].alpha = query.value(2).toDouble(); |
420 product->hops[product->hops_row].h_beta = query.value(3).toDouble(); |
420 product->hops[product->hops_row].beta = query.value(3).toDouble(); |
421 product->hops[product->hops_row].h_humulene = query.value(4).toDouble(); |
421 product->hops[product->hops_row].humulene = query.value(4).toDouble(); |
422 product->hops[product->hops_row].h_caryophyllene = query.value(5).toDouble(); |
422 product->hops[product->hops_row].caryophyllene = query.value(5).toDouble(); |
423 product->hops[product->hops_row].h_cohumulone = query.value(6).toDouble(); |
423 product->hops[product->hops_row].cohumulone = query.value(6).toDouble(); |
424 product->hops[product->hops_row].h_myrcene = query.value(7).toDouble(); |
424 product->hops[product->hops_row].myrcene = query.value(7).toDouble(); |
425 product->hops[product->hops_row].h_hsi = query.value(8).toDouble(); |
425 product->hops[product->hops_row].hsi = query.value(8).toDouble(); |
426 product->hops[product->hops_row].h_total_oil = query.value(9).toDouble(); |
426 product->hops[product->hops_row].total_oil = query.value(9).toDouble(); |
427 product->hops[product->hops_row].h_type = query.value(10).toInt(); |
427 product->hops[product->hops_row].type = query.value(10).toInt(); |
428 product->hops[product->hops_row].h_form = query.value(11).toInt(); |
428 product->hops[product->hops_row].form = query.value(11).toInt(); |
429 product->hops[product->hops_row].h_cost = query.value(12).toDouble(); |
429 product->hops[product->hops_row].cost = query.value(12).toDouble(); |
430 product->hops[product->hops_row].h_inventory = query.value(13).toDouble(); |
430 product->hops[product->hops_row].inventory = query.value(13).toDouble(); |
431 |
431 |
432 /* |
432 /* |
433 * Update the visible fields |
433 * Update the visible fields |
434 */ |
434 */ |
435 hnameEdit->setText(product->hops.at(product->hops_row).h_name); |
435 hnameEdit->setText(product->hops.at(product->hops_row).name); |
436 horiginEdit->setText(product->hops.at(product->hops_row).h_origin); |
436 horiginEdit->setText(product->hops.at(product->hops_row).origin); |
437 |
437 |
438 double ibu = Utils::toIBU(product->hops.at(product->hops_row).h_useat, product->hops.at(product->hops_row).h_form, product->preboil_sg, |
438 double ibu = Utils::toIBU(product->hops.at(product->hops_row).useat, product->hops.at(product->hops_row).form, product->preboil_sg, |
439 product->batch_size, product->hops.at(product->hops_row).h_amount, product->hops.at(product->hops_row).h_time, |
439 product->batch_size, product->hops.at(product->hops_row).amount, product->hops.at(product->hops_row).time, |
440 product->hops.at(product->hops_row).h_alpha, product->ibu_method, |
440 product->hops.at(product->hops_row).alpha, product->ibu_method, |
441 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); |
441 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); |
442 ibuEdit->setValue(ibu); |
442 ibuEdit->setValue(ibu); |
443 |
443 |
444 ui->hopsTable->setItem(product->hops_row, 0, new QTableWidgetItem(product->hops.at(product->hops_row).h_origin)); |
444 ui->hopsTable->setItem(product->hops_row, 0, new QTableWidgetItem(product->hops.at(product->hops_row).origin)); |
445 ui->hopsTable->setItem(product->hops_row, 1, new QTableWidgetItem(product->hops.at(product->hops_row).h_name)); |
445 ui->hopsTable->setItem(product->hops_row, 1, new QTableWidgetItem(product->hops.at(product->hops_row).name)); |
446 |
446 |
447 item = new QTableWidgetItem(hop_types[product->hops.at(product->hops_row).h_type]); |
447 item = new QTableWidgetItem(hop_types[product->hops.at(product->hops_row).type]); |
448 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
448 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
449 ui->hopsTable->setItem(product->hops_row, 2, item); |
449 ui->hopsTable->setItem(product->hops_row, 2, item); |
450 |
450 |
451 item = new QTableWidgetItem(hop_forms[product->hops.at(product->hops_row).h_form]); |
451 item = new QTableWidgetItem(hop_forms[product->hops.at(product->hops_row).form]); |
452 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
452 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
453 ui->hopsTable->setItem(product->hops_row, 3, item); |
453 ui->hopsTable->setItem(product->hops_row, 3, item); |
454 |
454 |
455 item = new QTableWidgetItem(QString("%1%").arg(product->hops.at(product->hops_row).h_alpha, 2, 'f', 1, '0')); |
455 item = new QTableWidgetItem(QString("%1%").arg(product->hops.at(product->hops_row).alpha, 2, 'f', 1, '0')); |
456 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
456 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
457 ui->hopsTable->setItem(product->hops_row, 4, item); |
457 ui->hopsTable->setItem(product->hops_row, 4, item); |
458 |
458 |
459 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); |
459 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); |
460 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
460 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
461 ui->hopsTable->setItem(product->hops_row, 7, item); |
461 ui->hopsTable->setItem(product->hops_row, 7, item); |
462 |
462 |
463 if (product->hops.at(product->hops_row).h_inventory < 1.0) { |
463 if (product->hops.at(product->hops_row).inventory < 1.0) { |
464 item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(product->hops_row).h_inventory * 1000.0, 2, 'f', 1, '0')); |
464 item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(product->hops_row).inventory * 1000.0, 2, 'f', 1, '0')); |
465 } else { |
465 } else { |
466 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(product->hops_row).h_inventory, 4, 'f', 3, '0')); |
466 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(product->hops_row).inventory, 4, 'f', 3, '0')); |
467 } |
467 } |
468 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
468 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
469 if (product->hops.at(product->hops_row).h_inventory < product->hops.at(product->hops_row).h_amount) |
469 if (product->hops.at(product->hops_row).inventory < product->hops.at(product->hops_row).amount) |
470 item->setForeground(QBrush(QColor(Qt::red))); |
470 item->setForeground(QBrush(QColor(Qt::red))); |
471 ui->hopsTable->setItem(product->hops_row, 9, item); |
471 ui->hopsTable->setItem(product->hops_row, 9, item); |
472 |
472 |
473 calcIBUs(); |
473 calcIBUs(); |
474 is_changed(); |
474 is_changed(); |
501 |
501 |
502 void EditProduct::hop_useat_changed(int val) |
502 void EditProduct::hop_useat_changed(int val) |
503 { |
503 { |
504 qDebug() << "hop_useat_changed()" << product->hops_row << val; |
504 qDebug() << "hop_useat_changed()" << product->hops_row << val; |
505 |
505 |
506 product->hops[product->hops_row].h_useat = val; |
506 product->hops[product->hops_row].useat = val; |
507 QTableWidgetItem *item = new QTableWidgetItem(hop_useat[val]); |
507 QTableWidgetItem *item = new QTableWidgetItem(hop_useat[val]); |
508 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
508 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
509 ui->hopsTable->setItem(product->hops_row, 5, item); |
509 ui->hopsTable->setItem(product->hops_row, 5, item); |
510 |
510 |
511 if (val == HOP_USEAT_BOIL || val == HOP_USEAT_WHIRLPOOL) { |
511 if (val == HOP_USEAT_BOIL || val == HOP_USEAT_WHIRLPOOL) { |
512 htimeLabel->setText(tr("Time in minutes:")); |
512 htimeLabel->setText(tr("Time in minutes:")); |
513 htimeEdit->setValue(product->hops.at(product->hops_row).h_time); |
513 htimeEdit->setValue(product->hops.at(product->hops_row).time); |
514 htimeEdit->setReadOnly(false); |
514 htimeEdit->setReadOnly(false); |
515 } else if (val == HOP_USEAT_DRY_HOP) { |
515 } else if (val == HOP_USEAT_DRY_HOP) { |
516 htimeLabel->setText(tr("Time in days:")); |
516 htimeLabel->setText(tr("Time in days:")); |
517 htimeEdit->setValue(product->hops.at(product->hops_row).h_time / 1440); |
517 htimeEdit->setValue(product->hops.at(product->hops_row).time / 1440); |
518 htimeEdit->setReadOnly(false); |
518 htimeEdit->setReadOnly(false); |
519 } else { |
519 } else { |
520 htimeLabel->setText(""); |
520 htimeLabel->setText(""); |
521 htimeEdit->setValue(0); |
521 htimeEdit->setValue(0); |
522 htimeEdit->setReadOnly(true); |
522 htimeEdit->setReadOnly(true); |
599 hselectEdit->setObjectName(QString::fromUtf8("selectEdit")); |
599 hselectEdit->setObjectName(QString::fromUtf8("selectEdit")); |
600 hselectEdit->setGeometry(QRect(160, 70, 371, 23)); |
600 hselectEdit->setGeometry(QRect(160, 70, 371, 23)); |
601 |
601 |
602 hnameEdit = new QLineEdit(dialog); |
602 hnameEdit = new QLineEdit(dialog); |
603 hnameEdit->setObjectName(QString::fromUtf8("hnameEdit")); |
603 hnameEdit->setObjectName(QString::fromUtf8("hnameEdit")); |
604 hnameEdit->setText(product->hops.at(product->hops_row).h_name); |
604 hnameEdit->setText(product->hops.at(product->hops_row).name); |
605 hnameEdit->setGeometry(QRect(160, 10, 511, 23)); |
605 hnameEdit->setGeometry(QRect(160, 10, 511, 23)); |
606 hnameEdit->setReadOnly(true); |
606 hnameEdit->setReadOnly(true); |
607 horiginEdit = new QLineEdit(dialog); |
607 horiginEdit = new QLineEdit(dialog); |
608 horiginEdit->setObjectName(QString::fromUtf8("horiginEdit")); |
608 horiginEdit->setObjectName(QString::fromUtf8("horiginEdit")); |
609 horiginEdit->setText(product->hops.at(product->hops_row).h_origin); |
609 horiginEdit->setText(product->hops.at(product->hops_row).origin); |
610 horiginEdit->setGeometry(QRect(160, 40, 511, 23)); |
610 horiginEdit->setGeometry(QRect(160, 40, 511, 23)); |
611 horiginEdit->setReadOnly(true); |
611 horiginEdit->setReadOnly(true); |
612 hamountEdit = new QDoubleSpinBox(dialog); |
612 hamountEdit = new QDoubleSpinBox(dialog); |
613 hamountEdit->setObjectName(QString::fromUtf8("hamountEdit")); |
613 hamountEdit->setObjectName(QString::fromUtf8("hamountEdit")); |
614 hamountEdit->setGeometry(QRect(160, 100, 121, 24)); |
614 hamountEdit->setGeometry(QRect(160, 100, 121, 24)); |
615 hamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
615 hamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
616 hamountEdit->setAccelerated(true); |
616 hamountEdit->setAccelerated(true); |
617 hamountEdit->setDecimals(1); |
617 hamountEdit->setDecimals(1); |
618 hamountEdit->setMaximum(1000000.0); |
618 hamountEdit->setMaximum(1000000.0); |
619 hamountEdit->setSingleStep(0.5); |
619 hamountEdit->setSingleStep(0.5); |
620 hamountEdit->setValue(product->hops.at(product->hops_row).h_amount * 1000.0); |
620 hamountEdit->setValue(product->hops.at(product->hops_row).amount * 1000.0); |
621 htimeEdit = new QSpinBox(dialog); |
621 htimeEdit = new QSpinBox(dialog); |
622 htimeEdit->setObjectName(QString::fromUtf8("htimeEdit")); |
622 htimeEdit->setObjectName(QString::fromUtf8("htimeEdit")); |
623 htimeEdit->setGeometry(QRect(160, 130, 121, 24)); |
623 htimeEdit->setGeometry(QRect(160, 130, 121, 24)); |
624 htimeEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
624 htimeEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
625 htimeEdit->setAccelerated(true); |
625 htimeEdit->setAccelerated(true); |
626 htimeEdit->setMaximum(10000.0); |
626 htimeEdit->setMaximum(10000.0); |
627 if (product->hops.at(product->hops_row).h_useat == HOP_USEAT_BOIL || product->hops.at(product->hops_row).h_useat == HOP_USEAT_WHIRLPOOL) { |
627 if (product->hops.at(product->hops_row).useat == HOP_USEAT_BOIL || product->hops.at(product->hops_row).useat == HOP_USEAT_WHIRLPOOL) { |
628 htimeEdit->setValue(product->hops.at(product->hops_row).h_time); |
628 htimeEdit->setValue(product->hops.at(product->hops_row).time); |
629 htimeEdit->setReadOnly(false); |
629 htimeEdit->setReadOnly(false); |
630 } else if (product->hops.at(product->hops_row).h_useat == HOP_USEAT_DRY_HOP) { |
630 } else if (product->hops.at(product->hops_row).useat == HOP_USEAT_DRY_HOP) { |
631 htimeEdit->setValue(product->hops.at(product->hops_row).h_time / 1440); |
631 htimeEdit->setValue(product->hops.at(product->hops_row).time / 1440); |
632 htimeEdit->setReadOnly(false); |
632 htimeEdit->setReadOnly(false); |
633 } else { |
633 } else { |
634 htimeEdit->setReadOnly(true); |
634 htimeEdit->setReadOnly(true); |
635 } |
635 } |
636 useatEdit = new QComboBox(dialog); |
636 useatEdit = new QComboBox(dialog); |
654 ibuEdit->setGeometry(QRect(550, 130, 121, 24)); |
654 ibuEdit->setGeometry(QRect(550, 130, 121, 24)); |
655 ibuEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
655 ibuEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
656 ibuEdit->setReadOnly(true); |
656 ibuEdit->setReadOnly(true); |
657 ibuEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); |
657 ibuEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); |
658 ibuEdit->setDecimals(1); |
658 ibuEdit->setDecimals(1); |
659 double ibu = Utils::toIBU(product->hops.at(product->hops_row).h_useat, product->hops.at(product->hops_row).h_form, product->preboil_sg, |
659 double ibu = Utils::toIBU(product->hops.at(product->hops_row).useat, product->hops.at(product->hops_row).form, product->preboil_sg, |
660 product->batch_size, product->hops.at(product->hops_row).h_amount, product->hops.at(product->hops_row).h_time, |
660 product->batch_size, product->hops.at(product->hops_row).amount, product->hops.at(product->hops_row).time, |
661 product->hops.at(product->hops_row).h_alpha, product->ibu_method, |
661 product->hops.at(product->hops_row).alpha, product->ibu_method, |
662 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); |
662 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time); |
663 ibuEdit->setValue(ibu); |
663 ibuEdit->setValue(ibu); |
664 |
664 |
665 hop_instock_changed(true); |
665 hop_instock_changed(true); |
666 |
666 |