diff options
author | Frédéric Brière <fbriere@fbriere.net> | 2016-01-16 16:12:39 -0500 |
---|---|---|
committer | Frédéric Brière <fbriere@fbriere.net> | 2016-01-16 16:25:23 -0500 |
commit | 57dc032be416665b50dc14874a6d62fb5b7678a5 (patch) | |
tree | afd2b9658a381aacd58797e35be0ca5a26a4785e /src/gui | |
parent | 48acf672dab806498872021beb717a41b6fbc552 (diff) | |
download | twinkle-57dc032be416665b50dc14874a6d62fb5b7678a5.tar twinkle-57dc032be416665b50dc14874a6d62fb5b7678a5.tar.gz twinkle-57dc032be416665b50dc14874a6d62fb5b7678a5.tar.lz twinkle-57dc032be416665b50dc14874a6d62fb5b7678a5.tar.xz twinkle-57dc032be416665b50dc14874a6d62fb5b7678a5.zip |
Ask for confirmation before deleting a local address book contact
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/getaddressform.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/gui/getaddressform.cpp b/src/gui/getaddressform.cpp index dd81257..2a433a0 100644 --- a/src/gui/getaddressform.cpp +++ b/src/gui/getaddressform.cpp @@ -17,12 +17,14 @@ */ #include "getaddressform.h" +#include <QMessageBox> #include <QRegExp> #include "sys_settings.h" #include "gui.h" #include "address_book.h" #include "addresstablemodel.h" #include "addresscardform.h" +#include "audits/memman.h" #define TAB_KABC 0 #define TAB_LOCAL 1 @@ -234,14 +236,29 @@ void GetAddressForm::deleteLocalAddress() t_address_card card = m_model->getAddress(sel[0].row()); - if (ab_local->del_address(card)) { - m_model->removeAddress(sel[0].row()); + QString card_name = QString::fromStdString(card.get_display_name()); + QString msg = tr("Are you sure you want to delete contact '%1' from the local address book?").arg(card_name); + QMessageBox *mb = new QMessageBox(tr("Delete contact"), msg, + QMessageBox::Warning, + QMessageBox::Yes, + QMessageBox::No, + QMessageBox::NoButton, + this); + MEMMAN_NEW(mb); - string error_msg; - if (!ab_local->save(error_msg)) { - ui->cb_show_msg(error_msg, MSG_CRITICAL); + if (mb->exec() == QMessageBox::Yes) { + if (ab_local->del_address(card)) { + m_model->removeAddress(sel[0].row()); + + string error_msg; + if (!ab_local->save(error_msg)) { + ui->cb_show_msg(error_msg, MSG_CRITICAL); + } } } + + MEMMAN_DELETE(mb); + delete mb; } void GetAddressForm::editLocalAddress() |