blob: a28fce0daa1330dbea41937bfdd008c9a6d7e419 [file] [log] [blame]
Edric Milaret5cbf2b62015-07-09 11:36:53 -04001/***************************************************************************
Edric Milaret5f316da2015-09-28 11:57:42 -04002 * Copyright (C) 2015 by Savoir-faire Linux *
Edric Milaret5cbf2b62015-07-09 11:36:53 -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
Edric Milaret5f316da2015-09-28 11:57:42 -040019#pragma once
Edric Milaret5cbf2b62015-07-09 11:36:53 -040020
21#include <QDialog>
22#include <QSortFilterProxyModel>
23
24#include "callmodel.h"
25
26namespace Ui {
27class TransferDialog;
28}
29
30class ActiveCallsProxyModel : public QSortFilterProxyModel
31{
32public:
33 ActiveCallsProxyModel(QAbstractItemModel* parent) : QSortFilterProxyModel(parent)
34 {
35 setSourceModel(parent);
36 }
37 virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
38 {
Edric Milaret4ba5c822015-10-06 16:27:33 -040039 if (not sourceModel() || source_parent.isValid())
40 return false;
41 auto idx = sourceModel()->index(source_row,0,source_parent);
42 if (not idx.isValid())
43 return false;
44 return idx.data(static_cast<int>(Call::Role::State))
45 .value<Call::State>() != Call::State::CURRENT;
Edric Milaret5cbf2b62015-07-09 11:36:53 -040046 }
47};
48
49
50class TransferDialog : public QDialog
51{
52 Q_OBJECT
53
54public:
55 explicit TransferDialog(QWidget *parent = 0);
56 ~TransferDialog();
57
58//UI SLOTS
59protected slots:
60 void showEvent(QShowEvent *event);
61private slots:
62 void on_transferButton_clicked();
63 void on_activeCallsView_doubleClicked(const QModelIndex &index);
64 void on_activeCallsView_clicked(const QModelIndex &index);
65
66private:
67 Ui::TransferDialog *ui;
68 Call *selectedCall_;
Edric Milaret4ba5c822015-10-06 16:27:33 -040069 ActiveCallsProxyModel *activeProxy_;
70
71 void removeProxyModel();
Edric Milaret5cbf2b62015-07-09 11:36:53 -040072};
73