Commit | Line | Data |
---|---|---|
8f661e5c TB |
1 | import QtQuick 2.0 |
2 | import QtQml.XmlListModel | |
3 | ||
5e60fd91 TB |
4 | import tlb.core 1.0 |
5 | import "qrc:/tlb/ui/qml/templates" | |
6 | /* import tlb.ui 1.0 */ | |
8f661e5c TB |
7 | |
8 | /* This view provides a summary of all podcasts. */ | |
9 | ||
10 | /* Sorting modes: | |
11 | * - marked favorite | |
12 | * - alphabetical | |
13 | * - most recent updated | |
14 | * - most unlistened | |
15 | * - most recently listened | |
16 | * - most episodes listened | |
17 | * - least episodes listened | |
18 | * - recently added | |
19 | * - added longest ago | |
20 | * - most hours available | |
21 | * - shortest average episode | |
22 | * - longest average episode | |
23 | */ | |
24 | ||
25 | /* with this fake data, provide a condensed list */ | |
26 | Page { | |
321b1d72 TB |
27 | pageTitle: "Summary" |
28 | ||
8f661e5c TB |
29 | content: Item { |
30 | id: root | |
31 | ||
32 | /* TODO: property holds fake data in it. */ | |
33 | /* readonly property var podcastNames: [ */ | |
34 | /* "pete q", */ | |
35 | /* "tom woods", */ | |
36 | /* "liberty report", */ | |
37 | /* "bob murphy", */ | |
38 | /* "buck johnson", */ | |
39 | /* "ancient faith" */ | |
40 | /* ] */ | |
41 | ||
42 | /* Load the real data from xml */ | |
43 | XmlListModel { | |
44 | id: epModel | |
45 | source: "file:///home/tlb/dev/git/android-qt-sandbox/example-data/collection_opml.xml" | |
46 | query: "/opml/body/outline/outline" | |
47 | XmlListModelRole { name: "title" | |
48 | attributeName: "text" } | |
49 | XmlListModelRole { name: "url" | |
50 | attributeName: "xmlUrl" } | |
51 | } | |
52 | ||
321b1d72 TB |
53 | property bool pressDown: false |
54 | property real curMouseX: 0.0 | |
55 | property real curMouseY: 0.0 | |
56 | property real jumpPos: 0.0 | |
1605f832 | 57 | /* property alias showBox: selector.visible */ |
321b1d72 TB |
58 | property string selectedTitle: "" |
59 | property string selectedUrl: "" | |
60 | ||
61 | function _common_released() | |
62 | { | |
63 | if(selectedTitle !== ""){ | |
64 | AppManager.shows.selectedName = selectedTitle | |
65 | AppManager.shows.selected = selectedUrl; | |
5e60fd91 | 66 | AppManager.requestNewSource("qrc:/tlb/ui/qml/views/Show.qml") |
321b1d72 TB |
67 | } |
68 | } | |
69 | ||
8f661e5c TB |
70 | Column { |
71 | id: col | |
72 | ||
321b1d72 TB |
73 | anchors{ |
74 | top: parent.top | |
75 | left: parent.left | |
76 | right: parent.right | |
77 | margins: 20 | |
78 | } | |
8f661e5c TB |
79 | spacing: 3 |
80 | Repeater { | |
8f661e5c TB |
81 | model: epModel |
82 | Rectangle { | |
321b1d72 TB |
83 | id: rec |
84 | ||
85 | implicitHeight: t.height | |
8f661e5c | 86 | width: col.width |
321b1d72 TB |
87 | |
88 | property bool isHovered: { | |
89 | if(root.pressDown){ | |
90 | var pnt = root.mapToItem(rec, root.curMouseX, root.curMouseY) | |
91 | ||
92 | if(rec.contains(pnt)){ | |
93 | return true | |
94 | } | |
95 | } | |
96 | return false | |
8f661e5c TB |
97 | } |
98 | ||
321b1d72 TB |
99 | onIsHoveredChanged:{ |
100 | if(isHovered){ | |
101 | var myMiddle = rec.height / 2 | |
102 | var newPoint = mapToItem(col, 0, myMiddle) | |
103 | jumpPos = newPoint.y | |
1605f832 | 104 | /* showBox = true */ |
321b1d72 TB |
105 | selectedTitle = title |
106 | selectedUrl = url | |
107 | }else if(selectedTitle === title){ | |
108 | console.error(title + " no longer hovered") | |
1605f832 | 109 | /* showBox = false */ |
321b1d72 TB |
110 | selectedTitle = "" |
111 | selectedUrl = "" | |
8f661e5c | 112 | } |
8f661e5c TB |
113 | } |
114 | ||
321b1d72 TB |
115 | border { |
116 | color: isHovered ? "red" : "black" | |
117 | width: 1 | |
118 | } | |
119 | ||
120 | Text { | |
121 | id: t | |
122 | anchors { | |
123 | left: parent.left | |
124 | leftMargin: 5 | |
125 | verticalCenter: parent.verticalCenter | |
8f661e5c | 126 | } |
321b1d72 | 127 | text: title |
8f661e5c TB |
128 | } |
129 | } | |
130 | } | |
131 | } | |
321b1d72 TB |
132 | |
133 | Rectangle { | |
134 | id: selector | |
135 | anchors { | |
136 | right: col.right | |
137 | } | |
138 | ||
139 | /* init - can't be assed but this is magic */ | |
140 | y: jumpPos - 16 | |
141 | visible: false | |
142 | ||
143 | color: "purple" | |
144 | width: 70 | |
145 | height: 70 | |
146 | border { | |
147 | width: 1 | |
148 | color: "yellow" | |
149 | } | |
150 | } | |
151 | ||
152 | MouseArea { | |
153 | anchors.fill: parent | |
154 | onPositionChanged: (mouse)=> { | |
155 | root.curMouseX = mouse.x | |
156 | root.curMouseY = mouse.y | |
157 | } | |
158 | onPressed: (mouse)=> { | |
159 | root.pressDown = true | |
160 | root.curMouseX = mouse.x | |
161 | root.curMouseY = mouse.y | |
162 | } | |
163 | onReleased: (mouse)=> { | |
164 | console.error("main release event") | |
165 | ||
166 | /* at this moment, check who is in control */ | |
167 | _common_released() | |
168 | ||
169 | root.pressDown = false | |
170 | root.curMouseX = mouse.x | |
171 | root.curMouseY = mouse.y | |
172 | } | |
173 | } | |
8f661e5c TB |
174 | } |
175 | } |