blob: 417d30cef03bdef1df563c18d7e3127eb25196f1 [file] [log] [blame]
Edric Milaret43f3c1e2015-07-16 17:52:47 -04001/***************************************************************************
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 "contactpicker.h"
20#include "ui_contactpicker.h"
21
22#include "categorizedcontactmodel.h"
23
24ContactPicker::ContactPicker(QWidget *parent) :
25 QDialog(parent),
26 ui(new Ui::ContactPicker),
27 personSelected_(nullptr)
28{
29 ui->setupUi(this);
30
31 this->setWindowFlags(Qt::CustomizeWindowHint);
32 this->setWindowFlags(Qt::FramelessWindowHint);
33
34 auto personModel = PersonModel::instance();
35 ui->contactView->setModel(personModel);
36}
37
38ContactPicker::~ContactPicker()
39{
40 delete ui;
41}
42
43void
44ContactPicker::on_contactView_doubleClicked(const QModelIndex &index)
45{
46 personSelected_ = index.data(static_cast<int>(Person::Role::Object)).value<Person*>();
47 this->accept();
48}
49
50Person*
51ContactPicker::getPersonSelected()
52{
53 return personSelected_;
54}
55
56void
57ContactPicker::on_cancelButton_clicked()
58{
59 this->reject();
60}