This commit is contained in:
朱子楚\zhuzi 2024-03-03 01:14:54 +08:00
parent 07de3b82b1
commit 644a0e509f
7 changed files with 424 additions and 319 deletions

View File

@ -261,16 +261,16 @@ FluContentPage{
FluComboBox { FluComboBox {
anchors.fill: parent anchors.fill: parent
focus: true focus: true
currentIndex: display editText: display
editable: true editable: true
model: ListModel { model: ListModel {
ListElement { text: 100 } ListElement { text: "100" }
ListElement { text: 300 } ListElement { text: "300" }
ListElement { text: 500 } ListElement { text: "500" }
ListElement { text: 1000 } ListElement { text: "1000" }
} }
Component.onCompleted: { Component.onCompleted: {
currentIndex=[100,300,500,1000].findIndex((element) => element === Number(display)) currentIndex=["100","300","500","1000"].findIndex((element) => element === display)
selectAll() selectAll()
} }
onCommit: { onCommit: {

View File

@ -261,16 +261,16 @@ FluContentPage{
FluComboBox { FluComboBox {
anchors.fill: parent anchors.fill: parent
focus: true focus: true
currentIndex: display editText: display
editable: true editable: true
model: ListModel { model: ListModel {
ListElement { text: 100 } ListElement { text: "100" }
ListElement { text: 300 } ListElement { text: "300" }
ListElement { text: 500 } ListElement { text: "500" }
ListElement { text: 1000 } ListElement { text: "1000" }
} }
Component.onCompleted: { Component.onCompleted: {
currentIndex=[100,300,500,1000].findIndex((element) => element === Number(display)) currentIndex=["100","300","500","1000"].findIndex((element) => element === display)
selectAll() selectAll()
} }
onCommit: { onCommit: {

View File

@ -207,8 +207,3 @@ void Log::setup(const QString &app,int level)
qInfo()<<"[LOG_PATH]"<<g_file_path; qInfo()<<"[LOG_PATH]"<<g_file_path;
qInfo()<<"==================================================="; qInfo()<<"===================================================";
} }
void Log::teardown()
{
qInstallMessageHandler(0);
}

View File

@ -6,7 +6,6 @@ namespace Log
{ {
QString prettyProductInfoWrapper(); QString prettyProductInfoWrapper();
void setup(const QString &app,int level = 4); void setup(const QString &app,int level = 4);
void teardown();
} }
#endif // LOG_H #endif // LOG_H

View File

@ -82,6 +82,5 @@ int main(int argc, char *argv[])
if (exec == 931) { if (exec == 931) {
QProcess::startDetached(qApp->applicationFilePath(), QStringList()); QProcess::startDetached(qApp->applicationFilePath(), QStringList());
} }
Log::teardown();
return exec; return exec;
} }

View File

@ -177,176 +177,232 @@ Rectangle {
onCanceled: { onCanceled: {
d.rowHoverIndex = -1 d.rowHoverIndex = -1
} }
ScrollView{ TableView {
id:table_view
ListModel{
id:model_columns
}
anchors.fill: parent anchors.fill: parent
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff boundsBehavior: Flickable.StopAtBounds
ScrollBar.vertical.policy: ScrollBar.AlwaysOff syncView: header_horizontal
TableView { syncDirection: Qt.Horizontal
id:table_view ScrollBar.vertical:scroll_bar_v
ListModel{ rowHeightProvider: function(row) {
id:model_columns if(row>=table_view.rows){
return 0
} }
boundsBehavior: Flickable.StopAtBounds var rowObject = control.getRow(row)
syncView: header_horizontal var h = rowObject.height
syncDirection: Qt.Horizontal if(!h){
ScrollBar.vertical:scroll_bar_v h = rowObject._minimumHeight
rowHeightProvider: function(row) {
if(row>=table_view.rows){
return 0
}
var rowObject = control.getRow(row)
var h = rowObject.height
if(!h){
h = rowObject._minimumHeight
}
if(!h){
h = d.defaultItemHeight
}
return h
} }
model: table_sort_model if(!h){
clip: true h = d.defaultItemHeight
onRowsChanged: {
closeEditor()
} }
delegate: MouseArea{ return h
property var rowObject : control.getRow(row) }
property var itemModel: model model: table_sort_model
hoverEnabled: true clip: true
implicitHeight: 40 onRowsChanged: {
implicitWidth: { closeEditor()
var w = columnSource[column].width }
if(!w){ delegate: MouseArea{
w = columnSource[column].minimumWidth id:item_table_mouse
} property var rowObject : control.getRow(row)
if(!w){ property var itemModel: model
w = d.defaultItemWidth property bool editVisible: {
} if(d.editPosition === undefined){
return w return false
} }
onEntered: { if(d.editPosition._key === rowObject._key && d.editPosition.column === column){
d.rowHoverIndex = row return true
} }
Rectangle{ return false
id:item_table }
anchors.fill: parent hoverEnabled: true
property point position: Qt.point(column,row) onEntered: {
property bool isRowSelected: { d.rowHoverIndex = row
if(rowObject === null) }
return false onWidthChanged: {
if(d.current){ if(editVisible){
return rowObject._key === d.current._key updateEditPosition()
} }
}
onHeightChanged: {
if(editVisible){
updateEditPosition()
}
}
onXChanged: {
if(editVisible){
updateEditPosition()
}
}
onYChanged: {
if(editVisible){
updateEditPosition()
}
}
function updateEditPosition(){
var obj = {}
obj._key = rowObject._key
obj.column = column
obj.row = row
obj.x = item_table_mouse.x
obj.y = item_table_mouse.y + 1
obj.width = item_table_mouse.width
obj.height = item_table_mouse.height - 2
d.editPosition = obj
}
Rectangle{
id:item_table
anchors.fill: parent
property point position: Qt.point(column,row)
property bool isRowSelected: {
if(rowObject === null)
return false return false
if(d.current){
return rowObject._key === d.current._key
} }
color:{ return false
if(item_table.isRowSelected){ }
return control.selectedColor color:{
} if(item_table.isRowSelected){
if(d.rowHoverIndex === row || item_table.isRowSelected){ return control.selectedColor
return FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06)
}
return (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.015) : Qt.rgba(0,0,0,0.015))
} }
MouseArea{ if(d.rowHoverIndex === row || item_table.isRowSelected){
anchors.fill: parent return FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06)
acceptedButtons: Qt.LeftButton }
onPressed:{ return (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.015) : Qt.rgba(0,0,0,0.015))
}
MouseArea{
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onPressed:{
closeEditor()
}
onCanceled: {
}
onReleased: {
}
onDoubleClicked:{
if(typeof(display) == "object"){
return
}
d.editDelegate = d.getEditDelegate(column)
updateEditPosition()
loader_edit.display = display
}
onClicked:
(event)=>{
d.current = rowObject
closeEditor() closeEditor()
event.accepted = true
} }
onCanceled: { }
FluLoader{
property var model: itemModel
property var display: itemModel.display
property int row: item_table.position.y
property int column: item_table.position.x
property var options: {
if(typeof(modelData) == "object"){
return modelData.options
} }
onReleased: { return {}
}
onDoubleClicked:{
if(typeof(display) == "object"){
return
}
d.editDelegate = d.getEditDelegate(column)
d.editPosition = {"_key":rowObject._key,"column":column}
}
onClicked:
(event)=>{
d.current = rowObject
closeEditor()
event.accepted = true
}
} }
FluLoader{ anchors.fill: parent
property var model: itemModel sourceComponent: {
property var display: itemModel.display if(typeof(modelData) == "object"){
property int row: item_table.position.y return modelData.comId
property int column: item_table.position.x
property var options: {
if(typeof(modelData) == "object"){
return modelData.options
}
return {}
}
anchors.fill: parent
sourceComponent: {
if(typeof(modelData) == "object"){
return modelData.comId
}
return com_text
} }
return com_text
} }
FluLoader{ }
property var display: itemModel.display Item{
property int column: item_table.position.x anchors.fill: parent
property int row: item_table.position.y visible: item_table.isRowSelected
property var tableView: control Rectangle{
signal editTextChaged(string text) width: 1
anchors.fill: parent height: parent.height
onEditTextChaged: anchors.left: parent.left
(text)=>{ color: control.selectedBorderColor
var obj = control.getRow(row) visible: column === 0
obj[columnSource[column].dataIndex] = text
control.setRow(row,obj)
}
sourceComponent: {
if(d.editPosition === undefined){
return undefined
}
if(d.editPosition._key === rowObject._key && d.editPosition.column === column){
return d.editDelegate
}
return undefined
}
} }
Item{ Rectangle{
anchors.fill: parent width: 1
visible: item_table.isRowSelected height: parent.height
Rectangle{ anchors.right: parent.right
width: 1 color: control.selectedBorderColor
height: parent.height visible: column === control.columns-1
anchors.left: parent.left }
color: control.selectedBorderColor Rectangle{
visible: column === 0 width: parent.width
} height: 1
Rectangle{ anchors.top: parent.top
width: 1 color: control.selectedBorderColor
height: parent.height }
anchors.right: parent.right Rectangle{
color: control.selectedBorderColor width: parent.width
visible: column === control.columns-1 height: 1
} anchors.bottom: parent.bottom
Rectangle{ color: control.selectedBorderColor
width: parent.width
height: 1
anchors.top: parent.top
color: control.selectedBorderColor
}
Rectangle{
width: parent.width
height: 1
anchors.bottom: parent.bottom
color: control.selectedBorderColor
}
} }
} }
} }
} }
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[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{

View File

@ -178,176 +178,232 @@ Rectangle {
onCanceled: { onCanceled: {
d.rowHoverIndex = -1 d.rowHoverIndex = -1
} }
ScrollView{ TableView {
id:table_view
ListModel{
id:model_columns
}
anchors.fill: parent anchors.fill: parent
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff boundsBehavior: Flickable.StopAtBounds
ScrollBar.vertical.policy: ScrollBar.AlwaysOff syncView: header_horizontal
TableView { syncDirection: Qt.Horizontal
id:table_view ScrollBar.vertical:scroll_bar_v
ListModel{ rowHeightProvider: function(row) {
id:model_columns if(row>=table_view.rows){
return 0
} }
boundsBehavior: Flickable.StopAtBounds var rowObject = control.getRow(row)
syncView: header_horizontal var h = rowObject.height
syncDirection: Qt.Horizontal if(!h){
ScrollBar.vertical:scroll_bar_v h = rowObject._minimumHeight
rowHeightProvider: function(row) {
if(row>=table_view.rows){
return 0
}
var rowObject = control.getRow(row)
var h = rowObject.height
if(!h){
h = rowObject._minimumHeight
}
if(!h){
h = d.defaultItemHeight
}
return h
} }
model: table_sort_model if(!h){
clip: true h = d.defaultItemHeight
onRowsChanged: {
closeEditor()
} }
delegate: MouseArea{ return h
property var rowObject : control.getRow(row) }
property var itemModel: model model: table_sort_model
hoverEnabled: true clip: true
implicitHeight: 40 onRowsChanged: {
implicitWidth: { closeEditor()
var w = columnSource[column].width }
if(!w){ delegate: MouseArea{
w = columnSource[column].minimumWidth id:item_table_mouse
} property var rowObject : control.getRow(row)
if(!w){ property var itemModel: model
w = d.defaultItemWidth property bool editVisible: {
} if(d.editPosition === undefined){
return w return false
} }
onEntered: { if(d.editPosition._key === rowObject._key && d.editPosition.column === column){
d.rowHoverIndex = row return true
} }
Rectangle{ return false
id:item_table }
anchors.fill: parent hoverEnabled: true
property point position: Qt.point(column,row) onEntered: {
property bool isRowSelected: { d.rowHoverIndex = row
if(rowObject === null) }
return false onWidthChanged: {
if(d.current){ if(editVisible){
return rowObject._key === d.current._key updateEditPosition()
} }
}
onHeightChanged: {
if(editVisible){
updateEditPosition()
}
}
onXChanged: {
if(editVisible){
updateEditPosition()
}
}
onYChanged: {
if(editVisible){
updateEditPosition()
}
}
function updateEditPosition(){
var obj = {}
obj._key = rowObject._key
obj.column = column
obj.row = row
obj.x = item_table_mouse.x
obj.y = item_table_mouse.y + 1
obj.width = item_table_mouse.width
obj.height = item_table_mouse.height - 2
d.editPosition = obj
}
Rectangle{
id:item_table
anchors.fill: parent
property point position: Qt.point(column,row)
property bool isRowSelected: {
if(rowObject === null)
return false return false
if(d.current){
return rowObject._key === d.current._key
} }
color:{ return false
if(item_table.isRowSelected){ }
return control.selectedColor color:{
} if(item_table.isRowSelected){
if(d.rowHoverIndex === row || item_table.isRowSelected){ return control.selectedColor
return FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06)
}
return (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.015) : Qt.rgba(0,0,0,0.015))
} }
MouseArea{ if(d.rowHoverIndex === row || item_table.isRowSelected){
anchors.fill: parent return FluTheme.dark ? Qt.rgba(1,1,1,0.06) : Qt.rgba(0,0,0,0.06)
acceptedButtons: Qt.LeftButton }
onPressed:{ return (row%2!==0) ? control.color : (FluTheme.dark ? Qt.rgba(1,1,1,0.015) : Qt.rgba(0,0,0,0.015))
}
MouseArea{
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onPressed:{
closeEditor()
}
onCanceled: {
}
onReleased: {
}
onDoubleClicked:{
if(typeof(display) == "object"){
return
}
d.editDelegate = d.getEditDelegate(column)
updateEditPosition()
loader_edit.display = display
}
onClicked:
(event)=>{
d.current = rowObject
closeEditor() closeEditor()
event.accepted = true
} }
onCanceled: { }
FluLoader{
property var model: itemModel
property var display: itemModel.display
property int row: item_table.position.y
property int column: item_table.position.x
property var options: {
if(typeof(modelData) == "object"){
return modelData.options
} }
onReleased: { return {}
}
onDoubleClicked:{
if(typeof(display) == "object"){
return
}
d.editDelegate = d.getEditDelegate(column)
d.editPosition = {"_key":rowObject._key,"column":column}
}
onClicked:
(event)=>{
d.current = rowObject
closeEditor()
event.accepted = true
}
} }
FluLoader{ anchors.fill: parent
property var model: itemModel sourceComponent: {
property var display: itemModel.display if(typeof(modelData) == "object"){
property int row: item_table.position.y return modelData.comId
property int column: item_table.position.x
property var options: {
if(typeof(modelData) == "object"){
return modelData.options
}
return {}
}
anchors.fill: parent
sourceComponent: {
if(typeof(modelData) == "object"){
return modelData.comId
}
return com_text
} }
return com_text
} }
FluLoader{ }
property var display: itemModel.display Item{
property int column: item_table.position.x anchors.fill: parent
property int row: item_table.position.y visible: item_table.isRowSelected
property var tableView: control Rectangle{
signal editTextChaged(string text) width: 1
anchors.fill: parent height: parent.height
onEditTextChaged: anchors.left: parent.left
(text)=>{ color: control.selectedBorderColor
var obj = control.getRow(row) visible: column === 0
obj[columnSource[column].dataIndex] = text
control.setRow(row,obj)
}
sourceComponent: {
if(d.editPosition === undefined){
return undefined
}
if(d.editPosition._key === rowObject._key && d.editPosition.column === column){
return d.editDelegate
}
return undefined
}
} }
Item{ Rectangle{
anchors.fill: parent width: 1
visible: item_table.isRowSelected height: parent.height
Rectangle{ anchors.right: parent.right
width: 1 color: control.selectedBorderColor
height: parent.height visible: column === control.columns-1
anchors.left: parent.left }
color: control.selectedBorderColor Rectangle{
visible: column === 0 width: parent.width
} height: 1
Rectangle{ anchors.top: parent.top
width: 1 color: control.selectedBorderColor
height: parent.height }
anchors.right: parent.right Rectangle{
color: control.selectedBorderColor width: parent.width
visible: column === control.columns-1 height: 1
} anchors.bottom: parent.bottom
Rectangle{ color: control.selectedBorderColor
width: parent.width
height: 1
anchors.top: parent.top
color: control.selectedBorderColor
}
Rectangle{
width: parent.width
height: 1
anchors.bottom: parent.bottom
color: control.selectedBorderColor
}
} }
} }
} }
} }
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[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{