添加自定义控件,通过header和footer属性添加控件

添加自定义控件,通过header和footer属性添加控件
This commit is contained in:
w-jt 2024-04-27 11:48:19 +08:00 committed by GitHub
parent 24fdff7e35
commit aecc3fe3b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,6 +5,7 @@ import FluentUI
Item {
signal requestPage(int page, int count)
property string previousText: qsTr("<Previous")
property string nextText: qsTr("Next>")
property int pageCurrent: 0
@ -13,6 +14,8 @@ Item {
property int pageCount: itemCount > 0 ? Math.ceil(itemCount / __itemPerPage) : 0
property int __itemPerPage: 10
property int __pageButtonHalf: Math.floor(pageButtonCount / 2) + 1
property Component header: null
property Component footer: null
id: control
implicitHeight: 40
implicitWidth: content.width
@ -21,6 +24,9 @@ Item {
height: control.height
spacing: 10
padding: 10
Loader {
sourceComponent: header
}
FluToggleButton {
visible: control.pageCount > 1
disabled: control.pageCurrent <= 1
@ -31,6 +37,7 @@ Item {
}
Row {
spacing: 5
FluToggleButton {
property int pageNumber: 1
visible: control.pageCount > 0
@ -86,9 +93,12 @@ Item {
control.calcNewPage(control.pageCurrent + 1);
}
}
Loader {
sourceComponent: footer
}
function calcNewPage(page)
{
}
function calcNewPage(page) {
if (!page)
return
let page_num = Number(page)
@ -97,4 +107,5 @@ Item {
control.pageCurrent = page_num
control.requestPage(page_num, control.__itemPerPage)
}
}