2024-05-29 11:10:19 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2023-01-04 16:05:07 +00:00
|
|
|
|
|
|
|
import Monitoring 1.0
|
2024-05-29 11:10:19 +00:00
|
|
|
import Qt.labs.settings 1.0
|
2023-01-04 16:05:07 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
import AppLayouts.Wallet.stores 1.0 as WalletStores
|
|
|
|
import shared.stores 1.0 as SharedStores
|
2023-01-04 16:05:07 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
ColumnLayout {
|
2023-01-04 16:05:07 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
spacing: 0
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Settings {
|
|
|
|
property alias tabIndex: tabBar.currentIndex
|
|
|
|
property alias modelObjectName: objectNameTextFiled.text
|
|
|
|
property alias modelObjectRootName: rootTextField.text
|
|
|
|
}
|
|
|
|
|
|
|
|
TabBar {
|
|
|
|
id: tabBar
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.bottomMargin: 10
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
TabButton {
|
|
|
|
text: "Context properties inspection"
|
|
|
|
}
|
|
|
|
TabButton {
|
|
|
|
text: "Models inspection"
|
2023-01-13 13:36:12 +00:00
|
|
|
}
|
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
currentIndex: swipeView.currentIndex
|
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
StackLayout {
|
|
|
|
id: swipeView
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
currentIndex: tabBar.currentIndex
|
|
|
|
//anchors.fill: parent
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
SplitView {
|
|
|
|
id: root
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
ColumnLayout {
|
|
|
|
SplitView.fillHeight: true
|
|
|
|
SplitView.preferredWidth: 450
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
spacing: 5
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.margins: 5
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
text: "Context properties:"
|
|
|
|
font.bold: true
|
2023-01-13 13:36:12 +00:00
|
|
|
}
|
2023-01-04 16:05:07 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
ListView {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.margins: 5
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
model: Monitor.contexPropertiesModel
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
clip: true
|
|
|
|
spacing: 5
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
delegate: Item {
|
|
|
|
implicitWidth: delegateRow.implicitWidth
|
|
|
|
implicitHeight: delegateRow.implicitHeight
|
2023-01-04 16:05:07 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
readonly property var contextPropertyValue:
|
|
|
|
MonitorUtils.contextPropertyBindingHelper(name, root).value
|
2023-01-04 16:05:07 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Row {
|
|
|
|
id: delegateRow
|
2023-01-04 16:05:07 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Label {
|
|
|
|
text: name
|
|
|
|
}
|
2024-04-26 07:43:24 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Label {
|
|
|
|
text: ` [${MonitorUtils.typeName(contextPropertyValue)}]`
|
|
|
|
color: "darkgreen"
|
|
|
|
}
|
2023-01-04 16:05:07 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Label {
|
|
|
|
text: ` (${MonitorUtils.valueToString(contextPropertyValue)})`
|
|
|
|
color: "darkred"
|
|
|
|
}
|
|
|
|
}
|
2023-01-04 16:05:07 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2024-04-26 07:43:24 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
onClicked: {
|
|
|
|
inspectionStackView.clear()
|
2023-01-04 16:05:07 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
const props = {
|
|
|
|
name: name,
|
|
|
|
objectForInspection: contextPropertyValue
|
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
inspectionStackView.push(inspectionList, props)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-26 07:43:24 +00:00
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
}
|
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Component {
|
|
|
|
id: modelInspectionComponent
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
ModelInspectionPane {}
|
2023-01-13 13:36:12 +00:00
|
|
|
}
|
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Component {
|
|
|
|
id: inspectionList
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Pane {
|
|
|
|
id: inspectionPanel
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
property var objectForInspection
|
|
|
|
property string name
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
onObjectForInspectionChanged: {
|
|
|
|
inspectionModel.clear()
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
if (!objectForInspection)
|
|
|
|
return
|
2024-04-26 07:43:24 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
const items = []
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
for (const property in objectForInspection) {
|
|
|
|
const type = typeof objectForInspection[property]
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
if (type === "function") {
|
|
|
|
items.push({
|
|
|
|
name: property,
|
|
|
|
category: "functions",
|
|
|
|
isModel: false,
|
|
|
|
type: type
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
const value = objectForInspection[property]
|
|
|
|
const detailedType = MonitorUtils.typeName(value)
|
|
|
|
const isModel = Monitor.isModel(value)
|
2024-04-26 07:43:24 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
items.push({
|
|
|
|
name: property,
|
|
|
|
type: detailedType,
|
|
|
|
category: isModel? "models" : "properties",
|
|
|
|
isModel: isModel
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
items.sort((a, b) => {
|
|
|
|
const nameA = a.category
|
|
|
|
const nameB = b.category
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
if (nameA === nameB)
|
|
|
|
return 0
|
2024-04-26 07:43:24 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
if (nameA === "models")
|
|
|
|
return -1
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
if (nameB === "models")
|
|
|
|
return 1
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
if (nameA < nameB)
|
|
|
|
return -1
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
if (nameA > nameB)
|
|
|
|
return 1
|
|
|
|
})
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
inspectionModel.append(items)
|
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 5
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Label {
|
|
|
|
text: name
|
|
|
|
font.pixelSize: 20
|
|
|
|
font.bold: true
|
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
MenuSeparator {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
ListView {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2024-04-26 07:43:24 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
spacing: 5
|
|
|
|
clip: true
|
2024-04-26 07:43:24 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
model: ListModel {
|
|
|
|
id: inspectionModel
|
|
|
|
}
|
2024-04-26 07:43:24 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
delegate: Item {
|
|
|
|
implicitWidth: delegateRow.implicitWidth
|
|
|
|
implicitHeight: delegateRow.implicitHeight
|
2024-04-26 07:43:24 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Row {
|
|
|
|
id: delegateRow
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
readonly property var object: objectForInspection[name]
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Label {
|
|
|
|
text: name
|
2023-01-13 13:36:12 +00:00
|
|
|
}
|
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Loader {
|
|
|
|
active: type !== "function"
|
|
|
|
sourceComponent: Label {
|
|
|
|
text: ` [${type}]`
|
|
|
|
color: "darkgreen"
|
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
}
|
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Loader {
|
|
|
|
active: type !== "function"
|
|
|
|
sourceComponent: Label {
|
|
|
|
text: ` (${MonitorUtils.valueToString(delegateRow.object)})`
|
|
|
|
color: "darkred"
|
2024-04-26 07:43:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
2024-05-29 11:10:19 +00:00
|
|
|
active: isModel
|
|
|
|
sourceComponent: Label {
|
|
|
|
text: `, ${delegateRow.object.rowCount()} items`
|
|
|
|
color: "darkred"
|
|
|
|
font.bold: true
|
2024-04-26 07:43:24 +00:00
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
onClicked: {
|
|
|
|
if (!isModel)
|
|
|
|
return
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
const props = {
|
|
|
|
name: name,
|
|
|
|
model: objectForInspection[name]
|
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
inspectionStackView.push(modelInspectionComponent,
|
|
|
|
props, StackView.Immediate)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
section.property: "category"
|
|
|
|
section.delegate: Pane {
|
|
|
|
leftPadding: 0
|
2023-01-13 13:36:12 +00:00
|
|
|
|
|
|
|
Label {
|
2024-05-29 11:10:19 +00:00
|
|
|
text: section
|
2023-01-13 13:36:12 +00:00
|
|
|
font.bold: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
StackView {
|
|
|
|
id: inspectionStackView
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
SplitView.fillHeight: true
|
|
|
|
SplitView.minimumWidth: 100
|
2023-01-13 13:36:12 +00:00
|
|
|
}
|
2024-05-29 11:10:19 +00:00
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Item {
|
2023-01-13 13:36:12 +00:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
2024-05-29 11:10:19 +00:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
|
|
|
|
text: "Note: 'applicationWindow' is good root object in"
|
|
|
|
+ " most cases. 'WalletStores.RootStore' and"
|
|
|
|
+ " `SharedStores.RootStore` are also exposed for"
|
2024-06-14 11:39:17 +00:00
|
|
|
+ " convenience for models created within those singletons. \n\n"
|
|
|
|
+ " Hack (see #15181): If you want to inspect a model that is not"
|
|
|
|
+ " from the root object (under a repeater), add objectName to a dummy object in AppMain.qml: \n"
|
|
|
|
+ " property var modelIWantToInspect: SortFilterProxyModel { \n"
|
|
|
|
+ " objectName: \"YYY\" \n"
|
|
|
|
+ " } \n"
|
|
|
|
+ " and inside your item add something like this: \n"
|
|
|
|
+ " Component.onCompleted: appMain.modelIWantToInspect.sourceModel = this.model \n"
|
|
|
|
+ " Then you can use 'YYY' as the object name in this search."
|
2023-01-13 13:36:12 +00:00
|
|
|
}
|
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
RowLayout {
|
|
|
|
Layout.fillHeight: false
|
2023-01-13 13:36:12 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Label {
|
|
|
|
text: "Model's object name:"
|
|
|
|
}
|
|
|
|
|
|
|
|
TextField {
|
|
|
|
id: objectNameTextFiled
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
selectByMouse: true
|
2023-01-13 13:36:12 +00:00
|
|
|
}
|
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Label {
|
|
|
|
text: "Root:"
|
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
TextField {
|
|
|
|
id: rootTextField
|
|
|
|
|
|
|
|
text: "applicationWindow"
|
|
|
|
selectByMouse: true
|
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Button {
|
|
|
|
text: "Search"
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
onClicked: {
|
|
|
|
let rootObj = null
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
try {
|
|
|
|
rootObj = eval(rootTextField.text)
|
|
|
|
} catch (error) {
|
|
|
|
objLabel.objStr = "Root object not found!"
|
|
|
|
return
|
2023-01-13 13:36:12 +00:00
|
|
|
}
|
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
const obj = Monitor.findChild(
|
|
|
|
rootObj, objectNameTextFiled.text)
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
objLabel.objStr = obj && Monitor.isModel(obj)
|
|
|
|
? obj.toString() : "Model not found!"
|
|
|
|
rolesModelContent.model = obj
|
2023-01-13 13:36:12 +00:00
|
|
|
}
|
2024-05-29 11:10:19 +00:00
|
|
|
}
|
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Label {
|
|
|
|
id: objLabel
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
property string objStr
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: objStr !== ""
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
text: "Object: " + objStr
|
|
|
|
}
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
ModelInspectionPane {
|
|
|
|
id: rolesModelContent
|
2023-01-13 13:36:12 +00:00
|
|
|
|
2024-05-29 11:10:19 +00:00
|
|
|
showControls: false
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2023-01-13 13:36:12 +00:00
|
|
|
}
|
|
|
|
}
|
2023-01-04 16:05:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|