This commit is contained in:
朱子楚\zhuzi 2024-04-30 12:59:09 +08:00
parent 30531079b5
commit bf001d99d2
12 changed files with 474 additions and 234 deletions

View File

@ -1964,7 +1964,7 @@ Some contents...</source>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="177"/> <location filename="qml/page/T_TableView.qml" line="177"/>
<location filename="qml/page/T_TableView.qml" line="513"/> <location filename="qml/page/T_TableView.qml" line="514"/>
<source>Name</source> <source>Name</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1984,67 +1984,67 @@ Some contents...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="359"/> <location filename="qml/page/T_TableView.qml" line="367"/>
<source>Age</source> <source>Age</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="434"/> <location filename="qml/page/T_TableView.qml" line="442"/>
<source>Clear All</source> <source>Clear All</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="441"/> <location filename="qml/page/T_TableView.qml" line="449"/>
<source>Delete Selection</source> <source>Delete Selection</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="464"/> <location filename="qml/page/T_TableView.qml" line="472"/>
<source>Add a row of Data</source> <source>Add a row of Data</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="470"/> <location filename="qml/page/T_TableView.qml" line="478"/>
<source>Insert a Row</source> <source>Insert a Row</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="477"/> <location filename="qml/page/T_TableView.qml" line="485"/>
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source> <source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="505"/> <location filename="qml/page/T_TableView.qml" line="519"/>
<source>Avatar</source> <source>Avatar</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="526"/> <location filename="qml/page/T_TableView.qml" line="533"/>
<source>Address</source> <source>Address</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="534"/> <location filename="qml/page/T_TableView.qml" line="541"/>
<source>Nickname</source> <source>Nickname</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="541"/> <location filename="qml/page/T_TableView.qml" line="548"/>
<source>Long String</source> <source>Long String</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="549"/> <location filename="qml/page/T_TableView.qml" line="556"/>
<source>Options</source> <source>Options</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="569"/> <location filename="qml/page/T_TableView.qml" line="576"/>
<source>&lt;Previous</source> <source>&lt;Previous</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="570"/> <location filename="qml/page/T_TableView.qml" line="577"/>
<source>Next&gt;</source> <source>Next&gt;</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -2110,7 +2110,7 @@ Some contents...</source>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="177"/> <location filename="qml/page/T_TableView.qml" line="177"/>
<location filename="qml/page/T_TableView.qml" line="513"/> <location filename="qml/page/T_TableView.qml" line="514"/>
<source>Name</source> <source>Name</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -2130,67 +2130,67 @@ Some contents...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="359"/> <location filename="qml/page/T_TableView.qml" line="367"/>
<source>Age</source> <source>Age</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="434"/> <location filename="qml/page/T_TableView.qml" line="442"/>
<source>Clear All</source> <source>Clear All</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="470"/> <location filename="qml/page/T_TableView.qml" line="478"/>
<source>Insert a Row</source> <source>Insert a Row</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="477"/> <location filename="qml/page/T_TableView.qml" line="485"/>
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source> <source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="505"/> <location filename="qml/page/T_TableView.qml" line="519"/>
<source>Avatar</source> <source>Avatar</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="526"/> <location filename="qml/page/T_TableView.qml" line="533"/>
<source>Address</source> <source>Address</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="534"/> <location filename="qml/page/T_TableView.qml" line="541"/>
<source>Nickname</source> <source>Nickname</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="541"/> <location filename="qml/page/T_TableView.qml" line="548"/>
<source>Long String</source> <source>Long String</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="549"/> <location filename="qml/page/T_TableView.qml" line="556"/>
<source>Options</source> <source>Options</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="569"/> <location filename="qml/page/T_TableView.qml" line="576"/>
<source>&lt;Previous</source> <source>&lt;Previous</source>
<translation type="unfinished">&lt;</translation> <translation type="unfinished">&lt;</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="570"/> <location filename="qml/page/T_TableView.qml" line="577"/>
<source>Next&gt;</source> <source>Next&gt;</source>
<translation type="unfinished">&gt;</translation> <translation type="unfinished">&gt;</translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="441"/> <location filename="qml/page/T_TableView.qml" line="449"/>
<source>Delete Selection</source> <source>Delete Selection</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="qml/page/T_TableView.qml" line="464"/> <location filename="qml/page/T_TableView.qml" line="472"/>
<source>Add a row of Data</source> <source>Add a row of Data</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -244,7 +244,9 @@ FluContentPage{
clickListener: function(){ clickListener: function(){
root.selectedAll = !root.selectedAll root.selectedAll = !root.selectedAll
var checked = root.selectedAll var checked = root.selectedAll
model.display = table_view.customItem(com_column_checbox,{"checked":checked}) var columnModel = model.display
columnModel.title = table_view.customItem(com_column_checbox,{"checked":checked})
model.display = columnModel
for(var i =0;i< table_view.rows ;i++){ for(var i =0;i< table_view.rows ;i++){
var rowData = table_view.getRow(i) var rowData = table_view.getRow(i)
rowData.checkbox = table_view.customItem(com_checbox,{"checked":checked}) rowData.checkbox = table_view.customItem(com_checbox,{"checked":checked})
@ -271,7 +273,9 @@ FluContentPage{
} }
Component.onCompleted: { Component.onCompleted: {
currentIndex=["100","300","500","1000"].findIndex((element) => element === display) currentIndex=["100","300","500","1000"].findIndex((element) => element === display)
selectAll() console.debug(textBox)
textBox.forceActiveFocus()
textBox.selectAll()
} }
onCommit: { onCommit: {
editTextChaged(editText) editTextChaged(editText)
@ -287,12 +291,14 @@ FluContentPage{
anchors.fill: parent anchors.fill: parent
focus: true focus: true
Component.onCompleted: { Component.onCompleted: {
console.debug("333333")
var data = ["傲来国界花果山水帘洞","傲来国界坎源山脏水洞","大唐国界黑风山黑风洞","大唐国界黄风岭黄风洞","大唐国界骷髅山白骨洞","宝象国界碗子山波月洞","宝象国界平顶山莲花洞","宝象国界压龙山压龙洞","乌鸡国界号山枯松涧火云洞","乌鸡国界衡阳峪黑水河河神府"] var data = ["傲来国界花果山水帘洞","傲来国界坎源山脏水洞","大唐国界黑风山黑风洞","大唐国界黄风岭黄风洞","大唐国界骷髅山白骨洞","宝象国界碗子山波月洞","宝象国界平顶山莲花洞","宝象国界压龙山压龙洞","乌鸡国界号山枯松涧火云洞","乌鸡国界衡阳峪黑水河河神府"]
var result = data.map(function(item) { var result = data.map(function(item) {
return {title: item}; return {title: item};
}); });
items = result items = result
textbox.text= String(display) textbox.text= String(display)
forceActiveFocus()
selectAll() selectAll()
} }
onCommit: { onCommit: {
@ -345,7 +351,9 @@ FluContentPage{
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
custom_update_dialog.showDialog(options.title,function(text){ custom_update_dialog.showDialog(options.title,function(text){
itemModel.display = table_view.customItem(com_column_update_title,{"title":text}) var columnModel = model.display
columnModel.title = table_view.customItem(com_column_update_title,{"title":text})
model.display = columnModel
}) })
} }
} }
@ -499,21 +507,20 @@ FluContentPage{
dataIndex: 'checkbox', dataIndex: 'checkbox',
width:100, width:100,
minimumWidth:100, minimumWidth:100,
maximumWidth:300 maximumWidth:300,
}, frozen: true
{
title: table_view.customItem(com_column_update_title,{title:qsTr("Avatar")}),
dataIndex: 'avatar',
width:100,
minimumWidth:100,
maximumWidth:100,
frozen:true
}, },
{ {
title: table_view.customItem(com_column_filter_name,{title:qsTr("Name")}), title: table_view.customItem(com_column_filter_name,{title:qsTr("Name")}),
dataIndex: 'name', dataIndex: 'name',
readOnly:true readOnly:true
}, },
{
title: table_view.customItem(com_column_update_title,{title:qsTr("Avatar")}),
dataIndex: 'avatar',
width:100,
frozen:true
},
{ {
title: table_view.customItem(com_column_sort_age,{sort:0}), title: table_view.customItem(com_column_sort_age,{sort:0}),
dataIndex: 'age', dataIndex: 'age',

View File

@ -15,7 +15,7 @@ FluWindow {
title: "FluentUI" title: "FluentUI"
width: 1000 width: 1000
height: 680 height: 680
minimumWidth: 680 minimumWidth: 1000
minimumHeight: 200 minimumHeight: 200
launchMode: FluWindowType.SingleTask launchMode: FluWindowType.SingleTask
fitsAppBarWindows: true fitsAppBarWindows: true

View File

@ -11,6 +11,7 @@ T.ComboBox {
property color normalColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1) property color normalColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1)
property color hoverColor: FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1) property color hoverColor: FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
property color disableColor: FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1) property color disableColor: FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1)
property alias textBox: text_field
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding) implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
@ -39,6 +40,7 @@ T.ComboBox {
opacity: enabled ? 1 : 0.3 opacity: enabled ? 1 : 0.3
} }
contentItem: T.TextField { contentItem: T.TextField {
id: text_field
property bool disabled: !control.editable property bool disabled: !control.editable
leftPadding: !control.mirrored ? 10 : control.editable && activeFocus ? 3 : 1 leftPadding: !control.mirrored ? 10 : control.editable && activeFocus ? 3 : 1
rightPadding: control.mirrored ? 10 : control.editable && activeFocus ? 3 : 1 rightPadding: control.mirrored ? 10 : control.editable && activeFocus ? 3 : 1

View File

@ -171,7 +171,7 @@ T.ScrollBar {
,Transition { ,Transition {
to: "show" to: "show"
SequentialAnimation { SequentialAnimation {
PauseAnimation { duration: 450 } PauseAnimation { duration: 150 }
NumberAnimation { NumberAnimation {
target: rect_bar target: rect_bar
properties: vertical ? "width" : "height" properties: vertical ? "width" : "height"

View File

@ -30,12 +30,19 @@ Rectangle {
if(columnSource.length!==0){ if(columnSource.length!==0){
var columns= [] var columns= []
var headerRow = {} var headerRow = {}
columnSource.forEach(function(item){ var offsetX = 0
for(var i=0;i<=columnSource.length-1;i++){
var item = columnSource[i]
if(!item.width){
item.width = d.defaultItemWidth
}
item.x = offsetX
offsetX = offsetX + item.width
var column = Qt.createQmlObject('import Qt.labs.qmlmodels 1.0;TableModelColumn{}',sourceModel); var column = Qt.createQmlObject('import Qt.labs.qmlmodels 1.0;TableModelColumn{}',sourceModel);
column.display = item.dataIndex column.display = item.dataIndex
columns.push(column) columns.push(column)
headerRow[item.dataIndex] = item.title headerRow[item.dataIndex] = item
}) }
header_column_model.columns = columns header_column_model.columns = columns
header_column_model.rows = [headerRow] header_column_model.rows = [headerRow]
} }
@ -48,6 +55,7 @@ Rectangle {
property int defaultItemHeight: 42 property int defaultItemHeight: 42
property var editDelegate property var editDelegate
property var editPosition property var editPosition
signal tableItemLayout(int column)
function getEditDelegate(column){ function getEditDelegate(column){
var obj =control.columnSource[column].editDelegate var obj =control.columnSource[column].editDelegate
if(obj){ if(obj){
@ -64,15 +72,15 @@ Rectangle {
sourceModel.rows = dataSource sourceModel.rows = dataSource
} }
TableModel{ TableModel{
id:header_column_model id: header_column_model
TableModelColumn { display : "title"} TableModelColumn { display : "title"}
} }
TableModel{ TableModel{
id:header_row_model id: header_row_model
TableModelColumn { display: "rowIndex" } TableModelColumn { display: "rowIndex" }
} }
FluTableSortProxyModel{ FluTableSortProxyModel{
id:table_sort_model id: table_sort_model
model: control.sourceModel model: control.sourceModel
} }
Component{ Component{
@ -189,7 +197,20 @@ 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 var currentTableView: TableView.view
visible: {
if(isMainTable && columnModel.frozen){
return false
}
if(!isMainTable){
if(currentTableView.dataIndex !== columnModel.dataIndex)
return false
}
return true
}
property bool isRowSelected: { property bool isRowSelected: {
if(rowModel === null) if(rowModel === null)
return false return false
@ -198,17 +219,17 @@ Rectangle {
} }
return false return false
} }
TableView.onPooled: {
if(d.editPosition && d.editPosition.row === row && d.editPosition.column === column){
control.closeEditor()
}
}
property bool editVisible: { property bool editVisible: {
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
} }
TableView.onPooled: {
if(d.editPosition && d.editPosition.row === row && d.editPosition.column === column){
control.closeEditor()
}
}
hoverEnabled: true hoverEnabled: true
onEntered: { onEntered: {
d.rowHoverIndex = row d.rowHoverIndex = row
@ -217,21 +238,33 @@ Rectangle {
if(editVisible){ if(editVisible){
updateEditPosition() updateEditPosition()
} }
if(isMainTable){
updateTableItem()
}
} }
onHeightChanged: { onHeightChanged: {
if(editVisible){ if(editVisible){
updateEditPosition() updateEditPosition()
} }
if(isMainTable){
updateTableItem()
}
} }
onXChanged: { onXChanged: {
if(editVisible){ if(editVisible){
updateEditPosition() updateEditPosition()
} }
if(isMainTable){
updateTableItem()
}
} }
onYChanged: { onYChanged: {
if(editVisible){ if(editVisible){
updateEditPosition() updateEditPosition()
} }
if(isMainTable){
updateTableItem()
}
} }
function updateEditPosition(){ function updateEditPosition(){
var obj = {} var obj = {}
@ -244,6 +277,12 @@ Rectangle {
obj.height = item_table_mouse.height - 2 obj.height = item_table_mouse.height - 2
d.editPosition = obj d.editPosition = obj
} }
function updateTableItem(){
var columnModel = control.columnSource[column]
columnModel.x = item_table_mouse.x
columnModel.y = item_table_mouse.y
d.tableItemLayout(column)
}
Rectangle{ Rectangle{
anchors.fill: parent anchors.fill: parent
color:{ color:{
@ -271,7 +310,7 @@ Rectangle {
} }
loader_edit.display = item_table_loader.display loader_edit.display = item_table_loader.display
d.editDelegate = d.getEditDelegate(column) d.editDelegate = d.getEditDelegate(column)
updateEditPosition() item_table_mouse.updateEditPosition()
} }
onClicked: onClicked:
(event)=>{ (event)=>{
@ -297,12 +336,50 @@ Rectangle {
} }
anchors.fill: parent anchors.fill: parent
sourceComponent: { sourceComponent: {
if(isObject){ if(item_table_mouse.visible){
return display.comId if(isObject){
return display.comId
}
return com_text
} }
return com_text return undefined
} }
} }
FluLoader{
id: loader_edit
property var tableView: control
property var display
property int column: {
if(d.editPosition){
return d.editPosition.column
}
return 0
}
property int row: {
if(d.editPosition){
return d.editPosition.row
}
return 0
}
anchors{
fill: parent
margins: 1
}
signal editTextChaged(string text)
sourceComponent: {
if(item_table_mouse.visible && d.editPosition && d.editPosition.column === model.column && d.editPosition.row === model.row){
return d.editDelegate
}
return undefined
}
onEditTextChaged:
(text)=>{
var obj = control.getRow(row)
obj[control.columnSource[column].dataIndex] = text
control.setRow(row,obj)
}
z:999
}
Item{ Item{
anchors.fill: parent anchors.fill: parent
visible: item_table_mouse.isRowSelected visible: item_table_mouse.isRowSelected
@ -358,24 +435,24 @@ Rectangle {
ScrollBar.horizontal:scroll_bar_h ScrollBar.horizontal:scroll_bar_h
ScrollBar.vertical:scroll_bar_v ScrollBar.vertical:scroll_bar_v
columnWidthProvider: function(column) { columnWidthProvider: function(column) {
var columnObject = control.columnSource[column] var columnModel = control.columnSource[column]
var width = columnObject.width var width = columnModel.width
if(width){ if(width){
return width return width
} }
var minimumWidth = columnObject.minimumWidth var minimumWidth = columnModel.minimumWidth
if(minimumWidth){ if(minimumWidth){
return minimumWidth return minimumWidth
} }
return d.defaultItemWidth return d.defaultItemWidth
} }
rowHeightProvider: function(row) { rowHeightProvider: function(row) {
var rowObject = control.getRow(row) var rowModel = control.getRow(row)
var height = rowObject.height var height = rowModel.height
if(height){ if(height){
return height return height
} }
var minimumHeight = rowObject._minimumHeight var minimumHeight = rowModel._minimumHeight
if(minimumHeight){ if(minimumHeight){
return minimumHeight return minimumHeight
} }
@ -388,70 +465,37 @@ Rectangle {
table_view.flick(0,1) table_view.flick(0,1)
} }
delegate: com_table_delegate delegate: com_table_delegate
FluLoader{
id:loader_edit
property var tableView: control
property var display
property int column: {
if(d.editPosition){
return d.editPosition.column
}
return 0
}
property int row: {
if(d.editPosition){
return d.editPosition.row
}
return 0
}
signal editTextChaged(string text)
sourceComponent: d.editPosition ? d.editDelegate : undefined
onEditTextChaged:
(text)=>{
var obj = control.getRow(row)
obj[control.columnSource[column].dataIndex] = text
control.setRow(row,obj)
}
width: {
if(d.editPosition){
return d.editPosition.width
}
return 0
}
height: {
if(d.editPosition){
return d.editPosition.height
}
return 0
}
x:{
if(d.editPosition){
return d.editPosition.x
}
return 0
}
y:{
if(d.editPosition){
return d.editPosition.y
}
return 0
}
z:999
}
} }
} }
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
readonly property real cellPadding: 8 readonly property real cellPadding: 8
property bool canceled: false property bool canceled: false
property var _model: model property var _model: model
readonly property var columnObject : control.columnSource[column] readonly property var columnModel : control.columnSource[_index]
implicitWidth: { readonly property int _index : {
return (item_column_loader.item && item_column_loader.item.implicitWidth) + (cellPadding * 2) const isDataIndex = (element) => {
return element.dataIndex === display.dataIndex
}
return control.columnSource.findIndex(isDataIndex)
}
readonly property bool isHeaderHorizontal: TableView.view == header_horizontal
implicitWidth: {
if(column_item_control.isHeaderHorizontal){
return (item_column_loader.item && item_column_loader.item.implicitWidth) + (cellPadding * 2)
}
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 TableView.view.height
} }
implicitHeight: Math.max(36, (item_column_loader.item&&item_column_loader.item.implicitHeight) + (cellPadding * 2))
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{
border.color: control.borderColor border.color: control.borderColor
@ -472,7 +516,7 @@ Rectangle {
width: 1 width: 1
height: parent.height height: parent.height
anchors.left: parent.left anchors.left: parent.left
visible: column !== 0 visible: column_item_control._index !== 0
color:"#00000000" color:"#00000000"
} }
Rectangle{ Rectangle{
@ -481,7 +525,7 @@ Rectangle {
height: parent.height height: parent.height
anchors.right: parent.right anchors.right: parent.right
color:"#00000000" color:"#00000000"
visible: column === table_view.columns - 1 visible: column_item_control._index === table_view.columns - 1
} }
MouseArea{ MouseArea{
id:column_item_control_mouse id:column_item_control_mouse
@ -504,17 +548,17 @@ Rectangle {
FluLoader{ FluLoader{
id:item_column_loader id:item_column_loader
property var model: column_item_control._model property var model: column_item_control._model
property var display: model.display property var display: model.display.title
property var tableView: table_view property var tableView: table_view
property var sourceModel: control.sourceModel property var sourceModel: control.sourceModel
property bool isObject: typeof(display) == "object" property bool isObject: typeof(display) == "object"
property var options:{ property var options:{
if(isObject){ if(isObject){
return display.options return display.options
} }
return {} return {}
} }
property int column: model.column property int column: column_item_control._index
width: parent.width width: parent.width
height: parent.height height: parent.height
sourceComponent: { sourceComponent: {
@ -531,7 +575,7 @@ Rectangle {
anchors.right: parent.right anchors.right: parent.right
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
hoverEnabled: true hoverEnabled: true
visible: !(columnObject.width === columnObject.minimumWidth && columnObject.width === columnObject.maximumWidth && columnObject.width) visible: !columnModel.frozen && !(columnModel.width === columnModel.minimumWidth && columnModel.width === columnModel.maximumWidth && columnModel.width)
cursorShape: Qt.SplitHCursor cursorShape: Qt.SplitHCursor
preventStealing: true preventStealing: true
onPressed : onPressed :
@ -551,9 +595,9 @@ Rectangle {
return return
} }
var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y) var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y)
var minimumWidth = columnObject.minimumWidth var minimumWidth = columnModel.minimumWidth
var maximumWidth = columnObject.maximumWidth var maximumWidth = columnModel.maximumWidth
var w = columnObject.width var w = columnModel.width
if(!w){ if(!w){
w = d.defaultItemWidth w = d.defaultItemWidth
} }
@ -563,9 +607,10 @@ Rectangle {
if(!maximumWidth){ if(!maximumWidth){
maximumWidth = 65535 maximumWidth = 65535
} }
columnObject.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()
} }
} }
} }
@ -576,7 +621,7 @@ Rectangle {
id:item_control id:item_control
readonly property real cellPadding: 8 readonly property real cellPadding: 8
property bool canceled: false property bool canceled: false
property var rowObject: control.getRow(row) property var rowModel: control.getRow(row)
implicitWidth: Math.max(30, row_text.implicitWidth + (cellPadding * 2)) implicitWidth: Math.max(30, row_text.implicitWidth + (cellPadding * 2))
implicitHeight: row_text.implicitHeight + (cellPadding * 2) implicitHeight: row_text.implicitHeight + (cellPadding * 2)
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)
@ -642,9 +687,9 @@ Rectangle {
cursorShape: Qt.SplitVCursor cursorShape: Qt.SplitVCursor
preventStealing: true preventStealing: true
visible: { visible: {
if(rowObject === null) if(rowModel === null)
return false return false
return !(rowObject.height === rowObject._minimumHeight && rowObject.height === rowObject._maximumHeight && rowObject.height) return !(rowModel.height === rowModel._minimumHeight && rowModel.height === rowModel._maximumHeight && rowModel.height)
} }
onPressed : onPressed :
(mouse)=>{ (mouse)=>{
@ -662,11 +707,11 @@ Rectangle {
if(!pressed){ if(!pressed){
return return
} }
var rowObject = control.getRow(row) var rowModel = control.getRow(row)
var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y) var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y)
var minimumHeight = rowObject._minimumHeight var minimumHeight = rowModel._minimumHeight
var maximumHeight = rowObject._maximumHeight var maximumHeight = rowModel._maximumHeight
var h = rowObject.height var h = rowModel.height
if(!h){ if(!h){
h = d.defaultItemHeight h = d.defaultItemHeight
} }
@ -676,8 +721,8 @@ Rectangle {
if(!maximumHeight){ if(!maximumHeight){
maximumHeight = 65535 maximumHeight = 65535
} }
rowObject.height = Math.min(Math.max(minimumHeight, h + delta.y),maximumHeight) rowModel.height = Math.min(Math.max(minimumHeight, h + delta.y),maximumHeight)
control.setRow(row,rowObject) control.setRow(row,rowModel)
table_view.forceLayout() table_view.forceLayout()
} }
} }
@ -790,6 +835,123 @@ Rectangle {
} }
} }
} }
Item{
anchors{
left: header_vertical.right
top: parent.top
bottom: parent.bottom
right: parent.right
}
Component{
id: com_table_frozen
Rectangle{
id: item_layout_frozen
anchors.fill: parent
color: {
if(Window.active){
return FluTheme.dark ? Qt.rgba(48/255,48/255,48/255,1) :Qt.rgba(1,1,1,1)
}
return FluTheme.dark ? Qt.rgba(56/255,56/255,56/255,1) :Qt.rgba(243/255,243/255,243/255,1)
}
Rectangle{
z:99
anchors.fill: parent
border.color: FluTheme.dark ? Qt.rgba(26/255,26/255,26/255,0.6) : Qt.rgba(191/255,191/255,191/255,0.3)
FluShadow{
radius: 0
anchors.fill: parent
}
color: "#00000000"
}
TableView {
id:item_table_frozen_header
model: header_column_model
boundsBehavior: Flickable.StopAtBounds
clip: true
interactive: false
anchors{
left: parent.left
right: parent.right
top: parent.top
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
}
}
}
}
Repeater{
model: control.columnSource
delegate: FluLoader{
id: item_layout_frozen
readonly property int _index : model.index
readonly property var columnModel : control.columnSource[_index]
Connections{
target: d
function onTableItemLayout(column){
if(item_layout_frozen._index === column){
updateLayout()
}
}
}
Connections{
target: table_view
function onContentXChanged(){
updateLayout()
}
}
function updateLayout(){
width = table_view.columnWidthProvider(_index)
x = Qt.binding(function(){
var minX = 0
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 + item.width
}
}
for(i=_index+1;i<control.columnSource.length;i++){
item = control.columnSource[i]
if(item.frozen){
maxX = maxX- item.width
}
}
return Math.min(Math.max(columnModel.x - table_view.contentX,minX),maxX)}
)
}
Component.onCompleted: {
updateLayout()
}
height: control.height
visible: {
if(modelData.frozen){
return true
}
return false
}
sourceComponent: visible ? com_table_frozen : undefined
}
}
}
FluScrollBar { FluScrollBar {
id: scroll_bar_h id: scroll_bar_h
anchors{ anchors{

View File

@ -302,7 +302,6 @@ Window {
info_bar.showError(text,duration,moremsg) info_bar.showError(text,duration,moremsg)
} }
function moveWindowToDesktopCenter(){ function moveWindowToDesktopCenter(){
screen = Qt.application.screens[FluTools.cursorScreenIndex()]
var availableGeometry = FluTools.desktopAvailableGeometry(window) var availableGeometry = FluTools.desktopAvailableGeometry(window)
window.setGeometry((availableGeometry.width-window.width)/2+Screen.virtualX,(availableGeometry.height-window.height)/2+Screen.virtualY,window.width,window.height) window.setGeometry((availableGeometry.width-window.width)/2+Screen.virtualX,(availableGeometry.height-window.height)/2+Screen.virtualY,window.width,window.height)
} }

View File

@ -11,6 +11,7 @@ T.ComboBox {
property color normalColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1) property color normalColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1)
property color hoverColor: FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1) property color hoverColor: FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
property color disableColor: FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1) property color disableColor: FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1)
property alias textBox: text_field
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding) implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
@ -39,6 +40,7 @@ T.ComboBox {
opacity: enabled ? 1 : 0.3 opacity: enabled ? 1 : 0.3
} }
contentItem: T.TextField { contentItem: T.TextField {
id: text_field
property bool disabled: !control.editable property bool disabled: !control.editable
leftPadding: !control.mirrored ? 10 : control.editable && activeFocus ? 3 : 1 leftPadding: !control.mirrored ? 10 : control.editable && activeFocus ? 3 : 1
rightPadding: control.mirrored ? 10 : control.editable && activeFocus ? 3 : 1 rightPadding: control.mirrored ? 10 : control.editable && activeFocus ? 3 : 1

View File

@ -173,7 +173,7 @@ T.ScrollBar {
,Transition { ,Transition {
to: "show" to: "show"
SequentialAnimation { SequentialAnimation {
PauseAnimation { duration: 450 } PauseAnimation { duration: 150 }
NumberAnimation { NumberAnimation {
target: rect_bar target: rect_bar
properties: vertical ? "width" : "height" properties: vertical ? "width" : "height"

View File

@ -33,16 +33,15 @@ Rectangle {
var offsetX = 0 var offsetX = 0
for(var i=0;i<=columnSource.length-1;i++){ for(var i=0;i<=columnSource.length-1;i++){
var item = columnSource[i] var item = columnSource[i]
var w = item.width if(!item.width){
if(!w){ item.width = d.defaultItemWidth
w = d.defaultItemWidth
} }
item.x = offsetX item.x = offsetX
offsetX = offsetX + w offsetX = offsetX + item.width
var column = Qt.createQmlObject('import Qt.labs.qmlmodels 1.0;TableModelColumn{}',sourceModel); var column = Qt.createQmlObject('import Qt.labs.qmlmodels 1.0;TableModelColumn{}',sourceModel);
column.display = item.dataIndex column.display = item.dataIndex
columns.push(column) columns.push(column)
headerRow[item.dataIndex] = item.title headerRow[item.dataIndex] = item
} }
header_column_model.columns = columns header_column_model.columns = columns
header_column_model.rows = [headerRow] header_column_model.rows = [headerRow]
@ -73,15 +72,15 @@ Rectangle {
sourceModel.rows = dataSource sourceModel.rows = dataSource
} }
TableModel{ TableModel{
id:header_column_model id: header_column_model
TableModelColumn { display : "title"} TableModelColumn { display : "title"}
} }
TableModel{ TableModel{
id:header_row_model id: header_row_model
TableModelColumn { display: "rowIndex" } TableModelColumn { display: "rowIndex" }
} }
FluTableSortProxyModel{ FluTableSortProxyModel{
id:table_sort_model id: table_sort_model
model: control.sourceModel model: control.sourceModel
} }
Component{ Component{
@ -200,6 +199,18 @@ Rectangle {
id:item_table_mouse id:item_table_mouse
implicitWidth: TableView.view.width implicitWidth: TableView.view.width
property var _model: model property var _model: model
property bool isMainTable: TableView.view == table_view
property var currentTableView: TableView.view
visible: {
if(isMainTable && columnModel.frozen){
return false
}
if(!isMainTable){
if(currentTableView.dataIndex !== columnModel.dataIndex)
return false
}
return true
}
property bool isRowSelected: { property bool isRowSelected: {
if(rowModel === null) if(rowModel === null)
return false return false
@ -227,25 +238,33 @@ Rectangle {
if(editVisible){ if(editVisible){
updateEditPosition() updateEditPosition()
} }
item_table_mouse.updateTableItem() if(isMainTable){
updateTableItem()
}
} }
onHeightChanged: { onHeightChanged: {
if(editVisible){ if(editVisible){
updateEditPosition() updateEditPosition()
} }
item_table_mouse.updateTableItem() if(isMainTable){
updateTableItem()
}
} }
onXChanged: { onXChanged: {
if(editVisible){ if(editVisible){
updateEditPosition() updateEditPosition()
} }
item_table_mouse.updateTableItem() if(isMainTable){
updateTableItem()
}
} }
onYChanged: { onYChanged: {
if(editVisible){ if(editVisible){
updateEditPosition() updateEditPosition()
} }
item_table_mouse.updateTableItem() if(isMainTable){
updateTableItem()
}
} }
function updateEditPosition(){ function updateEditPosition(){
var obj = {} var obj = {}
@ -317,12 +336,50 @@ Rectangle {
} }
anchors.fill: parent anchors.fill: parent
sourceComponent: { sourceComponent: {
if(isObject){ if(item_table_mouse.visible){
return display.comId if(isObject){
return display.comId
}
return com_text
} }
return com_text return undefined
} }
} }
FluLoader{
id: loader_edit
property var tableView: control
property var display
property int column: {
if(d.editPosition){
return d.editPosition.column
}
return 0
}
property int row: {
if(d.editPosition){
return d.editPosition.row
}
return 0
}
anchors{
fill: parent
margins: 1
}
signal editTextChaged(string text)
sourceComponent: {
if(item_table_mouse.visible && d.editPosition && d.editPosition.column === model.column && d.editPosition.row === model.row){
return d.editDelegate
}
return undefined
}
onEditTextChaged:
(text)=>{
var obj = control.getRow(row)
obj[control.columnSource[column].dataIndex] = text
control.setRow(row,obj)
}
z:999
}
Item{ Item{
anchors.fill: parent anchors.fill: parent
visible: item_table_mouse.isRowSelected visible: item_table_mouse.isRowSelected
@ -408,71 +465,37 @@ Rectangle {
table_view.flick(0,1) table_view.flick(0,1)
} }
delegate: com_table_delegate delegate: com_table_delegate
FluLoader{
id:loader_edit
property var tableView: control
property var display
property int column: {
if(d.editPosition){
return d.editPosition.column
}
return 0
}
property int row: {
if(d.editPosition){
return d.editPosition.row
}
return 0
}
signal editTextChaged(string text)
sourceComponent: d.editPosition ? d.editDelegate : undefined
onEditTextChaged:
(text)=>{
var obj = control.getRow(row)
obj[control.columnSource[column].dataIndex] = text
control.setRow(row,obj)
}
width: {
if(d.editPosition){
return d.editPosition.width
}
return 0
}
height: {
if(d.editPosition){
return d.editPosition.height
}
return 0
}
x:{
if(d.editPosition){
return d.editPosition.x
}
return 0
}
y:{
if(d.editPosition){
return d.editPosition.y
}
return 0
}
z:999
}
} }
} }
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
readonly property real cellPadding: 8 readonly property real cellPadding: 8
property bool canceled: false property bool canceled: false
property var _model: model property var _model: model
readonly property var columnModel : control.columnSource[column] readonly property var columnModel : control.columnSource[_index]
implicitWidth: { readonly property int _index : {
return (item_column_loader.item && item_column_loader.item.implicitWidth) + (cellPadding * 2) const isDataIndex = (element) => {
return element.dataIndex === display.dataIndex
}
return control.columnSource.findIndex(isDataIndex)
}
readonly property bool isHeaderHorizontal: TableView.view == header_horizontal
implicitWidth: {
if(column_item_control.isHeaderHorizontal){
return (item_column_loader.item && item_column_loader.item.implicitWidth) + (cellPadding * 2)
}
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 TableView.view.height
} }
implicitHeight: Math.max(36, (item_column_loader.item&&item_column_loader.item.implicitHeight) + (cellPadding * 2))
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{
border.color: control.borderColor border.color: control.borderColor
@ -493,7 +516,7 @@ Rectangle {
width: 1 width: 1
height: parent.height height: parent.height
anchors.left: parent.left anchors.left: parent.left
visible: column !== 0 visible: column_item_control._index !== 0
color:"#00000000" color:"#00000000"
} }
Rectangle{ Rectangle{
@ -502,7 +525,7 @@ Rectangle {
height: parent.height height: parent.height
anchors.right: parent.right anchors.right: parent.right
color:"#00000000" color:"#00000000"
visible: column === table_view.columns - 1 visible: column_item_control._index === table_view.columns - 1
} }
MouseArea{ MouseArea{
id:column_item_control_mouse id:column_item_control_mouse
@ -525,7 +548,7 @@ Rectangle {
FluLoader{ FluLoader{
id:item_column_loader id:item_column_loader
property var model: column_item_control._model property var model: column_item_control._model
property var display: model.display property var display: model.display.title
property var tableView: table_view property var tableView: table_view
property var sourceModel: control.sourceModel property var sourceModel: control.sourceModel
property bool isObject: typeof(display) == "object" property bool isObject: typeof(display) == "object"
@ -535,7 +558,7 @@ Rectangle {
} }
return {} return {}
} }
property int column: model.column property int column: column_item_control._index
width: parent.width width: parent.width
height: parent.height height: parent.height
sourceComponent: { sourceComponent: {
@ -552,7 +575,7 @@ Rectangle {
anchors.right: parent.right anchors.right: parent.right
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
hoverEnabled: true hoverEnabled: true
visible: !(columnModel.width === columnModel.minimumWidth && columnModel.width === columnModel.maximumWidth && columnModel.width) visible: !columnModel.frozen && !(columnModel.width === columnModel.minimumWidth && columnModel.width === columnModel.maximumWidth && columnModel.width)
cursorShape: Qt.SplitHCursor cursorShape: Qt.SplitHCursor
preventStealing: true preventStealing: true
onPressed : onPressed :
@ -587,6 +610,7 @@ 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()
} }
} }
} }
@ -811,60 +835,108 @@ Rectangle {
} }
} }
} }
Item{ Item{
anchors{ anchors{
left: header_vertical.right left: header_vertical.right
top: parent.top top: parent.top
bottom: parent.bottom bottom: parent.bottom
right: parent.right
} }
Component{ Component{
id: com_table_frozen id: com_table_frozen
Item{ Rectangle{
id: item_layout_frozen id: item_layout_frozen
property var sourceModel:FluTableModel { anchors.fill: parent
columnSource: columnModel color: {
rows: control.sourceModel.rows if(Window.active){
return FluTheme.dark ? Qt.rgba(48/255,48/255,48/255,1) :Qt.rgba(1,1,1,1)
}
return FluTheme.dark ? Qt.rgba(56/255,56/255,56/255,1) :Qt.rgba(243/255,243/255,243/255,1)
}
Rectangle{
z:99
anchors.fill: parent
border.color: FluTheme.dark ? Qt.rgba(26/255,26/255,26/255,0.6) : Qt.rgba(191/255,191/255,191/255,0.3)
FluShadow{
radius: 0
anchors.fill: parent
}
color: "#00000000"
}
TableView {
id:item_table_frozen_header
model: header_column_model
boundsBehavior: Flickable.StopAtBounds
clip: true
interactive: false
anchors{
left: parent.left
right: parent.right
top: parent.top
bottom: item_table_frozen.top
}
delegate: com_column_header_delegate
} }
TableView{ TableView{
property string dataIndex: columnModel.dataIndex
id: item_table_frozen
clip: true clip: true
interactive: false
anchors{ anchors{
fill: parent fill: parent
topMargin: header_horizontal.height topMargin: header_horizontal.height
} }
model: control.sourceModel boundsBehavior: TableView.StopAtBounds
model: table_sort_model
delegate: com_table_delegate delegate: com_table_delegate
syncDirection: Qt.Vertical syncDirection: Qt.Vertical
syncView: table_view syncView: table_view
Component.onCompleted: {
item_table_frozen_header.contentX = columnModel.width * _index
item_table_frozen.contentX = columnModel.width * _index
}
} }
} }
} }
Repeater{ Repeater{
model: control.columnSource model: control.columnSource
delegate: FluLoader{ delegate: FluLoader{
id: item_layout_frozen id: item_layout_frozen
readonly property var columnModel : control.columnSource[model.index] readonly property int _index : model.index
readonly property int index : model.index readonly property var columnModel : control.columnSource[_index]
width: table_view.columnWidthProvider(index)
Connections{ Connections{
target: d target: d
function onTableItemLayout(column){ function onTableItemLayout(column){
if(column === index){ if(item_layout_frozen._index === column){
item_layout_frozen.updateLayout() updateLayout()
} }
} }
} }
Connections{ Connections{
target: table_view target: table_view
function onContentXChanged(){ function onContentXChanged(){
item_layout_frozen.updateLayout() updateLayout()
} }
} }
function updateLayout(){ function updateLayout(){
width = table_view.columnWidthProvider(index) width = table_view.columnWidthProvider(_index)
x = Qt.binding(function(){ return Math.min(Math.max(columnModel.x - table_view.contentX,0),table_view.width-item_layout_frozen.width) }) x = Qt.binding(function(){
var minX = 0
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 + item.width
}
}
for(i=_index+1;i<control.columnSource.length;i++){
item = control.columnSource[i]
if(item.frozen){
maxX = maxX- item.width
}
}
return Math.min(Math.max(columnModel.x - table_view.contentX,minX),maxX)}
)
} }
Component.onCompleted: { Component.onCompleted: {
updateLayout() updateLayout()
@ -880,9 +952,6 @@ Rectangle {
} }
} }
} }
FluScrollBar { FluScrollBar {
id: scroll_bar_h id: scroll_bar_h
anchors{ anchors{

View File

@ -301,7 +301,6 @@ Window {
info_bar.showError(text,duration,moremsg) info_bar.showError(text,duration,moremsg)
} }
function moveWindowToDesktopCenter(){ function moveWindowToDesktopCenter(){
screen = Qt.application.screens[FluTools.cursorScreenIndex()]
var availableGeometry = FluTools.desktopAvailableGeometry(window) var availableGeometry = FluTools.desktopAvailableGeometry(window)
window.setGeometry((availableGeometry.width-window.width)/2+Screen.virtualX,(availableGeometry.height-window.height)/2+Screen.virtualY,window.width,window.height) window.setGeometry((availableGeometry.width-window.width)/2+Screen.virtualX,(availableGeometry.height-window.height)/2+Screen.virtualY,window.width,window.height)
} }