Commit 0c1d6929 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/modules/Linphone/Timeline): use `Connections` component

parent 92d076ff
...@@ -45,47 +45,51 @@ ColumnLayout { ...@@ -45,47 +45,51 @@ ColumnLayout {
spacing: 0 spacing: 0
Rectangle { // ---------------------------------------------------------------------------
anchors.fill: parent
color: TimelineStyle.color
}
SmartConnect { Connections {
Component.onCompleted: { target: model
// Handle if current entry was moved in timeline.
this.connect(model, 'dataChanged', function () { // Handle if current entry was moved in timeline.
var index = view.currentIndex onDataChanged: {
if ( var index = view.currentIndex
index !== -1 && if (
_selectedSipAddress !== model.data(model.index(index, 0)).sipAddress index !== -1 &&
) { _selectedSipAddress !== model.data(model.index(index, 0)).sipAddress
setSelectedEntry(_selectedSipAddress) ) {
} setSelectedEntry(_selectedSipAddress)
}) }
}
// A timeline entry is removed from timeline if there is no history entry. // A timeline entry is removed from timeline if there is no history entry.
this.connect(model, 'rowsAboutToBeRemoved', function (_, first, last) { onRowsAboutToBeRemoved: {
var index = view.currentIndex var index = view.currentIndex
if (index >= first && index <= last) { if (index >= first && index <= last) {
view.currentIndex = -1 view.currentIndex = -1
} }
}) }
// A entry is added when history is created. // A entry is added when history is created.
this.connect(model, 'rowsInserted', function (_, first, last) { onRowsInserted: {
if (_selectedSipAddress.length === 0) { if (_selectedSipAddress.length === 0) {
return return
} }
for (var i = first; i <= last; i++) { for (var i = first; i <= last; i++) {
if (_selectedSipAddress === model.data(model.index(i, 0)).sipAddress) { if (_selectedSipAddress === model.data(model.index(i, 0)).sipAddress) {
view.currentIndex = i view.currentIndex = i
}
} }
}) }
} }
} }
// ---------------------------------------------------------------------------
Rectangle {
anchors.fill: parent
color: TimelineStyle.color
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// 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