Warning, /sdk/rust-qt-binding-generator/demo/qml/DataAndChart.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright 2017 Jos van den Oever <jos@vandenoever.info> 0003 * 0004 * This program is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU General Public License as 0006 * published by the Free Software Foundation; either version 2 of 0007 * the License or (at your option) version 3 or any later version 0008 * accepted by the membership of KDE e.V. (or its successor approved 0009 * by the membership of KDE e.V.), which shall act as a proxy 0010 * defined in Section 14 of version 3 of the license. 0011 * 0012 * This program is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0015 * GNU General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU General Public License 0018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0019 */ 0020 0021 import QtQuick 2.6 0022 import QtQml.Models 2.2 0023 import QtQuick.Controls 1.5 0024 import QtQuick.Layouts 1.3 0025 0026 RowLayout { 0027 Component { 0028 id: editableDelegate 0029 Item { 0030 function round(v) { 0031 return Math.round(1000 * v) / 1000 0032 } 0033 Text { 0034 text: round(styleData.value) 0035 visible: !styleData.selected 0036 } 0037 Loader { 0038 id: loaderEditor 0039 anchors.fill: parent 0040 Connections { 0041 target: loaderEditor.item 0042 onEditingFinished: { 0043 if (!demo) { 0044 return 0045 } 0046 var val = loaderEditor.item.text 0047 var row = styleData.row 0048 if (styleData.column === 0) { 0049 demo.timeSeries.setTime(row, val) 0050 } else if (styleData.column === 1) { 0051 demo.timeSeries.setSin(row, val) 0052 } else { 0053 demo.timeSeries.setCos(row, val) 0054 } 0055 } 0056 } 0057 sourceComponent: styleData.selected ? editor : null 0058 } 0059 Component { 0060 id: editor 0061 TextInput { 0062 id: textInput 0063 text: round(styleData.value) 0064 MouseArea { 0065 anchors.fill: parent 0066 hoverEnabled: true 0067 onClicked: textInput.forceActiveFocus() 0068 } 0069 } 0070 } 0071 } 0072 } 0073 SplitView { 0074 Layout.fillWidth: true 0075 Layout.fillHeight: true 0076 handleDelegate: Rectangle { 0077 width: 3 0078 } 0079 TableView { 0080 model: demo.timeSeries 0081 Layout.fillHeight: true 0082 0083 TableViewColumn { 0084 role: "time" 0085 title: qsTr("time") 0086 } 0087 TableViewColumn { 0088 role: "sin" 0089 title: qsTr("sin") 0090 } 0091 TableViewColumn { 0092 role: "cos" 0093 title: qsTr("cos") 0094 } 0095 itemDelegate: { 0096 return editableDelegate 0097 } 0098 } 0099 Item { 0100 Layout.fillWidth: true 0101 Layout.fillHeight: true 0102 Text { 0103 anchors.centerIn: parent 0104 text: qsTr("QtChart is not available.") 0105 visible: chartLoader.status !== Loader.Ready 0106 } 0107 Loader { 0108 anchors.fill: parent 0109 id: chartLoader 0110 source: "chart.qml" 0111 } 0112 } 0113 } 0114 }