update FluTableView

This commit is contained in:
朱子楚\zhuzi 2024-03-04 11:31:32 +08:00
parent 26311d6342
commit 1baa1ca754
2 changed files with 64 additions and 40 deletions

View File

@ -182,24 +182,22 @@ Rectangle {
ListModel{ ListModel{
id:model_columns id:model_columns
} }
anchors.fill: parent
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
syncView: header_horizontal syncView: header_horizontal
syncDirection: Qt.Horizontal syncDirection: Qt.Horizontal
anchors.fill: parent
ScrollBar.vertical:scroll_bar_v ScrollBar.vertical:scroll_bar_v
rowHeightProvider: function(row) { rowHeightProvider: function(row) {
if(row>=table_view.rows){
return 0
}
var rowObject = control.getRow(row) var rowObject = control.getRow(row)
var h = rowObject.height var height = rowObject.height
if(!h){ if(height){
h = rowObject._minimumHeight return height
} }
if(!h){ var minimumHeight = rowObject._minimumHeight
h = d.defaultItemHeight if(minimumHeight){
return minimumHeight
} }
return h return d.defaultItemHeight
} }
model: table_sort_model model: table_sort_model
clip: true clip: true
@ -442,23 +440,37 @@ Rectangle {
rows: d.header_rows rows: d.header_rows
} }
syncDirection: Qt.Horizontal syncDirection: Qt.Horizontal
anchors.left: layout_mouse_table.left anchors{
anchors.top: parent.top left: header_vertical.right
right: parent.right
top: parent.top
}
visible: control.horizonalHeaderVisible visible: control.horizonalHeaderVisible
implicitWidth: table_view.width height: visible ? Math.max(1, contentHeight) : 0
implicitHeight: visible ? Math.max(1, contentHeight) : 0
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
clip: true clip: true
ScrollBar.horizontal:scroll_bar_h ScrollBar.horizontal:scroll_bar_h
columnWidthProvider: function(column) { columnWidthProvider: function(column) {
var w = columnSource[column].width var columnObject = columnSource[column]
if(!w){ var width = columnObject.width
w = columnSource[column].minimumWidth if(width){
return width
} }
if(!w){ var minimumWidth = columnObject.minimumWidth
w = d.defaultItemWidth if(minimumWidth){
return minimumWidth
}
return d.defaultItemWidth
}
onContentXChanged:{
timer_horizontal_force_layout.restart()
}
Timer{
id:timer_horizontal_force_layout
interval: 50
onTriggered: {
header_horizontal.forceLayout()
} }
return w
} }
delegate: Rectangle { delegate: Rectangle {
id:column_item_control id:column_item_control

View File

@ -183,24 +183,22 @@ Rectangle {
ListModel{ ListModel{
id:model_columns id:model_columns
} }
anchors.fill: parent
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
syncView: header_horizontal syncView: header_horizontal
syncDirection: Qt.Horizontal syncDirection: Qt.Horizontal
anchors.fill: parent
ScrollBar.vertical:scroll_bar_v ScrollBar.vertical:scroll_bar_v
rowHeightProvider: function(row) { rowHeightProvider: function(row) {
if(row>=table_view.rows){
return 0
}
var rowObject = control.getRow(row) var rowObject = control.getRow(row)
var h = rowObject.height var height = rowObject.height
if(!h){ if(height){
h = rowObject._minimumHeight return height
} }
if(!h){ var minimumHeight = rowObject._minimumHeight
h = d.defaultItemHeight if(minimumHeight){
return minimumHeight
} }
return h return d.defaultItemHeight
} }
model: table_sort_model model: table_sort_model
clip: true clip: true
@ -443,23 +441,37 @@ Rectangle {
rows: d.header_rows rows: d.header_rows
} }
syncDirection: Qt.Horizontal syncDirection: Qt.Horizontal
anchors.left: layout_mouse_table.left anchors{
anchors.top: parent.top left: header_vertical.right
right: parent.right
top: parent.top
}
visible: control.horizonalHeaderVisible visible: control.horizonalHeaderVisible
implicitWidth: table_view.width height: visible ? Math.max(1, contentHeight) : 0
implicitHeight: visible ? Math.max(1, contentHeight) : 0
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
clip: true clip: true
ScrollBar.horizontal:scroll_bar_h ScrollBar.horizontal:scroll_bar_h
columnWidthProvider: function(column) { columnWidthProvider: function(column) {
var w = columnSource[column].width var columnObject = columnSource[column]
if(!w){ var width = columnObject.width
w = columnSource[column].minimumWidth if(width){
return width
} }
if(!w){ var minimumWidth = columnObject.minimumWidth
w = d.defaultItemWidth if(minimumWidth){
return minimumWidth
}
return d.defaultItemWidth
}
onContentXChanged:{
timer_horizontal_force_layout.restart()
}
Timer{
id:timer_horizontal_force_layout
interval: 50
onTriggered: {
header_horizontal.forceLayout()
} }
return w
} }
delegate: Rectangle { delegate: Rectangle {
id:column_item_control id:column_item_control