Commit 17ddf3e2 authored by Laurent Montel's avatar Laurent Montel 😁

Extract email address directly.

foo <bla@kde.org> doesn't work.
Bug found by David
parent de48de93
......@@ -236,7 +236,8 @@ public:
for (const QString &addr : lstAddresses) {
if (mModel->insertRow(mModel->rowCount())) {
const QModelIndex index = mModel->index(mModel->rowCount() - 1, 0);
mModel->setData(index, addr, AclModel::UserIdRole);
const QString extractedAddress = KEmailAddress::extractEmailAddress(addr);
mModel->setData(index, extractedAddress, AclModel::UserIdRole);
mModel->setData(index, static_cast<int>(dlg.permissions()), AclModel::PermissionsRole);
mChanged = true;
......@@ -262,20 +263,20 @@ public:
}
const QStringList lstAddresses = KEmailAddress::splitAddressList(dlg.userId());
if (lstAddresses.count() == 1) {
mModel->setData(index, lstAddresses.at(0), AclModel::UserIdRole);
mModel->setData(index, KEmailAddress::extractEmailAddress(lstAddresses.at(0)), AclModel::UserIdRole);
mModel->setData(index, static_cast<int>(dlg.permissions()), AclModel::PermissionsRole);
mChanged = true;
} else {
bool firstElement = true;
for (const QString &addr : lstAddresses) {
if (firstElement) {
mModel->setData(index, lstAddresses.at(0), AclModel::UserIdRole);
mModel->setData(index, KEmailAddress::extractEmailAddress(lstAddresses.at(0)), AclModel::UserIdRole);
mModel->setData(index, static_cast<int>(dlg.permissions()), AclModel::PermissionsRole);
firstElement = false;
} else {
if (mModel->insertRow(mModel->rowCount())) {
const QModelIndex index = mModel->index(mModel->rowCount() - 1, 0);
mModel->setData(index, addr, AclModel::UserIdRole);
mModel->setData(index, KEmailAddress::extractEmailAddress(addr), AclModel::UserIdRole);
mModel->setData(index, static_cast<int>(dlg.permissions()), AclModel::PermissionsRole);
}
}
......
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