Browse Source

Don't allow duplicate address labels

pull/201/head
DenioD 4 years ago
parent
commit
be2bcab9e6
  1. 43
      src/chatmodel.cpp

43
src/chatmodel.cpp

@ -237,6 +237,20 @@ void MainWindow::renderContactRequest(){
return;
}
// Don't allow duplicate address labels.
if (!AddressBook::getInstance()->getAddressForLabel(newLabel).isEmpty())
{
QMessageBox::critical(
this,
QObject::tr("Label Error"),
QObject::tr("The label '%1' already exists. Please remove the existing label.").arg(newLabel),
QMessageBox::Ok
);
qDebug()<<"Doppelter Name";
return;
}
// Test if address is valid.
if (!Settings::isValidAddress(addr))
{
@ -248,6 +262,9 @@ void MainWindow::renderContactRequest(){
);
return;
}
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar);
rpc->refreshContacts(
ui->listContactWidget);
@ -829,6 +846,19 @@ void MainWindow::ContactRequest() {
return;
}
QString newLabel = contactRequest.getLabel();
if (!AddressBook::getInstance()->getAddressForLabel(newLabel).isEmpty())
{
QMessageBox::critical(
this,
QObject::tr("Label Error"),
QObject::tr("The label '%1' already exists. Please remove the existing label.").arg(newLabel),
QMessageBox::Ok
);
return;
}
int max = 512;
QString chattext = contactRequest.getMemo();;
int size = chattext.size();
@ -916,6 +946,17 @@ void MainWindow::ContactRequest() {
return;
}
if (!AddressBook::getInstance()->getAddressForLabel(newLabel).isEmpty())
{
QMessageBox::critical(
this,
QObject::tr("Label Error"),
QObject::tr("The label '%1' already exists. Please remove the existing label.").arg(newLabel),
QMessageBox::Ok
);
return;
}
// Test if address is valid.
if (!Settings::isValidAddress(addr))
{
@ -928,8 +969,6 @@ void MainWindow::ContactRequest() {
return;
}
///////Todo: Test if label allready exist!
////// Success, so show it
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar);
rpc->refreshContacts(

Loading…
Cancel
Save