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 KTTORRENTFILETREEMODEL_H
24 #define KTTORRENTFILETREEMODEL_H
26 #include "torrentfilemodel.h"
38 * Model for displaying file trees of a torrent
39 * @author Joris Guisson
41 class TorrentFileTreeModel
: public TorrentFileModel
45 TorrentFileTreeModel(bt::TorrentInterface
* tc
,DeselectMode mode
,QObject
* parent
);
46 virtual ~TorrentFileTreeModel();
48 virtual int rowCount(const QModelIndex
& parent
) const;
49 virtual int columnCount(const QModelIndex
& parent
) const;
50 virtual QVariant
headerData(int section
, Qt::Orientation orientation
,int role
) const;
51 virtual QVariant
data(const QModelIndex
& index
, int role
) const;
52 virtual QModelIndex
parent(const QModelIndex
& index
) const;
53 virtual QModelIndex
index(int row
,int column
,const QModelIndex
& parent
) const;
54 virtual Qt::ItemFlags
flags(const QModelIndex
& index
) const;
55 virtual bool setData(const QModelIndex
& index
, const QVariant
& value
, int role
);
56 virtual void checkAll();
57 virtual void uncheckAll();
58 virtual void invertCheck();
59 virtual bt::Uint64
bytesToDownload();
60 virtual QByteArray
saveExpandedState(QTreeView
* tv
);
61 virtual void loadExpandedState(QTreeView
* tv
,const QByteArray
& state
);
62 virtual bt::TorrentFileInterface
* indexToFile(const QModelIndex
& idx
);
63 virtual QString
dirPath(const QModelIndex
& idx
);
64 virtual void changePriority(const QModelIndexList
& indexes
,bt::Priority newpriority
);
67 void invertCheck(const QModelIndex
& idx
);
73 bt::TorrentFileInterface
* file
; // file (0 if this is a directory)
74 QString name
; // name or directory
75 QList
<Node
*> children
; // child dirs
78 Node(Node
* parent
,bt::TorrentFileInterface
* file
,const QString
& name
);
79 Node(Node
* parent
,const QString
& name
);
82 void insert(const QString
& path
,bt::TorrentFileInterface
* file
);
84 bt::Uint64
fileSize(const bt::TorrentInterface
* tc
);
85 bt::Uint64
bytesToDownload(const bt::TorrentInterface
* tc
);
86 Qt::CheckState
checkState(const bt::TorrentInterface
* tc
) const;
88 void saveExpandedState(const QModelIndex
& index
,QTreeView
* tv
,bt::BEncoder
* enc
);
89 void loadExpandedState(const QModelIndex
& index
,QTreeView
* tv
,bt::BNode
* node
);
93 bool emit_check_state_change
;