git.iko.soy/maciek134/podphoenix
on main help sign in
Converted all listview listitems to listitemlayout
commita9828db177caceabf16c50178a5f5a4e0f92eb76 authorNekhelesh Ramananthan <krnekhelesh@gmail.com> dateWed 24 Feb 2016, 16:56 (11 years ago) parent1949c22
4 files changed+203−105
app/ui/EpisodesPage.qml+43−17 app/ui/SearchPage.qml+80−38 app/ui/WhatsNewTab.qml+45−15 po/com.mikeasoft.podbird.pot+35−35
app/ui/EpisodesPage.qml+43−17
@@ -22,8 +22,7 @@ import Ubuntu.Components 1.3
2222import QtQuick.Layouts 1.1
2323import QtQuick.LocalStorage 2.0
2424import Ubuntu.DownloadManager 0.1
25−import Ubuntu.Components.Popups 1.0
26−import Ubuntu.Components.ListItems 1.0 as ListItem
25+import Ubuntu.Components.Popups 1.3
2726import "../podcasts.js" as Podcasts
2827import "../components"
2928
@@ -297,8 +296,8 @@ Page {
297296
298297 anchors.fill: parent
299298 model: sortedEpisodeModel
300−
301− clip: true
299+ currentIndex: -1
300+ clip: true
302301
303302 header: Column {
304303 height: blurredBackground.height + modeTabs.height + units.gu(2)
@@ -444,25 +443,52 @@ Page {
444443 height: units.gu(8)
445444 }
446445
447− delegate: ListDelegate {
446+ delegate: ListItem {
448447 id: listItem
449448
450− title: model.name !== undefined ? model.name.trim() : "Undefined"
451− titleColor: listItem.expanded || currentGuid === model.guid || downloader.downloadingGuid === model.guid ? podbird.appTheme.focusText
452− : podbird.appTheme.baseText
453−
454− subtitle: model.duration === 0 || model.duration === undefined ? Qt.formatDate(new Date(model.published), "MMM d, yyyy") : Podcasts.formatEpisodeTime(model.duration) + " | " + Qt.formatDate(new Date(model.published), "MMM d, yyyy")
449+ divider.visible: false
450+ highlightColor: "Transparent"
451+ height: visible ? listItemLayout.height + progressBarLoader.height + units.gu(1) : 0
452+ color: index % 2 === 0 ? podbird.appTheme.hightlightListView : "Transparent"
455453
456− isDownloaded: model.downloadedfile ? true : false
457− showProgressBar: downloader.downloadingGuid === model.guid
458− isInDeterminateDownload: downloader.progress < 0 || downloader.progress > 100 && downloader.downloadingGuid === model.guid
459− progress: downloader.progress
460454 visible: episodesPage.mode == "listened" ? model.listened
461455 : (episodesPage.mode == "unheard" ? !model.listened
462− : isDownloaded)
463− height: visible ? undefined : 0
456+ : model.downloadedfile)
464457
465− color: index % 2 === 0 ? podbird.appTheme.hightlightListView : "Transparent"
458+ ListItemLayout {
459+ id: listItemLayout
460+
461+ title.text: model.name !== undefined ? model.name.trim() : "Undefined"
462+ title.color: currentGuid === model.guid || downloader.downloadingGuid === model.guid ? podbird.appTheme.focusText
463+ : podbird.appTheme.baseText
464+ // #FIXME: Change this 2 to prevent title eliding when UITK is updated to rev > 1800
465+ title.maximumLineCount: 1
466+
467+ subtitle.text: model.duration === 0 || model.duration === undefined ? model.downloadedfile ? "📎 " + Qt.formatDate(new Date(model.published), "MMM d, yyyy")
468+ : Qt.formatDate(new Date(model.published), "MMM d, yyyy")
469+ : model.downloadedfile ? "📎 " + Podcasts.formatEpisodeTime(model.duration) + " | " + Qt.formatDate(new Date(model.published), "MMM d, yyyy")
470+ : Podcasts.formatEpisodeTime(model.duration) + " | " + Qt.formatDate(new Date(model.published), "MMM d, yyyy")
471+ subtitle.color: podbird.appTheme.baseSubText
472+
473+ padding.top: units.gu(1)
474+ padding.bottom: units.gu(0.5)
475+ }
476+
477+ Loader {
478+ id: progressBarLoader
479+ anchors { top: listItemLayout.bottom; left: parent.left; right: parent.right; leftMargin: units.gu(2); rightMargin: units.gu(2) }
480+ height: downloader.downloadingGuid === model.guid ? units.dp(5) : 0
481+ visible: sourceComponent !== undefined
482+ sourceComponent: downloader.downloadingGuid === model.guid ? progressBar : undefined
483+ }
484+
485+ Component {
486+ id: progressBar
487+ CustomProgressBar {
488+ indeterminateProgress: downloader.progress < 0 || downloader.progress > 100 && downloader.downloadingGuid === model.guid
489+ progress: downloader.progress
490+ }
491+ }
466492
467493 trailingActions: ListItemActions {
468494 actions: [
app/ui/SearchPage.qml+80−38
@@ -20,7 +20,7 @@ import QtQuick 2.4
2020import QtQuick.Layouts 1.1
2121import Ubuntu.Components 1.3
2222import QtQuick.LocalStorage 2.0
23−import Ubuntu.Components.Popups 1.0
23+import Ubuntu.Components.Popups 1.3
2424import "../podcasts.js" as Podcasts
2525import "../components"
2626
@@ -243,43 +243,91 @@ Page {
243243 height: units.gu(7)
244244 }
245245
246− delegate: ListDelegate {
246+ delegate: ListItem {
247247 id: listItem
248248
249249 property bool fetchedDescription: false
250+ property bool expanded: false
250251
251− title: model.name
252− subtitle: model.artist
253− coverArt: model.image
254−
255− // TRANSLATORS: The first argument here is the date of when the podcast was last updated followed by
256− // the podcast description.
257− description: i18n.tr("Last Updated: %1\n%2").arg(model.releaseDate.split("T")[0]).arg(model.description)
258− highlightColor: index % 2 === 0 ? "Transparent" : podbird.appTheme.hightlightListView
259−
260− buttonColor: !model.subscribed ? UbuntuColors.green : UbuntuColors.red
261− buttonText: !model.subscribed ? i18n.tr("Subscribe") : i18n.tr("Unsubscribe")
262− onButtonClicked: {
263− if (!model.subscribed) {
264− Podcasts.subscribe(model.artist, model.name, model.feed, model.image);
265− imageDownloader.feed = model.feed;
266− imageDownloader.download(model.image);
267− } else {
268− var db = Podcasts.init();
269− db.transaction(function (tx) {
270− var rs = tx.executeSql("SELECT rowid FROM Podcast WHERE feed = ?", model.feed);
271− if (rs.rows.length !== 0) {
272− var podcast = rs.rows.item(0)
273− var rs2 = tx.executeSql("SELECT downloadedfile FROM Episode WHERE downloadedfile NOT NULL AND podcast=?", [podcast.rowid]);
274− for(var i = 0; i < rs2.rows.length; i++) {
275− fileManager.deleteFile(rs2.rows.item(i).downloadedfile);
276− }
277− tx.executeSql("DELETE FROM Episode WHERE podcast=?", [podcast.rowid]);
278− tx.executeSql("DELETE FROM Podcast WHERE rowid=?", [podcast.rowid]);
252+ divider.visible: false
253+ highlightColor: "Transparent"
254+ height: expanded ? listItemLayout.height + descriptionLoader.height + units.gu(1) : listItemLayout.height + units.gu(0.5)
255+ color: index % 2 === 0 ? podbird.appTheme.hightlightListView : "Transparent"
256+
257+ ListItemLayout {
258+ id: listItemLayout
259+
260+ title.text: model.name
261+
262+ subtitle.text: model.artist
263+ subtitle.color: podbird.appTheme.baseSubText
264+
265+ padding.top: units.gu(1)
266+ padding.bottom: units.gu(0.5)
267+
268+ Image {
269+ height: width
270+ width: units.gu(6)
271+ source: model.image
272+ SlotsLayout.position: SlotsLayout.Leading
273+ sourceSize { width: width; height: height }
274+ }
275+
276+ Button {
277+ SlotsLayout.position: SlotsLayout.Trailing
278+ color: !model.subscribed ? UbuntuColors.green : UbuntuColors.red
279+ text: !model.subscribed ? i18n.tr("Subscribe") : i18n.tr("Unsubscribe")
280+ onClicked: {
281+ if (!model.subscribed) {
282+ Podcasts.subscribe(model.artist, model.name, model.feed, model.image);
283+ imageDownloader.feed = model.feed;
284+ imageDownloader.download(model.image);
285+ } else {
286+ var db = Podcasts.init();
287+ db.transaction(function (tx) {
288+ var rs = tx.executeSql("SELECT rowid FROM Podcast WHERE feed = ?", model.feed);
289+ if (rs.rows.length !== 0) {
290+ var podcast = rs.rows.item(0)
291+ var rs2 = tx.executeSql("SELECT downloadedfile FROM Episode WHERE downloadedfile NOT NULL AND podcast=?", [podcast.rowid]);
292+ for(var i = 0; i < rs2.rows.length; i++) {
293+ fileManager.deleteFile(rs2.rows.item(i).downloadedfile);
294+ }
295+ tx.executeSql("DELETE FROM Episode WHERE podcast=?", [podcast.rowid]);
296+ tx.executeSql("DELETE FROM Podcast WHERE rowid=?", [podcast.rowid]);
297+ }
298+ });
279299 }
280− });
300+ tabs.selectedTabIndex = 1;
301+ }
302+ }
303+ }
304+
305+ Loader {
306+ id: descriptionLoader
307+ anchors { top: listItemLayout.bottom; left: parent.left; right: parent.right; leftMargin: units.gu(2); rightMargin: units.gu(2) }
308+ visible: sourceComponent !== undefined
309+ sourceComponent: expanded ? _description : undefined
310+ }
311+
312+ Component {
313+ id: _description
314+ Label {
315+ clip: true
316+ // TRANSLATORS: The first argument here is the date of when the podcast was last updated followed by
317+ // the podcast description.
318+ text: i18n.tr("Last Updated: %1\n%2").arg(model.releaseDate.split("T")[0]).arg(model.description)
319+ wrapMode: Text.WordWrap
320+ fontSize: "small"
321+ color: podbird.appTheme.baseSubText
322+ linkColor: podbird.appTheme.linkText
323+ height: expanded ? contentHeight : 0
324+ onLinkActivated: Qt.openUrlExternally(link)
325+ Behavior on height {
326+ UbuntuNumberAnimation {
327+ duration: UbuntuAnimation.BriskDuration
328+ }
329+ }
281330 }
282− tabs.selectedTabIndex = 1;
283331 }
284332
285333 onClicked: {
@@ -291,12 +339,6 @@ Page {
291339 }
292340 }
293341
294− // #FIXME: Use SDK Scrollbar when it is themeable
295− CustomScrollBar {
296− listview: resultsView
297− }
298− }
299−
300342 ListModel {
301343 id: searchResults
302344 }
app/ui/WhatsNewTab.qml+45−15
@@ -4,8 +4,7 @@ import Ubuntu.Components 1.3
44import QtQuick.Layouts 1.1
55import QtQuick.LocalStorage 2.0
66import Ubuntu.DownloadManager 0.1
7−import Ubuntu.Components.Popups 1.0
8−import Ubuntu.Components.ListItems 1.0 as ListItem
7+import Ubuntu.Components.Popups 1.3
98import "../podcasts.js" as Podcasts
109import "../components"
1110
@@ -296,25 +295,56 @@ Tab {
296295 height: units.gu(8)
297296 }
298297
299− delegate: ListDelegate {
298+ delegate: ListItem {
300299 id: listItem
301300
302− coverArt: model.image !== undefined ? model.image : Qt.resolvedUrl("../graphics/podbird.png")
303−
304− title: model.name !== undefined ? model.name.trim() : "Undefined"
305− titleColor: expanded || currentGuid === model.guid || downloader.downloadingGuid === model.guid ? podbird.appTheme.focusText
306− : podbird.appTheme.baseText
301+ divider.visible: false
302+ highlightColor: "Transparent"
303+ height: downloader.downloadingGuid === model.guid ? listItemLayout.height + progressBarLoader.height + units.gu(1) : listItemLayout.height + units.gu(0.5)
304+ color: index % 2 === 0 ? podbird.appTheme.hightlightListView : "Transparent"
307305
308− subtitle: model.duration === 0 || model.duration === undefined ? model.artist
309− : Podcasts.formatEpisodeTime(model.duration) + " | " + model.artist
306+ ListItemLayout {
307+ id: listItemLayout
308+
309+ title.text: model.name !== undefined ? model.name.trim() : "Undefined"
310+ title.color: currentGuid === model.guid || downloader.downloadingGuid === model.guid ? podbird.appTheme.focusText
311+ : podbird.appTheme.baseText
312+ // #FIXME: Change this 2 to prevent title eliding when UITK is updated to rev > 1800
313+ title.maximumLineCount: 1
314+
315+ subtitle.text: model.duration === 0 || model.duration === undefined ? model.downloadedfile ? "📎 " + model.artist
316+ : model.artist
317+ : model.downloadedfile ? "📎 " + Podcasts.formatEpisodeTime(model.duration) + " | " + model.artist
318+ : Podcasts.formatEpisodeTime(model.duration) + " | " + model.artist
319+ subtitle.color: podbird.appTheme.baseSubText
320+
321+ Image {
322+ height: width
323+ width: units.gu(6)
324+ source: model.image !== undefined ? model.image : Qt.resolvedUrl("../graphics/podbird.png")
325+ SlotsLayout.position: SlotsLayout.Leading
326+ sourceSize { width: width; height: height }
327+ }
310328
311− isDownloaded: model.downloadedfile ? true : false
329+ padding.top: units.gu(1)
330+ padding.bottom: units.gu(0.5)
331+ }
312332
313− showProgressBar: downloader.downloadingGuid === model.guid
314− isInDeterminateDownload: downloader.progress < 0 || downloader.progress > 100 && downloader.downloadingGuid === model.guid
315− progress: downloader.progress
333+ Loader {
334+ id: progressBarLoader
335+ anchors { top: listItemLayout.bottom; left: parent.left; right: parent.right; leftMargin: units.gu(2); rightMargin: units.gu(2) }
336+ height: sourceComponent !== undefined ? units.dp(5) : 0
337+ visible: sourceComponent !== undefined
338+ sourceComponent: downloader.downloadingGuid === model.guid ? progressBar : undefined
339+ }
316340
317− color: index % 2 === 0 ? podbird.appTheme.hightlightListView : "Transparent"
341+ Component {
342+ id: progressBar
343+ CustomProgressBar {
344+ indeterminateProgress: downloader.progress < 0 || downloader.progress > 100 && downloader.downloadingGuid === model.guid
345+ progress: downloader.progress
346+ }
347+ }
318348
319349 trailingActions: ListItemActions {
320350 actions: [
po/com.mikeasoft.podbird.pot+35−35
@@ -8,7 +8,7 @@ msgid ""
88msgstr ""
99"Project-Id-Version: \n"
1010"Report-Msgid-Bugs-To: \n"
11−"POT-Creation-Date: 2016-02-24 16:17+0530\n"
11+"POT-Creation-Date: 2016-02-24 20:49+0530\n"
1212"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,7 +18,7 @@ msgstr ""
1818"Content-Transfer-Encoding: 8bit\n"
1919"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
2020
21−#: ../app/components/TabsList.qml:11 ../app/ui/WhatsNewTab.qml:32
21+#: ../app/components/TabsList.qml:11 ../app/ui/WhatsNewTab.qml:31
2222msgid "What's New"
2323msgstr ""
2424
@@ -143,7 +143,7 @@ msgstr ""
143143#: ../app/settings/DownloadSetting.qml:34
144144#: ../app/settings/DownloadSetting.qml:35
145145#: ../app/settings/DownloadSetting.qml:36
146−#: ../app/settings/DownloadSetting.qml:37 ../app/ui/EpisodesPage.qml:350
146+#: ../app/settings/DownloadSetting.qml:37 ../app/ui/EpisodesPage.qml:349
147147#, qt-format
148148msgid "%1 episode"
149149msgid_plural "%1 episodes"
@@ -164,69 +164,69 @@ msgstr ""
164164msgid "Dark"
165165msgstr ""
166166
167−#: ../app/ui/EpisodesPage.qml:34
167+#: ../app/ui/EpisodesPage.qml:33
168168msgid "Podcast"
169169msgstr ""
170170
171−#: ../app/ui/EpisodesPage.qml:75 ../app/ui/WhatsNewTab.qml:46
171+#: ../app/ui/EpisodesPage.qml:74 ../app/ui/WhatsNewTab.qml:45
172172msgid "Search Episode"
173173msgstr ""
174174
175−#: ../app/ui/EpisodesPage.qml:84 ../app/ui/WhatsNewTab.qml:55
175+#: ../app/ui/EpisodesPage.qml:83 ../app/ui/WhatsNewTab.qml:54
176176msgid "Mark all listened"
177177msgstr ""
178178
179−#: ../app/ui/EpisodesPage.qml:95 ../app/ui/EpisodesPage.qml:189
180−#: ../app/ui/SearchPage.qml:261
179+#: ../app/ui/EpisodesPage.qml:94 ../app/ui/EpisodesPage.qml:188
180+#: ../app/ui/SearchPage.qml:279
181181msgid "Unsubscribe"
182182msgstr ""
183183
184−#: ../app/ui/EpisodesPage.qml:112 ../app/ui/EpisodesPage.qml:206
184+#: ../app/ui/EpisodesPage.qml:111 ../app/ui/EpisodesPage.qml:205
185185#: ../app/ui/PodcastsTab.qml:93 ../app/ui/SearchPage.qml:94
186186#: ../app/ui/SearchPage.qml:132 ../app/ui/SettingsPage.qml:83
187−#: ../app/ui/SettingsPage.qml:118 ../app/ui/WhatsNewTab.qml:105
187+#: ../app/ui/SettingsPage.qml:118 ../app/ui/WhatsNewTab.qml:104
188188msgid "Cancel"
189189msgstr ""
190190
191−#: ../app/ui/EpisodesPage.qml:141 ../app/ui/WhatsNewTab.qml:118
191+#: ../app/ui/EpisodesPage.qml:140 ../app/ui/WhatsNewTab.qml:117
192192msgid "Search episode"
193193msgstr ""
194194
195−#: ../app/ui/EpisodesPage.qml:186
195+#: ../app/ui/EpisodesPage.qml:185
196196msgid "Unsubscribe Confirmation"
197197msgstr ""
198198
199−#: ../app/ui/EpisodesPage.qml:187
199+#: ../app/ui/EpisodesPage.qml:186
200200#, qt-format
201201msgid "Are you sure you want to unsubscribe from <b>%1</b>?"
202202msgstr ""
203203
204−#: ../app/ui/EpisodesPage.qml:228 ../app/ui/WhatsNewTab.qml:220
204+#: ../app/ui/EpisodesPage.qml:227 ../app/ui/WhatsNewTab.qml:219
205205msgid "Episode Description"
206206msgstr ""
207207
208−#: ../app/ui/EpisodesPage.qml:240 ../app/ui/SearchPage.qml:181
209−#: ../app/ui/WhatsNewTab.qml:232
208+#: ../app/ui/EpisodesPage.qml:239 ../app/ui/SearchPage.qml:181
209+#: ../app/ui/WhatsNewTab.qml:231
210210msgid "Close"
211211msgstr ""
212212
213−#: ../app/ui/EpisodesPage.qml:270
213+#: ../app/ui/EpisodesPage.qml:269
214214msgid "No episodes found"
215215msgstr ""
216216
217−#: ../app/ui/EpisodesPage.qml:271
217+#: ../app/ui/EpisodesPage.qml:270
218218msgid "No episodes found matching the search term."
219219msgstr ""
220220
221−#: ../app/ui/EpisodesPage.qml:367
221+#: ../app/ui/EpisodesPage.qml:366
222222msgid "Unheard"
223223msgstr ""
224224
225−#: ../app/ui/EpisodesPage.qml:394
225+#: ../app/ui/EpisodesPage.qml:393
226226msgid "Listened"
227227msgstr ""
228228
229−#: ../app/ui/EpisodesPage.qml:419
229+#: ../app/ui/EpisodesPage.qml:418
230230msgid "Downloaded"
231231msgstr ""
232232
@@ -325,20 +325,20 @@ msgid ""
325325"Click the 'magnifier' at the top to search or the 'plus' button to add by URL"
326326msgstr ""
327327
328+#: ../app/ui/SearchPage.qml:279
329+msgid "Subscribe"
330+msgstr ""
331+
328332#. TRANSLATORS: The first argument here is the date of when the podcast was last updated followed by
329333#. the podcast description.
330−#: ../app/ui/SearchPage.qml:257
334+#: ../app/ui/SearchPage.qml:318
331335#, qt-format
332336msgid ""
333337"Last Updated: %1\n"
334338"%2"
335339msgstr ""
336340
337−#: ../app/ui/SearchPage.qml:261
338−msgid "Subscribe"
339−msgstr ""
340−
341−#: ../app/ui/SearchPage.qml:332
341+#: ../app/ui/SearchPage.qml:428
342342msgid "Not Available"
343343msgstr ""
344344
@@ -405,35 +405,35 @@ msgstr ""
405405msgid "Report Bug"
406406msgstr ""
407407
408−#: ../app/ui/WhatsNewTab.qml:69
408+#: ../app/ui/WhatsNewTab.qml:68
409409msgid "Download all"
410410msgstr ""
411411
412−#: ../app/ui/WhatsNewTab.qml:142
412+#: ../app/ui/WhatsNewTab.qml:141
413413msgid "No New Episodes"
414414msgstr ""
415415
416−#: ../app/ui/WhatsNewTab.qml:142
416+#: ../app/ui/WhatsNewTab.qml:141
417417msgid "No Episodes Found"
418418msgstr ""
419419
420−#: ../app/ui/WhatsNewTab.qml:143
420+#: ../app/ui/WhatsNewTab.qml:142
421421msgid "No more episodes to listen to!"
422422msgstr ""
423423
424−#: ../app/ui/WhatsNewTab.qml:143
424+#: ../app/ui/WhatsNewTab.qml:142
425425msgid "No Episodes found matching the search term."
426426msgstr ""
427427
428−#: ../app/ui/WhatsNewTab.qml:281
428+#: ../app/ui/WhatsNewTab.qml:280
429429msgid "Today"
430430msgstr ""
431431
432−#: ../app/ui/WhatsNewTab.qml:285
432+#: ../app/ui/WhatsNewTab.qml:284
433433msgid "Yesterday"
434434msgstr ""
435435
436−#: ../app/ui/WhatsNewTab.qml:289
436+#: ../app/ui/WhatsNewTab.qml:288
437437msgid "Older"
438438msgstr ""
439439