394 return; |
396 return; |
395 |
397 |
396 /* |
398 /* |
397 * Search the hop pointed by the index and instock flag. |
399 * Search the hop pointed by the index and instock flag. |
398 */ |
400 */ |
399 QString sql = "SELECT name,origin,alpha,beta,humulene,caryophyllene,cohumulone,myrcene,hsi,total_oil,type,form,cost FROM inventory_hops "; |
401 QString sql = "SELECT * FROM inventory_hops "; |
400 if (instock) |
402 if (instock) |
401 sql.append("WHERE inventory > 0 "); |
403 sql.append("WHERE inventory > 0 "); |
402 sql.append("ORDER BY origin,name"); |
404 sql.append("ORDER BY origin,name"); |
403 query.prepare(sql); |
405 query.prepare(sql); |
404 query.exec(); |
406 query.exec(); |
408 } |
410 } |
409 |
411 |
410 /* |
412 /* |
411 * Replace the hop record contents |
413 * Replace the hop record contents |
412 */ |
414 */ |
413 recipe->hops[recipe->hops_row].name = query.value(0).toString(); |
415 recipe->hops[recipe->hops_row].name = query.value("name").toString(); |
414 recipe->hops[recipe->hops_row].origin = query.value(1).toString(); |
416 recipe->hops[recipe->hops_row].origin = query.value("origin").toString(); |
415 recipe->hops[recipe->hops_row].alpha = query.value(2).toDouble(); |
417 recipe->hops[recipe->hops_row].alpha = query.value("alpha").toDouble(); |
416 recipe->hops[recipe->hops_row].beta = query.value(3).toDouble(); |
418 recipe->hops[recipe->hops_row].beta = query.value("beta").toDouble(); |
417 recipe->hops[recipe->hops_row].humulene = query.value(4).toDouble(); |
419 recipe->hops[recipe->hops_row].humulene = query.value("humulene").toDouble(); |
418 recipe->hops[recipe->hops_row].caryophyllene = query.value(5).toDouble(); |
420 recipe->hops[recipe->hops_row].caryophyllene = query.value("caryophyllene").toDouble(); |
419 recipe->hops[recipe->hops_row].cohumulone = query.value(6).toDouble(); |
421 recipe->hops[recipe->hops_row].cohumulone = query.value("cohumulone").toDouble(); |
420 recipe->hops[recipe->hops_row].myrcene = query.value(7).toDouble(); |
422 recipe->hops[recipe->hops_row].myrcene = query.value("myrcene").toDouble(); |
421 recipe->hops[recipe->hops_row].hsi = query.value(8).toDouble(); |
423 recipe->hops[recipe->hops_row].hsi = query.value("hsi").toDouble(); |
422 recipe->hops[recipe->hops_row].total_oil = query.value(9).toDouble(); |
424 recipe->hops[recipe->hops_row].total_oil = query.value("total_oil").toDouble(); |
423 recipe->hops[recipe->hops_row].type = query.value(10).toInt(); |
425 recipe->hops[recipe->hops_row].type = query.value("type").toInt(); |
424 recipe->hops[recipe->hops_row].form = query.value(11).toInt(); |
426 recipe->hops[recipe->hops_row].form = query.value("form").toInt(); |
425 recipe->hops[recipe->hops_row].cost = query.value(12).toDouble(); |
427 recipe->hops[recipe->hops_row].cost = query.value("cost").toDouble(); |
|
428 recipe->hops[recipe->hops_row].utilisation = query.value("utilisation").toDouble(); |
|
429 recipe->hops[recipe->hops_row].bu_factor = query.value("bu_factor").toDouble(); |
426 |
430 |
427 /* |
431 /* |
428 * Update the visible fields |
432 * Update the visible fields |
429 */ |
433 */ |
430 hnameEdit->setText(recipe->hops.at(recipe->hops_row).name); |
434 hnameEdit->setText(recipe->hops.at(recipe->hops_row).name); |