Typica is a free program for professional coffee roasters. https://typica.us
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

cuppingsessionlist.xml 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <window id="sessionlist">
  2. <layout type="vertical">
  3. <sqlview id="table" />
  4. </layout>
  5. <program>
  6. <![CDATA[
  7. var table = findChildObject(this, 'table');
  8. table.setQuery("SELECT id, name, time FROM cupping_sessions WHERE open = true ORDER BY time DESC");
  9. table.openEntry.connect(function(arg) {
  10. var q = "SELECT event FROM cupping_sessions WHERE id = :id";
  11. var query = new QSqlQuery;
  12. query.prepare(q);
  13. query.bind(":id", arg);
  14. query.exec();
  15. query.next();
  16. var formwindow = createWindow("cuppingform");
  17. formwindow.windowTitle = "Typica - Cupping";
  18. var sessionfield = findChildObject(formwindow, 'session');
  19. sessionfield.text = arg;
  20. var eventfield = findChildObject(formwindow, 'event');
  21. eventfield.text = query.value(0);
  22. q = "SELECT sample FROM cupping_samples WHERE session = :id ORDER BY position ASC";
  23. query.prepare(q);
  24. query.bind(":id", Number(arg));
  25. query.exec();
  26. var view = findChildObject(formwindow, 'form');
  27. view.setMaximumElementHeight(300);
  28. view.setMaximumElementWidth(1100);
  29. while(query.next())
  30. {
  31. view.addElements(1);
  32. var element = view.elementAt(view.elements() - 1)
  33. var sampleBox = findChildObject(element, 'sampleID');
  34. sampleBox.text = query.value(0);
  35. var aromaScale = findChildObject(element, 'aroma');
  36. var aromaBox = findChildObject(element, 'aromabox');
  37. aromaScale.finalChanged.connect(aromaBox.setValue);
  38. aromaBox['valueChanged(double)'].connect(aromaScale.setFinalValue);
  39. var flavorScale = findChildObject(element, 'flavor');
  40. var flavorBox = findChildObject(element, 'flavorbox');
  41. flavorScale.finalChanged.connect(flavorBox.setValue);
  42. flavorBox['valueChanged(double)'].connect(flavorScale.setFinalValue);
  43. var acidityScale = findChildObject(element, 'acidity');
  44. var acidityBox = findChildObject(element, 'aciditybox');
  45. acidityScale.finalChanged.connect(acidityBox.setValue);
  46. acidityBox['valueChanged(double)'].connect(acidityScale.setFinalValue);
  47. var bodyScale = findChildObject(element, 'body');
  48. var bodyBox = findChildObject(element, 'bodybox');
  49. bodyScale.finalChanged.connect(bodyBox.setValue);
  50. bodyBox['valueChanged(double)'].connect(bodyScale.setFinalValue);
  51. var balanceScale = findChildObject(element, 'balance');
  52. var balanceBox = findChildObject(element, 'balancebox');
  53. balanceScale.finalChanged.connect(balanceBox.setValue);
  54. balanceBox['valueChanged(double)'].connect(balanceScale.setFinalValue);
  55. var aftertasteScale = findChildObject(element, 'aftertaste');
  56. var aftertasteBox = findChildObject(element, 'aftertastebox');
  57. aftertasteScale.finalChanged.connect(aftertasteBox.setValue);
  58. aftertasteBox['valueChanged(double)'].connect(aftertasteScale.setFinalValue);
  59. var overallScale = findChildObject(element, 'overall');
  60. var overallBox = findChildObject(element, 'overallbox');
  61. overallScale.finalChanged.connect(overallBox.setValue);
  62. overallBox['valueChanged(double)'].connect(overallScale.setFinalValue);
  63. var uc1 = findChildObject(element, 'u1');
  64. var uc2 = findChildObject(element, 'u2');
  65. var uc3 = findChildObject(element, 'u3');
  66. var uc4 = findChildObject(element, 'u4');
  67. var uc5 = findChildObject(element, 'u5');
  68. var cc1 = findChildObject(element, 'c1');
  69. var cc2 = findChildObject(element, 'c2');
  70. var cc3 = findChildObject(element, 'c3');
  71. var cc4 = findChildObject(element, 'c4');
  72. var cc5 = findChildObject(element, 'c5');
  73. var sc1 = findChildObject(element, 's1');
  74. var sc2 = findChildObject(element, 's2');
  75. var sc3 = findChildObject(element, 's3');
  76. var sc4 = findChildObject(element, 's4');
  77. var sc5 = findChildObject(element, 's5');
  78. var uniformityBox = findChildObject(element, 'uniformity');
  79. var cleancupBox = findChildObject(element, 'cleancup');
  80. var sweetnessBox = findChildObject(element, 'sweetness');
  81. uc1.checked = true;
  82. uc2.checked = true;
  83. uc3.checked = true;
  84. uc4.checked = true;
  85. uc5.checked = true;
  86. cc1.checked = true;
  87. cc2.checked = true;
  88. cc3.checked = true;
  89. cc4.checked = true;
  90. cc5.checked = true;
  91. sc1.checked = true;
  92. sc2.checked = true;
  93. sc3.checked = true;
  94. sc4.checked = true;
  95. sc5.checked = true;
  96. uniformityBox.value = 10;
  97. cleancupBox.value = 10;
  98. sweetnessBox.value = 10;
  99. var recalculateUniformity = function() {
  100. for(var i = 0; i < view.elements(); i++)
  101. {
  102. var u = 0;
  103. uc1 = findChildObject(view.elementAt(i), 'u1');
  104. uc2 = findChildObject(view.elementAt(i), 'u2');
  105. uc3 = findChildObject(view.elementAt(i), 'u3');
  106. uc4 = findChildObject(view.elementAt(i), 'u4');
  107. uc5 = findChildObject(view.elementAt(i), 'u5');
  108. uniformityBox = findChildObject(view.elementAt(i), 'uniformity');
  109. if(uc1.checked)
  110. {
  111. u += 2;
  112. }
  113. if(uc2.checked)
  114. {
  115. u += 2;
  116. }
  117. if(uc3.checked)
  118. {
  119. u += 2;
  120. }
  121. if(uc4.checked)
  122. {
  123. u += 2;
  124. }
  125. if(uc5.checked)
  126. {
  127. u += 2;
  128. }
  129. uniformityBox.value = u;
  130. }
  131. };
  132. uc1.clicked.connect(recalculateUniformity);
  133. uc2.clicked.connect(recalculateUniformity);
  134. uc3.clicked.connect(recalculateUniformity);
  135. uc4.clicked.connect(recalculateUniformity);
  136. uc5.clicked.connect(recalculateUniformity);
  137. var recalculateCleancup = function()
  138. {
  139. for(var i = 0; i < view.elements(); i++)
  140. {
  141. var c = 0;
  142. cc1 = findChildObject(view.elementAt(i), 'c1');
  143. cc2 = findChildObject(view.elementAt(i), 'c2');
  144. cc3 = findChildObject(view.elementAt(i), 'c3');
  145. cc4 = findChildObject(view.elementAt(i), 'c4');
  146. cc5 = findChildObject(view.elementAt(i), 'c5');
  147. cleancupBox = findChildObject(view.elementAt(i), 'cleancup');
  148. if(cc1.checked)
  149. {
  150. c += 2;
  151. }
  152. if(cc2.checked)
  153. {
  154. c += 2;
  155. }
  156. if(cc3.checked)
  157. {
  158. c += 2;
  159. }
  160. if(cc4.checked)
  161. {
  162. c += 2;
  163. }
  164. if(cc5.checked)
  165. {
  166. c += 2;
  167. }
  168. cleancupBox.value = c;
  169. }
  170. };
  171. cc1.clicked.connect(recalculateCleancup);
  172. cc2.clicked.connect(recalculateCleancup);
  173. cc3.clicked.connect(recalculateCleancup);
  174. cc4.clicked.connect(recalculateCleancup);
  175. cc5.clicked.connect(recalculateCleancup);
  176. var recalculateSweetness = function() {
  177. for(var i = 0; i < view.elements(); i++)
  178. {
  179. sc1 = findChildObject(view.elementAt(i), 's1');
  180. sc2 = findChildObject(view.elementAt(i), 's2');
  181. sc3 = findChildObject(view.elementAt(i), 's3');
  182. sc4 = findChildObject(view.elementAt(i), 's4');
  183. sc5 = findChildObject(view.elementAt(i), 's5');
  184. sweetnessBox = findChildObject(view.elementAt(i), 'sweetness');
  185. var s = 0;
  186. if(sc1.checked)
  187. {
  188. s += 2;
  189. }
  190. if(sc2.checked)
  191. {
  192. s += 2;
  193. }
  194. if(sc3.checked)
  195. {
  196. s += 2;
  197. }
  198. if(sc4.checked)
  199. {
  200. s += 2;
  201. }
  202. if(sc5.checked)
  203. {
  204. s += 2;
  205. }
  206. sweetnessBox.value = s;
  207. }
  208. };
  209. sc1.clicked.connect(recalculateSweetness);
  210. sc2.clicked.connect(recalculateSweetness);
  211. sc3.clicked.connect(recalculateSweetness);
  212. sc4.clicked.connect(recalculateSweetness);
  213. sc5.clicked.connect(recalculateSweetness);
  214. var totalBox = findChildObject(element, 'totalscore');
  215. var finalBox = findChildObject(element, 'finalscore');
  216. var taintBox = findChildObject(element, 'taints');
  217. var faultBox = findChildObject(element, 'faults');
  218. totalBox.enabled = false;
  219. finalBox.enabled = false;
  220. var recalculateTotals = function() {
  221. for(var i = 0; i < view.elements(); i++)
  222. {
  223. aromaBox = findChildObject(view.elementAt(i), 'aromabox');
  224. flavorBox = findChildObject(view.elementAt(i), 'flavorbox');
  225. acidityBox = findChildObject(view.elementAt(i), 'aciditybox');
  226. bodyBox = findChildObject(view.elementAt(i), 'bodybox');
  227. balanceBox = findChildObject(view.elementAt(i), 'balancebox');
  228. aftertasteBox = findChildObject(view.elementAt(i), 'aftertastebox');
  229. overallBox = findChildObject(view.elementAt(i), 'overallbox');
  230. uniformityBox = findChildObject(view.elementAt(i), 'uniformity');
  231. cleancupBox = findChildObject(view.elementAt(i), 'cleancup');
  232. sweetnessBox = findChildObject(view.elementAt(i), 'sweetness');
  233. taintBox = findChildObject(view.elementAt(i), 'taints');
  234. faultBox = findChildObject(view.elementAt(i), 'faults');
  235. totalBox = findChildObject(view.elementAt(i), 'totalscore');
  236. finalBox = findChildObject(view.elementAt(i), 'finalscore');
  237. var total = aromaBox.value + flavorBox.value + acidityBox.value + bodyBox.value + balanceBox.value + aftertasteBox.value + overallBox.value + uniformityBox.value + cleancupBox.value + sweetnessBox.value;
  238. var taints = -(taintBox.value * 2);
  239. var faults = -(faultBox.value * 4);
  240. var final = total + taints + faults;
  241. totalBox.value = total;
  242. finalBox.value = final;
  243. }
  244. };
  245. aromaBox['valueChanged(double)'].connect(recalculateTotals);
  246. taintBox['valueChanged(double)'].connect(recalculateTotals);
  247. faultBox['valueChanged(double)'].connect(recalculateTotals);
  248. flavorBox['valueChanged(double)'].connect(recalculateTotals);
  249. acidityBox['valueChanged(double)'].connect(recalculateTotals);
  250. bodyBox['valueChanged(double)'].connect(recalculateTotals);
  251. balanceBox['valueChanged(double)'].connect(recalculateTotals);
  252. aftertasteBox['valueChanged(double)'].connect(recalculateTotals);
  253. overallBox['valueChanged(double)'].connect(recalculateTotals);
  254. uniformityBox['valueChanged(double)'].connect(recalculateTotals);
  255. cleancupBox['valueChanged(double)'].connect(recalculateTotals);
  256. sweetnessBox['valueChanged(double)'].connect(recalculateTotals);
  257. recalculateTotals();
  258. }
  259. formwindow.showMaximized();
  260. });
  261. ]]>
  262. </program>
  263. </window>