Compare commits

...

7 Commits

Author SHA1 Message Date
zhuzichu
2d4e61445e
Merge pull request #488 from yanhuacuo/path-for-insertRow
Add the functionality to insert new rows into the table
2024-04-28 10:47:28 +08:00
zhuzichu
cc79854191
Merge pull request #489 from w-jt/main
FluPagination.qml 添加自定义控件,通过header和footer属性添加控件
2024-04-28 10:46:47 +08:00
w-jt
500efa6298
添加自定义控件,通过header和footer属性添加控件
添加自定义控件,通过header和footer属性添加控件
2024-04-27 11:54:42 +08:00
w-jt
355332da96
添加自定义控件,通过header和footer属性添加控件
添加自定义控件,通过header和footer属性添加控件
2024-04-27 11:53:57 +08:00
w-jt
a0d662a8a5
添加自定义控件,通过header和footer属性添加控件
添加自定义控件,通过header和footer属性添加控件
2024-04-27 11:49:29 +08:00
w-jt
aecc3fe3b4
添加自定义控件,通过header和footer属性添加控件
添加自定义控件,通过header和footer属性添加控件
2024-04-27 11:48:19 +08:00
wubixiaozhu
3554fb99cd Add the functionality to insert new rows into the table 2024-04-27 09:40:37 +08:00
5 changed files with 281 additions and 224 deletions

View File

@ -1968,7 +1968,7 @@ Some contents...</source>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="177"/>
<location filename="qml/page/T_TableView.qml" line="499"/>
<location filename="qml/page/T_TableView.qml" line="513"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
@ -1998,37 +1998,47 @@ Some contents...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="494"/>
<location filename="qml/page/T_TableView.qml" line="470"/>
<source>Insert a Row</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="478"/>
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="508"/>
<source>Avatar</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="512"/>
<location filename="qml/page/T_TableView.qml" line="526"/>
<source>Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="520"/>
<location filename="qml/page/T_TableView.qml" line="534"/>
<source>Nickname</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="527"/>
<location filename="qml/page/T_TableView.qml" line="541"/>
<source>Long String</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="535"/>
<location filename="qml/page/T_TableView.qml" line="549"/>
<source>Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="554"/>
<location filename="qml/page/T_TableView.qml" line="568"/>
<source>&lt;Previous</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="555"/>
<location filename="qml/page/T_TableView.qml" line="569"/>
<source>Next&gt;</source>
<translation type="unfinished"></translation>
</message>

View File

@ -2110,7 +2110,7 @@ Some contents...</source>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="177"/>
<location filename="qml/page/T_TableView.qml" line="499"/>
<location filename="qml/page/T_TableView.qml" line="513"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
@ -2140,37 +2140,47 @@ Some contents...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="494"/>
<location filename="qml/page/T_TableView.qml" line="470"/>
<source>Insert a Row</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="478"/>
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="508"/>
<source>Avatar</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="512"/>
<location filename="qml/page/T_TableView.qml" line="526"/>
<source>Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="520"/>
<location filename="qml/page/T_TableView.qml" line="534"/>
<source>Nickname</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="527"/>
<location filename="qml/page/T_TableView.qml" line="541"/>
<source>Long String</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="535"/>
<location filename="qml/page/T_TableView.qml" line="549"/>
<source>Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="554"/>
<location filename="qml/page/T_TableView.qml" line="568"/>
<source>&lt;Previous</source>
<translation type="unfinished">&lt;</translation>
</message>
<message>
<location filename="qml/page/T_TableView.qml" line="555"/>
<location filename="qml/page/T_TableView.qml" line="569"/>
<source>Next&gt;</source>
<translation type="unfinished">&gt;</translation>
</message>

View File

@ -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<count;i++){
dataSource.push(genTestObject())

View File

@ -3,98 +3,110 @@ import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import FluentUI 1.0
Item {
signal requestPage(int page,int count)
signal requestPage(int page, int count)
property string previousText: qsTr("<Previous")
property string nextText: qsTr("Next>")
property int pageCurrent: 0
property int itemCount: 0
property int pageButtonCount: 5
property int pageCount: itemCount>0?Math.ceil(itemCount/__itemPerPage):0
property int pageCount: itemCount > 0 ? Math.ceil(itemCount / __itemPerPage) : 0
property int __itemPerPage: 10
property int __pageButtonHalf: Math.floor(pageButtonCount/2)+1
property int __pageButtonHalf: Math.floor(pageButtonCount / 2) + 1
property Component header: null
property Component footer: null
id: control
implicitHeight: 40
implicitWidth: content.width
Row{
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);
Loader {
sourceComponent: header
}
FluToggleButton {
visible: control.pageCount > 1
disabled: control.pageCurrent <= 1
text: control.previousText
clickListener: function () {
control.calcNewPage(control.pageCurrent - 1);
}
}
Row{
Row {
spacing: 5
FluToggleButton{
property int pageNumber:1
visible: control.pageCount>0
FluToggleButton {
property int pageNumber: 1
visible: control.pageCount > 0
checked: pageNumber === control.pageCurrent
text:String(pageNumber)
clickListener:function() {
text: String(pageNumber)
clickListener: function () {
control.calcNewPage(pageNumber);
}
}
FluText{
visible: (control.pageCount>control.pageButtonCount&&
control.pageCurrent>control.__pageButtonHalf)
FluText {
visible: (control.pageCount > control.pageButtonCount &&
control.pageCurrent > control.__pageButtonHalf)
text: "..."
}
Repeater{
Repeater {
id: button_repeator
model: (control.pageCount<2)?0:(control.pageCount>=control.pageButtonCount)?(control.pageButtonCount-2):(control.pageCount-2)
delegate:FluToggleButton{
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)
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)
text: String(pageNumber)
checked: pageNumber === control.pageCurrent
clickListener:function(){
clickListener: function () {
control.calcNewPage(pageNumber);
}
}
}
FluText{
visible: (control.pageCount>control.pageButtonCount&&
control.pageCount-control.pageCurrent>control.pageButtonCount-control.__pageButtonHalf)
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
FluToggleButton {
property int pageNumber: control.pageCount
visible: control.pageCount > 1
checked: pageNumber === control.pageCurrent
text:String(pageNumber)
clickListener:function(){
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);
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)
function calcNewPage(page) {
if (!page)
return
let page_num=Number(page)
if(page_num<1||page_num>control.pageCount||page_num===control.pageCurrent)
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)
control.pageCurrent = page_num
control.requestPage(page_num, control.__itemPerPage)
}
}

View File

@ -1,100 +1,111 @@
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)
signal requestPage(int page, int count)
property string previousText: qsTr("<Previous")
property string nextText: qsTr("Next>")
property int pageCurrent: 0
property int itemCount: 0
property int pageButtonCount: 5
property int pageCount: itemCount>0?Math.ceil(itemCount/__itemPerPage):0
property int pageCount: itemCount > 0 ? Math.ceil(itemCount / __itemPerPage) : 0
property int __itemPerPage: 10
property int __pageButtonHalf: Math.floor(pageButtonCount/2)+1
property int __pageButtonHalf: Math.floor(pageButtonCount / 2) + 1
property Component header: null
property Component footer: null
id: control
implicitHeight: 40
implicitWidth: content.width
Row{
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);
Loader {
sourceComponent: header
}
FluToggleButton {
visible: control.pageCount > 1
disabled: control.pageCurrent <= 1
text: control.previousText
clickListener: function () {
control.calcNewPage(control.pageCurrent - 1);
}
}
Row{
Row {
spacing: 5
FluToggleButton{
property int pageNumber:1
visible: control.pageCount>0
FluToggleButton {
property int pageNumber: 1
visible: control.pageCount > 0
checked: pageNumber === control.pageCurrent
text:String(pageNumber)
clickListener:function() {
text: String(pageNumber)
clickListener: function () {
control.calcNewPage(pageNumber);
}
}
FluText{
visible: (control.pageCount>control.pageButtonCount&&
control.pageCurrent>control.__pageButtonHalf)
FluText {
visible: (control.pageCount > control.pageButtonCount &&
control.pageCurrent > control.__pageButtonHalf)
text: "..."
}
Repeater{
Repeater {
id: button_repeator
model: (control.pageCount<2)?0:(control.pageCount>=control.pageButtonCount)?(control.pageButtonCount-2):(control.pageCount-2)
delegate:FluToggleButton{
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)
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)
text: String(pageNumber)
checked: pageNumber === control.pageCurrent
clickListener:function(){
clickListener: function () {
control.calcNewPage(pageNumber);
}
}
}
FluText{
visible: (control.pageCount>control.pageButtonCount&&
control.pageCount-control.pageCurrent>control.pageButtonCount-control.__pageButtonHalf)
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
FluToggleButton {
property int pageNumber: control.pageCount
visible: control.pageCount > 1
checked: pageNumber === control.pageCurrent
text:String(pageNumber)
clickListener:function(){
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);
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)
function calcNewPage(page) {
if (!page)
return
let page_num=Number(page)
if(page_num<1||page_num>control.pageCount||page_num===control.pageCurrent)
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)
control.pageCurrent = page_num
control.requestPage(page_num, control.__itemPerPage)
}
}