Typica is a free program for professional coffee roasters. https://typica.us
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

roastspec.xml 3.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <window id="roastspec">
  2. <layout type="horizontal">
  3. <layout type="vertical">
  4. <layout type="horizontal">
  5. <label>Coffee:</label>
  6. <sqldrop data="0" display="1" showdata="false" id="currentitems">
  7. <query>SELECT id, name FROM items WHERE id IN (SELECT item FROM current_items) ORDER BY name</query>
  8. </sqldrop>
  9. </layout>
  10. <layout type="horizontal">
  11. <label>Expected % weight loss:</label>
  12. <line validator="numeric" id="expectedloss" />
  13. </layout>
  14. <layout type="horizontal">
  15. <label>Tolerance</label>
  16. <line validator="numeric" id="tolerance" />
  17. </layout>
  18. <label>Specification Notes:</label>
  19. <textarea id="notes" />
  20. <layout type="horizontal">
  21. <stretch />
  22. <button id="save" type="push" name="Save" />
  23. </layout>
  24. </layout>
  25. </layout>
  26. <program>
  27. <![CDATA[
  28. var window = this;
  29. this.windowTitle = TTR("roastspec", "Typica - Edit Roasting Specification");
  30. var selector = findChildObject(this, 'currentitems');
  31. var expected = findChildObject(this, 'expectedloss');
  32. var tolerance = findChildObject(this, 'tolerance');
  33. var notes = findChildObject(this, 'notes');
  34. var savebutton = findChildObject(this, 'save');
  35. var updateDisplay = function() {
  36. var query = new QSqlQuery();
  37. query.prepare("SELECT loss, tolerance, notes FROM roasting_specification WHERE item = :id1 AND time = (SELECT max(time) FROM roasting_specification WHERE item = :id2)");
  38. query.bind(":id1", selector.currentData());
  39. query.bind(":id2", selector.currentData());
  40. query.exec();
  41. if(query.next()) {
  42. if(query.value(0).length > 0) {
  43. expected.text = Number(query.value(0)) * 100;
  44. } else {
  45. expected.text = "";
  46. }
  47. if(query.value(1).length > 0) {
  48. tolerance.text = Number(query.value(1)) * 100;
  49. } else {
  50. tolerance.text = "";
  51. }
  52. notes.plainText = query.value(2);
  53. } else {
  54. expected.text = "";
  55. tolerance.text = "";
  56. notes.plainText = "";
  57. }
  58. query = query.invalidate();
  59. };
  60. updateDisplay();
  61. selector['currentIndexChanged(int)'].connect(function() {
  62. updateDisplay();
  63. });
  64. savebutton.clicked.connect(function() {
  65. var query = new QSqlQuery();
  66. var columnspec = "time, item, ";
  67. var valuespec = "'now', :id, ";
  68. if(expected.text.length > 0) {
  69. columnspec += "loss, ";
  70. valuespec += ":loss, ";
  71. }
  72. if(tolerance.text.length > 0) {
  73. columnspec += "tolerance, ";
  74. valuespec += ":tolerance, ";
  75. }
  76. columnspec += "notes";
  77. valuespec += ":notes";
  78. query.prepare("INSERT INTO roasting_specification (" + columnspec + ") VALUES (" + valuespec + ")");
  79. query.bind(":id", selector.currentData());
  80. if(expected.text.length > 0) {
  81. query.bind(":loss", Number(expected.text) / 100);
  82. }
  83. if(tolerance.text.length > 0) {
  84. query.bind(":tolerance", Number(tolerance.text) / 100);
  85. }
  86. query.bind(":notes", notes.plainText);
  87. query.exec();
  88. window.close();
  89. });
  90. ]]>
  91. </program>
  92. </window>