SELECT id, name FROM items WHERE id IN (SELECT item FROM current_items) ORDER BY name
0) {
expected.text = Number(query.value(0)) * 100;
}
if(query.value(1).length > 0) {
tolerance.text = Number(query.value(1)) * 100;
}
notes.plainText = query.value(2);
}
query = query.invalidate();
});
savebutton.clicked.connect(function() {
var query = new QSqlQuery();
var columnspec = "time, item, ";
var valuespec = "'now', :id, ";
if(expected.text.length > 0) {
columnspec += "loss, ";
valuespec += ":loss, ";
}
if(tolerance.text.length > 0) {
columnspec += "tolerance, ";
valuespec += ":tolerance, ";
}
columnspec += "notes";
valuespec += ":notes";
query.prepare("INSERT INTO roasting_specification (" + columnspec + ") VALUES (" + valuespec + ")");
query.bind(":id", selector.currentData());
if(expected.text.length > 0) {
query.bind(":loss", Number(expected.text) / 100);
}
if(tolerance.text.length > 0) {
query.bind(":tolerance", Number(tolerance.text) / 100);
}
query.bind(":notes", notes.plainText);
query.exec();
window.close();
});
]]>