Typica is a free program for professional coffee roasters. https://typica.us
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536
  1. <window id="importTargets">
  2. <layout type="horizontal">
  3. <sqldrop data="0" display="1" showdata="true" id="roasted">
  4. <query>SELECT id, name FROM items WHERE category = 'Coffee: Roasted' AND id IN (SELECT item FROM current_items) ORDER BY name</query>
  5. </sqldrop>
  6. <button name="File…" id="file" type="push" />
  7. </layout>
  8. <program>
  9. var button = findChildObject(this, 'file');
  10. var box = findChildObject(this, 'roasted');
  11. var win = this;
  12. button.clicked.connect(function() {
  13. var filename = QFileDialog.getOpenFileName(win, TTR("importTargets", "Open Log..."), QSettings.value('script/lastDir', '') + '/');
  14. if(filename != '') {
  15. QSettings.setValue("script/lastDir", dir(filename));
  16. var q = "INSERT INTO files (id, name, type, note, file) VALUES(default, :name, 'profile', NULL, :data) RETURNING id";
  17. query = new QSqlQuery();
  18. query.prepare(q);
  19. query.bind(":name", baseName(filename));
  20. query.bindFileData(":data", filename);
  21. query.exec();
  22. query.next();
  23. var fileno = query.value(0);
  24. var id = box.currentData();
  25. q = "INSERT INTO item_files (time, item, files) VALUES('now', ";
  26. q = q + id;
  27. q = q + ", '{";
  28. q = q + fileno;
  29. q = q + "}')";
  30. query.exec(q);
  31. query = query.invalidate();
  32. var success = createWindow("success");
  33. }
  34. });
  35. </program>
  36. </window>