From 3554fb99cd1f467df7cdf9ed24f8aacd811cc9d9 Mon Sep 17 00:00:00 2001 From: wubixiaozhu Date: Sat, 27 Apr 2024 09:40:37 +0800 Subject: [PATCH 1/5] Add the functionality to insert new rows into the table --- example/example_en_US.ts | 26 ++++++++++++++++++-------- example/example_zh_CN.ts | 26 ++++++++++++++++++-------- example/qml/page/T_TableView.qml | 30 ++++++++++++++++++++++-------- 3 files changed, 58 insertions(+), 24 deletions(-) diff --git a/example/example_en_US.ts b/example/example_en_US.ts index 1bdac57a..ceabe270 100644 --- a/example/example_en_US.ts +++ b/example/example_en_US.ts @@ -1968,7 +1968,7 @@ Some contents... - + Name @@ -1998,37 +1998,47 @@ Some contents... - + + Insert a Row + + + + + Focus not acquired: Please click any item in the form as the target for insertion! + + + + Avatar - + Address - + Nickname - + Long String - + Options - + <Previous - + Next> diff --git a/example/example_zh_CN.ts b/example/example_zh_CN.ts index 4ba2c182..c86300be 100644 --- a/example/example_zh_CN.ts +++ b/example/example_zh_CN.ts @@ -2110,7 +2110,7 @@ Some contents... - + Name 名称 @@ -2140,37 +2140,47 @@ Some contents... 清除所有 - + + Insert a Row + 插入一行 + + + + Focus not acquired: Please click any item in the form as the target for insertion! + 焦点未获取:请点击表格中的任意一项,作为插入的靶点! + + + Avatar 头像 - + Address 地址 - + Nickname 昵称 - + Long String 长字符串 - + Options 操作 - + <Previous <上一页 - + Next> 下一页> diff --git a/example/qml/page/T_TableView.qml b/example/qml/page/T_TableView.qml index 27059281..b309c369 100644 --- a/example/qml/page/T_TableView.qml +++ b/example/qml/page/T_TableView.qml @@ -13,7 +13,7 @@ FluContentPage{ property var dataSource : [] property int sortType: 0 - property bool seletedAll: true + property bool selectedAll: true property string nameKeyword: "" onNameKeywordChanged: { @@ -32,11 +32,11 @@ FluContentPage{ onCheckBoxChanged: { for(var i =0;i< table_view.rows ;i++){ if(false === table_view.getRow(i).checkbox.options.checked){ - root.seletedAll = false + root.selectedAll = false return } } - root.seletedAll = true + root.selectedAll = true } onSortTypeChanged: { @@ -238,12 +238,12 @@ FluContentPage{ Layout.alignment: Qt.AlignVCenter } FluCheckBox{ - checked: true === root.seletedAll + checked: true === root.selectedAll animationEnabled: false Layout.alignment: Qt.AlignVCenter clickListener: function(){ - root.seletedAll = !root.seletedAll - var checked = root.seletedAll + root.selectedAll = !root.selectedAll + var checked = root.selectedAll itemModel.display = table_view.customItem(com_column_checbox,{"checked":checked}) for(var i =0;i< table_view.rows ;i++){ var rowData = table_view.getRow(i) @@ -466,6 +466,20 @@ FluContentPage{ table_view.appendRow(genTestObject()) } } + FluButton{ + text: qsTr("Insert a Row") + onClicked: { + if(typeof table_view.current !== 'undefined'){ + var newLine = genTestObject() + var currentLine = dataSource.findIndex(obj => obj._key === table_view.current._key) + root.dataSource.splice(currentLine, 0, newLine); + table_view.dataSource = root.dataSource + }else{ + showWarning(qsTr("Focus not acquired: Please click any item in the form as the target for insertion!")) + } + + } + } } } @@ -588,7 +602,7 @@ FluContentPage{ return avatars[randomIndex]; } return { - checkbox: table_view.customItem(com_checbox,{checked:root.seletedAll}), + checkbox: table_view.customItem(com_checbox,{checked:root.selectedAll}), avatar:table_view.customItem(com_avatar,{avatar:getAvatar()}), name: getRandomName(), age:getRandomAge(), @@ -601,7 +615,7 @@ FluContentPage{ } } function loadData(page,count){ - root.seletedAll = true + root.selectedAll = true const dataSource = [] for(var i=0;i Date: Sat, 27 Apr 2024 11:48:19 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=8E=A7=E4=BB=B6=EF=BC=8C=E9=80=9A=E8=BF=87header?= =?UTF-8?q?=E5=92=8Cfooter=E5=B1=9E=E6=80=A7=E6=B7=BB=E5=8A=A0=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加自定义控件,通过header和footer属性添加控件 --- .../FluentUI/Controls/FluPagination.qml | 211 +++++++++--------- 1 file changed, 111 insertions(+), 100 deletions(-) diff --git a/src/Qt6/imports/FluentUI/Controls/FluPagination.qml b/src/Qt6/imports/FluentUI/Controls/FluPagination.qml index 37f6807d..d350d997 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluPagination.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluPagination.qml @@ -1,100 +1,111 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import FluentUI - -Item { - signal requestPage(int page,int count) - property string previousText: qsTr("") - property int pageCurrent: 0 - property int itemCount: 0 - property int pageButtonCount: 5 - property int pageCount: itemCount>0?Math.ceil(itemCount/__itemPerPage):0 - property int __itemPerPage: 10 - property int __pageButtonHalf: Math.floor(pageButtonCount/2)+1 - id: control - implicitHeight: 40 - implicitWidth: content.width - Row{ - id: content - height: control.height - spacing: 10 - padding: 10 - FluToggleButton{ - visible: control.pageCount>1 - disabled: control.pageCurrent<=1 - text:control.previousText - clickListener:function() { - control.calcNewPage(control.pageCurrent-1); - } - } - Row{ - spacing: 5 - FluToggleButton{ - property int pageNumber:1 - visible: control.pageCount>0 - checked: pageNumber === control.pageCurrent - text:String(pageNumber) - clickListener:function() { - control.calcNewPage(pageNumber); - } - } - FluText{ - visible: (control.pageCount>control.pageButtonCount&& - control.pageCurrent>control.__pageButtonHalf) - text: "..." - } - Repeater{ - id: button_repeator - model: (control.pageCount<2)?0:(control.pageCount>=control.pageButtonCount)?(control.pageButtonCount-2):(control.pageCount-2) - delegate:FluToggleButton{ - property int pageNumber: { - return (control.pageCurrent<=control.__pageButtonHalf) - ?(2+index) - :(control.pageCount-control.pageCurrent<=control.pageButtonCount-control.__pageButtonHalf) - ?(control.pageCount-button_repeator.count+index) - :(control.pageCurrent+2+index-control.__pageButtonHalf) - } - text:String(pageNumber) - checked: pageNumber === control.pageCurrent - clickListener:function(){ - control.calcNewPage(pageNumber); - } - } - } - FluText{ - visible: (control.pageCount>control.pageButtonCount&& - control.pageCount-control.pageCurrent>control.pageButtonCount-control.__pageButtonHalf) - text: "..." - } - FluToggleButton{ - property int pageNumber:control.pageCount - visible: control.pageCount>1 - checked: pageNumber === control.pageCurrent - text:String(pageNumber) - clickListener:function(){ - control.calcNewPage(pageNumber); - } - } - } - FluToggleButton{ - visible: control.pageCount>1 - disabled: control.pageCurrent>=control.pageCount - text:control.nextText - clickListener:function() { - control.calcNewPage(control.pageCurrent+1); - } - } - } - function calcNewPage(page) - { - if(!page) - return - let page_num=Number(page) - if(page_num<1||page_num>control.pageCount||page_num===control.pageCurrent) - return - control.pageCurrent=page_num - control.requestPage(page_num,control.__itemPerPage) - } -} +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import FluentUI + +Item { + signal requestPage(int page, int count) + + property string previousText: qsTr("") + property int pageCurrent: 0 + property int itemCount: 0 + property int pageButtonCount: 5 + 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 + Row { + id: content + height: control.height + spacing: 10 + padding: 10 + Loader { + sourceComponent: header + } + FluToggleButton { + visible: control.pageCount > 1 + disabled: control.pageCurrent <= 1 + text: control.previousText + clickListener: function () { + control.calcNewPage(control.pageCurrent - 1); + } + } + Row { + spacing: 5 + + FluToggleButton { + property int pageNumber: 1 + visible: control.pageCount > 0 + checked: pageNumber === control.pageCurrent + text: String(pageNumber) + clickListener: function () { + control.calcNewPage(pageNumber); + } + } + FluText { + visible: (control.pageCount > control.pageButtonCount && + control.pageCurrent > control.__pageButtonHalf) + text: "..." + } + Repeater { + id: button_repeator + model: (control.pageCount < 2) ? 0 : (control.pageCount >= control.pageButtonCount) ? (control.pageButtonCount - 2) : (control.pageCount - 2) + delegate: FluToggleButton { + property int pageNumber: { + return (control.pageCurrent <= control.__pageButtonHalf) + ? (2 + index) + : (control.pageCount - control.pageCurrent <= control.pageButtonCount - control.__pageButtonHalf) + ? (control.pageCount - button_repeator.count + index) + : (control.pageCurrent + 2 + index - control.__pageButtonHalf) + } + text: String(pageNumber) + checked: pageNumber === control.pageCurrent + clickListener: function () { + control.calcNewPage(pageNumber); + } + } + } + FluText { + visible: (control.pageCount > control.pageButtonCount && + control.pageCount - control.pageCurrent > control.pageButtonCount - control.__pageButtonHalf) + text: "..." + } + FluToggleButton { + property int pageNumber: control.pageCount + visible: control.pageCount > 1 + checked: pageNumber === control.pageCurrent + text: String(pageNumber) + clickListener: function () { + control.calcNewPage(pageNumber); + } + } + } + FluToggleButton { + visible: control.pageCount > 1 + disabled: control.pageCurrent >= control.pageCount + text: control.nextText + clickListener: function () { + control.calcNewPage(control.pageCurrent + 1); + } + } + Loader { + sourceComponent: footer + } + } + + function calcNewPage(page) { + if (!page) + return + let page_num = Number(page) + if (page_num < 1 || page_num > control.pageCount || page_num === control.pageCurrent) + return + control.pageCurrent = page_num + control.requestPage(page_num, control.__itemPerPage) + } + +} From a0d662a8a53f6b5fcbed18299ac6e59356d6ce7b Mon Sep 17 00:00:00 2001 From: w-jt <88316720+w-jt@users.noreply.github.com> Date: Sat, 27 Apr 2024 11:49:29 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=8E=A7=E4=BB=B6=EF=BC=8C=E9=80=9A=E8=BF=87header?= =?UTF-8?q?=E5=92=8Cfooter=E5=B1=9E=E6=80=A7=E6=B7=BB=E5=8A=A0=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加自定义控件,通过header和footer属性添加控件 --- .../FluentUI/Controls/FluPagination.qml | 211 +++++++++--------- 1 file changed, 111 insertions(+), 100 deletions(-) diff --git a/src/Qt5/imports/FluentUI/Controls/FluPagination.qml b/src/Qt5/imports/FluentUI/Controls/FluPagination.qml index a5a155a8..d350d997 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluPagination.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluPagination.qml @@ -1,100 +1,111 @@ -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 1.15 -import FluentUI 1.0 - -Item { - signal requestPage(int page,int count) - property string previousText: qsTr("") - property int pageCurrent: 0 - property int itemCount: 0 - property int pageButtonCount: 5 - property int pageCount: itemCount>0?Math.ceil(itemCount/__itemPerPage):0 - property int __itemPerPage: 10 - property int __pageButtonHalf: Math.floor(pageButtonCount/2)+1 - id: control - implicitHeight: 40 - implicitWidth: content.width - Row{ - id: content - height: control.height - spacing: 10 - padding: 10 - FluToggleButton{ - visible: control.pageCount>1 - disabled: control.pageCurrent<=1 - text:control.previousText - clickListener:function() { - control.calcNewPage(control.pageCurrent-1); - } - } - Row{ - spacing: 5 - FluToggleButton{ - property int pageNumber:1 - visible: control.pageCount>0 - checked: pageNumber === control.pageCurrent - text:String(pageNumber) - clickListener:function() { - control.calcNewPage(pageNumber); - } - } - FluText{ - visible: (control.pageCount>control.pageButtonCount&& - control.pageCurrent>control.__pageButtonHalf) - text: "..." - } - Repeater{ - id: button_repeator - model: (control.pageCount<2)?0:(control.pageCount>=control.pageButtonCount)?(control.pageButtonCount-2):(control.pageCount-2) - delegate:FluToggleButton{ - property int pageNumber: { - return (control.pageCurrent<=control.__pageButtonHalf) - ?(2+index) - :(control.pageCount-control.pageCurrent<=control.pageButtonCount-control.__pageButtonHalf) - ?(control.pageCount-button_repeator.count+index) - :(control.pageCurrent+2+index-control.__pageButtonHalf) - } - text:String(pageNumber) - checked: pageNumber === control.pageCurrent - clickListener:function(){ - control.calcNewPage(pageNumber); - } - } - } - FluText{ - visible: (control.pageCount>control.pageButtonCount&& - control.pageCount-control.pageCurrent>control.pageButtonCount-control.__pageButtonHalf) - text: "..." - } - FluToggleButton{ - property int pageNumber:control.pageCount - visible: control.pageCount>1 - checked: pageNumber === control.pageCurrent - text:String(pageNumber) - clickListener:function(){ - control.calcNewPage(pageNumber); - } - } - } - FluToggleButton{ - visible: control.pageCount>1 - disabled: control.pageCurrent>=control.pageCount - text:control.nextText - clickListener:function() { - control.calcNewPage(control.pageCurrent+1); - } - } - } - function calcNewPage(page) - { - if(!page) - return - let page_num=Number(page) - if(page_num<1||page_num>control.pageCount||page_num===control.pageCurrent) - return - control.pageCurrent=page_num - control.requestPage(page_num,control.__itemPerPage) - } -} +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import FluentUI + +Item { + signal requestPage(int page, int count) + + property string previousText: qsTr("") + property int pageCurrent: 0 + property int itemCount: 0 + property int pageButtonCount: 5 + 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 + Row { + id: content + height: control.height + spacing: 10 + padding: 10 + Loader { + sourceComponent: header + } + FluToggleButton { + visible: control.pageCount > 1 + disabled: control.pageCurrent <= 1 + text: control.previousText + clickListener: function () { + control.calcNewPage(control.pageCurrent - 1); + } + } + Row { + spacing: 5 + + FluToggleButton { + property int pageNumber: 1 + visible: control.pageCount > 0 + checked: pageNumber === control.pageCurrent + text: String(pageNumber) + clickListener: function () { + control.calcNewPage(pageNumber); + } + } + FluText { + visible: (control.pageCount > control.pageButtonCount && + control.pageCurrent > control.__pageButtonHalf) + text: "..." + } + Repeater { + id: button_repeator + model: (control.pageCount < 2) ? 0 : (control.pageCount >= control.pageButtonCount) ? (control.pageButtonCount - 2) : (control.pageCount - 2) + delegate: FluToggleButton { + property int pageNumber: { + return (control.pageCurrent <= control.__pageButtonHalf) + ? (2 + index) + : (control.pageCount - control.pageCurrent <= control.pageButtonCount - control.__pageButtonHalf) + ? (control.pageCount - button_repeator.count + index) + : (control.pageCurrent + 2 + index - control.__pageButtonHalf) + } + text: String(pageNumber) + checked: pageNumber === control.pageCurrent + clickListener: function () { + control.calcNewPage(pageNumber); + } + } + } + FluText { + visible: (control.pageCount > control.pageButtonCount && + control.pageCount - control.pageCurrent > control.pageButtonCount - control.__pageButtonHalf) + text: "..." + } + FluToggleButton { + property int pageNumber: control.pageCount + visible: control.pageCount > 1 + checked: pageNumber === control.pageCurrent + text: String(pageNumber) + clickListener: function () { + control.calcNewPage(pageNumber); + } + } + } + FluToggleButton { + visible: control.pageCount > 1 + disabled: control.pageCurrent >= control.pageCount + text: control.nextText + clickListener: function () { + control.calcNewPage(control.pageCurrent + 1); + } + } + Loader { + sourceComponent: footer + } + } + + function calcNewPage(page) { + if (!page) + return + let page_num = Number(page) + if (page_num < 1 || page_num > control.pageCount || page_num === control.pageCurrent) + return + control.pageCurrent = page_num + control.requestPage(page_num, control.__itemPerPage) + } + +} From 355332da96bd7d95446715c6a5f2de88f604ebcd Mon Sep 17 00:00:00 2001 From: w-jt <88316720+w-jt@users.noreply.github.com> Date: Sat, 27 Apr 2024 11:53:57 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=8E=A7=E4=BB=B6=EF=BC=8C=E9=80=9A=E8=BF=87header?= =?UTF-8?q?=E5=92=8Cfooter=E5=B1=9E=E6=80=A7=E6=B7=BB=E5=8A=A0=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加自定义控件,通过header和footer属性添加控件 --- src/Qt6/imports/FluentUI/Controls/FluPagination.qml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Qt6/imports/FluentUI/Controls/FluPagination.qml b/src/Qt6/imports/FluentUI/Controls/FluPagination.qml index d350d997..91bff6e7 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluPagination.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluPagination.qml @@ -1,7 +1,7 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import FluentUI +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.15 +import FluentUI 1.0 Item { signal requestPage(int page, int count) From 500efa6298059df3dfe85ee847ec1cb1426688bb Mon Sep 17 00:00:00 2001 From: w-jt <88316720+w-jt@users.noreply.github.com> Date: Sat, 27 Apr 2024 11:54:42 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=8E=A7=E4=BB=B6=EF=BC=8C=E9=80=9A=E8=BF=87header?= =?UTF-8?q?=E5=92=8Cfooter=E5=B1=9E=E6=80=A7=E6=B7=BB=E5=8A=A0=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加自定义控件,通过header和footer属性添加控件 --- src/Qt5/imports/FluentUI/Controls/FluPagination.qml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Qt5/imports/FluentUI/Controls/FluPagination.qml b/src/Qt5/imports/FluentUI/Controls/FluPagination.qml index d350d997..acf2d796 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluPagination.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluPagination.qml @@ -1,7 +1,8 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import FluentUI +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 1.15 +import FluentUI 1.0 + Item { signal requestPage(int page, int count)