Compare commits

...

2 Commits

Author SHA1 Message Date
朱子楚\zhuzi
2367c6978a update 2024-05-11 22:21:11 +08:00
朱子楚\zhuzi
6b941697b0 update 2024-05-11 21:45:45 +08:00
8 changed files with 142 additions and 125 deletions

View File

@ -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

View File

@ -31,16 +31,6 @@ QHash<int, QByteArray> 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();

View File

@ -28,10 +28,6 @@ public:
[[nodiscard]] QHash<int, QByteArray> 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);

View File

@ -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();
}

View File

@ -107,10 +107,6 @@ public:
[[nodiscard]] QHash<int, QByteArray> 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<FluTreeNode *> &data);

View File

@ -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 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
@ -475,7 +483,7 @@ Rectangle {
}
Component{
id:com_column_header_delegate
id: com_column_header_delegate
Rectangle{
id: column_item_control
property var currentTableView : TableView.view
@ -490,17 +498,31 @@ 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)
}
return TableView.view.width
return Math.max(TableView.view.width,Number.MIN_VALUE)
}
implicitHeight: {
if(column_item_control.isHeaderHorizontal){
return Math.max(36, (item_column_loader.item&&item_column_loader.item.implicitHeight) + (cellPadding * 2))
}
return TableView.view.height
return Math.max(TableView.view.height,Number.MIN_VALUE)
}
color: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
Rectangle{
@ -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
@ -883,24 +924,14 @@ Rectangle {
bottom: item_table_frozen.top
}
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
}
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
item_table_frozen_header.forceLayout()
}
}
Connections{
target: table_view
function onWidthChanged() {
item_table_frozen_header.forceLayout()
}
}
@ -914,6 +945,12 @@ Rectangle {
id: item_layout_frozen
readonly property int _index : model.index
readonly property var columnModel : control.columnSource[_index]
readonly property bool isHide:{
if(columnModel.frozen){
return false
}
return true
}
Connections{
target: d
function onTableItemLayout(column){
@ -932,17 +969,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<control.columnSource.length;i++){
item = control.columnSource[i]
if(item.frozen){
maxX = maxX- item.width
maxX = maxX - table_view.columnWidthProvider(i)
}
}
return Math.min(Math.max(columnModel.x - table_view.contentX,minX),maxX)}
@ -952,23 +989,8 @@ Rectangle {
updateLayout()
}
height: control.height
visible: {
if(modelData.frozen){
return true
}
return false
}
sourceComponent: visible ? com_table_frozen : undefined
onStatusChanged: {
if(status === Loader.Ready){
sourceComponent = Qt.binding(function(){
if(modelData.frozen){
return com_table_frozen
}
return undefined
})
}
}
visible: !item_layout_frozen.isHide
sourceComponent: item_layout_frozen.isHide ? undefined : com_table_frozen
}
}
}

View File

@ -1,5 +1,6 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic
import QtQuick.Layouts
import QtQuick.Window
import FluentUI

View File

@ -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 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
@ -475,7 +483,7 @@ Rectangle {
}
Component{
id:com_column_header_delegate
id: com_column_header_delegate
Rectangle{
id: column_item_control
property var currentTableView : TableView.view
@ -490,17 +498,31 @@ 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)
}
return TableView.view.width
return Math.max(TableView.view.width,Number.MIN_VALUE)
}
implicitHeight: {
if(column_item_control.isHeaderHorizontal){
return Math.max(36, (item_column_loader.item&&item_column_loader.item.implicitHeight) + (cellPadding * 2))
}
return TableView.view.height
return Math.max(TableView.view.height,Number.MIN_VALUE)
}
color: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
Rectangle{
@ -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
@ -883,24 +924,14 @@ Rectangle {
bottom: item_table_frozen.top
}
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
}
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
item_table_frozen_header.forceLayout()
}
}
Connections{
target: table_view
function onWidthChanged() {
item_table_frozen_header.forceLayout()
}
}
@ -914,6 +945,12 @@ Rectangle {
id: item_layout_frozen
readonly property int _index : model.index
readonly property var columnModel : control.columnSource[_index]
readonly property bool isHide:{
if(columnModel.frozen){
return false
}
return true
}
Connections{
target: d
function onTableItemLayout(column){
@ -932,17 +969,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<control.columnSource.length;i++){
item = control.columnSource[i]
if(item.frozen){
maxX = maxX- item.width
maxX = maxX - table_view.columnWidthProvider(i)
}
}
return Math.min(Math.max(columnModel.x - table_view.contentX,minX),maxX)}
@ -952,23 +989,8 @@ Rectangle {
updateLayout()
}
height: control.height
visible: {
if(modelData.frozen){
return true
}
return false
}
sourceComponent: visible ? com_table_frozen : undefined
onStatusChanged: {
if(status === Loader.Ready){
sourceComponent = Qt.binding(function(){
if(modelData.frozen){
return com_table_frozen
}
return undefined
})
}
}
visible: !item_layout_frozen.isHide
sourceComponent: item_layout_frozen.isHide ? undefined : com_table_frozen
}
}
}