From 8bf2472060d77120e44c822a91551d1381127dca Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Thu, 24 Oct 2024 11:59:28 +0200 Subject: [PATCH] Fix phone numbers combobox (resetModel events and binding loop on y) --- Linphone/core/proxy/LimitProxy.cpp | 1 + Linphone/core/proxy/Proxy.cpp | 1 + Linphone/view/Control/Button/CountryIndicatorCombobox.qml | 5 +---- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Linphone/core/proxy/LimitProxy.cpp b/Linphone/core/proxy/LimitProxy.cpp index 4f493f29..6877a1b0 100644 --- a/Linphone/core/proxy/LimitProxy.cpp +++ b/Linphone/core/proxy/LimitProxy.cpp @@ -23,6 +23,7 @@ LimitProxy::LimitProxy(QObject *parent) : QSortFilterProxyModel(parent) { connect(this, &LimitProxy::rowsInserted, this, &LimitProxy::countChanged); connect(this, &LimitProxy::rowsRemoved, this, &LimitProxy::countChanged); + connect(this, &LimitProxy::modelReset, this, &LimitProxy::countChanged); } /* LimitProxy::LimitProxy(QAbstractItemModel *sortFilterProxy, QObject *parent) : QSortFilterProxyModel(parent) { diff --git a/Linphone/core/proxy/Proxy.cpp b/Linphone/core/proxy/Proxy.cpp index bb1a31b2..445f6528 100644 --- a/Linphone/core/proxy/Proxy.cpp +++ b/Linphone/core/proxy/Proxy.cpp @@ -23,6 +23,7 @@ Proxy::Proxy(QObject *parent) : QAbstractListModel(parent) { connect(this, &Proxy::rowsInserted, this, &Proxy::countChanged); connect(this, &Proxy::rowsRemoved, this, &Proxy::countChanged); + connect(this, &Proxy::modelReset, this, &Proxy::countChanged); } int Proxy::getCount() const { diff --git a/Linphone/view/Control/Button/CountryIndicatorCombobox.qml b/Linphone/view/Control/Button/CountryIndicatorCombobox.qml index f8af24ca..131aaaf0 100644 --- a/Linphone/view/Control/Button/CountryIndicatorCombobox.qml +++ b/Linphone/view/Control/Button/CountryIndicatorCombobox.qml @@ -25,11 +25,9 @@ ColumnLayout { Control.ComboBox { id: combobox + currentIndex: phoneNumberModel.count > 0 ? Math.max(0, phoneNumberModel.findIndexByCountryCallingCode(defaultCallingCode)) : -1 model: PhoneNumberProxy { id: phoneNumberModel - onCountChanged: { - combobox.currentIndex = Math.max(0, findIndexByCountryCallingCode(defaultCallingCode)) - } } background: Rectangle { implicitWidth: mainItem.implicitWidth @@ -120,7 +118,6 @@ ColumnLayout { height: listView.height color: DefaultStyle.main2_300 // radius: 15 * DefaultStyle.dp - y: listView.currentItem? listView.currentItem.y : 0 } delegate: Item {