Commit ad7d3cd0 authored by Ronan Abhamon's avatar Ronan Abhamon

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

parent c821636a
...@@ -11,7 +11,7 @@ ListView { ...@@ -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 property var _mapStatusToParams
...@@ -156,25 +156,54 @@ ListView { ...@@ -156,25 +156,54 @@ ListView {
} }
} }
// ---------------------------------------------------------------------------
// Update the current selected call and the current index.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
SmartConnect { SmartConnect {
id: smartConnect
property var selectedCall
Component.onCompleted: { Component.onCompleted: {
this.connect(model, 'rowsAboutToBeRemoved', function (_, first, last) { this.connect(model, 'rowsAboutToBeRemoved', function (_, first, last) {
var index = calls.currentIndex var index = calls.currentIndex
if (index >= first && index <= last) { // Remove current call. if (index >= first && index <= last) { // Remove current call.
if (model.rowCount() - (last - first + 1) <= 0) { if (model.rowCount() - (last - first + 1) <= 0) {
calls.currentIndex = -1 selectedCall = null
} else {
if (first === 0) {
selectedCall = model.data(model.index(last + 1, 0))
} else {
selectedCall = model.data(model.index(0, 0))
}
}
}
})
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 { } else {
calls.currentIndex = 0 calls.currentIndex = 0 // The first call becomes the selected call.
} }
} else if (last < index) { // Remove before current 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) calls.currentIndex = index - (last - first + 1)
} }
}) })
// The last inserted element become the selected call.
this.connect(model, 'rowsInserted', function (_, first, last) { this.connect(model, 'rowsInserted', function (_, first, last) {
calls.currentIndex = first calls.currentIndex = first
selectedCall = model.data(model.index(first, 0))
}) })
} }
} }
......
...@@ -39,7 +39,7 @@ function encodeTextToQmlRichFormat (text, options) { ...@@ -39,7 +39,7 @@ function encodeTextToQmlRichFormat (text, options) {
} }
text = text text = text
.replace(/&/g, '&#38;') .replace(/&/g, '&#38;') // TODO: deal correctly with urls and `&m`
.replace(/</g, '\u2063&lt;') .replace(/</g, '\u2063&lt;')
.replace(/>/g, '\u2063&gt;') .replace(/>/g, '\u2063&gt;')
.replace(/\r\n|\n/g, '<br/>') .replace(/\r\n|\n/g, '<br/>')
......
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