348 double tcells = start; |
348 double tcells = start; |
349 QIcon iconT; |
349 QIcon iconT; |
350 |
350 |
351 iconT.addFile(QString::fromUtf8(":/icons/silk/pencil.png"), QSize(), QIcon::Normal, QIcon::Off); |
351 iconT.addFile(QString::fromUtf8(":/icons/silk/pencil.png"), QSize(), QIcon::Normal, QIcon::Off); |
352 |
352 |
353 if ((product->prop1_volume + product->prop2_volume + product->prop3_volume + product->prop4_volume) == 0) { |
353 if ((product->prop_volume[0] + product->prop_volume[1] + product->prop_volume[2] + product->prop_volume[3]) == 0) { |
354 /* |
354 /* |
355 * Auto calculate the starter. |
355 * Auto calculate the starter. |
356 */ |
356 */ |
357 qDebug() << " calcSteps() auto"; |
357 qDebug() << " calcSteps() auto"; |
358 |
358 |
411 pLayout->addWidget(btn_edit); |
411 pLayout->addWidget(btn_edit); |
412 pLayout->setContentsMargins(5, 0, 5, 0); |
412 pLayout->setContentsMargins(5, 0, 5, 0); |
413 pWidget->setLayout(pLayout); |
413 pWidget->setLayout(pLayout); |
414 ui->starterTable->setCellWidget(step -1, 6, pWidget); |
414 ui->starterTable->setCellWidget(step -1, 6, pWidget); |
415 |
415 |
416 if (step == 1) { |
416 product->prop_type[step -1] = product->starter_type; |
417 product->prop1_type = product->starter_type; |
417 product->prop_volume[step -1] = result.svol / 1000.0; |
418 product->prop1_volume = result.svol / 1000.0; |
|
419 } else if (step == 2) { |
|
420 product->prop2_type = product->starter_type; |
|
421 product->prop2_volume = result.svol / 1000.0; |
|
422 } else if (step == 3) { |
|
423 product->prop3_type = product->starter_type; |
|
424 product->prop3_volume = result.svol / 1000.0; |
|
425 } else if (step == 4) { |
|
426 product->prop4_type = product->starter_type; |
|
427 product->prop4_volume = result.svol / 1000.0; |
|
428 } |
|
429 |
418 |
430 tcells = result.totcells; |
419 tcells = result.totcells; |
431 if (result.totcells > needed) // Hit the target |
420 if (result.totcells > needed) // Hit the target |
432 return; |
421 return; |
433 } |
422 } |
436 /* |
425 /* |
437 * Recalculate the starter. |
426 * Recalculate the starter. |
438 */ |
427 */ |
439 qDebug() << " calcSteps() recalculate"; |
428 qDebug() << " calcSteps() recalculate"; |
440 |
429 |
441 if (product->prop1_volume > 0) { |
430 if (product->prop_volume[0] > 0) { |
442 result = calcStep(product->prop1_volume * 1000, product->prop1_type, tcells); |
431 result = calcStep(product->prop_volume[0] * 1000, product->prop_type[0], tcells); |
443 ui->starterTable->setRowCount(1); |
432 ui->starterTable->setRowCount(1); |
444 item = new QTableWidgetItem(starters[product->prop1_type]); |
433 item = new QTableWidgetItem(starters[product->prop_type[0]]); |
445 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
434 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
446 ui->starterTable->setItem(0, 0, item); |
435 ui->starterTable->setItem(0, 0, item); |
447 |
436 |
448 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters |
437 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters |
449 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
438 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
476 pWidget->setLayout(pLayout); |
465 pWidget->setLayout(pLayout); |
477 ui->starterTable->setCellWidget(0, 6, pWidget); |
466 ui->starterTable->setCellWidget(0, 6, pWidget); |
478 |
467 |
479 tcells = result.totcells; |
468 tcells = result.totcells; |
480 if (result.totcells > needed) { // Hit the target |
469 if (result.totcells > needed) { // Hit the target |
481 product->prop2_volume = product->prop3_volume = product->prop4_volume = 0; |
470 product->prop_volume[1] = product->prop_volume[2] = product->prop_volume[3] = 0; |
482 product->prop2_type = product->prop3_type = product->prop4_type = 0; |
471 product->prop_type[1] = product->prop_type[2] = product->prop_type[3] = 0; |
483 return; |
472 return; |
484 } else if (product->prop2_volume == 0) { // Extra step needed, start with the same size. |
473 } else if (product->prop_volume[1] == 0) { // Extra step needed, start with the same size. |
485 product->prop2_volume = product->prop1_volume; |
474 product->prop_volume[1] = product->prop_volume[0]; |
486 product->prop2_type = product->prop1_type; |
475 product->prop_type[1] = product->prop_type[0]; |
487 } |
476 } |
488 } |
477 } |
489 if (product->prop2_volume > 0) { |
478 if (product->prop_volume[1] > 0) { |
490 result = calcStep(product->prop2_volume * 1000, product->prop2_type, tcells); |
479 result = calcStep(product->prop_volume[1] * 1000, product->prop_type[1], tcells); |
491 ui->starterTable->setRowCount(2); |
480 ui->starterTable->setRowCount(2); |
492 item = new QTableWidgetItem(starters[product->prop2_type]); |
481 item = new QTableWidgetItem(starters[product->prop_type[1]]); |
493 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
482 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
494 ui->starterTable->setItem(1, 0, item); |
483 ui->starterTable->setItem(1, 0, item); |
495 |
484 |
496 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters |
485 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters |
497 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
486 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
524 pWidget->setLayout(pLayout); |
513 pWidget->setLayout(pLayout); |
525 ui->starterTable->setCellWidget(1, 6, pWidget); |
514 ui->starterTable->setCellWidget(1, 6, pWidget); |
526 |
515 |
527 tcells = result.totcells; |
516 tcells = result.totcells; |
528 if (result.totcells > needed) { // Hit the target |
517 if (result.totcells > needed) { // Hit the target |
529 product->prop3_volume = product->prop4_volume = 0; |
518 product->prop_volume[2] = product->prop_volume[3] = 0; |
530 product->prop3_type = product->prop4_type = 0; |
519 product->prop_type[2] = product->prop_type[3] = 0; |
531 return; |
520 return; |
532 } else if (product->prop3_volume == 0) { // Extra step needed, start with the same size. |
521 } else if (product->prop_volume[2] == 0) { // Extra step needed, start with the same size. |
533 product->prop3_volume = product->prop2_volume; |
522 product->prop_volume[2] = product->prop_volume[1]; |
534 product->prop3_type = product->prop2_type; |
523 product->prop_type[2] = product->prop_type[1]; |
535 } |
524 } |
536 } |
525 } |
537 if (product->prop3_volume > 0) { |
526 if (product->prop_volume[2] > 0) { |
538 result = calcStep(product->prop3_volume * 1000, product->prop3_type, tcells); |
527 result = calcStep(product->prop_volume[2] * 1000, product->prop_type[2], tcells); |
539 ui->starterTable->setRowCount(3); |
528 ui->starterTable->setRowCount(3); |
540 item = new QTableWidgetItem(starters[product->prop3_type]); |
529 item = new QTableWidgetItem(starters[product->prop_type[2]]); |
541 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
530 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
542 ui->starterTable->setItem(2, 0, item); |
531 ui->starterTable->setItem(2, 0, item); |
543 |
532 |
544 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters |
533 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters |
545 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
534 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
572 pWidget->setLayout(pLayout); |
561 pWidget->setLayout(pLayout); |
573 ui->starterTable->setCellWidget(2, 6, pWidget); |
562 ui->starterTable->setCellWidget(2, 6, pWidget); |
574 |
563 |
575 tcells = result.totcells; |
564 tcells = result.totcells; |
576 if (result.totcells > needed) { // Hit the target |
565 if (result.totcells > needed) { // Hit the target |
577 product->prop4_volume = 0; |
566 product->prop_volume[3] = 0; |
578 product->prop4_type = 0; |
567 product->prop_type[3] = 0; |
579 return; |
568 return; |
580 } else if (product->prop4_volume == 0) { // Extra step needed, start with the same size. |
569 } else if (product->prop_volume[3] == 0) { // Extra step needed, start with the same size. |
581 product->prop4_volume = product->prop3_volume; |
570 product->prop_volume[3] = product->prop_volume[2]; |
582 product->prop4_type = product->prop3_type; |
571 product->prop_type[3] = product->prop_type[2]; |
583 } |
572 } |
584 } |
573 } |
585 if (product->prop4_volume > 0) { |
574 if (product->prop_volume[3] > 0) { |
586 result = calcStep(product->prop4_volume * 1000, product->prop4_type, tcells); |
575 result = calcStep(product->prop_volume[3] * 1000, product->prop_type[3], tcells); |
587 ui->starterTable->setRowCount(4); |
576 ui->starterTable->setRowCount(4); |
588 item = new QTableWidgetItem(starters[product->prop4_type]); |
577 item = new QTableWidgetItem(starters[product->prop_type[3]]); |
589 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
578 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
590 ui->starterTable->setItem(3, 0, item); |
579 ui->starterTable->setItem(3, 0, item); |
591 |
580 |
592 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters |
581 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters |
593 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
582 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
652 } |
641 } |
653 |
642 |
654 |
643 |
655 void EditProduct::yeast_starter_edit_clicked() |
644 void EditProduct::yeast_starter_edit_clicked() |
656 { |
645 { |
|
646 int stype; |
|
647 double svol; |
|
648 |
657 QToolButton *pb = qobject_cast<QToolButton *>(QObject::sender()); |
649 QToolButton *pb = qobject_cast<QToolButton *>(QObject::sender()); |
658 int row = pb->objectName().toInt(); |
650 int row = pb->objectName().toInt(); |
659 qDebug() << "yeast_starter_edit_clicked" << row; |
651 qDebug() << "yeast_starter_edit_clicked" << row; |
|
652 |
|
653 stype = product->prop_type[row]; |
|
654 svol = product->prop_volume[row]; |
660 } |
655 } |
661 |
656 |
662 |
657 |
663 void EditProduct::addYeastRow_clicked() |
658 void EditProduct::addYeastRow_clicked() |
664 { |
659 { |