From 22be234f7c0256cfa6bbf6574a80ffb9fd7e31e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Thu, 13 Jun 2024 13:56:31 +0200 Subject: [PATCH] featch(MonitoringTool): Add possibility to copy model to clipboard as JSON --- monitoring/ModelInspectionPane.qml | 38 +++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/monitoring/ModelInspectionPane.qml b/monitoring/ModelInspectionPane.qml index ce161883b..4e9efabd4 100644 --- a/monitoring/ModelInspectionPane.qml +++ b/monitoring/ModelInspectionPane.qml @@ -3,7 +3,7 @@ import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 import Monitoring 1.0 - +import StatusQ.Core.Utils 0.1 Pane { property string name @@ -83,19 +83,45 @@ Pane { } Label { - visible: showControls - text: "Hint: use right/left button click on a column " + "header to adjust width, press cell content to " + "see full value" } - Label { - text: model ? `rows count: ${model.rowCount()}` : "" - font.bold: true + RowLayout { + Layout.fillHeight: false + + visible: listView.count > 0 + + Label { + text: `rows count: ${listView.count}` + font.bold: true + } + + Label { + textFormat: Text.RichText + text: `copy json to clipboard` + font.bold: true + + TextInput { + id: hiddenTextInput + visible: false + } + + onLinkActivated: { + const json = JSON.stringify( + ModelUtils.modelToArray(model), null, 2) + + hiddenTextInput.text = json + hiddenTextInput.selectAll() + hiddenTextInput.copy() + } + } } ListView { + id: listView + Layout.fillWidth: true Layout.fillHeight: true