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.8KB

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