Commit 32f09dd0 authored by Ronan Abhamon's avatar Ronan Abhamon

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

parent bd53a150
...@@ -15,6 +15,8 @@ ColumnLayout { ...@@ -15,6 +15,8 @@ ColumnLayout {
property alias model: view.model property alias model: view.model
property string _selectedSipAddress
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
signal entrySelected (var entry) signal entrySelected (var entry)
...@@ -27,6 +29,7 @@ ColumnLayout { ...@@ -27,6 +29,7 @@ ColumnLayout {
for (var i = 0; i < n; i++) { for (var i = 0; i < n; i++) {
if (sipAddress === model.data(model.index(i, 0)).sipAddress) { if (sipAddress === model.data(model.index(i, 0)).sipAddress) {
view.currentIndex = i view.currentIndex = i
_selectedSipAddress = sipAddress
return return
} }
} }
...@@ -34,12 +37,25 @@ ColumnLayout { ...@@ -34,12 +37,25 @@ ColumnLayout {
function resetSelectedEntry () { function resetSelectedEntry () {
view.currentIndex = -1 view.currentIndex = -1
_selectedSipAddress = ''
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
spacing: 0 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. // Legend.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
......
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