Verified Commit e0f24ab2 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

Fix removing phone numbers / instant messenger contacts

parent a20f951d
......@@ -140,10 +140,10 @@ Kirigami.ScrollablePage {
delegate: RowLayout {
Controls.TextField {
id: phoneField
text: display
text: model.display
Layout.fillWidth: true
onAccepted: {
display = text
model.display = text
}
Connections {
......@@ -155,7 +155,7 @@ Kirigami.ScrollablePage {
icon.name: "list-remove"
implicitWidth: implicitHeight
onClicked: {
addressee.phoneNumbers.removePhoneNumber(display)
addressee.phoneNumbers.removePhoneNumber(model.display)
}
}
}
......@@ -264,10 +264,10 @@ Kirigami.ScrollablePage {
delegate: RowLayout {
Controls.TextField {
id: imppField
text: display
text: model.display
Layout.fillWidth: true
onAccepted: {
display = text
model.display = text
}
Connections {
......@@ -279,7 +279,8 @@ Kirigami.ScrollablePage {
icon.name: "list-remove"
implicitWidth: implicitHeight
onClicked: {
addressee.impps.removeImpp(display)
print("remove", model.display)
addressee.impps.removeImpp(model.display)
}
}
}
......
......@@ -84,17 +84,17 @@ void ImppModel::addImpp(const QString &address)
void ImppModel::removeImpp(const QString &address)
{
// Find Impp object belonging to the address and remove it.
for (int i = 0; i < m_addressee->m_addressee.imppList().count(); i++) {
if (m_addressee->m_addressee.imppList()[i].address().toString().contains(address)) {
if (m_addressee->m_addressee.imppList().at(i).address().toString() == address) {
beginRemoveRows({}, i, i);
auto imppList = m_addressee->m_addressee.imppList();
imppList.remove(i);
m_addressee->m_addressee.setImppList(imppList);
endRemoveRows();
break;
}
}
endRemoveRows();
}
......@@ -78,19 +78,16 @@ void PhonesModel::addPhoneNumber(const QString &number)
void PhonesModel::removePhoneNumber(const QString &number)
{
for (int i = 0; i < m_addressee->m_addressee.phoneNumbers().count(); i++) {
if (m_addressee->m_addressee.phoneNumbers()[i].number() == number) {
beginRemoveRows({}, i, i);
break;
}
}
const auto phoneNumbers = m_addressee->m_addressee.phoneNumbers();
for (const auto &phoneNumber : m_addressee->m_addressee.phoneNumbers()) {
// Find PhoneNumber object that belongs to the number and remove it
for (const auto &phoneNumber : phoneNumbers) {
if (phoneNumber.number() == number) {
int index = phoneNumbers.indexOf(phoneNumber);
beginRemoveRows({}, index, index);
m_addressee->m_addressee.removePhoneNumber(phoneNumber);
endRemoveRows();
break;
}
}
endRemoveRows();
}
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