Try to use recycler on entrylistdelegate

This commit is contained in:
Bart De Vries 2021-04-06 12:46:01 +02:00
parent 8506068b1f
commit ddb64c5f42
2 changed files with 25 additions and 17 deletions

View File

@ -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 <author(s)>", "by") + " " + model.entry.authors[0].name)
text: entry.updated.toLocaleString(Qt.locale(), Locale.ShortFormat) + (entry.authors.length === 0 ? "" : " " + i18nc("by <author(s)>", "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
}
]
}

View File

@ -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 { }
}
}