Fix phone numbers combobox (resetModel events and binding loop on y)

This commit is contained in:
Julien Wadel 2024-10-24 11:59:28 +02:00
parent 30c36757c0
commit 8bf2472060
3 changed files with 3 additions and 4 deletions

View file

@ -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) {

View file

@ -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 {

View file

@ -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 {