Commit 71525d5c authored by Karel Slaný's avatar Karel Slaný Committed by Martin Straka

Replaced selectedFileName with selectedFileIndex in FileDialogue.

parent bdcd0728
......@@ -33,7 +33,7 @@ Dialog {
focus: true
modal: true
title: ""
standardButtons: (selectedFileName != "") ? (Dialog.Ok | Dialog.Cancel) : Dialog.Cancel
standardButtons: (selectedFileIndex != -1) ? (Dialog.Ok | Dialog.Cancel) : Dialog.Cancel
/* Place the dialogue in the centre. */
x: parent.width / 2 - width / 2
......@@ -41,7 +41,7 @@ Dialog {
signal finished(string path)
property string selectedFileName: ""
property int selectedFileIndex: -1
function raise() {
folderModel.folder = standardLocationUrl(InteractionFilesystem.DESKTOP_LOCATION)
......@@ -152,7 +152,7 @@ Dialog {
folder: standardLocationUrl(InteractionFilesystem.DESKTOP_LOCATION)
onFolderChanged: {
selectedFileName = ""
selectedFileIndex = -1
pathField.text = stripUrlPrefix(folder)
}
}
......@@ -161,7 +161,7 @@ Dialog {
id: fileDelegate
Rectangle {
color: (fileName == selectedFileName) ? datovkaPalette.highlight : "#00000000"
color: (index == selectedFileIndex) ? datovkaPalette.highlight : "#00000000"
width: childrenRect.width
height: childrenRect.height
......@@ -173,11 +173,12 @@ Dialog {
MouseArea {
anchors.fill: parent
onClicked: {
/* Navigate to selected directory. */
if (fileIsDir) {
/* Navigate to selected directory. */
folderModel.folder = fileURL
} else {
selectedFileName = fileName
/* Select file. */
selectedFileIndex = index
}
}
}
......@@ -190,8 +191,8 @@ Dialog {
}
onAccepted: {
if (selectedFileName != "") {
finished(stripUrlPrefix(folderModel.folder) + "/" + selectedFileName)
if (selectedFileIndex != -1) {
finished(stripUrlPrefix(folderModel.folder) + "/" + folderModel.get(selectedFileIndex, "fileName"))
} else {
finished("")
}
......
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