This commit is contained in:
zhuzichu 2023-10-17 16:11:09 +08:00
parent b836b25028
commit 487cbefd82
2 changed files with 44 additions and 34 deletions

View File

@ -43,6 +43,7 @@ Rectangle {
var cellPosition = cellItem.mapToItem(scroll_table, 0, 0) var cellPosition = cellItem.mapToItem(scroll_table, 0, 0)
item_loader.column = column item_loader.column = column
item_loader.row = row item_loader.row = row
item_loader_layout.cellItem = cellItem
item_loader_layout.x = table_view.contentX + cellPosition.x item_loader_layout.x = table_view.contentX + cellPosition.x
item_loader_layout.y = table_view.contentY + cellPosition.y item_loader_layout.y = table_view.contentY + cellPosition.y
item_loader_layout.width = table_view.columnWidthProvider(column) item_loader_layout.width = table_view.columnWidthProvider(column)
@ -204,14 +205,13 @@ Rectangle {
if(!w){ if(!w){
w = d.defaultItemWidth w = d.defaultItemWidth
} }
if(item_loader_layout.cellItem){
if(column === item_loader.column){ if(column === item_loader.column){
item_loader.width = w item_loader_layout.width = w
} }
if(column === item_loader.column-1){ if(column === item_loader.column-1){
let cellItem = table_view.itemAtCell(item_loader.column, item_loader.row) let cellPosition = item_loader_layout.cellItem.mapToItem(scroll_table, 0, 0)
if(cellItem){ item_loader_layout.x = table_view.contentX + cellPosition.x
let cellPosition = cellItem.mapToItem(scroll_table, 0, 0)
item_loader.x = table_view.contentX + cellPosition.x
} }
} }
return w return w
@ -225,16 +225,15 @@ Rectangle {
h = table_model.getRow(row).minimumHeight h = table_model.getRow(row).minimumHeight
} }
if(!h){ if(!h){
return d.defaultItemHeight h = d.defaultItemHeight
} }
if(item_loader_layout.cellItem){
if(row === item_loader.row){ if(row === item_loader.row){
item_loader.height = h item_loader_layout.height = h
} }
if(row === item_loader.row-1){ if(row === item_loader.row-1){
let cellItem = table_view.itemAtCell(item_loader.column, item_loader.row) let cellPosition = item_loader_layout.cellItem.mapToItem(scroll_table, 0, 0)
if(cellItem){ item_loader_layout.y = table_view.contentY + cellPosition.y
let cellPosition = cellItem.mapToItem(scroll_table, 0, 0)
item_loader.y = table_view.contentY + cellPosition.y
} }
} }
return h return h
@ -330,9 +329,15 @@ Rectangle {
} }
MouseArea{ MouseArea{
property var cellItem
id:item_loader_layout id:item_loader_layout
acceptedButtons: Qt.NoButton acceptedButtons: Qt.NoButton
visible: item_loader.sourceComponent visible: item_loader.sourceComponent
onVisibleChanged: {
if(!visible){
item_loader_layout.cellItem = undefined
}
}
hoverEnabled: true hoverEnabled: true
z:2 z:2
onEntered: { onEntered: {

View File

@ -44,6 +44,7 @@ Rectangle {
var cellPosition = cellItem.mapToItem(scroll_table, 0, 0) var cellPosition = cellItem.mapToItem(scroll_table, 0, 0)
item_loader.column = column item_loader.column = column
item_loader.row = row item_loader.row = row
item_loader_layout.cellItem = cellItem
item_loader_layout.x = table_view.contentX + cellPosition.x item_loader_layout.x = table_view.contentX + cellPosition.x
item_loader_layout.y = table_view.contentY + cellPosition.y item_loader_layout.y = table_view.contentY + cellPosition.y
item_loader_layout.width = table_view.columnWidthProvider(column) item_loader_layout.width = table_view.columnWidthProvider(column)
@ -205,14 +206,13 @@ Rectangle {
if(!w){ if(!w){
w = d.defaultItemWidth w = d.defaultItemWidth
} }
if(item_loader_layout.cellItem){
if(column === item_loader.column){ if(column === item_loader.column){
item_loader.width = w item_loader_layout.width = w
} }
if(column === item_loader.column-1){ if(column === item_loader.column-1){
let cellItem = table_view.itemAtCell(item_loader.column, item_loader.row) let cellPosition = item_loader_layout.cellItem.mapToItem(scroll_table, 0, 0)
if(cellItem){ item_loader_layout.x = table_view.contentX + cellPosition.x
let cellPosition = cellItem.mapToItem(scroll_table, 0, 0)
item_loader.x = table_view.contentX + cellPosition.x
} }
} }
return w return w
@ -226,16 +226,15 @@ Rectangle {
h = table_model.getRow(row).minimumHeight h = table_model.getRow(row).minimumHeight
} }
if(!h){ if(!h){
return d.defaultItemHeight h = d.defaultItemHeight
} }
if(item_loader_layout.cellItem){
if(row === item_loader.row){ if(row === item_loader.row){
item_loader.height = h item_loader_layout.height = h
} }
if(row === item_loader.row-1){ if(row === item_loader.row-1){
let cellItem = table_view.itemAtCell(item_loader.column, item_loader.row) let cellPosition = item_loader_layout.cellItem.mapToItem(scroll_table, 0, 0)
if(cellItem){ item_loader_layout.y = table_view.contentY + cellPosition.y
let cellPosition = cellItem.mapToItem(scroll_table, 0, 0)
item_loader.y = table_view.contentY + cellPosition.y
} }
} }
return h return h
@ -331,9 +330,15 @@ Rectangle {
} }
MouseArea{ MouseArea{
property var cellItem
id:item_loader_layout id:item_loader_layout
acceptedButtons: Qt.NoButton acceptedButtons: Qt.NoButton
visible: item_loader.sourceComponent visible: item_loader.sourceComponent
onVisibleChanged: {
if(!visible){
item_loader_layout.cellItem = undefined
}
}
hoverEnabled: true hoverEnabled: true
z:2 z:2
onEntered: { onEntered: {