From 6b941697b0abce76a24479580fe10fb5c7a89621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Sat, 11 May 2024 21:45:45 +0800 Subject: [PATCH] update --- src/FluFrameless.cpp | 2 +- src/FluTableModel.cpp | 10 -- src/FluTableModel.h | 4 - src/FluTreeModel.cpp | 10 -- src/FluTreeModel.h | 4 - .../FluentUI/Controls/FluTableView.qml | 97 +++++++++++-------- .../FluentUI/Controls/FluColorPicker.qml | 1 + .../FluentUI/Controls/FluTableView.qml | 97 +++++++++++-------- 8 files changed, 116 insertions(+), 109 deletions(-) diff --git a/src/FluFrameless.cpp b/src/FluFrameless.cpp index a27a4d89..0cd986f4 100644 --- a/src/FluFrameless.cpp +++ b/src/FluFrameless.cpp @@ -375,7 +375,7 @@ void FluFrameless::_showSystemMenu(QPoint point) { } const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), nativePos.x(), nativePos.y(), 0, hwnd, nullptr); - if (result != FALSE) { + if (result) { ::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0); } #endif diff --git a/src/FluTableModel.cpp b/src/FluTableModel.cpp index 1a0e9c7c..eb22de64 100644 --- a/src/FluTableModel.cpp +++ b/src/FluTableModel.cpp @@ -31,16 +31,6 @@ QHash FluTableModel::roleNames() const { }; } -QModelIndex FluTableModel::parent(const QModelIndex &child) const { - return {}; -} - -QModelIndex FluTableModel::index(int row, int column, const QModelIndex &parent) const { - if (!hasIndex(row, column, parent) || parent.isValid()) - return {}; - return createIndex(row, column); -} - void FluTableModel::clear() { beginResetModel(); this->_rows.clear(); diff --git a/src/FluTableModel.h b/src/FluTableModel.h index 80e56e57..a734aa80 100644 --- a/src/FluTableModel.h +++ b/src/FluTableModel.h @@ -28,10 +28,6 @@ public: [[nodiscard]] QHash roleNames() const override; - [[nodiscard]] QModelIndex parent(const QModelIndex &child) const override; - - [[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override; - Q_INVOKABLE void clear(); Q_INVOKABLE QVariant getRow(int rowIndex); diff --git a/src/FluTreeModel.cpp b/src/FluTreeModel.cpp index baaaf010..f080a034 100644 --- a/src/FluTreeModel.cpp +++ b/src/FluTreeModel.cpp @@ -9,16 +9,6 @@ FluTreeModel::FluTreeModel(QObject *parent) : QAbstractTableModel{parent} { _dataSourceSize = 0; } -QModelIndex FluTreeModel::parent(const QModelIndex &child) const { - return {}; -} - -QModelIndex FluTreeModel::index(int row, int column, const QModelIndex &parent) const { - if (!hasIndex(row, column, parent) || parent.isValid()) - return {}; - return createIndex(row, column); -} - int FluTreeModel::rowCount(const QModelIndex &parent) const { return _rows.count(); } diff --git a/src/FluTreeModel.h b/src/FluTreeModel.h index 0fc1b53c..e9d5f48b 100644 --- a/src/FluTreeModel.h +++ b/src/FluTreeModel.h @@ -107,10 +107,6 @@ public: [[nodiscard]] QHash roleNames() const override; - [[nodiscard]] QModelIndex parent(const QModelIndex &child) const override; - - [[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override; - Q_INVOKABLE void removeRows(int row, int count); Q_INVOKABLE void insertRows(int row, const QList &data); diff --git a/src/Qt5/imports/FluentUI/Controls/FluTableView.qml b/src/Qt5/imports/FluentUI/Controls/FluTableView.qml index b398df29..0f8da39d 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluTableView.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluTableView.qml @@ -225,22 +225,21 @@ Rectangle { id:com_table_delegate MouseArea{ id:item_table_mouse - implicitWidth: TableView.view.width property var _model: model property bool isMainTable: TableView.view == table_view property var currentTableView: TableView.view - visible: { + property bool isHide: { if(isMainTable && columnModel.frozen){ - return false + return true } if(!isMainTable){ if(currentTableView.dataIndex !== columnModel.dataIndex) - return false + return true } - return true + return false } property bool isRowSelected: { - if(rowModel === null) + if(!rowModel) return false if(d.current){ return rowModel._key === d.current._key @@ -248,11 +247,15 @@ Rectangle { return false } property bool editVisible: { + if(!rowModel) + return false if(d.editPosition && d.editPosition._key === rowModel._key && d.editPosition.column === column){ return true } return false } + implicitWidth: isHide ? Number.MIN_VALUE : TableView.view.width + visible: !isHide TableView.onPooled: { if(d.editPosition && d.editPosition.row === row && d.editPosition.column === column){ control.closeEditor() @@ -441,6 +444,11 @@ Rectangle { } } } + + onWidthChanged:{ + table_view.forceLayout() + } + MouseArea{ id:layout_mouse_table hoverEnabled: true @@ -490,7 +498,21 @@ Rectangle { return control.columnSource.findIndex(isDataIndex) } readonly property bool isHeaderHorizontal: TableView.view == header_horizontal + readonly property bool isHide: { + if(isHeaderHorizontal && columnModel.frozen){ + return true + } + if(!isHeaderHorizontal){ + if(currentTableView.dataIndex !== columnModel.dataIndex) + return true + } + return false + } + visible: !isHide implicitWidth: { + if(isHide){ + return Number.MIN_VALUE + } if(column_item_control.isHeaderHorizontal){ return (item_column_loader.item && item_column_loader.item.implicitWidth) + (cellPadding * 2) } @@ -616,7 +638,6 @@ Rectangle { columnModel.width = Math.min(Math.max(minimumWidth, w + delta.x),maximumWidth) table_view.forceLayout() header_horizontal.forceLayout() -// column_item_control.currentTableView.forceLayout() } } } @@ -870,12 +891,32 @@ Rectangle { } color: "#00000000" } + TableView{ + property string dataIndex: columnModel.dataIndex + id: item_table_frozen + interactive: false + clip: true + anchors{ + left: parent.left + right: parent.right + } + contentWidth: width + height: table_view.height + y: header_horizontal.height + boundsBehavior: TableView.StopAtBounds + model: table_view.model + delegate: table_view.delegate + syncDirection: Qt.Vertical + syncView: table_view + } TableView { + property string dataIndex: columnModel.dataIndex id:item_table_frozen_header model: header_column_model boundsBehavior: Flickable.StopAtBounds - clip: true interactive: false + clip: true + contentWidth: width anchors{ left: parent.left right: parent.right @@ -884,25 +925,11 @@ Rectangle { } delegate: com_column_header_delegate } - TableView{ - property string dataIndex: columnModel.dataIndex - id: item_table_frozen - clip: true - interactive: false - anchors{ - fill: parent - topMargin: header_horizontal.height + Connections{ + target: control + function onWidthChanged() { + item_table_frozen_header.forceLayout() } - boundsBehavior: TableView.StopAtBounds - model: table_sort_model - delegate: com_table_delegate - syncDirection: Qt.Vertical - syncView: table_view - Component.onCompleted: { - item_table_frozen_header.contentX = columnModel.width * _index - item_table_frozen.contentX = columnModel.width * _index - } - } } } @@ -932,17 +959,17 @@ Rectangle { width = table_view.columnWidthProvider(_index) x = Qt.binding(function(){ var minX = 0 - var maxX = table_view.width-item_layout_frozen.width + var maxX = table_view.width-width for(var i=0;i<_index;i++){ var item = control.columnSource[i] if(item.frozen){ - minX = minX + item.width + minX = minX + table_view.columnWidthProvider(i) } } for(i=_index+1;i