Compare commits

..

No commits in common. "2367c6978a53e372277487b160c558390e87a93f" and "4997b991db3238376121af5aa9e9cbe3a52c4616" have entirely different histories.

8 changed files with 125 additions and 142 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) {
if (result != FALSE) {
::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
}
#endif

View File

@ -31,6 +31,16 @@ 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,6 +28,10 @@ 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,6 +9,16 @@ 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,6 +107,10 @@ 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,21 +225,22 @@ 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
property bool isHide: {
visible: {
if(isMainTable && columnModel.frozen){
return true
return false
}
if(!isMainTable){
if(currentTableView.dataIndex !== columnModel.dataIndex)
return true
return false
}
return false
return true
}
property bool isRowSelected: {
if(!rowModel)
if(rowModel === null)
return false
if(d.current){
return rowModel._key === d.current._key
@ -247,15 +248,11 @@ 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()
@ -444,11 +441,6 @@ Rectangle {
}
}
}
onWidthChanged:{
table_view.forceLayout()
}
MouseArea{
id:layout_mouse_table
hoverEnabled: true
@ -483,7 +475,7 @@ Rectangle {
}
Component{
id: com_column_header_delegate
id:com_column_header_delegate
Rectangle{
id: column_item_control
property var currentTableView : TableView.view
@ -498,31 +490,17 @@ 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 Math.max(TableView.view.width,Number.MIN_VALUE)
return TableView.view.width
}
implicitHeight: {
if(column_item_control.isHeaderHorizontal){
return Math.max(36, (item_column_loader.item&&item_column_loader.item.implicitHeight) + (cellPadding * 2))
}
return Math.max(TableView.view.height,Number.MIN_VALUE)
return TableView.view.height
}
color: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
Rectangle{
@ -638,6 +616,7 @@ Rectangle {
columnModel.width = Math.min(Math.max(minimumWidth, w + delta.x),maximumWidth)
table_view.forceLayout()
header_horizontal.forceLayout()
// column_item_control.currentTableView.forceLayout()
}
}
}
@ -891,32 +870,12 @@ 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
interactive: false
clip: true
contentWidth: width
interactive: false
anchors{
left: parent.left
right: parent.right
@ -924,14 +883,24 @@ Rectangle {
bottom: item_table_frozen.top
}
delegate: com_column_header_delegate
Component.onCompleted: {
item_table_frozen_header.forceLayout()
}
}
Connections{
target: table_view
function onWidthChanged() {
item_table_frozen_header.forceLayout()
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
}
}
@ -945,12 +914,6 @@ 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){
@ -969,17 +932,17 @@ Rectangle {
width = table_view.columnWidthProvider(_index)
x = Qt.binding(function(){
var minX = 0
var maxX = table_view.width-width
var maxX = table_view.width-item_layout_frozen.width
for(var i=0;i<_index;i++){
var item = control.columnSource[i]
if(item.frozen){
minX = minX + table_view.columnWidthProvider(i)
minX = minX + item.width
}
}
for(i=_index+1;i<control.columnSource.length;i++){
item = control.columnSource[i]
if(item.frozen){
maxX = maxX - table_view.columnWidthProvider(i)
maxX = maxX- item.width
}
}
return Math.min(Math.max(columnModel.x - table_view.contentX,minX),maxX)}
@ -989,8 +952,23 @@ Rectangle {
updateLayout()
}
height: control.height
visible: !item_layout_frozen.isHide
sourceComponent: item_layout_frozen.isHide ? undefined : com_table_frozen
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
})
}
}
}
}
}

View File

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

View File

@ -225,21 +225,22 @@ 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
property bool isHide: {
visible: {
if(isMainTable && columnModel.frozen){
return true
return false
}
if(!isMainTable){
if(currentTableView.dataIndex !== columnModel.dataIndex)
return true
return false
}
return false
return true
}
property bool isRowSelected: {
if(!rowModel)
if(rowModel === null)
return false
if(d.current){
return rowModel._key === d.current._key
@ -247,15 +248,11 @@ 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()
@ -444,11 +441,6 @@ Rectangle {
}
}
}
onWidthChanged:{
table_view.forceLayout()
}
MouseArea{
id:layout_mouse_table
hoverEnabled: true
@ -483,7 +475,7 @@ Rectangle {
}
Component{
id: com_column_header_delegate
id:com_column_header_delegate
Rectangle{
id: column_item_control
property var currentTableView : TableView.view
@ -498,31 +490,17 @@ 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 Math.max(TableView.view.width,Number.MIN_VALUE)
return TableView.view.width
}
implicitHeight: {
if(column_item_control.isHeaderHorizontal){
return Math.max(36, (item_column_loader.item&&item_column_loader.item.implicitHeight) + (cellPadding * 2))
}
return Math.max(TableView.view.height,Number.MIN_VALUE)
return TableView.view.height
}
color: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
Rectangle{
@ -638,6 +616,7 @@ Rectangle {
columnModel.width = Math.min(Math.max(minimumWidth, w + delta.x),maximumWidth)
table_view.forceLayout()
header_horizontal.forceLayout()
// column_item_control.currentTableView.forceLayout()
}
}
}
@ -891,32 +870,12 @@ 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
interactive: false
clip: true
contentWidth: width
interactive: false
anchors{
left: parent.left
right: parent.right
@ -924,14 +883,24 @@ Rectangle {
bottom: item_table_frozen.top
}
delegate: com_column_header_delegate
Component.onCompleted: {
item_table_frozen_header.forceLayout()
}
}
Connections{
target: table_view
function onWidthChanged() {
item_table_frozen_header.forceLayout()
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
}
}
@ -945,12 +914,6 @@ 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){
@ -969,17 +932,17 @@ Rectangle {
width = table_view.columnWidthProvider(_index)
x = Qt.binding(function(){
var minX = 0
var maxX = table_view.width-width
var maxX = table_view.width-item_layout_frozen.width
for(var i=0;i<_index;i++){
var item = control.columnSource[i]
if(item.frozen){
minX = minX + table_view.columnWidthProvider(i)
minX = minX + item.width
}
}
for(i=_index+1;i<control.columnSource.length;i++){
item = control.columnSource[i]
if(item.frozen){
maxX = maxX - table_view.columnWidthProvider(i)
maxX = maxX- item.width
}
}
return Math.min(Math.max(columnModel.x - table_view.contentX,minX),maxX)}
@ -989,8 +952,23 @@ Rectangle {
updateLayout()
}
height: control.height
visible: !item_layout_frozen.isHide
sourceComponent: item_layout_frozen.isHide ? undefined : com_table_frozen
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
})
}
}
}
}
}