瀏覽代碼

Add search

Neal Wilson 6 年之前
父節點
當前提交
e1ecc2a371
共有 1 個文件被更改,包括 29 次插入2 次删除
  1. 29
    2
      config/Windows/batchdetailsnew.xml

+ 29
- 2
config/Windows/batchdetailsnew.xml 查看文件

3
         <layout type="horizontal">
3
         <layout type="horizontal">
4
             <button type="push" id="target" name="Load profile as target" />
4
             <button type="push" id="target" name="Load profile as target" />
5
             <button type="push" id="compare" name="Compare profile" />
5
             <button type="push" id="compare" name="Compare profile" />
6
+            <stretch />
7
+            <label>Search:</label>
8
+            <line id="search" />
6
         </layout>
9
         </layout>
7
         <tabbar id="tabs" />
10
         <tabbar id="tabs" />
8
         <layout type="stack" id="pages">
11
         <layout type="stack" id="pages">
354
                         wholecolor.value = "";
357
                         wholecolor.value = "";
355
                         groundcolor.value = "";
358
                         groundcolor.value = "";
356
                     }
359
                     }
360
+                } else {
361
+                    wholecolor.value = "";
362
+                    groundcolor.value = "";
357
                 }
363
                 }
358
-                
359
-                
360
                 output.writeStartElement("p");
364
                 output.writeStartElement("p");
361
                 output.writeTextElement("strong", TTR("batchDetails", "Approved: "));
365
                 output.writeTextElement("strong", TTR("batchDetails", "Approved: "));
362
                 output.writeCharacters(query.value(6));
366
                 output.writeCharacters(query.value(6));
495
                 query.bind(":time", batchTime);
499
                 query.bind(":time", batchTime);
496
                 query.bind(":machine", Number(machine));
500
                 query.bind(":machine", Number(machine));
497
                 query.exec();
501
                 query.exec();
502
+                query = query.invalidate();
498
                 window.loadBatch(machine, batchTime);
503
                 window.loadBatch(machine, batchTime);
499
                 displayInfo(TTR("batchDetails", "Batch Data Saved"),
504
                 displayInfo(TTR("batchDetails", "Batch Data Saved"),
500
                             TTR("roastspec", "New batch details saved"));
505
                             TTR("roastspec", "New batch details saved"));
557
                 batchTag.setContent(buffer);
562
                 batchTag.setContent(buffer);
558
                 buffer.close();
563
                 buffer.close();
559
             };
564
             };
565
+            var search = findChildObject(this, 'search');
566
+            search.returnPressed.connect(function() {
567
+                if(search.text.length == 0) {
568
+                    return;
569
+                }
570
+                if(Number(search.text)) {
571
+                    var query = new QSqlQuery();
572
+                    query.prepare("SELECT machine, time FROM roasting_log WHERE files[1] = :file");
573
+                    query.bind(":file", Number(search.text));
574
+                    query.exec();
575
+                    if(query.next()) {
576
+                        window.loadBatch(query.value(0), query.value(1));
577
+                    }
578
+                    query = query.invalidate();
579
+                } else {
580
+                    var tag = JSON.parse(search.text);
581
+                    if(tag.m != undefined && tag.t != undefined) {
582
+                        window.loadBatch(tag.m, tag.t);
583
+                    }
584
+                }
585
+                search.text = "";
586
+            });
560
         ]]>
587
         ]]>
561
     </program>
588
     </program>
562
 </window>
589
 </window>

Loading…
取消
儲存