diff options
author | Luboš Doležel <lubos@dolezel.info> | 2016-01-17 13:16:46 +0100 |
---|---|---|
committer | Luboš Doležel <lubos@dolezel.info> | 2016-01-17 13:16:46 +0100 |
commit | 1770095867e000bc5dd424ae4c5738b9b92fb0b2 (patch) | |
tree | 313b16b316b5158862b1199edc108a2d87e4692a | |
parent | d54fe443fc5a08006fc36ad8d04c96281cf051e2 (diff) | |
parent | 57dc032be416665b50dc14874a6d62fb5b7678a5 (diff) | |
download | twinkle-1770095867e000bc5dd424ae4c5738b9b92fb0b2.tar twinkle-1770095867e000bc5dd424ae4c5738b9b92fb0b2.tar.gz twinkle-1770095867e000bc5dd424ae4c5738b9b92fb0b2.tar.lz twinkle-1770095867e000bc5dd424ae4c5738b9b92fb0b2.tar.xz twinkle-1770095867e000bc5dd424ae4c5738b9b92fb0b2.zip |
Merge pull request #54 from fbriere/addressbook-sort-and-confirm
Local address book: re-sort after adding/editing, and confirm before deleting
-rw-r--r-- | src/gui/getaddressform.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/gui/getaddressform.cpp b/src/gui/getaddressform.cpp index 2303c38..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 @@ -216,6 +218,8 @@ void GetAddressForm::addLocalAddress() ab_local->add_address(card); m_model->appendAddress(card); + + localListView->sortByColumn(localListView->horizontalHeader()->sortIndicatorSection(), localListView->horizontalHeader()->sortIndicatorOrder()); string error_msg; if (!ab_local->save(error_msg)) { @@ -232,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() @@ -254,6 +273,8 @@ void GetAddressForm::editLocalAddress() if (f.exec(newCard)) { if (ab_local->update_address(oldCard, newCard)) { m_model->modifyAddress(sel[0].row(), newCard); + + localListView->sortByColumn(localListView->horizontalHeader()->sortIndicatorSection(), localListView->horizontalHeader()->sortIndicatorOrder()); string error_msg; if (!ab_local->save(error_msg)) { |