Edric Milaret | 2afd2bf | 2015-07-21 17:12:25 -0400 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2015 by Savoir-Faire Linux * |
| 3 | * 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 | |
| 24 | ContactMethodPicker::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 | |
| 41 | ContactMethodPicker::~ContactMethodPicker() |
| 42 | { |
| 43 | delete ui; |
| 44 | } |
| 45 | |
| 46 | void |
| 47 | ContactMethodPicker::on_contactMethodListWidget_clicked(const QModelIndex &index) |
| 48 | { |
| 49 | index_ = index.row(); |
| 50 | accept(); |
| 51 | } |
| 52 | |
| 53 | ContactMethod* |
| 54 | ContactMethodPicker::getSelected() const |
| 55 | { |
| 56 | return contactMethods_.at(index_); |
| 57 | } |