feat(MonitoringTool): Ability to inspect submodels

Closes: #14496
This commit is contained in:
Michał Cieślak 2024-04-26 09:43:24 +02:00 committed by Michał
parent ccc1539178
commit 18adfbe6fa
1 changed files with 63 additions and 3 deletions

View File

@ -84,6 +84,8 @@ Component {
property var model property var model
readonly property var rootModel: model readonly property var rootModel: model
property bool showControls: true
readonly property var roles: Monitor.modelRoles(model) readonly property var roles: Monitor.modelRoles(model)
readonly property var rolesModelContent: roles.map(role => ({ readonly property var rolesModelContent: roles.map(role => ({
@ -92,13 +94,21 @@ Component {
width: Math.ceil(fontMetrics.advanceWidth(` ${role.name} `)) width: Math.ceil(fontMetrics.advanceWidth(` ${role.name} `))
})) }))
onRolesModelContentChanged: {
rolesModel.clear()
rolesModel.append(rolesModelContent)
}
property int columnsTotalWidth: property int columnsTotalWidth:
rolesModelContent.reduce((a, x) => a + x.width, 0) rolesModelContent.reduce((a, x) => a + x.width, 0)
ListModel { ListModel {
id: rolesModel id: rolesModel
Component.onCompleted: append(rolesModelContent) Component.onCompleted: {
clear()
append(rolesModelContent)
}
} }
Control { Control {
@ -119,6 +129,8 @@ Component {
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
visible: showControls
RoundButton { RoundButton {
text: "⬅️" text: "⬅️"
@ -127,13 +139,16 @@ Component {
} }
} }
Label { TextInput {
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
text: name text: name
font.pixelSize: 20 font.pixelSize: 20
font.bold: true font.bold: true
selectByMouse: true
readOnly: true
} }
} }
@ -142,6 +157,8 @@ Component {
} }
Label { Label {
visible: showControls
text: "Hint: use right/left button click on a column " + text: "Hint: use right/left button click on a column " +
"header to ajust width, press cell content to " + "header to ajust width, press cell content to " +
"see full value" "see full value"
@ -180,7 +197,19 @@ Component {
width: model.width width: model.width
height: implicitHeight * 1.2 height: implicitHeight * 1.2
text: topModel[model.name].toString() text: {
const value = topModel[model.name]
const isModel = Monitor.isModel(value)
let text = value.toString()
if (isModel) {
text += " (" + value.rowCount() + ")"
}
return text
}
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: 1 maximumLineCount: 1
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
@ -208,6 +237,37 @@ Component {
id: labelMouseArea id: labelMouseArea
anchors.fill: parent anchors.fill: parent
onClicked: {
const value = topModel[model.name]
const isModel = Monitor.isModel(value)
if (isModel)
loader.active = true
}
}
Loader {
id: loader
active: false
sourceComponent: ApplicationWindow {
width: 500
height: 400
visible: true
onClosing: loader.active = false
Loader {
anchors.fill: parent
sourceComponent: modelInspectionComponent
Component.onCompleted: {
item.showControls = false
item.model = topModel[model.name]
}
}
}
} }
ToolTip.visible: labelMouseArea.pressed ToolTip.visible: labelMouseArea.pressed