blob: 9d7d11ac0fe539da1c440601915780b8639627ac [file] [log] [blame]
Edric Milaret2afd2bf2015-07-21 17:12:25 -04001/***************************************************************************
Anthony LĂ©onard2fde81d2017-04-17 10:06:55 -04002 * Copyright (C) 2015-2017 by Savoir-faire Linux *
Edric Milaret2afd2bf2015-07-21 17:12:25 -04003 * Author: Edric Ladent Milaret <edric.ladent-milaret@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 "contactmethodpicker.h"
20#include "ui_contactmethodpicker.h"
21
22#include "contactmethod.h"
23
24ContactMethodPicker::ContactMethodPicker(const Person::ContactMethods& cM, QWidget *parent) :
25 QDialog(parent),
26 ui(new Ui::ContactMethodPicker),
27 contactMethods_(cM)
28{
29 ui->setupUi(this);
30
31 this->setWindowFlags(Qt::CustomizeWindowHint);
32 this->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
33
34 for (auto contactMethod : cM) {
35 auto item = new QListWidgetItem();
36 item->setText(contactMethod->uri());
37 ui->contactMethodListWidget->addItem(item);
38 }
39}
40
41ContactMethodPicker::~ContactMethodPicker()
42{
43 delete ui;
44}
45
46void
47ContactMethodPicker::on_contactMethodListWidget_clicked(const QModelIndex &index)
48{
49 index_ = index.row();
50 accept();
51}
52
53ContactMethod*
54ContactMethodPicker::getSelected() const
55{
56 return contactMethods_.at(index_);
57}