340 query.first(); |
341 query.first(); |
341 for (int i = 0; i < (val - 1); i++) { |
342 for (int i = 0; i < (val - 1); i++) { |
342 query.next(); |
343 query.next(); |
343 } |
344 } |
344 #ifdef DEBUG_YEAST |
345 #ifdef DEBUG_YEAST |
345 qDebug() << "found" << query.value(0).toString() << query.value(2).toString(); |
346 qDebug() << "found" << query.value("name").toString() << query.value("product_id").toString(); |
346 #endif |
347 #endif |
347 |
348 |
348 /* |
349 /* |
349 * Replace the yeast record contents |
350 * Replace the yeast record contents |
350 */ |
351 */ |
351 recipe->yeasts[recipe->yeasts_row].name = query.value(0).toString(); |
352 recipe->yeasts[recipe->yeasts_row].name = query.value("name").toString(); |
352 recipe->yeasts[recipe->yeasts_row].laboratory = query.value(1).toString(); |
353 recipe->yeasts[recipe->yeasts_row].laboratory = query.value("laboratory").toString(); |
353 recipe->yeasts[recipe->yeasts_row].product_id = query.value(2).toString(); |
354 recipe->yeasts[recipe->yeasts_row].product_id = query.value("product_id").toString(); |
354 recipe->yeasts[recipe->yeasts_row].type = query.value(3).toInt(); |
355 recipe->yeasts[recipe->yeasts_row].type = query.value("type").toInt(); |
355 recipe->yeasts[recipe->yeasts_row].form = query.value(4).toInt(); |
356 recipe->yeasts[recipe->yeasts_row].form = query.value("form").toInt(); |
356 recipe->yeasts[recipe->yeasts_row].min_temperature = query.value(5).toDouble(); |
357 recipe->yeasts[recipe->yeasts_row].min_temperature = query.value("min_temperature").toDouble(); |
357 recipe->yeasts[recipe->yeasts_row].max_temperature = query.value(6).toDouble(); |
358 recipe->yeasts[recipe->yeasts_row].max_temperature = query.value("max_temperature").toDouble(); |
358 recipe->yeasts[recipe->yeasts_row].flocculation = query.value(7).toInt(); |
359 recipe->yeasts[recipe->yeasts_row].flocculation = query.value("flocculation").toInt(); |
359 recipe->yeasts[recipe->yeasts_row].attenuation = query.value(8).toDouble(); |
360 recipe->yeasts[recipe->yeasts_row].attenuation = query.value("attenuation").toDouble(); |
360 recipe->yeasts[recipe->yeasts_row].cells = query.value(9).toDouble(); |
361 recipe->yeasts[recipe->yeasts_row].cells = query.value("cells").toDouble(); |
361 recipe->yeasts[recipe->yeasts_row].tolerance = query.value(10).toDouble(); |
362 recipe->yeasts[recipe->yeasts_row].tolerance = query.value("tolerance").toDouble(); |
362 recipe->yeasts[recipe->yeasts_row].sta1 = query.value(11).toInt() ? true:false; |
363 recipe->yeasts[recipe->yeasts_row].sta1 = query.value("sta1").toInt() ? true:false; |
363 recipe->yeasts[recipe->yeasts_row].bacteria = query.value(12).toInt() ? true:false; |
364 recipe->yeasts[recipe->yeasts_row].bacteria = query.value("bacteria").toInt() ? true:false; |
364 recipe->yeasts[recipe->yeasts_row].harvest_top = query.value(13).toInt() ? true:false; |
365 recipe->yeasts[recipe->yeasts_row].harvest_top = query.value("harvest_top").toInt() ? true:false; |
365 recipe->yeasts[recipe->yeasts_row].harvest_time = query.value(14).toInt(); |
366 recipe->yeasts[recipe->yeasts_row].harvest_time = query.value("harvest_time").toInt(); |
366 recipe->yeasts[recipe->yeasts_row].pitch_temperature = query.value(15).toDouble(); |
367 recipe->yeasts[recipe->yeasts_row].pitch_temperature = query.value("pitch_temperature").toDouble(); |
367 recipe->yeasts[recipe->yeasts_row].pofpos = query.value(16).toInt() ? true:false; |
368 recipe->yeasts[recipe->yeasts_row].pofpos = query.value("pofpos").toInt() ? true:false; |
368 recipe->yeasts[recipe->yeasts_row].zymocide = query.value(17).toInt(); |
369 recipe->yeasts[recipe->yeasts_row].zymocide = query.value("zymocide").toInt(); |
369 recipe->yeasts[recipe->yeasts_row].gr_hl_lo = query.value(18).toInt(); |
370 recipe->yeasts[recipe->yeasts_row].gr_hl_lo = query.value("gr_hl_lo").toInt(); |
370 recipe->yeasts[recipe->yeasts_row].sg_lo = query.value(19).toDouble(); |
371 recipe->yeasts[recipe->yeasts_row].sg_lo = query.value("sg_lo").toDouble(); |
371 recipe->yeasts[recipe->yeasts_row].gr_hl_hi = query.value(20).toInt(); |
372 recipe->yeasts[recipe->yeasts_row].gr_hl_hi = query.value("gr_hl_hi").toInt(); |
372 recipe->yeasts[recipe->yeasts_row].sg_hi = query.value(21).toDouble(); |
373 recipe->yeasts[recipe->yeasts_row].sg_hi = query.value("sg_hi").toDouble(); |
373 recipe->yeasts[recipe->yeasts_row].cost = query.value(22).toDouble(); |
374 recipe->yeasts[recipe->yeasts_row].cost = query.value("cost").toDouble(); |
374 |
375 |
375 /* |
376 /* |
376 * Update the visible fields |
377 * Update the visible fields |
377 */ |
378 */ |
|
379 const QSignalBlocker blocker1(yamountEdit); |
378 ynameEdit->setText(recipe->yeasts.at(recipe->yeasts_row).name); |
380 ynameEdit->setText(recipe->yeasts.at(recipe->yeasts_row).name); |
379 ylaboratoryEdit->setText(recipe->yeasts.at(recipe->yeasts_row).laboratory); |
381 ylaboratoryEdit->setText(recipe->yeasts.at(recipe->yeasts_row).laboratory); |
380 yproduct_idEdit->setText(recipe->yeasts.at(recipe->yeasts_row).product_id); |
382 yproduct_idEdit->setText(recipe->yeasts.at(recipe->yeasts_row).product_id); |
381 if (recipe->yeasts.at(recipe->yeasts_row).form == 0) { |
383 if (recipe->yeasts.at(recipe->yeasts_row).form == YEAST_FORMS_LIQUID) { |
|
384 if (oldform != YEAST_FORMS_LIQUID) |
|
385 recipe->yeasts[recipe->yeasts_row].amount = 1; |
|
386 yamountEdit->setValue(recipe->yeasts[recipe->yeasts_row].amount); |
382 yamountEdit->setDecimals(0); |
387 yamountEdit->setDecimals(0); |
383 yamountEdit->setSingleStep(1.0); |
388 yamountEdit->setSingleStep(1.0); |
384 yamountLabel->setText(tr("Total packs:")); |
389 yamountLabel->setText(tr("Total packs:")); |
385 } else if (recipe->yeasts.at(recipe->yeasts_row).form == 1) { |
390 } else if ((recipe->yeasts.at(recipe->yeasts_row).form == YEAST_FORMS_DRY) || (recipe->yeasts.at(recipe->yeasts_row).form == YEAST_FORMS_DRIED)) { |
|
391 if (oldform == YEAST_FORMS_LIQUID) |
|
392 recipe->yeasts[recipe->yeasts_row].amount = 0.01; |
|
393 yamountEdit->setValue(recipe->yeasts[recipe->yeasts_row].amount * 1000.0); |
386 yamountEdit->setDecimals(1); |
394 yamountEdit->setDecimals(1); |
387 yamountEdit->setSingleStep(0.5); |
395 yamountEdit->setSingleStep(0.5); |
388 yamountLabel->setText(tr("Amount in gr:")); |
396 yamountLabel->setText(tr("Amount in gr:")); |
389 } else { |
397 } else { |
|
398 if (oldform == YEAST_FORMS_LIQUID) |
|
399 recipe->yeasts[recipe->yeasts_row].amount = 0.01; |
|
400 yamountEdit->setValue(recipe->yeasts[recipe->yeasts_row].amount * 1000.0); |
390 yamountEdit->setDecimals(1); |
401 yamountEdit->setDecimals(1); |
391 yamountEdit->setSingleStep(0.5); |
402 yamountEdit->setSingleStep(0.5); |
392 yamountLabel->setText(tr("Amount in ml:")); |
403 yamountLabel->setText(tr("Amount in ml:")); |
393 } |
404 } |
394 |
405 |
414 |
425 |
415 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(recipe->yeasts_row).attenuation, 2, 'f', 1, '0')); |
426 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(recipe->yeasts_row).attenuation, 2, 'f', 1, '0')); |
416 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
427 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
417 ui->yeastsTable->setItem(recipe->yeasts_row, 8, item); |
428 ui->yeastsTable->setItem(recipe->yeasts_row, 8, item); |
418 |
429 |
419 if (recipe->yeasts.at(product->yeasts_row).use != YEAST_USE_BOTTLE && recipe->yeasts.at(product->yeasts_row).sta1) { |
430 if (recipe->yeasts.at(recipe->yeasts_row).use != YEAST_USE_BOTTLE && recipe->yeasts.at(recipe->yeasts_row).sta1) { |
420 QWidget *pWidget = new QWidget(); |
431 QWidget *pWidget = new QWidget(); |
421 QLabel *label = new QLabel; |
432 QLabel *label = new QLabel; |
422 label->setPixmap(QPixmap(":icons/silk/tick.png")); |
433 label->setPixmap(QPixmap(":icons/silk/tick.png")); |
423 QHBoxLayout *pLayout = new QHBoxLayout(pWidget); |
434 QHBoxLayout *pLayout = new QHBoxLayout(pWidget); |
424 pLayout->addWidget(label); |
435 pLayout->addWidget(label); |
425 pLayout->setAlignment(Qt::AlignCenter); |
436 pLayout->setAlignment(Qt::AlignCenter); |
426 pLayout->setContentsMargins(0, 0, 0, 0); |
437 pLayout->setContentsMargins(0, 0, 0, 0); |
427 pWidget->setLayout(pLayout); |
438 pWidget->setLayout(pLayout); |
428 ui->yeastsTable->setCellWidget(product->yeasts_row, 9, pWidget); |
439 ui->yeastsTable->setCellWidget(recipe->yeasts_row, 9, pWidget); |
429 } else { |
440 } else { |
430 ui->yeastsTable->removeCellWidget(product->yeasts_row, 9); |
441 ui->yeastsTable->removeCellWidget(recipe->yeasts_row, 9); |
431 } |
442 } |
432 |
443 |
433 is_changed(); |
444 is_changed(); |
434 } |
445 } |
435 |
446 |