Added TorrentPickerPage.
[qtrapids] / src / qml-client / qml / MainPage.qml
1 import QtQuick 1.1
2 import Qt.labs.components 1.0
3 import com.nokia.meego 1.0
4 import com.meego 1.0
5 import com.nokia.extras 1.0
6 import Qt 4.7
7
8 import QtRapids 1.0
9
10 Page {
11     id: mainPage
12
13     property bool busy: Boolean(tabGroup.currentTab.busy)
14     anchors.margins: rootWindow.pageMargin
15
16     tools: ToolBarLayout {
17         ToolIcon { iconId: "toolbar-back"; onClicked: pageStack.pop(); }
18         ButtonRow {
19             platformStyle: TabButtonStyle { }
20             TabButton {
21                 text: "Downloads"
22                 tab: downloads
23             }
24             TabButton {
25                 text: "Seeds"
26                 tab: seeds
27             }
28         }
29         ToolIcon {
30             iconId: "toolbar-view-menu"
31             onClicked: (myMenu.status == DialogStatus.Closed) ? myMenu.open() : myMenu.close()
32         }
33     }
34 //  Text {
35 //      text: "Hello World!"
36 //      font.family: "Helvetica"
37 //      font.pointSize: 24
38 //      color: "red"
39 //     anchors.fill: parent
40 //  }
41
42     ListView {
43         width: 200; height: 400
44 /*
45         DownloadListModel {
46             id: downloadModel
47             // TODO: Does not work like this. Need properties to set from QML?
48             // Try setting test data from C++ side and view here..
49             /*
50             ListElement {
51                 Hash: "QMLHASH1"
52                 Size: "Size1"
53                 Status: "DONE1"
54             }
55             ListElement {
56                 Hash: "QMLHASH2"
57                 Size: "Size2"
58                 Status: "DONE2"
59             }
60             ListElement {
61                 Hash: "QMLHASH3"
62                 Size: "Size3"
63                 Status: "DONE3"
64             }
65         }
66 */
67         Component {
68             id: downloadDelegate
69             Item {
70                 height: 40
71                 width: parent.width
72                 Text {
73                     id: hashText
74                     text: hash
75                 }
76                 Text {
77                     id: nameText
78                     anchors.leftMargin: 10
79                     anchors.left: hashText.right
80                     text: name
81                 }
82                 Text {
83                     id: seedsText
84                     anchors.leftMargin: 10
85                     anchors.left: nameText.right
86                     text: seeds
87                 }
88                 Text {
89                     id: leechesText
90                     anchors.leftMargin: 10
91                     anchors.left: seedsText.right
92                     text: leeches
93                 }
94             }
95         }
96
97         // downloadModel is from rootContext, set in main.cpp
98         model: downloadModel
99         delegate: downloadDelegate
100     }
101
102     /*
103     ListModel {
104         id: pagesModel
105         ListElement {
106             page: "CountBubble.qml"
107             title: "CountBubble"
108             subtitle: "Indicates current count"
109         }
110         ListElement {
111             page: "NetPromoterScore.qml"
112             title: "NetPromoterScore"
113             subtitle: "Shows net promotion query page"
114         }
115         ListElement {
116             page: "PageIndicator.qml"
117             title: "PageIndicator"
118             subtitle: "Indicates total & current pages"
119         }
120         ListElement {
121             page: "RatingIndicator.qml"
122             title: "RatingIndicator"
123             subtitle: "Indicates ratings"
124         }
125         ListElement {
126             page: "ListDelegates.qml"
127             title: "List Delegates"
128             subtitle: "Various List Delegates"
129         }
130         ListElement {
131             page: "MoreIndicator.qml"
132             title: "MoreIndicator"
133             subtitle: "Indicates that there are more contents"
134         }
135         ListElement {
136             page: "StyledButtons.qml"
137             title: "StyledButtons"
138             subtitle: "Buttons with different styles"
139         }
140     }
141     ListView {
142         id: listview
143         anchors.fill: parent
144         model: pagesModel
145
146         delegate: ListDelegate {
147             Image {
148                 source: "image://theme/icon-m-common-drilldown-arrow" + (theme.inverted ? "-inverse" : "")
149                 anchors.right: parent.right;
150                 anchors.verticalCenter: parent.verticalCenter
151             }
152
153             subtitleColor: "#cc6633"
154             onClicked: { openFile(model.page); }
155         }
156     }
157 */
158     TabGroup {
159         id: tabGroup
160
161         currentTab: downloads
162
163         PageStack {
164             id: downloads
165         }
166         PageStack {
167             id: seeds
168         }
169         Page {
170             id: tab3
171             Column {
172                 spacing: 10
173
174                 Text {
175                     text: "This is a single page"
176                 }
177             }
178         }
179     }
180     Menu {
181         id: myMenu
182         visualParent: mainPage
183         MenuLayout {
184             MenuItem {
185                 id: menuItemOpenFile
186                 text: "Open"
187                 onClicked: { console.log("opening torrent picker"); pageStack.push(torrentPickerComp); }
188             }
189         }
190     }
191     Component {
192         id: torrentPickerComp
193         TorrentPickerPage { }
194     }
195 }