From c23981b81dcbda4ed5c8fdb70d89d519a3306fff Mon Sep 17 00:00:00 2001 From: zhuzihcu Date: Fri, 26 May 2023 14:08:22 +0800 Subject: [PATCH] update --- example/qml/page/T_Expander.qml | 4 +- .../FluentUI/Controls/FluTableView2.qml | 235 ++++++++++++++++++ src/imports/FluentUI/Controls/FluTreeView.qml | 4 +- 3 files changed, 239 insertions(+), 4 deletions(-) create mode 100644 src/imports/FluentUI/Controls/FluTableView2.qml diff --git a/example/qml/page/T_Expander.qml b/example/qml/page/T_Expander.qml index bb7a673..64a1288 100644 --- a/example/qml/page/T_Expander.qml +++ b/example/qml/page/T_Expander.qml @@ -40,9 +40,9 @@ FluScrollablePage{ property int selecIndex : 0 model: 3 delegate: FluRadioButton{ - selected : repeater.selecIndex===index + checked : repeater.selecIndex===index text:"Radio Button_"+index - onClicked:{ + clickListener:function() { repeater.selecIndex = index } } diff --git a/src/imports/FluentUI/Controls/FluTableView2.qml b/src/imports/FluentUI/Controls/FluTableView2.qml new file mode 100644 index 0000000..f2512bd --- /dev/null +++ b/src/imports/FluentUI/Controls/FluTableView2.qml @@ -0,0 +1,235 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Basic +import QtQuick.Layouts +import FluentUI + +Item { + property var columns : [] + property var dataSource : [] + property int pageCurrent: 1 + property int itemCount: 1000 + property int pageCount: 10 + property int itemHeight: 56 + property bool pageVisible: true + signal requestPage(int page,int count) + id:control + implicitHeight: layout_table.height + QtObject{ + id:d + property int coumnsWidth: parent.width + } + MouseArea{ + anchors.fill: parent + preventStealing: true + } + ListModel{ + id:model_coumns + } + ListModel{ + id:model_data_source + } + onColumnsChanged: { + model_coumns.clear() + model_coumns.append(columns) + var w = 0 + for(var i=0;i { + control.requestPage(page,count) + } + anchors{ + top: parent.top + right: parent.right + } + Connections{ + target: control + function onPageCurrentChanged(){ + if (control.pageCurrent!==pagination.pageCurrent) + { + pagination.calcNewPage(control.pageCurrent) + } + } + } + } + } + model:model_data_source + delegate: Control{ + id:item_control + height: table_row.maxHeight + width: layout_table.width + property var model_values : getObjectValues(index) + property var itemObject: getObject(index) + property var listModel: model + Rectangle{ + anchors.fill: parent + color: { + if(item_control.hovered){ + return FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1) + } + return FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(1,1,1,1) + } + } + Row{ + id: table_row + spacing: 0 + anchors.fill: parent + property int maxHeight: itemHeight + Repeater{ + model: model_values + delegate:Item{ + height: table_row.maxHeight + width: modelData.width + Loader{ + property var model : modelData + property var dataModel : listModel + property var dataObject : itemObject + anchors.fill: parent + sourceComponent: { + if(model.itemData instanceof Component){ + return model.itemData + } + return com_text + } + onHeightChanged: + { + table_row.maxHeight = Math.max(table_row.maxHeight,height,itemHeight) + parent.height = table_row.maxHeight + table_row.parent.height = table_row.maxHeight + } + } + } + } + } + FluDivider{ + width: parent.width + height: 1 + anchors.right: parent.right + anchors.bottom: parent.bottom + } + } + } + } + Component{ + id:com_text + Item{ + FluCopyableText{ + id:table_value + text:String(model.itemData) + width: Math.min(parent.width - 14,implicitWidth) + wrapMode: Text.WordWrap + onImplicitHeightChanged: parent.parent.parent.height = Math.max(implicitHeight + 20,itemHeight) + anchors{ + verticalCenter: parent.verticalCenter + left: parent.left + leftMargin: 14 + } + MouseArea{ + id:item_mouse + hoverEnabled: true + anchors.fill: parent + cursorShape: Qt.IBeamCursor + acceptedButtons: Qt.NoButton + } + FluTooltip{ + visible: item_mouse.containsMouse + text:parent.text + delay: 1000 + } + } + } + } + function getObject(index){ + return model_data_source.get(index) + } + function getObjectValues(index) { + var obj = model_data_source.get(index) + if(!obj) + return + var data = [] + for(var i=0;i 0) {