Compare commits

..

No commits in common. "26311d63429eea8200078e594a99c0e72a2099d5" and "07de3b82b1f9244b24fd2675056c8e025ffbd071" have entirely different histories.

7 changed files with 325 additions and 422 deletions

View File

@ -261,16 +261,16 @@ FluContentPage{
FluComboBox { FluComboBox {
anchors.fill: parent anchors.fill: parent
focus: true focus: true
editText: display currentIndex: 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 === display) currentIndex=[100,300,500,1000].findIndex((element) => element === Number(display))
selectAll() selectAll()
} }
onCommit: { onCommit: {

View File

@ -261,16 +261,16 @@ FluContentPage{
FluComboBox { FluComboBox {
anchors.fill: parent anchors.fill: parent
focus: true focus: true
editText: display currentIndex: 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 === display) currentIndex=[100,300,500,1000].findIndex((element) => element === Number(display))
selectAll() selectAll()
} }
onCommit: { onCommit: {

View File

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

View File

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