Warning, file /network/kget/transfer-plugins/bittorrent/advanceddetails/torrentfilemodel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /*************************************************************************** 0002 * Copyright (C) 2007 by Joris Guisson and Ivan Vasic * 0003 * joris.guisson@gmail.com * 0004 * ivasic@gmail.com * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, * 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0014 * GNU General Public License for more details. * 0015 * * 0016 * You should have received a copy of the GNU General Public License * 0017 * along with this program; if not, write to the * 0018 * Free Software Foundation, Inc., * 0019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0020 ***************************************************************************/ 0021 #ifndef KTTORRENTFILEMODEL_HH 0022 #define KTTORRENTFILEMODEL_HH 0023 0024 #include <QAbstractItemModel> 0025 #include <QByteArray> 0026 0027 #include <util/constants.h> 0028 0029 class QTreeView; 0030 class QSortFilterProxyModel; 0031 0032 namespace bt 0033 { 0034 class TorrentInterface; 0035 class TorrentFileInterface; 0036 } 0037 0038 namespace kt 0039 { 0040 class TorrentFileModel : public QAbstractItemModel 0041 { 0042 Q_OBJECT 0043 public: 0044 enum DeselectMode { KEEP_FILES, DELETE_FILES }; 0045 TorrentFileModel(bt::TorrentInterface *tc, DeselectMode mode, QObject *parent); 0046 ~TorrentFileModel() override; 0047 0048 /** 0049 * Check all the files in the torrent. 0050 */ 0051 virtual void checkAll() = 0; 0052 0053 /** 0054 * Uncheck all files in the torrent. 0055 */ 0056 virtual void uncheckAll() = 0; 0057 0058 /** 0059 * Invert the check of each file of the torrent 0060 */ 0061 virtual void invertCheck() = 0; 0062 0063 /** 0064 * Calculate the number of bytes to download 0065 * @return Bytes to download 0066 */ 0067 virtual bt::Uint64 bytesToDownload() = 0; 0068 0069 /** 0070 * Save which items are expanded. 0071 * @param pm Proxy model of the view 0072 * @param tv The QTreeView 0073 * @return The expanded state encoded in a byte array 0074 */ 0075 virtual QByteArray saveExpandedState(QSortFilterProxyModel *pm, QTreeView *tv); 0076 0077 /** 0078 * Restore the expanded state of the tree.in a QTreeView 0079 * @param pm Proxy model of the view 0080 * @param tv The QTreeView 0081 * @param state The encoded expanded state 0082 */ 0083 virtual void loadExpandedState(QSortFilterProxyModel *pm, QTreeView *tv, const QByteArray &state); 0084 0085 /** 0086 * Convert a model index to a file. 0087 * @param idx The model index 0088 * @return The file index or 0 for a directory 0089 **/ 0090 virtual bt::TorrentFileInterface *indexToFile(const QModelIndex &idx) = 0; 0091 0092 /** 0093 * Get the path of a directory (root directory not included) 0094 * @param idx The model index 0095 * @return The path 0096 */ 0097 virtual QString dirPath(const QModelIndex &idx) = 0; 0098 0099 /** 0100 * Change the priority of a bunch of items. 0101 * @param indexes The list of items 0102 * @param newpriority The new priority 0103 */ 0104 virtual void changePriority(const QModelIndexList &indexes, bt::Priority newpriority) = 0; 0105 0106 /** 0107 * Missing files have been marked DND, update the preview and selection information. 0108 */ 0109 virtual void missingFilesMarkedDND(); 0110 0111 /** 0112 * Update gui if necessary 0113 */ 0114 virtual void update(); 0115 0116 /** 0117 * Codec has changed, so update the model. 0118 */ 0119 virtual void onCodecChange(); 0120 0121 /// Set the file names editable 0122 void setFileNamesEditable(bool on) 0123 { 0124 file_names_editable = on; 0125 } 0126 0127 /// Are the file names editable 0128 bool fileNamesEditable() const 0129 { 0130 return file_names_editable; 0131 } 0132 0133 Qt::ItemFlags flags(const QModelIndex &index) const override; 0134 0135 virtual void filePercentageChanged(bt::TorrentFileInterface *file, float percentage); 0136 virtual void filePreviewChanged(bt::TorrentFileInterface *file, bool preview); 0137 Q_SIGNALS: 0138 /** 0139 * Emitted whenever one or more items changes check state 0140 */ 0141 void checkStateChanged(); 0142 0143 protected: 0144 bt::TorrentInterface *tc; 0145 DeselectMode mode; 0146 bool file_names_editable; 0147 }; 0148 } 0149 0150 #endif