Typica is a free program for professional coffee roasters. https://typica.us
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

editreminder.xml 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <window id="editreminder">
  2. <layout type="vertical">
  3. <layout type="horizontal">
  4. <label>Name:</label>
  5. <line id="name" />
  6. </layout>
  7. <label>Description:</label>
  8. <textarea id="description" />
  9. <layout type="horizontal">
  10. <label>Since:</label>
  11. <calendar time="true" id="since" />
  12. <button name="Now" id="now" type="push" />
  13. </layout>
  14. <layout type="horizontal">
  15. <label>Condition:</label>
  16. <sqldrop id="condition" />
  17. </layout>
  18. <layout type="stack" id="conditionvars">
  19. <page>
  20. <layout type="horizontal">
  21. <line id="productionweight" validator="numeric" />
  22. <sqldrop id="productionunit" />
  23. </layout>
  24. </page>
  25. <page>
  26. <layout type="horizontal">
  27. <line id="days" validator="numeric" />
  28. </layout>
  29. </page>
  30. <page>
  31. <layout type="horizontal">
  32. <line id="batches" validator="numeric" />
  33. </layout>
  34. </page>
  35. <page>
  36. <layout type="horizontal">
  37. <line id="roastingtime" validator="numeric" />
  38. </layout>
  39. </page>
  40. </layout>
  41. <layout type="horizontal">
  42. <button name="Delete" id="delete" type="push" />
  43. <button name="Save" id="save" type="push" />
  44. </layout>
  45. </layout>
  46. <program>
  47. <![CDATA[
  48. var window = this;
  49. window.setRefreshFunction = function(callback) {
  50. window.refreshCallback = callback;
  51. }
  52. window.currentReminder = new Object();
  53. this.windowTitle = "Typica - Edit Reminder";
  54. var unitBox = findChildObject(this, 'productionunit');
  55. unitBox.addItem("Kg");
  56. unitBox.addItem("Lb");
  57. unitBox.currentIndex = QSettings.value("script/report_unit", 1);
  58. var condition = findChildObject(this, 'condition');
  59. condition.addItem("Roasted Coffee Production");
  60. condition.addItem("Days");
  61. condition.addItem("Batches Roasted");
  62. condition.addItem("Hours of Roasting Time");
  63. var conditionpage = findChildObject(this, 'conditionvars');
  64. condition['currentIndexChanged(int)'].connect(function(c) {
  65. conditionpage.setCurrentIndex(c);
  66. });
  67. var namefield = findChildObject(this, 'name');
  68. var descfield = findChildObject(this, 'description');
  69. var sincefield = findChildObject(this, 'since');
  70. var prodweight = findChildObject(this, 'productionweight');
  71. var daysfield = findChildObject(this, 'days');
  72. var batchesfield = findChildObject(this, 'batches');
  73. var hoursfield = findChildObject(this, 'roastingtime');
  74. var time = new QTime();
  75. var deleteButton = findChildObject(this, 'delete');
  76. deleteButton.enabled = false;
  77. deleteButton.clicked.connect(function() {
  78. var query = new QSqlQuery;
  79. query.prepare("DELETE FROM reminders WHERE id = :id");
  80. query.bind("id", window.currentReminder.dbid);
  81. query.exec();
  82. query = query.invalidate();
  83. window.refreshCallback();
  84. window.close();
  85. });
  86. var saveButton = findChildObject(this, 'save');
  87. saveButton.clicked.connect(function() {
  88. r = new Object();
  89. r.title = namefield.text;
  90. r.description = descfield.plainText;
  91. r.start_year = sincefield.year();
  92. r.start_month = sincefield.month();
  93. r.start_day = sincefield.day();
  94. r.start_time = sincefield.time.toString("hh:mm:ss");
  95. switch(condition.currentIndex)
  96. {
  97. case 0:
  98. r.condition = "PRODUCTIONWEIGHT";
  99. r.value = Number(prodweight.text);
  100. if(unitBox.currentIndex == 0)
  101. {
  102. r.unit = "KG";
  103. }
  104. else
  105. {
  106. r.unit = "LB";
  107. }
  108. break;
  109. case 1:
  110. r.condition = "DAYS";
  111. r.value = daysfield.text;
  112. break;
  113. case 2:
  114. r.condition = "PRODUCTIONBATCHES";
  115. r.value = batchesfield.text;
  116. break;
  117. case 3:
  118. r.condition = "PRODUCTIONHOURS";
  119. r.value = hoursfield.text;
  120. break;
  121. }
  122. var query = new QSqlQuery;
  123. if(window.currentReminder.hasOwnProperty("dbid"))
  124. {
  125. query.prepare("UPDATE reminders SET reminder = :reminder WHERE id = :id");
  126. query.bind("reminder", JSON.stringify(r));
  127. query.bind("id", window.currentReminder.dbid);
  128. }
  129. else
  130. {
  131. query.prepare("INSERT INTO reminders (id, reminder) VALUES(default, :reminder)");
  132. query.bind("reminder", JSON.stringify(r));
  133. }
  134. query.exec();
  135. query = query.invalidate();
  136. window.refreshCallback();
  137. window.close();
  138. });
  139. window.loadData = function(reminder) {
  140. window.currentReminder = reminder;
  141. deleteButton.enabled = reminder.hasOwnProperty("dbid");
  142. if(reminder.hasOwnProperty("title"))
  143. {
  144. namefield.text = reminder.title;
  145. }
  146. if(reminder.hasOwnProperty("description"))
  147. {
  148. descfield.plainText = reminder.description;
  149. }
  150. if(reminder.hasOwnProperty("start_year") &&
  151. reminder.hasOwnProperty("start_month") &&
  152. reminder.hasOwnProperty("start_day"))
  153. {
  154. sincefield.setDate(reminder.start_year, reminder.start_month, reminder.start_day);
  155. }
  156. if(reminder.hasOwnProperty("start_time"))
  157. {
  158. sincefield.time = time.fromString(reminder.start_time, "hh:mm:ss");
  159. }
  160. if(reminder.hasOwnProperty("condition"))
  161. {
  162. if(reminder.condition == "PRODUCTIONWEIGHT")
  163. {
  164. condition.setCurrentIndex(0);
  165. if(reminder.hasOwnProperty("value"))
  166. {
  167. prodweight.text = reminder.value;
  168. }
  169. if(reminder.unit == "KG")
  170. {
  171. unitBox.setCurrentIndex(0);
  172. }
  173. else
  174. {
  175. unitBox.setCurrentIndex(1);
  176. }
  177. }
  178. else if(reminder.condition == "DAYS")
  179. {
  180. condition.setCurrentIndex(1);
  181. if(reminder.hasOwnProperty("value"))
  182. {
  183. daysfield.text = reminder.value;
  184. }
  185. }
  186. else if(reminder.condition == "PRODUCTIONBATCHES")
  187. {
  188. condition.setCurrentIndex(2);
  189. if(reminder.hasOwnProperty("value"))
  190. {
  191. batchesfield.text = reminder.value;
  192. }
  193. }
  194. else if(reminder.condition == "PRODUCTIONHOURS")
  195. {
  196. condition.setCurrentIndex(3);
  197. if(reminder.hasOwnProperty("value"))
  198. {
  199. hoursfield.text = reminder.value;
  200. }
  201. }
  202. }
  203. }
  204. ]]>
  205. </program>
  206. </window>