fix call history list sorting #LINQT-2346

This commit is contained in:
Gaelle Braud 2026-01-15 11:44:22 +01:00
parent f039784b26
commit 7f1708dacb
3 changed files with 9 additions and 18 deletions

View file

@ -70,7 +70,7 @@ void CallHistoryList::setSelf(QSharedPointer<CallHistoryList> me) {
for (auto it : linphoneCallLogs) {
auto model = createCallHistoryCore(it);
toConnect(model.get());
callLogs->push_back(model);
callLogs->push_front(model);
}
mModelConnection->invokeToCore([this, callLogs]() {
mustBeInMainThread(getClassName());

View file

@ -68,8 +68,5 @@ bool CallHistoryProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QMo
}
bool CallHistoryProxy::SortFilterList::lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const {
auto l = getItemAtSource<CallHistoryList, CallHistoryCore>(sourceLeft.row());
auto r = getItemAtSource<CallHistoryList, CallHistoryCore>(sourceRight.row());
if (l && r) return l->mDate < r->mDate;
return false;
return true;
}

View file

@ -21,7 +21,6 @@ ListView {
onResultsReceived: {
loading = false
// contentY = 0
}
model: CallHistoryProxy {
@ -49,13 +48,12 @@ ListView {
Component.onCompleted: cacheBuffer = Math.max(mainItem.height,0) //contentHeight>0 ? contentHeight : 0// cache all items
// remove binding loop
onContentHeightChanged: Qt.callLater(function () {
if (mainItem)
mainItem.cacheBuffer = Math?.max(contentHeight, 0) || 0
})
// onContentHeightChanged: Qt.callLater(function () {
// if (mainItem)
// mainItem.cacheBuffer = Math?.max(contentHeight, 0) || 0
// })
onActiveFocusChanged: if (activeFocus && currentIndex < 0 && count > 0)
currentIndex = 0
onActiveFocusChanged: if (activeFocus && currentIndex < 0 && count > 0) currentIndex = 0
onCountChanged: {
if (currentIndex < 0 && count > 0) {
mainItem.currentIndex = 0 // Select first item after loading model
@ -86,8 +84,8 @@ ListView {
// Update position only if we are moving to current item and its position is changing.
property var _currentItemY: currentItem?.y
on_CurrentItemYChanged: if (_currentItemY && moveAnimation.running) {
moveToCurrentItem()
}
moveToCurrentItem()
}
Behavior on contentY {
NumberAnimation {
id: moveAnimation
@ -98,10 +96,6 @@ ListView {
}
//----------------------------------------------------------------
onVisibleChanged: {
// if (!visible)
// currentIndex = -1
}
BusyIndicator {
anchors.horizontalCenter: mainItem.horizontalCenter