Olivier SOLDANO | cc28a0d | 2017-07-21 13:53:31 -0400 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2015-2017 by Savoir-faire Linux * |
| 3 | * Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com> * |
| 4 | * * |
| 5 | * This program is free software; you can redistribute it and/or modify * |
| 6 | * it under the terms of the GNU General Public License as published by * |
| 7 | * the Free Software Foundation; either version 3 of the License, or * |
| 8 | * (at your option) any later version. * |
| 9 | * * |
| 10 | * This program is distributed in the hope that it will be useful, * |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 13 | * GNU General Public License for more details. * |
| 14 | * * |
| 15 | * You should have received a copy of the GNU General Public License * |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * |
| 17 | **************************************************************************/ |
| 18 | |
| 19 | #include "deletecontactdialog.h" |
| 20 | #include "ui_deletecontactdialog.h" |
| 21 | |
| 22 | // LRC |
| 23 | #include "person.h" |
| 24 | #include "account.h" |
| 25 | #include "bannedcontactmodel.h" |
| 26 | |
| 27 | DeleteContactDialog::DeleteContactDialog(ContactMethod* cm, Account* ac, QWidget *parent) : |
| 28 | QDialog(parent), |
| 29 | ui(new Ui::DeleteContactDialog), |
| 30 | contactMethod_(cm), |
| 31 | account_(ac) |
| 32 | { |
| 33 | setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); |
| 34 | ui->setupUi(this); |
| 35 | ui->contactNameLabel->setText(cm->bestName()); |
| 36 | if (cm->bestName() != cm->bestId()) |
| 37 | ui->contactIdLabel->setText(cm->bestId()); |
| 38 | else |
| 39 | ui->contactIdLabel->hide(); |
| 40 | } |
| 41 | |
| 42 | DeleteContactDialog::~DeleteContactDialog() |
| 43 | { |
| 44 | delete ui; |
| 45 | } |
| 46 | |
| 47 | void DeleteContactDialog::on_deleteCancelBtn_clicked() |
| 48 | { |
| 49 | close(); |
| 50 | } |
| 51 | |
| 52 | void DeleteContactDialog::on_deleteAcceptBtn_clicked() |
| 53 | { |
| 54 | account_->removeContact(contactMethod_); |
| 55 | accept(); |
| 56 | } |
| 57 | |
| 58 | void DeleteContactDialog::on_deleteBanBtn_clicked() |
| 59 | { |
| 60 | account_->removeContact(contactMethod_); |
| 61 | account_->bannedContactModel()->add(contactMethod_); |
| 62 | accept(); |
| 63 | } |