This commit is contained in:
zhuzichu 2023-06-28 13:13:39 +08:00
parent 90943674b3
commit 192c65a510
7 changed files with 140 additions and 84 deletions

View File

@ -19,7 +19,7 @@ endif()
file(TO_CMAKE_PATH "/" PATH_SEPARATOR) file(TO_CMAKE_PATH "/" PATH_SEPARATOR)
# #
add_definitions(-DVERSION=1,3,6,2) add_definitions(-DVERSION=1,3,7,0)
find_package(Qt6 REQUIRED COMPONENTS Quick) find_package(Qt6 REQUIRED COMPONENTS Quick)

View File

@ -5,76 +5,80 @@ import QtQuick.Window
import FluentUI import FluentUI
import "qrc:///example/qml/component" import "qrc:///example/qml/component"
FluScrollablePage{ FluPage{
title:"Pivot" Component.onDestruction: {
console.debug("------------------------->")
FluArea{
Layout.fillWidth: true
Layout.topMargin: 20
height: 400
paddings: 10
FluPivot{
anchors.fill: parent
currentIndex: 2
FluPivotItem{
title:"All"
contentItem:FluText{
text:"All emails go here."
}
}
FluPivotItem{
title:"Unread"
contentItem:FluText{
text:"Unread emails go here."
}
}
FluPivotItem{
title:"Flagged"
contentItem:FluText{
text:"Flagged emails go here."
}
}
FluPivotItem{
title:"Urgent"
contentItem:FluText{
text:"Urgent emails go here."
}
}
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -1
code:'FluPivot{
anchors.fill: parent
FluPivotItem:{
text:"All"
contentItem: FluText{
text:"All emails go here."
}
}
FluPivotItem:{
text:"Unread"
contentItem: FluText{
text:"Unread emails go here."
}
}
FluPivotItem:{
text:"Flagged"
contentItem: FluText{
text:"Flagged emails go here."
}
}
FluPivotItem:{
text:"Urgent"
contentItem: FluText{
text:"Urgent emails go here."
}
}
}
'
} }
// title:"Pivot"
// FluArea{
// Layout.fillWidth: true
// Layout.topMargin: 20
// height: 400
// paddings: 10
// FluPivot{
// anchors.fill: parent
// currentIndex: 2
// FluPivotItem{
// title:"All"
// contentItem:FluText{
// text:"All emails go here."
// }
// }
// FluPivotItem{
// title:"Unread"
// contentItem:FluText{
// text:"Unread emails go here."
// }
// }
// FluPivotItem{
// title:"Flagged"
// contentItem:FluText{
// text:"Flagged emails go here."
// }
// }
// FluPivotItem{
// title:"Urgent"
// contentItem:FluText{
// text:"Urgent emails go here."
// }
// }
// }
// }
// CodeExpander{
// Layout.fillWidth: true
// Layout.topMargin: -1
// code:'FluPivot{
// anchors.fill: parent
// FluPivotItem:{
// text:"All"
// contentItem: FluText{
// text:"All emails go here."
// }
// }
// FluPivotItem:{
// text:"Unread"
// contentItem: FluText{
// text:"Unread emails go here."
// }
// }
// FluPivotItem:{
// text:"Flagged"
// contentItem: FluText{
// text:"Flagged emails go here."
// }
// }
// FluPivotItem:{
// text:"Urgent"
// contentItem: FluText{
// text:"Urgent emails go here."
// }
// }
//}
//'
// }
} }

View File

@ -13,8 +13,26 @@ FluContentPage{
loadData(1,1000) loadData(1,1000)
} }
Component.onDestruction: { Component{
console.debug("T_TableView已经销毁") id:com_action
Item{
RowLayout{
anchors.centerIn: parent
FluButton{
text:"删除"
onClicked: {
table_view.closeEditor()
tableModel.removeRow(row)
}
}
FluFilledButton{
text:"编辑"
onClicked: {
showSuccess(JSON.stringify(tableModel.getRow(row)))
}
}
}
}
} }
function loadData(page,count){ function loadData(page,count){
@ -47,7 +65,8 @@ FluContentPage{
nickname: getRandomNickname(), nickname: getRandomNickname(),
height:40, height:40,
minimumHeight:40, minimumHeight:40,
maximumHeight:200 maximumHeight:200,
action:com_action
}) })
} }
table_view.dataSource = dataSource table_view.dataSource = dataSource
@ -116,6 +135,13 @@ FluContentPage{
width:100, width:100,
minimumWidth:80, minimumWidth:80,
maximumWidth:200 maximumWidth:200
},
{
title: '操作',
dataIndex: 'action',
width:160,
minimumWidth:160,
maximumWidth:160
} }
] ]
} }

View File

@ -12,7 +12,7 @@ endif()
set(QML_PLUGIN_DIRECTORY ${CMAKE_PREFIX_PATH}/qml/FluentUI) set(QML_PLUGIN_DIRECTORY ${CMAKE_PREFIX_PATH}/qml/FluentUI)
# #
add_definitions(-DVERSION=1,3,6,2) add_definitions(-DVERSION=1,3,7,0)
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml) find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml)

View File

@ -111,6 +111,9 @@ void FluApp::closeApp(){
} }
void FluApp::deleteWindow(QQuickWindow* window){ void FluApp::deleteWindow(QQuickWindow* window){
if(window){
wnds.remove(window->winId()); wnds.remove(window->winId());
window->deleteLater(); window->deleteLater();
window = nullptr;
}
} }

View File

@ -89,5 +89,8 @@ void FluTools::restoreOverrideCursor(){
} }
void FluTools::deleteItem(QObject *p){ void FluTools::deleteItem(QObject *p){
p->deleteLater(); if(p){
delete p;
p = nullptr;
}
} }

View File

@ -59,6 +59,16 @@ Rectangle {
} }
} }
} }
Component{
id:com_text
FluText {
text: itemData
anchors.fill: parent
anchors.margins: 10
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
}
ScrollView{ ScrollView{
id:scroll_table id:scroll_table
anchors.left: header_vertical.right anchors.left: header_vertical.right
@ -110,6 +120,8 @@ Rectangle {
model: table_model model: table_model
clip: true clip: true
delegate: Rectangle { delegate: Rectangle {
id:item_table
property var position: Qt.point(column,row)
required property bool selected required property bool selected
property bool current: selection_model.currentIndex === table_model.index(row,column) property bool current: selection_model.currentIndex === table_model.index(row,column)
color: selected ? FluTheme.primaryColor.lightest: (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06)) color: selected ? FluTheme.primaryColor.lightest: (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06))
@ -118,6 +130,9 @@ Rectangle {
TapHandler{ TapHandler{
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
onDoubleTapped: { onDoubleTapped: {
if(display instanceof Component){
return
}
selection_model.setCurrentIndex(table_model.index(row,column), ItemSelectionModel.Current) selection_model.setCurrentIndex(table_model.index(row,column), ItemSelectionModel.Current)
item_loader.sourceComponent = obtEditDelegate(column,row) item_loader.sourceComponent = obtEditDelegate(column,row)
var index = table_model.index(row,column) var index = table_model.index(row,column)
@ -128,12 +143,20 @@ Rectangle {
} }
} }
} }
FluText { Loader{
text: display property var itemData: display
property var tableView: table_view
property var tableModel: table_model
property var position: item_table.position
property int row: position.y
property int column: position.x
anchors.fill: parent anchors.fill: parent
anchors.margins: 10 sourceComponent: {
elide: Text.ElideRight if(itemData instanceof Component){
verticalAlignment: Text.AlignVCenter return itemData
}
return com_text
}
} }
} }
} }
@ -353,13 +376,10 @@ Rectangle {
} }
} }
} }
function closeEditor(){ function closeEditor(){
item_loader.sourceComponent = null item_loader.sourceComponent = null
} }
function resetPosition(){ function resetPosition(){
table_view.positionViewAtCell(Qt.point(0, 0),Qt.AlignTop|Qt.AlignLeft) table_view.positionViewAtCell(Qt.point(0, 0),Qt.AlignTop|Qt.AlignLeft)
} }
} }