From ddb64c5f428cc945611cf4bd60c854a4f0410e8a Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Tue, 6 Apr 2021 12:46:01 +0200 Subject: [PATCH] Try to use recycler on entrylistdelegate --- src/qml/EntryListDelegate.qml | 30 +++++++++++++++--------------- src/qml/EntryListPage.qml | 12 ++++++++++-- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/qml/EntryListDelegate.qml b/src/qml/EntryListDelegate.qml index c313bea3..7cbed50a 100644 --- a/src/qml/EntryListDelegate.qml +++ b/src/qml/EntryListDelegate.qml @@ -16,7 +16,7 @@ Kirigami.SwipeListItem { contentItem: RowLayout { Kirigami.Icon { - source: model.entry.image === "" ? "rss" : Fetcher.image(model.entry.image) + source: entry.image === "" ? "rss" : Fetcher.image(entry.image) height: parent.height width: height } @@ -25,10 +25,10 @@ Kirigami.SwipeListItem { Layout.fillWidth: true Layout.alignment: Qt.AlignVCenter Controls.Label { - text: model.entry.title + text: entry.title Layout.fillWidth: true elide: Text.ElideRight - font.weight: model.entry.read ? Font.Normal : Font.Bold + font.weight: entry.read ? Font.Normal : Font.Bold opacity: 1 } Loader { @@ -37,11 +37,11 @@ Kirigami.SwipeListItem { Component { id: subtitle Controls.Label { - text: model.entry.updated.toLocaleString(Qt.locale(), Locale.ShortFormat) + (model.entry.authors.length === 0 ? "" : " " + i18nc("by ", "by") + " " + model.entry.authors[0].name) + text: entry.updated.toLocaleString(Qt.locale(), Locale.ShortFormat) + (entry.authors.length === 0 ? "" : " " + i18nc("by ", "by") + " " + entry.authors[0].name) Layout.fillWidth: true elide: Text.ElideRight font: Kirigami.Theme.smallFont - opacity: model.entry.read ? 0.7 : 0.9 + opacity: entry.read ? 0.7 : 0.9 visible: !downloadProgress.visible } } @@ -50,8 +50,8 @@ Kirigami.SwipeListItem { Controls.ProgressBar { from: 0 to: 100 - value: model.entry.enclosure.downloadProgress - visible: model.entry.enclosure && model.entry.enclosure.status === Enclosure.Downloading + value: entry.enclosure.downloadProgress + visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloading Layout.fillWidth: true } } @@ -60,28 +60,28 @@ Kirigami.SwipeListItem { } onClicked: { - model.entry.read = true - pageStack.push("qrc:/EntryPage.qml", {"entry": model.entry}) + entry.read = true + pageStack.push("qrc:/EntryPage.qml", {"entry": entry}) } actions: [ Kirigami.Action { text: i18n("Download") icon.name: "download" - onTriggered: model.entry.enclosure.download() - visible: model.entry.enclosure && model.entry.enclosure.status === Enclosure.Downloadable + onTriggered: entry.enclosure.download() + visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloadable }, Kirigami.Action { text: i18n("Cancel download") icon.name: "edit-delete-remove" - onTriggered: model.entry.enclosure.cancelDownload() - visible: model.entry.enclosure && model.entry.enclosure.status === Enclosure.Downloading + onTriggered: entry.enclosure.cancelDownload() + visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloading }, Kirigami.Action { text: i18n("Delete download") icon.name: "delete" - onTriggered: model.entry.enclosure.deleteFile() - visible: model.entry.enclosure && model.entry.enclosure.status === Enclosure.Downloaded + onTriggered: entry.enclosure.deleteFile() + visible: entry.enclosure && entry.enclosure.status === Enclosure.Downloaded } ] } diff --git a/src/qml/EntryListPage.qml b/src/qml/EntryListPage.qml index b766f162..2666a64d 100644 --- a/src/qml/EntryListPage.qml +++ b/src/qml/EntryListPage.qml @@ -62,11 +62,21 @@ Kirigami.ScrollablePage { icon.name: feed.errorId === 0 ? "" : "data-error" } + Component { + id: entryListDelegate + EntryListDelegate { } + } + ListView { id: entryList visible: count !== 0 model: page.feed.entries + delegate: Kirigami.DelegateRecycler { + width: entryList.width + sourceComponent: entryListDelegate + } + onOriginYChanged: contentY = originY header: ColumnLayout { @@ -112,7 +122,5 @@ Kirigami.ScrollablePage { } } } - - delegate: EntryListDelegate { } } }