mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-22 13:36:31 +02:00
[ui] use ListModel for storing log-line and duration to avoid evaluation order issues
This commit is contained in:
parent
7b286ff901
commit
e7c84b9483
2 changed files with 45 additions and 33 deletions
|
@ -25,7 +25,7 @@ Item {
|
||||||
onAutoReloadChanged: loadSource()
|
onAutoReloadChanged: loadSource()
|
||||||
onVisibleChanged: if(visible) loadSource()
|
onVisibleChanged: if(visible) loadSource()
|
||||||
|
|
||||||
function getLineTime(line)
|
function getLogLineTime(line)
|
||||||
{
|
{
|
||||||
const regex = /[0-9]{2}:[0-9]{2}:[0-9]{2}/;
|
const regex = /[0-9]{2}:[0-9]{2}:[0-9]{2}/;
|
||||||
const found = line.match(regex);
|
const found = line.match(regex);
|
||||||
|
@ -41,36 +41,21 @@ Item {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeLinesDuration(lines)
|
function updateLogLinesModel(llm, text)
|
||||||
{
|
{
|
||||||
const times = lines.map(line => getLineTime(line));
|
llm.clear();
|
||||||
|
const lines = text.split('\n');
|
||||||
let durations = new Array(lines.length);
|
const times = lines.map(line => getLogLineTime(line));
|
||||||
durations.fill(-1);
|
|
||||||
|
|
||||||
let prev_idx = -1;
|
let prev_idx = -1;
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
let delta = -1;
|
||||||
if (times[i] >= 0) {
|
if (times[i] >= 0) {
|
||||||
if (prev_idx >= 0) {
|
if (prev_idx >= 0) {
|
||||||
durations[prev_idx] = times[i]-times[prev_idx];
|
delta = times[i]-times[prev_idx];
|
||||||
}
|
}
|
||||||
prev_idx = i;
|
prev_idx = i;
|
||||||
}
|
}
|
||||||
}
|
llm.append({"line": lines[i], "duration": delta});
|
||||||
|
|
||||||
return durations;
|
|
||||||
}
|
|
||||||
|
|
||||||
function timeColorScale(time)
|
|
||||||
{
|
|
||||||
if (time < 0) {
|
|
||||||
return "#FFFFFF";
|
|
||||||
} else if (time < 60) {
|
|
||||||
return "#0000FF";
|
|
||||||
} else if (time < 3600) {
|
|
||||||
return "#FFFF00";
|
|
||||||
} else {
|
|
||||||
return "#FF0000";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +103,7 @@ Item {
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
var t = "";
|
var t = "";
|
||||||
for(var i = textView.firstVisibleIndex(); i < textView.lastVisibleIndex(); ++i)
|
for(var i = textView.firstVisibleIndex(); i < textView.lastVisibleIndex(); ++i)
|
||||||
t += textView.model[i] + "\n";
|
t += textView.model.get(i).line + "\n";
|
||||||
Clipboard.setText(t);
|
Clipboard.setText(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,11 +134,16 @@ Item {
|
||||||
|
|
||||||
property string text
|
property string text
|
||||||
|
|
||||||
// model consists in text split by line
|
ListModel {
|
||||||
model: textView.text.split("\n")
|
id: logLinesModel
|
||||||
visible: text != ""
|
}
|
||||||
|
|
||||||
property var durations: computeLinesDuration(model)
|
onTextChanged: {
|
||||||
|
updateLogLinesModel(logLinesModel, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
model: logLinesModel
|
||||||
|
visible: text != ""
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
clip: true
|
clip: true
|
||||||
|
@ -241,6 +231,13 @@ Item {
|
||||||
width: textView.width
|
width: textView.width
|
||||||
spacing: 6
|
spacing: 6
|
||||||
|
|
||||||
|
// Duration color
|
||||||
|
Rectangle {
|
||||||
|
width: 4
|
||||||
|
height: lineMetrics.height
|
||||||
|
color: Colors.durationColorScale(textView.model.get(index).duration)
|
||||||
|
}
|
||||||
|
|
||||||
// Line number
|
// Line number
|
||||||
Label {
|
Label {
|
||||||
text: index + 1
|
text: index + 1
|
||||||
|
@ -249,7 +246,6 @@ Item {
|
||||||
enabled: false
|
enabled: false
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
horizontalAlignment: Text.AlignRight
|
horizontalAlignment: Text.AlignRight
|
||||||
color: timeColorScale(textView.durations[index])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
|
@ -264,8 +260,8 @@ Item {
|
||||||
State {
|
State {
|
||||||
name: "progressBar"
|
name: "progressBar"
|
||||||
// detect textual progressbar (non empty line with only progressbar character)
|
// detect textual progressbar (non empty line with only progressbar character)
|
||||||
when: modelData.trim().length
|
when: textView.model.get(index).line.trim().length
|
||||||
&& modelData.split(progressMetrics.character).length - 1 === modelData.trim().length
|
&& textView.model.get(index).line.split(progressMetrics.character).length - 1 === textView.model.get(index).line.trim().length
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: delegateLoader
|
target: delegateLoader
|
||||||
sourceComponent: progressBar_component
|
sourceComponent: progressBar_component
|
||||||
|
@ -286,7 +282,7 @@ Item {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
from: 0
|
from: 0
|
||||||
to: progressMetrics.count
|
to: progressMetrics.count
|
||||||
value: modelData.length
|
value: textView.model.get(index).line.length
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +292,7 @@ Item {
|
||||||
id: line_component
|
id: line_component
|
||||||
TextInput {
|
TextInput {
|
||||||
wrapMode: Text.WrapAnywhere
|
wrapMode: Text.WrapAnywhere
|
||||||
text: modelData
|
text: textView.model.get(index).line
|
||||||
font.family: "Monospace, Consolas, Monaco"
|
font.family: "Monospace, Consolas, Monaco"
|
||||||
padding: 0
|
padding: 0
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
|
|
|
@ -60,4 +60,20 @@ QtObject {
|
||||||
console.warn("Unknown status : " + chunk.status)
|
console.warn("Unknown status : " + chunk.status)
|
||||||
return "magenta"
|
return "magenta"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function durationColorScale(t) {
|
||||||
|
if (t < 0) {
|
||||||
|
return "transparent";
|
||||||
|
} else if (t < 10) {
|
||||||
|
return cyan;
|
||||||
|
} else if (t < 30) {
|
||||||
|
return green;
|
||||||
|
} else if (t < 60) {
|
||||||
|
return yellow;
|
||||||
|
} else if (t < 180) {
|
||||||
|
return orange;
|
||||||
|
} else {
|
||||||
|
return red;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue