* fix a lot of compiler warnings
[kdenetwork.git] / kget / transfer-plugins / bittorrent / torrentfilemodel.h
blobf95c4f4f37f8c45e0cc20e27d2a45ae9bafcf3c0
1 /** IMPORTANT: please keep this file in sync with ktorrent! ****************/
3 /***************************************************************************
4 * Copyright (C) 2007 by Joris Guisson and Ivan Vasic *
5 * joris.guisson@gmail.com *
6 * ivasic@gmail.com *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
22 ***************************************************************************/
23 #ifndef KTTORRENTFILEMODEL_HH
24 #define KTTORRENTFILEMODEL_HH
26 #include <QByteArray>
27 #include <QAbstractItemModel>
28 #include <util/constants.h>
30 class QTreeView;
32 namespace bt
34 class TorrentInterface;
35 class TorrentFileInterface;
38 namespace kt
40 class TorrentFileModel : public QAbstractItemModel
42 Q_OBJECT
43 public:
44 enum DeselectMode
46 KEEP_FILES,DELETE_FILES
48 TorrentFileModel(bt::TorrentInterface* tc,DeselectMode mode,QObject* parent);
49 virtual ~TorrentFileModel();
52 /**
53 * Check all the files in the torrent.
55 virtual void checkAll() = 0;
57 /**
58 * Uncheck all files in the torrent.
60 virtual void uncheckAll() = 0;
62 /**
63 * Invert the check of each file of the torrent
65 virtual void invertCheck() = 0;
67 /**
68 * Calculate the number of bytes to download
69 * @return Bytes to download
71 virtual bt::Uint64 bytesToDownload() = 0;
73 /**
74 * Save which items are expanded.
75 * @param tv The QTreeView
76 * @return The expanded state encoded in a byte array
78 virtual QByteArray saveExpandedState(QTreeView* tv);
80 /**
81 * Retore the expanded state of the tree.in a QTreeView
82 * @param tv The QTreeView
83 * @param state The encoded expanded state
85 virtual void loadExpandedState(QTreeView* tv,const QByteArray & state);
87 /**
88 * Convert a model index to a file.
89 * @param idx The model index
90 * @return The file index or 0 for a directory
91 **/
92 virtual bt::TorrentFileInterface* indexToFile(const QModelIndex & idx) = 0;
94 /**
95 * Get the path of a directory (root directory not included)
96 * @param idx The model index
97 * @return The path
99 virtual QString dirPath(const QModelIndex & idx) = 0;
102 * Change the priority of a bunch of items.
103 * @param indexes The list of items
104 * @param newpriority The new priority
106 virtual void changePriority(const QModelIndexList & indexes,bt::Priority newpriority) = 0;
109 * Missing files have been marked DND, update the preview and selection information.
111 virtual void missingFilesMarkedDND();
114 * Update gui if necessary
116 virtual void update();
117 signals:
119 * Emitted whenever one or more items changes check state
121 void checkStateChanged();
123 protected:
124 bt::TorrentInterface* tc;
125 DeselectMode mode;
129 #endif