264 if (parseError.error != QJsonParseError::NoError) { |
264 if (parseError.error != QJsonParseError::NoError) { |
265 qDebug() << "Parse error: " << parseError.errorString() << "at" << parseError.offset; |
265 qDebug() << "Parse error: " << parseError.errorString() << "at" << parseError.offset; |
266 } else if (miscs.isArray()) { |
266 } else if (miscs.isArray()) { |
267 for (int i = 0; i < miscs.array().size(); i++) { |
267 for (int i = 0; i < miscs.array().size(); i++) { |
268 QJsonObject obj = miscs.array().at(i).toObject(); |
268 QJsonObject obj = miscs.array().at(i).toObject(); |
269 qDebug() << i << obj; |
269 //qDebug() << i << obj; |
270 Miscs m; |
270 Miscs m; |
271 m.m_name = obj["m_name"].toString(); |
271 m.m_name = obj["m_name"].toString(); |
272 m.m_amount = obj["m_amount"].toDouble(); |
272 m.m_amount = obj["m_amount"].toDouble(); |
273 m.m_type = obj["m_type"].toInt(); |
273 m.m_type = obj["m_type"].toInt(); |
274 m.m_use_use = obj["m_use_use"].toInt(); |
274 m.m_use_use = obj["m_use_use"].toInt(); |
281 } |
281 } |
282 } else { |
282 } else { |
283 qDebug() << "empty miscs"; |
283 qDebug() << "empty miscs"; |
284 } |
284 } |
285 |
285 |
286 qDebug() << query.value(87).toString(); |
|
287 const auto& y_json = query.value(87).toString(); |
286 const auto& y_json = query.value(87).toString(); |
288 if (!y_json.trimmed().isEmpty()) { |
287 if (!y_json.trimmed().isEmpty()) { |
289 const auto& formattedJson = QString("%1").arg(y_json); |
288 const auto& formattedJson = QString("%1").arg(y_json); |
290 QJsonDocument yeasts = QJsonDocument::fromJson(formattedJson.toUtf8(), &parseError); |
289 QJsonDocument yeasts = QJsonDocument::fromJson(formattedJson.toUtf8(), &parseError); |
291 if (parseError.error != QJsonParseError::NoError) { |
290 if (parseError.error != QJsonParseError::NoError) { |
328 y.y_sg_lo = obj["y_sg_lo"].toDouble(); |
327 y.y_sg_lo = obj["y_sg_lo"].toDouble(); |
329 y.y_gr_hl_hi = obj["y_gr_hl_hi"].toInt(); |
328 y.y_gr_hl_hi = obj["y_gr_hl_hi"].toInt(); |
330 y.y_sg_hi = obj["y_sg_hi"].toDouble(); |
329 y.y_sg_hi = obj["y_sg_hi"].toDouble(); |
331 y.y_cost = obj["y_cost"].toDouble(); |
330 y.y_cost = obj["y_cost"].toDouble(); |
332 |
331 |
333 // Upgrade fields from current database: |
332 if (y.y_tolerance == 0) { // More and better tests? |
334 // y_tolerance y_sta1 y_bacteria y_harvest_top y_harvest_time y_pitch_temperature |
333 /* |
335 // y_pofpos y_zymocide y_gr_hl_lo y_sg_lo y_gr_hl_hi y_sg_hi |
334 * Possible data upgrade needed. |
|
335 */ |
|
336 query.prepare("SELECT tolerance,cells,sta1,bacteria,harvest_top,harvest_time,pitch_temperature," |
|
337 "pofpos,zymocide,gr_hl_lo,sg_lo,gr_hl_hi,sg_hi " |
|
338 "FROM inventory_yeasts WHERE name=:name AND laboratory=:laboratory AND product_id=:product_id"); |
|
339 query.bindValue(":name", y.y_name); |
|
340 query.bindValue(":laboratory", y.y_laboratory); |
|
341 query.bindValue(":product_id", y.y_product_id); |
|
342 query.exec(); |
|
343 if (query.first()) { |
|
344 y.y_tolerance = query.value(0).toDouble(); |
|
345 y.y_cells = query.value(1).toDouble(); |
|
346 y.y_sta1 = query.value(2).toInt() ? true:false; |
|
347 y.y_bacteria = query.value(3).toInt() ? true:false; |
|
348 y.y_harvest_top = query.value(4).toInt() ? true:false; |
|
349 y.y_harvest_time = query.value(5).toInt(); |
|
350 y.y_pitch_temperature = query.value(6).toDouble(); |
|
351 y.y_pofpos = query.value(7).toInt() ? true:false; |
|
352 y.y_zymocide = query.value(8).toInt(); |
|
353 y.y_gr_hl_lo = query.value(9).toInt(); |
|
354 y.y_sg_lo = query.value(10).toDouble(); |
|
355 y.y_gr_hl_hi = query.value(11).toInt(); |
|
356 y.y_sg_hi = query.value(12).toDouble(); |
|
357 } else { |
|
358 qDebug() << y.y_name << y.y_product_id << "not found for upgrade"; |
|
359 } |
|
360 } |
336 recipe->yeasts.append(y); |
361 recipe->yeasts.append(y); |
337 } |
362 } |
338 qDebug() << "yeasts" << recipe->yeasts.size(); |
363 qDebug() << "yeasts" << recipe->yeasts.size(); |
339 } |
364 } |
340 } else { |
365 } else { |
341 qDebug() << "empty yeasts"; |
366 qDebug() << "empty yeasts"; |
342 } |
367 } |
343 |
368 |
|
369 qDebug() << query.value(88).toString(); |
344 const auto& ma_json = query.value(88).toString(); |
370 const auto& ma_json = query.value(88).toString(); |
345 if (!ma_json.trimmed().isEmpty()) { |
371 if (!ma_json.trimmed().isEmpty()) { |
346 const auto& formattedJson = QString("%1").arg(ma_json); |
372 const auto& formattedJson = QString("%1").arg(ma_json); |
347 QJsonDocument mashs = QJsonDocument::fromJson(formattedJson.toUtf8(), &parseError); |
373 QJsonDocument mashs = QJsonDocument::fromJson(formattedJson.toUtf8(), &parseError); |
348 if (parseError.error != QJsonParseError::NoError) { |
374 if (parseError.error != QJsonParseError::NoError) { |
641 // All signals from tab "Miscs" |
667 // All signals from tab "Miscs" |
642 ui->miscsTable->setEditTriggers(QAbstractItemView::NoEditTriggers); |
668 ui->miscsTable->setEditTriggers(QAbstractItemView::NoEditTriggers); |
643 connect(ui->addMisc, SIGNAL(clicked()), this, SLOT(addMiscRow_clicked())); |
669 connect(ui->addMisc, SIGNAL(clicked()), this, SLOT(addMiscRow_clicked())); |
644 |
670 |
645 // All signals from tab "Yeasts" |
671 // All signals from tab "Yeasts" |
|
672 ui->yeastsTable->setEditTriggers(QAbstractItemView::NoEditTriggers); |
|
673 connect(ui->addYeast, SIGNAL(clicked()), this, SLOT(addYeastRow_clicked())); |
646 |
674 |
647 // All signals from tab "Mash" |
675 // All signals from tab "Mash" |
648 |
676 |
649 // All signals from tab "Water" |
677 // All signals from tab "Water" |
650 connect(ui->bs_cacl2Edit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::wb_cacl2_changed); |
678 connect(ui->bs_cacl2Edit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::wb_cacl2_changed); |