mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-01-23 04:14:35 +08:00
Compare commits
2 Commits
4997b991db
...
2367c6978a
Author | SHA1 | Date | |
---|---|---|---|
|
2367c6978a | ||
|
6b941697b0 |
@ -375,7 +375,7 @@ void FluFrameless::_showSystemMenu(QPoint point) {
|
|||||||
}
|
}
|
||||||
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), nativePos.x(),
|
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), nativePos.x(),
|
||||||
nativePos.y(), 0, hwnd, nullptr);
|
nativePos.y(), 0, hwnd, nullptr);
|
||||||
if (result != FALSE) {
|
if (result) {
|
||||||
::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
|
::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -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() {
|
void FluTableModel::clear() {
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
this->_rows.clear();
|
this->_rows.clear();
|
||||||
|
@ -28,10 +28,6 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
[[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 void clear();
|
||||||
|
|
||||||
Q_INVOKABLE QVariant getRow(int rowIndex);
|
Q_INVOKABLE QVariant getRow(int rowIndex);
|
||||||
|
@ -9,16 +9,6 @@ FluTreeModel::FluTreeModel(QObject *parent) : QAbstractTableModel{parent} {
|
|||||||
_dataSourceSize = 0;
|
_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 {
|
int FluTreeModel::rowCount(const QModelIndex &parent) const {
|
||||||
return _rows.count();
|
return _rows.count();
|
||||||
}
|
}
|
||||||
|
@ -107,10 +107,6 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
[[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 removeRows(int row, int count);
|
||||||
|
|
||||||
Q_INVOKABLE void insertRows(int row, const QList<FluTreeNode *> &data);
|
Q_INVOKABLE void insertRows(int row, const QList<FluTreeNode *> &data);
|
||||||
|
@ -225,22 +225,21 @@ Rectangle {
|
|||||||
id:com_table_delegate
|
id:com_table_delegate
|
||||||
MouseArea{
|
MouseArea{
|
||||||
id:item_table_mouse
|
id:item_table_mouse
|
||||||
implicitWidth: TableView.view.width
|
|
||||||
property var _model: model
|
property var _model: model
|
||||||
property bool isMainTable: TableView.view == table_view
|
property bool isMainTable: TableView.view == table_view
|
||||||
property var currentTableView: TableView.view
|
property var currentTableView: TableView.view
|
||||||
visible: {
|
property bool isHide: {
|
||||||
if(isMainTable && columnModel.frozen){
|
if(isMainTable && columnModel.frozen){
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
if(!isMainTable){
|
if(!isMainTable){
|
||||||
if(currentTableView.dataIndex !== columnModel.dataIndex)
|
if(currentTableView.dataIndex !== columnModel.dataIndex)
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
property bool isRowSelected: {
|
property bool isRowSelected: {
|
||||||
if(rowModel === null)
|
if(!rowModel)
|
||||||
return false
|
return false
|
||||||
if(d.current){
|
if(d.current){
|
||||||
return rowModel._key === d.current._key
|
return rowModel._key === d.current._key
|
||||||
@ -248,11 +247,15 @@ Rectangle {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
property bool editVisible: {
|
property bool editVisible: {
|
||||||
|
if(!rowModel)
|
||||||
|
return false
|
||||||
if(d.editPosition && d.editPosition._key === rowModel._key && d.editPosition.column === column){
|
if(d.editPosition && d.editPosition._key === rowModel._key && d.editPosition.column === column){
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
implicitWidth: isHide ? Number.MIN_VALUE : TableView.view.width
|
||||||
|
visible: !isHide
|
||||||
TableView.onPooled: {
|
TableView.onPooled: {
|
||||||
if(d.editPosition && d.editPosition.row === row && d.editPosition.column === column){
|
if(d.editPosition && d.editPosition.row === row && d.editPosition.column === column){
|
||||||
control.closeEditor()
|
control.closeEditor()
|
||||||
@ -441,6 +444,11 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onWidthChanged:{
|
||||||
|
table_view.forceLayout()
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea{
|
MouseArea{
|
||||||
id:layout_mouse_table
|
id:layout_mouse_table
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
@ -475,7 +483,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component{
|
Component{
|
||||||
id:com_column_header_delegate
|
id: com_column_header_delegate
|
||||||
Rectangle{
|
Rectangle{
|
||||||
id: column_item_control
|
id: column_item_control
|
||||||
property var currentTableView : TableView.view
|
property var currentTableView : TableView.view
|
||||||
@ -490,17 +498,31 @@ Rectangle {
|
|||||||
return control.columnSource.findIndex(isDataIndex)
|
return control.columnSource.findIndex(isDataIndex)
|
||||||
}
|
}
|
||||||
readonly property bool isHeaderHorizontal: TableView.view == header_horizontal
|
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: {
|
implicitWidth: {
|
||||||
|
if(isHide){
|
||||||
|
return Number.MIN_VALUE
|
||||||
|
}
|
||||||
if(column_item_control.isHeaderHorizontal){
|
if(column_item_control.isHeaderHorizontal){
|
||||||
return (item_column_loader.item && item_column_loader.item.implicitWidth) + (cellPadding * 2)
|
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: {
|
implicitHeight: {
|
||||||
if(column_item_control.isHeaderHorizontal){
|
if(column_item_control.isHeaderHorizontal){
|
||||||
return Math.max(36, (item_column_loader.item&&item_column_loader.item.implicitHeight) + (cellPadding * 2))
|
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)
|
color: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
|
||||||
Rectangle{
|
Rectangle{
|
||||||
@ -616,7 +638,6 @@ Rectangle {
|
|||||||
columnModel.width = Math.min(Math.max(minimumWidth, w + delta.x),maximumWidth)
|
columnModel.width = Math.min(Math.max(minimumWidth, w + delta.x),maximumWidth)
|
||||||
table_view.forceLayout()
|
table_view.forceLayout()
|
||||||
header_horizontal.forceLayout()
|
header_horizontal.forceLayout()
|
||||||
// column_item_control.currentTableView.forceLayout()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -870,12 +891,32 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
color: "#00000000"
|
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 {
|
TableView {
|
||||||
|
property string dataIndex: columnModel.dataIndex
|
||||||
id:item_table_frozen_header
|
id:item_table_frozen_header
|
||||||
model: header_column_model
|
model: header_column_model
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
clip: true
|
|
||||||
interactive: false
|
interactive: false
|
||||||
|
clip: true
|
||||||
|
contentWidth: width
|
||||||
anchors{
|
anchors{
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
right: parent.right
|
||||||
@ -883,24 +924,14 @@ Rectangle {
|
|||||||
bottom: item_table_frozen.top
|
bottom: item_table_frozen.top
|
||||||
}
|
}
|
||||||
delegate: com_column_header_delegate
|
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: {
|
Component.onCompleted: {
|
||||||
item_table_frozen_header.contentX = columnModel.width * _index
|
item_table_frozen_header.forceLayout()
|
||||||
item_table_frozen.contentX = columnModel.width * _index
|
}
|
||||||
|
}
|
||||||
|
Connections{
|
||||||
|
target: table_view
|
||||||
|
function onWidthChanged() {
|
||||||
|
item_table_frozen_header.forceLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -914,6 +945,12 @@ Rectangle {
|
|||||||
id: item_layout_frozen
|
id: item_layout_frozen
|
||||||
readonly property int _index : model.index
|
readonly property int _index : model.index
|
||||||
readonly property var columnModel : control.columnSource[_index]
|
readonly property var columnModel : control.columnSource[_index]
|
||||||
|
readonly property bool isHide:{
|
||||||
|
if(columnModel.frozen){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
Connections{
|
Connections{
|
||||||
target: d
|
target: d
|
||||||
function onTableItemLayout(column){
|
function onTableItemLayout(column){
|
||||||
@ -932,17 +969,17 @@ Rectangle {
|
|||||||
width = table_view.columnWidthProvider(_index)
|
width = table_view.columnWidthProvider(_index)
|
||||||
x = Qt.binding(function(){
|
x = Qt.binding(function(){
|
||||||
var minX = 0
|
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++){
|
for(var i=0;i<_index;i++){
|
||||||
var item = control.columnSource[i]
|
var item = control.columnSource[i]
|
||||||
if(item.frozen){
|
if(item.frozen){
|
||||||
minX = minX + item.width
|
minX = minX + table_view.columnWidthProvider(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i=_index+1;i<control.columnSource.length;i++){
|
for(i=_index+1;i<control.columnSource.length;i++){
|
||||||
item = control.columnSource[i]
|
item = control.columnSource[i]
|
||||||
if(item.frozen){
|
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)}
|
return Math.min(Math.max(columnModel.x - table_view.contentX,minX),maxX)}
|
||||||
@ -952,23 +989,8 @@ Rectangle {
|
|||||||
updateLayout()
|
updateLayout()
|
||||||
}
|
}
|
||||||
height: control.height
|
height: control.height
|
||||||
visible: {
|
visible: !item_layout_frozen.isHide
|
||||||
if(modelData.frozen){
|
sourceComponent: item_layout_frozen.isHide ? undefined : com_table_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
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Controls.Basic
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import QtQuick.Window
|
import QtQuick.Window
|
||||||
import FluentUI
|
import FluentUI
|
||||||
|
@ -225,22 +225,21 @@ Rectangle {
|
|||||||
id:com_table_delegate
|
id:com_table_delegate
|
||||||
MouseArea{
|
MouseArea{
|
||||||
id:item_table_mouse
|
id:item_table_mouse
|
||||||
implicitWidth: TableView.view.width
|
|
||||||
property var _model: model
|
property var _model: model
|
||||||
property bool isMainTable: TableView.view == table_view
|
property bool isMainTable: TableView.view == table_view
|
||||||
property var currentTableView: TableView.view
|
property var currentTableView: TableView.view
|
||||||
visible: {
|
property bool isHide: {
|
||||||
if(isMainTable && columnModel.frozen){
|
if(isMainTable && columnModel.frozen){
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
if(!isMainTable){
|
if(!isMainTable){
|
||||||
if(currentTableView.dataIndex !== columnModel.dataIndex)
|
if(currentTableView.dataIndex !== columnModel.dataIndex)
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
property bool isRowSelected: {
|
property bool isRowSelected: {
|
||||||
if(rowModel === null)
|
if(!rowModel)
|
||||||
return false
|
return false
|
||||||
if(d.current){
|
if(d.current){
|
||||||
return rowModel._key === d.current._key
|
return rowModel._key === d.current._key
|
||||||
@ -248,11 +247,15 @@ Rectangle {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
property bool editVisible: {
|
property bool editVisible: {
|
||||||
|
if(!rowModel)
|
||||||
|
return false
|
||||||
if(d.editPosition && d.editPosition._key === rowModel._key && d.editPosition.column === column){
|
if(d.editPosition && d.editPosition._key === rowModel._key && d.editPosition.column === column){
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
implicitWidth: isHide ? Number.MIN_VALUE : TableView.view.width
|
||||||
|
visible: !isHide
|
||||||
TableView.onPooled: {
|
TableView.onPooled: {
|
||||||
if(d.editPosition && d.editPosition.row === row && d.editPosition.column === column){
|
if(d.editPosition && d.editPosition.row === row && d.editPosition.column === column){
|
||||||
control.closeEditor()
|
control.closeEditor()
|
||||||
@ -441,6 +444,11 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onWidthChanged:{
|
||||||
|
table_view.forceLayout()
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea{
|
MouseArea{
|
||||||
id:layout_mouse_table
|
id:layout_mouse_table
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
@ -475,7 +483,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component{
|
Component{
|
||||||
id:com_column_header_delegate
|
id: com_column_header_delegate
|
||||||
Rectangle{
|
Rectangle{
|
||||||
id: column_item_control
|
id: column_item_control
|
||||||
property var currentTableView : TableView.view
|
property var currentTableView : TableView.view
|
||||||
@ -490,17 +498,31 @@ Rectangle {
|
|||||||
return control.columnSource.findIndex(isDataIndex)
|
return control.columnSource.findIndex(isDataIndex)
|
||||||
}
|
}
|
||||||
readonly property bool isHeaderHorizontal: TableView.view == header_horizontal
|
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: {
|
implicitWidth: {
|
||||||
|
if(isHide){
|
||||||
|
return Number.MIN_VALUE
|
||||||
|
}
|
||||||
if(column_item_control.isHeaderHorizontal){
|
if(column_item_control.isHeaderHorizontal){
|
||||||
return (item_column_loader.item && item_column_loader.item.implicitWidth) + (cellPadding * 2)
|
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: {
|
implicitHeight: {
|
||||||
if(column_item_control.isHeaderHorizontal){
|
if(column_item_control.isHeaderHorizontal){
|
||||||
return Math.max(36, (item_column_loader.item&&item_column_loader.item.implicitHeight) + (cellPadding * 2))
|
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)
|
color: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
|
||||||
Rectangle{
|
Rectangle{
|
||||||
@ -616,7 +638,6 @@ Rectangle {
|
|||||||
columnModel.width = Math.min(Math.max(minimumWidth, w + delta.x),maximumWidth)
|
columnModel.width = Math.min(Math.max(minimumWidth, w + delta.x),maximumWidth)
|
||||||
table_view.forceLayout()
|
table_view.forceLayout()
|
||||||
header_horizontal.forceLayout()
|
header_horizontal.forceLayout()
|
||||||
// column_item_control.currentTableView.forceLayout()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -870,12 +891,32 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
color: "#00000000"
|
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 {
|
TableView {
|
||||||
|
property string dataIndex: columnModel.dataIndex
|
||||||
id:item_table_frozen_header
|
id:item_table_frozen_header
|
||||||
model: header_column_model
|
model: header_column_model
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
clip: true
|
|
||||||
interactive: false
|
interactive: false
|
||||||
|
clip: true
|
||||||
|
contentWidth: width
|
||||||
anchors{
|
anchors{
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
right: parent.right
|
||||||
@ -883,24 +924,14 @@ Rectangle {
|
|||||||
bottom: item_table_frozen.top
|
bottom: item_table_frozen.top
|
||||||
}
|
}
|
||||||
delegate: com_column_header_delegate
|
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: {
|
Component.onCompleted: {
|
||||||
item_table_frozen_header.contentX = columnModel.width * _index
|
item_table_frozen_header.forceLayout()
|
||||||
item_table_frozen.contentX = columnModel.width * _index
|
}
|
||||||
|
}
|
||||||
|
Connections{
|
||||||
|
target: table_view
|
||||||
|
function onWidthChanged() {
|
||||||
|
item_table_frozen_header.forceLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -914,6 +945,12 @@ Rectangle {
|
|||||||
id: item_layout_frozen
|
id: item_layout_frozen
|
||||||
readonly property int _index : model.index
|
readonly property int _index : model.index
|
||||||
readonly property var columnModel : control.columnSource[_index]
|
readonly property var columnModel : control.columnSource[_index]
|
||||||
|
readonly property bool isHide:{
|
||||||
|
if(columnModel.frozen){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
Connections{
|
Connections{
|
||||||
target: d
|
target: d
|
||||||
function onTableItemLayout(column){
|
function onTableItemLayout(column){
|
||||||
@ -932,17 +969,17 @@ Rectangle {
|
|||||||
width = table_view.columnWidthProvider(_index)
|
width = table_view.columnWidthProvider(_index)
|
||||||
x = Qt.binding(function(){
|
x = Qt.binding(function(){
|
||||||
var minX = 0
|
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++){
|
for(var i=0;i<_index;i++){
|
||||||
var item = control.columnSource[i]
|
var item = control.columnSource[i]
|
||||||
if(item.frozen){
|
if(item.frozen){
|
||||||
minX = minX + item.width
|
minX = minX + table_view.columnWidthProvider(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i=_index+1;i<control.columnSource.length;i++){
|
for(i=_index+1;i<control.columnSource.length;i++){
|
||||||
item = control.columnSource[i]
|
item = control.columnSource[i]
|
||||||
if(item.frozen){
|
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)}
|
return Math.min(Math.max(columnModel.x - table_view.contentX,minX),maxX)}
|
||||||
@ -952,23 +989,8 @@ Rectangle {
|
|||||||
updateLayout()
|
updateLayout()
|
||||||
}
|
}
|
||||||
height: control.height
|
height: control.height
|
||||||
visible: {
|
visible: !item_layout_frozen.isHide
|
||||||
if(modelData.frozen){
|
sourceComponent: item_layout_frozen.isHide ? undefined : com_table_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
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user