fix(ui/modules/Linphone/Calls/Calls): refresh correctly the selected call

This commit is contained in:
Ronan Abhamon 2017-01-24 10:26:29 +01:00
parent c821636a33
commit ad7d3cd0de
2 changed files with 34 additions and 5 deletions

View file

@ -11,7 +11,7 @@ ListView {
// ---------------------------------------------------------------------------
readonly property var selectedCall: currentIndex >= 0 ? model.data(model.index(currentIndex, 0)) : null
readonly property var selectedCall: smartConnect.selectedCall
property var _mapStatusToParams
@ -156,25 +156,54 @@ ListView {
}
}
// ---------------------------------------------------------------------------
// Update the current selected call and the current index.
// ---------------------------------------------------------------------------
SmartConnect {
id: smartConnect
property var selectedCall
Component.onCompleted: {
this.connect(model, 'rowsAboutToBeRemoved', function (_, first, last) {
var index = calls.currentIndex
if (index >= first && index <= last) { // Remove current call.
if (model.rowCount() - (last - first + 1) <= 0) {
calls.currentIndex = -1
selectedCall = null
} else {
calls.currentIndex = 0
if (first === 0) {
selectedCall = model.data(model.index(last + 1, 0))
} else {
selectedCall = model.data(model.index(0, 0))
}
}
} else if (last < index) { // Remove before current call.
}
})
this.connect(model, 'rowsRemoved', function (_, first, last) {
var index = calls.currentIndex
// The current call has been removed.
if (index >= first && index <= last) {
if (model.rowCount() === 0) {
calls.currentIndex = -1 // No calls.
} else {
calls.currentIndex = 0 // The first call becomes the selected call.
}
}
// Update the current index of the selected call if it was after the removed calls.
else if (last < index) {
calls.currentIndex = index - (last - first + 1)
}
})
// The last inserted element become the selected call.
this.connect(model, 'rowsInserted', function (_, first, last) {
calls.currentIndex = first
selectedCall = model.data(model.index(first, 0))
})
}
}

View file

@ -39,7 +39,7 @@ function encodeTextToQmlRichFormat (text, options) {
}
text = text
.replace(/&/g, '&#38;')
.replace(/&/g, '&#38;') // TODO: deal correctly with urls and `&m`
.replace(/</g, '\u2063&lt;')
.replace(/>/g, '\u2063&gt;')
.replace(/\r\n|\n/g, '<br/>')