Don't allow duplicate address labels
This commit is contained in:
@@ -237,6 +237,20 @@ void MainWindow::renderContactRequest(){
|
|||||||
return;
|
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.
|
// Test if address is valid.
|
||||||
if (!Settings::isValidAddress(addr))
|
if (!Settings::isValidAddress(addr))
|
||||||
{
|
{
|
||||||
@@ -248,12 +262,15 @@ void MainWindow::renderContactRequest(){
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar);
|
|
||||||
rpc->refreshContacts(
|
|
||||||
ui->listContactWidget);
|
|
||||||
|
|
||||||
QMessageBox::information(this, "Added Contact","successfully added your new contact. You can now Chat with this contact");
|
|
||||||
dialog.close();
|
|
||||||
|
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar);
|
||||||
|
rpc->refreshContacts(
|
||||||
|
ui->listContactWidget);
|
||||||
|
|
||||||
|
QMessageBox::information(this, "Added Contact","successfully added your new contact. You can now Chat with this contact");
|
||||||
|
dialog.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
@@ -829,6 +846,19 @@ void MainWindow::ContactRequest() {
|
|||||||
return;
|
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;
|
int max = 512;
|
||||||
QString chattext = contactRequest.getMemo();;
|
QString chattext = contactRequest.getMemo();;
|
||||||
int size = chattext.size();
|
int size = chattext.size();
|
||||||
@@ -916,6 +946,17 @@ void MainWindow::ContactRequest() {
|
|||||||
return;
|
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.
|
// Test if address is valid.
|
||||||
if (!Settings::isValidAddress(addr))
|
if (!Settings::isValidAddress(addr))
|
||||||
{
|
{
|
||||||
@@ -928,8 +969,6 @@ void MainWindow::ContactRequest() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////Todo: Test if label allready exist!
|
|
||||||
|
|
||||||
////// Success, so show it
|
////// Success, so show it
|
||||||
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar);
|
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar);
|
||||||
rpc->refreshContacts(
|
rpc->refreshContacts(
|
||||||
|
|||||||
Reference in New Issue
Block a user