Typica is a free program for professional coffee roasters. https://typica.us
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

roastspec.xml 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. selector['currentIndexChanged(int)'].connect(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. }
  43. if(query.value(1).length > 0) {
  44. tolerance.text = Number(query.value(1)) * 100;
  45. }
  46. notes.plainText = query.value(2);
  47. }
  48. query = query.invalidate();
  49. });
  50. savebutton.clicked.connect(function() {
  51. var query = new QSqlQuery();
  52. var columnspec = "time, item, ";
  53. var valuespec = "'now', :id, ";
  54. if(expected.text.length > 0) {
  55. columnspec += "loss, ";
  56. valuespec += ":loss, ";
  57. }
  58. if(tolerance.text.length > 0) {
  59. columnspec += "tolerance, ";
  60. valuespec += ":tolerance, ";
  61. }
  62. columnspec += "notes";
  63. valuespec += ":notes";
  64. query.prepare("INSERT INTO roasting_specification (" + columnspec + ") VALUES (" + valuespec + ")");
  65. query.bind(":id", selector.currentData());
  66. if(expected.text.length > 0) {
  67. query.bind(":loss", Number(expected.text) / 100);
  68. }
  69. if(tolerance.text.length > 0) {
  70. query.bind(":tolerance", Number(tolerance.text) / 100);
  71. }
  72. query.bind(":notes", notes.plainText);
  73. query.exec();
  74. window.close();
  75. });
  76. ]]>
  77. </program>
  78. </window>