featch(MonitoringTool): Add possibility to copy model to clipboard as JSON

This commit is contained in:
Michał Cieślak 2024-06-13 13:56:31 +02:00 committed by Michał
parent 436ae9f1f3
commit 22be234f7c
1 changed files with 32 additions and 6 deletions

View File

@ -3,7 +3,7 @@ import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import Monitoring 1.0 import Monitoring 1.0
import StatusQ.Core.Utils 0.1
Pane { Pane {
property string name property string name
@ -83,19 +83,45 @@ Pane {
} }
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 adjust width, press cell content to " + "header to adjust width, press cell content to " +
"see full value" "see full value"
} }
RowLayout {
Layout.fillHeight: false
visible: listView.count > 0
Label { Label {
text: model ? `rows count: ${model.rowCount()}` : "" text: `rows count: ${listView.count}`
font.bold: true font.bold: true
} }
Label {
textFormat: Text.RichText
text: `<a href="copy">copy json to clipboard</a>`
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 { ListView {
id: listView
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true