From 77bb12b164b79d6a3154ddcdc1c17d700d2bb0a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Mon, 18 Mar 2024 22:11:39 +0800 Subject: [PATCH] update --- .../FluentUI/Controls/FluTableView.qml | 33 ++++++++++++------- .../FluentUI/Controls/FluTableView.qml | 33 ++++++++++++------- 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/Qt5/imports/FluentUI/Controls/FluTableView.qml b/src/Qt5/imports/FluentUI/Controls/FluTableView.qml index 4afe9e6a..8aa5fb5e 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluTableView.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluTableView.qml @@ -341,12 +341,9 @@ Rectangle { } TableView { id:table_view - ListModel{ - id:model_columns - } boundsBehavior: Flickable.StopAtBounds anchors.fill: parent - contentX: header_horizontal.contentX + ScrollBar.horizontal:scroll_bar_h ScrollBar.vertical:scroll_bar_v columnWidthProvider: function(column) { var columnObject = d.columns_data[column] @@ -731,9 +728,10 @@ Rectangle { height: visible ? Math.max(1, contentHeight) : 0 boundsBehavior: Flickable.StopAtBounds clip: true - contentX: table_view.contentX + syncDirection: Qt.Horizontal + ScrollBar.horizontal:scroll_bar_h_2 columnWidthProvider: table_view.columnWidthProvider - ScrollBar.horizontal:scroll_bar_h + syncView: table_view.rows === 0 ? null : table_view onContentXChanged:{ timer_horizontal_force_layout.restart() } @@ -760,15 +758,16 @@ Rectangle { syncView: table_view clip: true model: header_row_model + delegate: com_row_header_delegate + onContentYChanged:{ + timer_vertical_force_layout.restart() + } Connections{ target: table_model function onRowCountChanged(){ header_row_model.rows = Array.from({length: table_model.rows.length}, (_, i) => ({rowIndex:i+1})) } } - onContentYChanged:{ - timer_vertical_force_layout.restart() - } Timer{ id:timer_vertical_force_layout interval: 50 @@ -776,19 +775,29 @@ Rectangle { header_vertical.forceLayout() } } - delegate: com_row_header_delegate } FluScrollBar { - id:scroll_bar_h + id: scroll_bar_h anchors{ left: layout_mouse_table.left right: parent.right bottom: layout_mouse_table.bottom } + visible: table_view.rows !== 0 z:999 } FluScrollBar { - id:scroll_bar_v + id: scroll_bar_h_2 + anchors{ + left: layout_mouse_table.left + right: parent.right + bottom: layout_mouse_table.bottom + } + visible: table_view.rows === 0 + z:999 + } + FluScrollBar { + id: scroll_bar_v anchors{ top: layout_mouse_table.top bottom: layout_mouse_table.bottom diff --git a/src/Qt6/imports/FluentUI/Controls/FluTableView.qml b/src/Qt6/imports/FluentUI/Controls/FluTableView.qml index d3ae14e2..b934c4fb 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluTableView.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluTableView.qml @@ -342,12 +342,9 @@ Rectangle { } TableView { id:table_view - ListModel{ - id:model_columns - } boundsBehavior: Flickable.StopAtBounds anchors.fill: parent - contentX: header_horizontal.contentX + ScrollBar.horizontal:scroll_bar_h ScrollBar.vertical:scroll_bar_v columnWidthProvider: function(column) { var columnObject = d.columns_data[column] @@ -732,9 +729,10 @@ Rectangle { height: visible ? Math.max(1, contentHeight) : 0 boundsBehavior: Flickable.StopAtBounds clip: true - contentX: table_view.contentX + syncDirection: Qt.Horizontal + ScrollBar.horizontal:scroll_bar_h_2 columnWidthProvider: table_view.columnWidthProvider - ScrollBar.horizontal:scroll_bar_h + syncView: table_view.rows === 0 ? null : table_view onContentXChanged:{ timer_horizontal_force_layout.restart() } @@ -761,15 +759,16 @@ Rectangle { syncView: table_view clip: true model: header_row_model + delegate: com_row_header_delegate + onContentYChanged:{ + timer_vertical_force_layout.restart() + } Connections{ target: table_model function onRowCountChanged(){ header_row_model.rows = Array.from({length: table_model.rows.length}, (_, i) => ({rowIndex:i+1})) } } - onContentYChanged:{ - timer_vertical_force_layout.restart() - } Timer{ id:timer_vertical_force_layout interval: 50 @@ -777,19 +776,29 @@ Rectangle { header_vertical.forceLayout() } } - delegate: com_row_header_delegate } FluScrollBar { - id:scroll_bar_h + id: scroll_bar_h anchors{ left: layout_mouse_table.left right: parent.right bottom: layout_mouse_table.bottom } + visible: table_view.rows !== 0 z:999 } FluScrollBar { - id:scroll_bar_v + id: scroll_bar_h_2 + anchors{ + left: layout_mouse_table.left + right: parent.right + bottom: layout_mouse_table.bottom + } + visible: table_view.rows === 0 + z:999 + } + FluScrollBar { + id: scroll_bar_v anchors{ top: layout_mouse_table.top bottom: layout_mouse_table.bottom