388 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
389 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
389 ui->starterTable->setItem(step -1, 1, item); |
390 ui->starterTable->setItem(step -1, 1, item); |
390 |
391 |
391 item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); |
392 item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); |
392 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
393 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
394 if ((result.irate < 25) || (result.irate > 100)) |
|
395 item->setForeground(QBrush(QColor(Qt::red))); |
393 ui->starterTable->setItem(step -1, 2, item); |
396 ui->starterTable->setItem(step -1, 2, item); |
394 |
397 |
395 item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); |
398 item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); |
396 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
399 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
397 ui->starterTable->setItem(step -1, 3, item); |
400 ui->starterTable->setItem(step -1, 3, item); |
398 |
401 |
399 item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); |
402 item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); |
400 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
403 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
404 item->setForeground(QBrush(QColor((result.totcells > needed) ? Qt::green:Qt::red))); |
401 ui->starterTable->setItem(step -1, 4, item); |
405 ui->starterTable->setItem(step -1, 4, item); |
402 |
406 |
403 item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); |
407 item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); |
404 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
408 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
409 if (result.growf < 1) |
|
410 item->setForeground(QBrush(QColor(Qt::red))); |
|
411 if ((stype > 0) && (result.growf > 3)) |
|
412 item->setForeground(QBrush(QColor(Qt::red))); |
405 ui->starterTable->setItem(step -1, 5, item); |
413 ui->starterTable->setItem(step -1, 5, item); |
406 |
414 |
407 pWidget = new QWidget(); |
415 pWidget = new QWidget(); |
408 QToolButton* btn_edit = new QToolButton(); |
416 QToolButton* btn_edit = new QToolButton(); |
409 btn_edit->setObjectName(QString("%1").arg(step - 1)); /* Send row with the button */ |
417 btn_edit->setObjectName(QString("%1").arg(step - 1)); /* Send row with the button */ |
427 /* |
435 /* |
428 * Recalculate the starter. |
436 * Recalculate the starter. |
429 */ |
437 */ |
430 qDebug() << " calcSteps() recalculate"; |
438 qDebug() << " calcSteps() recalculate"; |
431 |
439 |
432 if (product->prop_volume[0] > 0) { |
440 for (step = 0; step < 4; step++) { |
433 result = calcStep(product->prop_volume[0] * 1000, product->prop_type[0], tcells); |
441 if (product->prop_volume[step] > 0) { |
434 ui->starterTable->setRowCount(1); |
442 result = calcStep(product->prop_volume[step] * 1000, product->prop_type[step], tcells); |
435 item = new QTableWidgetItem(starters[product->prop_type[0]]); |
443 ui->starterTable->setRowCount(step + 1); |
436 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
444 item = new QTableWidgetItem(starters[product->prop_type[step]]); |
437 ui->starterTable->setItem(0, 0, item); |
445 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
438 |
446 ui->starterTable->setItem(step, 0, item); |
439 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters |
447 |
440 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
448 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters |
441 ui->starterTable->setItem(0, 1, item); |
449 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
442 |
450 ui->starterTable->setItem(step, 1, item); |
443 item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); |
451 |
444 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
452 item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); |
445 ui->starterTable->setItem(0, 2, item); |
453 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
446 |
454 if ((result.irate < 25) || (result.irate > 100)) |
447 item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); |
455 item->setForeground(QBrush(QColor(Qt::red))); |
448 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
456 ui->starterTable->setItem(step, 2, item); |
449 ui->starterTable->setItem(0, 3, item); |
457 |
450 |
458 item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); |
451 item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); |
459 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
452 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
460 ui->starterTable->setItem(step, 3, item); |
453 ui->starterTable->setItem(0, 4, item); |
461 |
454 |
462 item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); |
455 item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); |
463 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
456 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
464 item->setForeground(QBrush(QColor((result.totcells > needed) ? Qt::green:Qt::red))); |
457 ui->starterTable->setItem(0, 5, item); |
465 ui->starterTable->setItem(step, 4, item); |
458 |
466 |
459 pWidget = new QWidget(); |
467 item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); |
460 QToolButton* btn_edit = new QToolButton(); |
468 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
461 btn_edit->setObjectName(QString("0")); /* Send row with the button */ |
469 if (result.growf < 1) |
462 btn_edit->setIcon(iconT); |
470 item->setForeground(QBrush(QColor(Qt::red))); |
463 connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); |
471 if ((stype > 0) && (result.growf > 3)) |
464 pLayout = new QHBoxLayout(pWidget); |
472 item->setForeground(QBrush(QColor(Qt::red))); |
465 pLayout->addWidget(btn_edit); |
473 ui->starterTable->setItem(step, 5, item); |
466 pLayout->setContentsMargins(5, 0, 5, 0); |
474 |
467 pWidget->setLayout(pLayout); |
475 pWidget = new QWidget(); |
468 ui->starterTable->setCellWidget(0, 6, pWidget); |
476 QToolButton* btn_edit = new QToolButton(); |
469 |
477 btn_edit->setObjectName(QString("%1").arg(step)); /* Send row with the button */ |
470 tcells = result.totcells; |
478 btn_edit->setIcon(iconT); |
471 if (result.totcells > needed) { // Hit the target |
479 connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); |
472 product->prop_volume[1] = product->prop_volume[2] = product->prop_volume[3] = 0; |
480 pLayout = new QHBoxLayout(pWidget); |
473 product->prop_type[1] = product->prop_type[2] = product->prop_type[3] = 0; |
481 pLayout->addWidget(btn_edit); |
474 return; |
482 pLayout->setContentsMargins(5, 0, 5, 0); |
475 } else if (product->prop_volume[1] == 0) { // Extra step needed, start with the same size. |
483 pWidget->setLayout(pLayout); |
476 product->prop_volume[1] = product->prop_volume[0]; |
484 ui->starterTable->setCellWidget(step, 6, pWidget); |
477 product->prop_type[1] = product->prop_type[0]; |
485 |
|
486 tcells = result.totcells; |
|
487 if (result.totcells > needed) { // Hit the target |
|
488 for (int i = step + 1; i < 4; i++) { |
|
489 product->prop_volume[i] = 0; |
|
490 product->prop_type[i] = 0; |
|
491 } |
|
492 return; |
|
493 } else if ((step < 3) && (product->prop_volume[step + 1] == 0)) { // Extra step needed, start with the same size. |
|
494 product->prop_volume[step + 1] = product->prop_volume[step]; |
|
495 product->prop_type[step + 1] = product->prop_type[step]; |
|
496 } |
478 } |
497 } |
479 } |
498 } |
480 if (product->prop_volume[1] > 0) { |
|
481 result = calcStep(product->prop_volume[1] * 1000, product->prop_type[1], tcells); |
|
482 ui->starterTable->setRowCount(2); |
|
483 item = new QTableWidgetItem(starters[product->prop_type[1]]); |
|
484 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
|
485 ui->starterTable->setItem(1, 0, item); |
|
486 |
|
487 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters |
|
488 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
489 ui->starterTable->setItem(1, 1, item); |
|
490 |
|
491 item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); |
|
492 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
493 ui->starterTable->setItem(1, 2, item); |
|
494 |
|
495 item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); |
|
496 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
497 ui->starterTable->setItem(1, 3, item); |
|
498 |
|
499 item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); |
|
500 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
501 ui->starterTable->setItem(1, 4, item); |
|
502 |
|
503 item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); |
|
504 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
505 ui->starterTable->setItem(1, 5, item); |
|
506 |
|
507 pWidget = new QWidget(); |
|
508 QToolButton* btn_edit = new QToolButton(); |
|
509 btn_edit->setObjectName(QString("1")); /* Send row with the button */ |
|
510 btn_edit->setIcon(iconT); |
|
511 connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); |
|
512 pLayout = new QHBoxLayout(pWidget); |
|
513 pLayout->addWidget(btn_edit); |
|
514 pLayout->setContentsMargins(5, 0, 5, 0); |
|
515 pWidget->setLayout(pLayout); |
|
516 ui->starterTable->setCellWidget(1, 6, pWidget); |
|
517 |
|
518 tcells = result.totcells; |
|
519 if (result.totcells > needed) { // Hit the target |
|
520 product->prop_volume[2] = product->prop_volume[3] = 0; |
|
521 product->prop_type[2] = product->prop_type[3] = 0; |
|
522 return; |
|
523 } else if (product->prop_volume[2] == 0) { // Extra step needed, start with the same size. |
|
524 product->prop_volume[2] = product->prop_volume[1]; |
|
525 product->prop_type[2] = product->prop_type[1]; |
|
526 } |
|
527 } |
|
528 if (product->prop_volume[2] > 0) { |
|
529 result = calcStep(product->prop_volume[2] * 1000, product->prop_type[2], tcells); |
|
530 ui->starterTable->setRowCount(3); |
|
531 item = new QTableWidgetItem(starters[product->prop_type[2]]); |
|
532 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
|
533 ui->starterTable->setItem(2, 0, item); |
|
534 |
|
535 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters |
|
536 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
537 ui->starterTable->setItem(2, 1, item); |
|
538 |
|
539 item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); |
|
540 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
541 ui->starterTable->setItem(2, 2, item); |
|
542 |
|
543 item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); |
|
544 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
545 ui->starterTable->setItem(2, 3, item); |
|
546 |
|
547 item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); |
|
548 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
549 ui->starterTable->setItem(2, 4, item); |
|
550 |
|
551 item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); |
|
552 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
553 ui->starterTable->setItem(2, 5, item); |
|
554 |
|
555 pWidget = new QWidget(); |
|
556 QToolButton* btn_edit = new QToolButton(); |
|
557 btn_edit->setObjectName(QString("2")); /* Send row with the button */ |
|
558 btn_edit->setIcon(iconT); |
|
559 connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); |
|
560 pLayout = new QHBoxLayout(pWidget); |
|
561 pLayout->addWidget(btn_edit); |
|
562 pLayout->setContentsMargins(5, 0, 5, 0); |
|
563 pWidget->setLayout(pLayout); |
|
564 ui->starterTable->setCellWidget(2, 6, pWidget); |
|
565 |
|
566 tcells = result.totcells; |
|
567 if (result.totcells > needed) { // Hit the target |
|
568 product->prop_volume[3] = 0; |
|
569 product->prop_type[3] = 0; |
|
570 return; |
|
571 } else if (product->prop_volume[3] == 0) { // Extra step needed, start with the same size. |
|
572 product->prop_volume[3] = product->prop_volume[2]; |
|
573 product->prop_type[3] = product->prop_type[2]; |
|
574 } |
|
575 } |
|
576 if (product->prop_volume[3] > 0) { |
|
577 result = calcStep(product->prop_volume[3] * 1000, product->prop_type[3], tcells); |
|
578 ui->starterTable->setRowCount(4); |
|
579 item = new QTableWidgetItem(starters[product->prop_type[3]]); |
|
580 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
|
581 ui->starterTable->setItem(3, 0, item); |
|
582 |
|
583 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters |
|
584 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
585 ui->starterTable->setItem(3, 1, item); |
|
586 |
|
587 item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0')); |
|
588 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
589 ui->starterTable->setItem(3, 2, item); |
|
590 |
|
591 item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0')); |
|
592 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
593 ui->starterTable->setItem(3, 3, item); |
|
594 |
|
595 item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0')); |
|
596 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
597 ui->starterTable->setItem(3, 4, item); |
|
598 |
|
599 item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0')); |
|
600 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
601 ui->starterTable->setItem(3, 5, item); |
|
602 |
|
603 pWidget = new QWidget(); |
|
604 QToolButton* btn_edit = new QToolButton(); |
|
605 btn_edit->setObjectName(QString("3")); /* Send row with the button */ |
|
606 btn_edit->setIcon(iconT); |
|
607 connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked())); |
|
608 pLayout = new QHBoxLayout(pWidget); |
|
609 pLayout->addWidget(btn_edit); |
|
610 pLayout->setContentsMargins(5, 0, 5, 0); |
|
611 pWidget->setLayout(pLayout); |
|
612 ui->starterTable->setCellWidget(3, 6, pWidget); |
|
613 } |
|
614 } |
499 } |
615 } |
500 } |
616 |
501 |
617 |
502 |
618 void EditProduct::calcViability() |
503 void EditProduct::calcViability() |