callutilsdialog.h 2.68 KB
Newer Older
1
/***************************************************************************
2
 * Copyright (C) 2015-2016 by Savoir-faire Linux                                *
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
 *                                                                         *
 * This program is free software; you can redistribute it and/or modify    *
 * it under the terms of the GNU General Public License as published by    *
 * the Free Software Foundation; either version 3 of the License, or       *
 * (at your option) any later version.                                     *
 *                                                                         *
 * This program is distributed in the hope that it will be useful,         *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 * GNU General Public License for more details.                            *
 *                                                                         *
 * You should have received a copy of the GNU General Public License       *
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
 **************************************************************************/

Edric Milaret's avatar
Edric Milaret committed
19
#pragma once
20 21 22 23 24

#include <QDialog>
#include <QSortFilterProxyModel>

#include "callmodel.h"
25 26 27
#include "recentmodel.h"

#include "smartlistdelegate.h"
28 29

namespace Ui {
30
    class CallUtilsDialog;
31 32
}

33
class NotCurrentProxyModel : public QSortFilterProxyModel
34 35
{
public:
36
    NotCurrentProxyModel(QAbstractItemModel* parent) : QSortFilterProxyModel(parent)
37 38 39 40 41
    {
        setSourceModel(parent);
    }
    virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
    {
42 43 44 45 46
        if (not sourceModel() || source_parent.isValid())
            return false;
        auto idx = sourceModel()->index(source_row,0,source_parent);
        if (not idx.isValid())
            return false;
47 48
        auto call = RecentModel::instance().getActiveCall(idx);
        return not call || not (call->state() == Call::State::CURRENT);
49 50 51
    }
};

52
class CallUtilsDialog : public QDialog
53 54 55 56
{
    Q_OBJECT

public:
57 58 59 60
    explicit CallUtilsDialog(QWidget* parent = 0);
    ~CallUtilsDialog();

    void setConfMode(bool active);
61 62 63

//UI SLOTS
protected slots:
64 65
    void showEvent(QShowEvent* event);
    void closeEvent(QCloseEvent* event);
66
private slots:
Edric Milaret's avatar
Edric Milaret committed
67
    void on_doTransferButton_clicked();
68
    void on_contactView_doubleClicked(const QModelIndex& index);
69 70

private:
71 72 73 74
    Ui::CallUtilsDialog* ui;
    bool confMode_;
    SmartListDelegate* smartListDelegate_;
    NotCurrentProxyModel* notCurrentProxyModel_;
75 76

    void removeProxyModel();
77 78
};