79fabca678de603ac1e21cc118350515319177bd
[ubi] / qml / ubi / DownloadArea.qml
1 import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
2 import "components"
3 import "UIConstants.js" as Const
4
5 Item {
6     id: root
7
8     property int count: 0
9
10     height: taskView.height
11
12     function addTask(type,filename)
13     {
14         //emptyLabel.visible = Utils.emptyQuee();
15         //emptyLabel.visible = false;
16         var comp = Qt.createComponent("components/Bar.qml");
17         var obj = comp.createObject(taskView);
18         if (obj==null) {
19             console.log("Error creating object");
20         } else {
21             root.count++;
22             obj.width = root.width
23             obj.label = filename;
24             if(type=="download")
25                 obj.isDownload = true;
26             if(type=="upload")
27                 obj.isUpload = true;
28         }
29     }
30
31     function setProgress(filename, progress)
32     {
33         var l = taskView.children.length;
34         for(var i=0;i<l;++i) {
35             var item = taskView.children[i];
36             if(item && item.label==filename)
37                 item.setProgres(progress);
38         }
39     }
40
41     function start(filename)
42     {
43         var l = taskView.children.length;
44         for(var i=0;i<l;++i) {
45             var item = taskView.children[i];
46             if(item && item.label==filename)
47                 item.start();
48         }
49     }
50
51     function stop(filename)
52     {
53         console.log("stop task");
54         var l = taskView.children.length;
55         for(var i=0;i<l;++i) {
56             var item = taskView.children[i];
57             if(item && item.label==filename) {
58                 //console.log("stop task 2");
59                 item.destroy();
60                 root.count--;
61             }
62         }
63         //emptyLabel.visible = Utils.emptyQuee();
64     }
65
66     Column {
67         id: taskView
68         width: parent.width
69         spacing: Const.DEFAULT_MARGIN
70
71         Text {
72             font.pixelSize: Const.DEFAULT_FONT_PIXEL_SIZE
73             color: Const.DEFAULT_FOREGROUND_COLOR
74             text: qsTr("No active downloads")
75             visible: taskBar.isEmpty
76         }
77
78     }
79 }