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 *
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. *
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. *
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
27 #include <QAbstractItemModel>
28 #include <util/constants.h>
34 class TorrentInterface
;
35 class TorrentFileInterface
;
40 class TorrentFileModel
: public QAbstractItemModel
46 KEEP_FILES
,DELETE_FILES
48 TorrentFileModel(bt::TorrentInterface
* tc
,DeselectMode mode
,QObject
* parent
);
49 virtual ~TorrentFileModel();
53 * Check all the files in the torrent.
55 virtual void checkAll() = 0;
58 * Uncheck all files in the torrent.
60 virtual void uncheckAll() = 0;
63 * Invert the check of each file of the torrent
65 virtual void invertCheck() = 0;
68 * Calculate the number of bytes to download
69 * @return Bytes to download
71 virtual bt::Uint64
bytesToDownload() = 0;
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
);
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
);
88 * Convert a model index to a file.
89 * @param idx The model index
90 * @return The file index or 0 for a directory
92 virtual bt::TorrentFileInterface
* indexToFile(const QModelIndex
& idx
) = 0;
95 * Get the path of a directory (root directory not included)
96 * @param idx The model index
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();
119 * Emitted whenever one or more items changes check state
121 void checkStateChanged();
124 bt::TorrentInterface
* tc
;