[ui] NodeLog: set TextFileViewer source when chunks ListView is ready

Avoid going through an empty source when switching from one node to another (currentChunk being invalid the time the ListView is being constructed).
This commit is contained in:
Yann Lanthony 2019-05-15 20:12:55 +02:00
parent 17556427fd
commit d7f8311dcf
No known key found for this signature in database
GPG key ID: 519FAE6DF7A70642

View file

@ -85,6 +85,13 @@ FocusScope {
id: fileSelector
Layout.fillWidth: true
property string currentFile: chunksLV.currentChunk ? chunksLV.currentChunk[currentItem.fileProperty] : ""
onCurrentFileChanged: {
// only set text file viewer source when ListView is fully ready
// (either empty or fully populated with a valid currentChunk)
// to avoid going through an empty url when switching between two nodes
if(!chunksLV.count || chunksLV.currentChunk)
textFileViewer.source = Filepath.stringToUrl(currentFile);
}
TabButton {
property string fileProperty: "logFile"
@ -105,10 +112,11 @@ FocusScope {
}
TextFileViewer {
id: textFileViewer
Layout.fillWidth: true
Layout.fillHeight: true
autoReload: chunksLV.currentChunk !== undefined && chunksLV.currentChunk.statusName === "RUNNING"
source: Filepath.stringToUrl(fileSelector.currentFile)
// source is set in fileSelector
}
}
}