1 /***************************************************************************
2 * Copyright (C) 2005-2016 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
23 #include <QAbstractTableModel>
30 class TransferManager;
33 * Model that holds the current list of transfers.
35 class TransferModel : public QAbstractTableModel
40 using QAbstractTableModel::QAbstractTableModel;
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;
49 * Access the transfer for the given ID
51 * @param[in] transferId Transfer ID
52 * @returns A pointer to the transfer with the given ID, or nullptr for an unknown ID
54 Transfer *transfer(const QUuid &transferId) const;
57 * Sets the TransferManager associated with this model.
59 * The model receives data from the given TransferManager instance. If set to nullptr, the model
62 * @param[in] manager Pointer to the TransferManager instance, or nullptr for clearing the model
64 void setManager(const TransferManager *manager);
68 * Slot to be called when a transfer is added.
70 * @param[in] transferId The transfer's ID
72 void onTransferAdded(const QUuid &transferId);
75 * Slot to be called when a transfer is removed.
77 * @param[in] transferId The transfer's ID
79 void onTransferRemoved(const QUuid &transferId);
82 * Slot to be called when a transfer's data changes.
84 void onTransferDataChanged();
87 const TransferManager *_manager{nullptr}; ///< Pointer to the active TransferManager instance, if any
88 QVector<QUuid> _transferIds; ///< List of transfer IDs