feat(ui/modules/Linphone/Timeline): update current index if necessary when data changed

This commit is contained in:
Ronan Abhamon 2017-01-11 14:33:56 +01:00
parent bd53a15002
commit 32f09dd0dd

View file

@ -15,6 +15,8 @@ ColumnLayout {
property alias model: view.model
property string _selectedSipAddress
// ---------------------------------------------------------------------------
signal entrySelected (var entry)
@ -27,6 +29,7 @@ ColumnLayout {
for (var i = 0; i < n; i++) {
if (sipAddress === model.data(model.index(i, 0)).sipAddress) {
view.currentIndex = i
_selectedSipAddress = sipAddress
return
}
}
@ -34,12 +37,25 @@ ColumnLayout {
function resetSelectedEntry () {
view.currentIndex = -1
_selectedSipAddress = ''
}
// ---------------------------------------------------------------------------
spacing: 0
SmartConnect {
Component.onCompleted: this.connect(model, 'dataChanged', function () {
var index = view.currentIndex
if (
index !== -1 &&
_selectedSipAddress !== model.data(model.index(index, 0)).sipAddress
) {
setSelectedEntry(_selectedSipAddress)
}
})
}
// ---------------------------------------------------------------------------
// Legend.
// ---------------------------------------------------------------------------