Commit 58cc2a47 authored by Don Gagne's avatar Don Gagne

Show existing file to save to

parent 44682709
import QtQuick 2.3 import QtQuick 2.3
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2 import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.2
import QGroundControl 1.0 import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
...@@ -21,12 +22,14 @@ Item { ...@@ -21,12 +22,14 @@ Item {
property bool selectExisting property bool selectExisting
property bool selectFolder property bool selectFolder
property bool _openForLoad property bool _openForLoad: true
property real _margins: ScreenTools.defaultFontPixelHeight / 2 property real _margins: ScreenTools.defaultFontPixelHeight / 2
property bool _mobile: ScreenTools.isMobile
function openForLoad() { function openForLoad() {
_openForLoad = true _openForLoad = true
if (ScreenTools.isMobile && folder.length !== 0) { if (_mobile && folder.length !== 0) {
qgcView.showDialog(mobileFileOpenDialog, title, qgcView.showDialogDefaultWidth, StandardButton.Cancel) qgcView.showDialog(mobileFileOpenDialog, title, qgcView.showDialogDefaultWidth, StandardButton.Cancel)
} else { } else {
fullFileDialog.open() fullFileDialog.open()
...@@ -35,7 +38,7 @@ Item { ...@@ -35,7 +38,7 @@ Item {
function openForSave() { function openForSave() {
_openForLoad = false _openForLoad = false
if (ScreenTools.isMobile && folder.length !== 0) { if (_mobile && folder.length !== 0) {
qgcView.showDialog(mobileFileSaveDialog, title, qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) qgcView.showDialog(mobileFileSaveDialog, title, qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok)
} else { } else {
fullFileDialog.open() fullFileDialog.open()
...@@ -76,18 +79,23 @@ Item { ...@@ -76,18 +79,23 @@ Item {
id: mobileFileOpenDialog id: mobileFileOpenDialog
QGCViewDialog { QGCViewDialog {
Item { QGCFlickable {
anchors.margins: _margins
anchors.fill: parent anchors.fill: parent
contentHeight: fileOpenColumn.height
QGCListView { Column {
id: listView id: fileOpenColumn
anchors.fill: parent anchors.left: parent.left
spacing: _margins / 2 anchors.right: parent.right
orientation: ListView.Vertical spacing: ScreenTools.defaultFontPixelHeight / 2
Repeater {
id: fileList;
model: controller.getFiles(folder, fileExtension) model: controller.getFiles(folder, fileExtension)
delegate: QGCButton { QGCButton {
anchors.left: parent.left
anchors.right: parent.right
text: modelData text: modelData
onClicked: { onClicked: {
...@@ -99,7 +107,8 @@ Item { ...@@ -99,7 +107,8 @@ Item {
QGCLabel { QGCLabel {
text: qsTr("No files") text: qsTr("No files")
visible: listView.model.length == 0 visible: fileList.model.length == 0
}
} }
} }
} }
...@@ -123,19 +132,29 @@ Item { ...@@ -123,19 +132,29 @@ Item {
hideDialog() hideDialog()
} }
QGCFlickable {
anchors.fill: parent
contentHeight: fileSaveColumn.height
Column { Column {
id: fileSaveColumn
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelHeight spacing: ScreenTools.defaultFontPixelHeight / 2
QGCLabel { RowLayout {
text: qsTr("File name:") anchors.left: parent.left
} anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel { text: qsTr("New file name:") }
QGCTextField { QGCTextField {
id: filenameTextField id: filenameTextField
Layout.fillWidth: true
onTextChanged: replaceMessage.visible = false onTextChanged: replaceMessage.visible = false
} }
}
QGCLabel { QGCLabel {
anchors.left: parent.left anchors.left: parent.left
...@@ -153,6 +172,30 @@ Item { ...@@ -153,6 +172,30 @@ Item {
visible: false visible: false
color: qgcPal.warningText color: qgcPal.warningText
} }
SectionHeader {
anchors.left: parent.left
anchors.right: parent.right
text: qsTr("Save to existing file:")
}
Repeater {
model: controller.getFiles(folder, fileExtension)
QGCButton {
anchors.left: parent.left
anchors.right: parent.right
text: modelData
onClicked: {
hideDialog()
_root.acceptedForSave(controller.fullyQualifiedFilename(folder, modelData, fileExtension))
}
}
}
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment