Add a flag to enable Qt deprecation warnings on Qt < 5.13
[quassel.git] / src / client / transfermodel.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2019 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
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 2 of the License, or     *
8  *   (at your option) version 3.                                           *
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, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #pragma once
22
23 #include <QAbstractTableModel>
24 #include <QString>
25 #include <QUuid>
26 #include <QVector>
27
28 #include "transfer.h"
29
30 class TransferManager;
31
32 /**
33  * Model that holds the current list of transfers.
34  */
35 class TransferModel : public QAbstractTableModel
36 {
37     Q_OBJECT
38
39 public:
40     using QAbstractTableModel::QAbstractTableModel;
41
42     // see base class docs
43     int rowCount(const QModelIndex& index = {}) const override;
44     int columnCount(const QModelIndex& index = {}) const override;
45     QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
46     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
47
48     /**
49      * Access the transfer for the given ID
50      *
51      * @param[in] transferId Transfer ID
52      * @returns A pointer to the transfer with the given ID, or nullptr for an unknown ID
53      */
54     Transfer* transfer(const QUuid& transferId) const;
55
56     /**
57      * Sets the TransferManager associated with this model.
58      *
59      * The model receives data from the given TransferManager instance. If set to nullptr, the model
60      * is cleared.
61      *
62      * @param[in] manager Pointer to the TransferManager instance, or nullptr for clearing the model
63      */
64     void setManager(const TransferManager* manager);
65
66 private slots:
67     /**
68      * Slot to be called when a transfer is added.
69      *
70      * @param[in] transferId The transfer's ID
71      */
72     void onTransferAdded(const QUuid& transferId);
73
74     /**
75      * Slot to be called when a transfer is removed.
76      *
77      * @param[in] transferId The transfer's ID
78      */
79     void onTransferRemoved(const QUuid& transferId);
80
81     /**
82      * Slot to be called when a transfer's data changes.
83      */
84     void onTransferDataChanged();
85
86 private:
87     const TransferManager* _manager{nullptr};  ///< Pointer to the active TransferManager instance, if any
88     QVector<QUuid> _transferIds;               ///< List of transfer IDs
89 };