Anthony Léonard | 2fde81d | 2017-04-17 10:06:55 -0400 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2015-2017 by Savoir-faire Linux * |
| 3 | * Author: Anthony Léonard <anthony.leonard@savoirfairelinux.com> * |
| 4 | * Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com> * |
| 5 | * * |
| 6 | * This program is free software; you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 3 of the License, or * |
| 9 | * (at your option) any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * |
| 18 | **************************************************************************/ |
| 19 | |
Anthony Léonard | d47179c | 2017-03-28 10:39:10 -0400 | [diff] [blame] | 20 | #include "contactrequestwidget.h" |
| 21 | #include "ui_contactrequestwidget.h" |
| 22 | |
| 23 | ContactRequestWidget::ContactRequestWidget(QWidget *parent) : |
| 24 | QWidget(parent), |
| 25 | ui(new Ui::ContactRequestWidget) |
| 26 | { |
| 27 | ui->setupUi(this); |
| 28 | } |
| 29 | |
| 30 | ContactRequestWidget::~ContactRequestWidget() |
| 31 | { |
| 32 | delete ui; |
| 33 | } |
| 34 | |
| 35 | void |
| 36 | ContactRequestWidget::setCurrentContactRequest(ContactRequest *cr) |
| 37 | { |
| 38 | cr_ = cr; |
| 39 | if (cr_ != nullptr) { |
Anthony Léonard | 2fde81d | 2017-04-17 10:06:55 -0400 | [diff] [blame] | 40 | QString remoteId = QString::fromLocal8Bit(cr_->roleData(Qt::DisplayRole).value<QByteArray>()); |
| 41 | ui->remoteIdLabel->setText(QString("Current ContactRequest: %1").arg(remoteId)); |
Anthony Léonard | d47179c | 2017-03-28 10:39:10 -0400 | [diff] [blame] | 42 | } |
| 43 | } |
| 44 | |
| 45 | void |
| 46 | ContactRequestWidget::on_acceptCRButton_clicked() |
| 47 | { |
| 48 | if (cr_ != nullptr) { |
| 49 | cr_->accept(); |
| 50 | } |
| 51 | setCurrentContactRequest(nullptr); |
| 52 | emit choiceMade(); |
| 53 | } |
| 54 | |
| 55 | void ContactRequestWidget::on_discardCRButton_clicked() |
| 56 | { |
| 57 | if (cr_ != nullptr) { |
| 58 | cr_->discard(); |
| 59 | } |
| 60 | setCurrentContactRequest(nullptr); |
| 61 | emit choiceMade(); |
| 62 | } |