mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-23 22:58:15 +00:00
feat(ui/modules/Linphone/Timeline): use Connections component
This commit is contained in:
parent
92d076ffb8
commit
0c1d6929cd
1 changed files with 40 additions and 36 deletions
|
|
@ -45,47 +45,51 @@ ColumnLayout {
|
|||
|
||||
spacing: 0
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Connections {
|
||||
target: model
|
||||
|
||||
// Handle if current entry was moved in timeline.
|
||||
onDataChanged: {
|
||||
var index = view.currentIndex
|
||||
if (
|
||||
index !== -1 &&
|
||||
_selectedSipAddress !== model.data(model.index(index, 0)).sipAddress
|
||||
) {
|
||||
setSelectedEntry(_selectedSipAddress)
|
||||
}
|
||||
}
|
||||
|
||||
// A timeline entry is removed from timeline if there is no history entry.
|
||||
onRowsAboutToBeRemoved: {
|
||||
var index = view.currentIndex
|
||||
if (index >= first && index <= last) {
|
||||
view.currentIndex = -1
|
||||
}
|
||||
}
|
||||
|
||||
// A entry is added when history is created.
|
||||
onRowsInserted: {
|
||||
if (_selectedSipAddress.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
for (var i = first; i <= last; i++) {
|
||||
if (_selectedSipAddress === model.data(model.index(i, 0)).sipAddress) {
|
||||
view.currentIndex = i
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: TimelineStyle.color
|
||||
}
|
||||
|
||||
SmartConnect {
|
||||
Component.onCompleted: {
|
||||
// Handle if current entry was moved in timeline.
|
||||
this.connect(model, 'dataChanged', function () {
|
||||
var index = view.currentIndex
|
||||
if (
|
||||
index !== -1 &&
|
||||
_selectedSipAddress !== model.data(model.index(index, 0)).sipAddress
|
||||
) {
|
||||
setSelectedEntry(_selectedSipAddress)
|
||||
}
|
||||
})
|
||||
|
||||
// A timeline entry is removed from timeline if there is no history entry.
|
||||
this.connect(model, 'rowsAboutToBeRemoved', function (_, first, last) {
|
||||
var index = view.currentIndex
|
||||
if (index >= first && index <= last) {
|
||||
view.currentIndex = -1
|
||||
}
|
||||
})
|
||||
|
||||
// A entry is added when history is created.
|
||||
this.connect(model, 'rowsInserted', function (_, first, last) {
|
||||
if (_selectedSipAddress.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
for (var i = first; i <= last; i++) {
|
||||
if (_selectedSipAddress === model.data(model.index(i, 0)).sipAddress) {
|
||||
view.currentIndex = i
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Legend.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue