import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Layouts 1.0 import org.openpilot 1.0 import "functions.js" as Functions Rectangle { width: 600 height: 400 ColumnLayout { anchors.fill: parent anchors.margins: 10 spacing: 10 Rectangle { Layout.fillWidth: true Layout.fillHeight: true border.width: 1 radius: 4 ColumnLayout { id: exportTab anchors.margins: 10 anchors.fill: parent visible: true Text { Layout.fillWidth: true text: "" + qsTr("Log entries") + "" } TableView { Layout.fillWidth: true Layout.fillHeight: true Layout.preferredHeight: 1000; model: logManager.logEntries enabled: !logManager.disableControls && logManager.boardConnected rowDelegate: Rectangle { height: 22 color: styleData.selected ? "#ccc" : (styleData.alternate ? "#fff" : "#eee") } itemDelegate: Text { verticalAlignment: Text.AlignVCenter text: styleData.value } TableViewColumn { role: "Flight"; title: qsTr("Flight"); width: 50; delegate: Text { verticalAlignment: Text.AlignVCenter text: styleData.value + 1 } } TableViewColumn { role: "FlightTime"; title: qsTr("Time"); width: 100; delegate: Text { verticalAlignment: Text.AlignVCenter text: Functions.millisToTime(styleData.value) } } TableViewColumn { role: "Type"; title: "Type"; width: 60; delegate: Text { verticalAlignment: Text.AlignVCenter text: { switch(styleData.value) { case 0 : text: qsTr("Empty"); break; case 1 : text: qsTr("Text"); break; case 2 : text: qsTr("UAVO"); break; default: text: qsTr("Unknown"); break; } } } } TableViewColumn { role: "LogString"; title: qsTr("Data"); width: 280 } } RowLayout { anchors.margins: 10 spacing: 10 ColumnLayout { spacing: 10 Text { id: totalFlights text: "" + qsTr("Flights recorded: ") + "" + (logStatus.Flight + 1) } Text { id: totalEntries text: "" + qsTr("Entries logged (free): ") + "" + logStatus.UsedSlots + " (" + logStatus.FreeSlots + ")" } Rectangle { Layout.fillHeight: true } CheckBox { id: exportRelativeTimeCB enabled: !logManager.disableControls && !logManager.disableExport && logManager.boardConnected text: qsTr("Adjust timestamps") activeFocusOnPress: true checked: logManager.adjustExportedTimestamps onCheckedChanged: logManager.setAdjustExportedTimestamps(checked) } } Rectangle { Layout.fillWidth: true } ColumnLayout { spacing: 10 RowLayout { Rectangle { Layout.fillWidth: true } Text { text: "" + qsTr("Flight to download:") + "" } ComboBox { id: flightCombo enabled: !logManager.disableControls && logManager.boardConnected model: logManager.flightEntries } } RowLayout { spacing: 10 Rectangle { Layout.fillWidth: true } Button { text: qsTr("Download logs") enabled: !logManager.disableControls && logManager.boardConnected activeFocusOnPress: true onClicked: logManager.retrieveLogs(flightCombo.currentIndex - 1) } } Rectangle { Layout.fillHeight: true } RowLayout { Rectangle { Layout.fillWidth: true } Button { id: clearButton enabled: !logManager.disableControls && logManager.boardConnected text: qsTr("Clear all logs") activeFocusOnPress: true onClicked: logManager.clearAllLogs() } Button { id: exportButton enabled: !logManager.disableControls && !logManager.disableExport && logManager.boardConnected text: qsTr("Export logs...") activeFocusOnPress: true onClicked: logManager.exportLogs() } } } } } ColumnLayout { id: settingsTab visible: false anchors.margins: 10 anchors.fill: parent Text { Layout.fillWidth: true text: "" + qsTr("Log settings") + "" } Component { id: comboEditableDelegate Item { Text { width: parent.width anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter elide: styleData.elideMode text: styleData.value !== undefined ? logManager.logSettings[styleData.value] : "" color: styleData.textColor visible: !styleData.selected } Loader { id: loaderEditor anchors.fill: parent Connections { target: loaderEditor.item onCurrentIndexChanged: { logManager.uavoEntries[styleData.row].setting = loaderEditor.item.currentIndex } } sourceComponent: styleData.selected ? editor : null Component { id: editor ComboBox { id: combo model: logManager.logSettings currentIndex: styleData.value } } } } } TableView { id: settingsTable Layout.fillWidth: true Layout.fillHeight: true Layout.preferredHeight: 1000; model: logManager.uavoEntries enabled: !logManager.disableControls && logManager.boardConnected rowDelegate: Rectangle { height: 22 color: styleData.selected ? "#ccc" : (styleData.alternate ? "#fff" : "#eee") } TableViewColumn { role: "name"; title: qsTr("UAVObject"); width: 200; delegate: Text { verticalAlignment: Text.AlignVCenter anchors.leftMargin: 5 text: styleData.value } } TableViewColumn { role: "setting"; title: qsTr("Settings"); width: 200; delegate: comboEditableDelegate } } } } RowLayout { Layout.fillWidth: true height: 40 Button { id: settingsButton enabled: !logManager.disableControls text: qsTr("Log settings...") activeFocusOnPress: true property bool showSettings: false onClicked: { showSettings = !showSettings; settingsTab.visible = showSettings; exportTab.visible = !showSettings; text = (showSettings ? qsTr("View logs...") : qsTr("Log settings...")); } } Rectangle { Layout.fillWidth: true } Button { id: cancelButton enabled: logManager.disableControls text: qsTr("Cancel") activeFocusOnPress: true onClicked: logManager.cancelExportLogs() } Button { id: okButton enabled: !logManager.disableControls text: qsTr("OK") isDefault: true activeFocusOnPress: true onClicked: dialog.close() } } } }