blob: b8cb31cafdf20c434256b8694482d4eb6a6db6bf [file] [log] [blame]
Anthony Léonard2fde81d2017-04-17 10:06:55 -04001/***************************************************************************
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éonardd47179c2017-03-28 10:39:10 -040020#include "contactrequestwidget.h"
21#include "ui_contactrequestwidget.h"
22
23ContactRequestWidget::ContactRequestWidget(QWidget *parent) :
24 QWidget(parent),
25 ui(new Ui::ContactRequestWidget)
26{
27 ui->setupUi(this);
28}
29
30ContactRequestWidget::~ContactRequestWidget()
31{
32 delete ui;
33}
34
35void
36ContactRequestWidget::setCurrentContactRequest(ContactRequest *cr)
37{
38 cr_ = cr;
39 if (cr_ != nullptr) {
Anthony Léonard2fde81d2017-04-17 10:06:55 -040040 QString remoteId = QString::fromLocal8Bit(cr_->roleData(Qt::DisplayRole).value<QByteArray>());
41 ui->remoteIdLabel->setText(QString("Current ContactRequest: %1").arg(remoteId));
Anthony Léonardd47179c2017-03-28 10:39:10 -040042 }
43}
44
45void
46ContactRequestWidget::on_acceptCRButton_clicked()
47{
48 if (cr_ != nullptr) {
49 cr_->accept();
50 }
51 setCurrentContactRequest(nullptr);
52 emit choiceMade();
53}
54
55void ContactRequestWidget::on_discardCRButton_clicked()
56{
57 if (cr_ != nullptr) {
58 cr_->discard();
59 }
60 setCurrentContactRequest(nullptr);
61 emit choiceMade();
62}