• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kget

  • sources
  • kde-4.12
  • kdenetwork
  • kget
  • transfer-plugins
  • bittorrent
  • advanceddetails
torrentfiletreemodel.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2007 by Joris Guisson and Ivan Vasic *
3  * joris.guisson@gmail.com *
4  * ivasic@gmail.com *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation; either version 2 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this program; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20  ***************************************************************************/
21 #include "torrentfiletreemodel.h"
22 
23 #include <klocale.h>
24 #include <kicon.h>
25 #include <kmimetype.h>
26 #include <QTreeView>
27 #include <QSortFilterProxyModel>
28 #include <bcodec/bdecoder.h>
29 #include <bcodec/bencoder.h>
30 #include <bcodec/bnode.h>
31 #include <interfaces/torrentinterface.h>
32 #include <interfaces/torrentfileinterface.h>
33 #include <util/functions.h>
34 #include <util/log.h>
35 
36 using namespace bt;
37 
38 namespace kt
39 {
40 
41  TorrentFileTreeModel::Node::Node(Node* parent,bt::TorrentFileInterface* file,
42  const QString & name, const bt::Uint32 total_chunks)
43  : parent(parent),file(file),name(name),size(0),chunks(total_chunks),chunks_set(false),percentage(0.0f)
44  {
45  chunks.setAll(false);
46  }
47 
48  TorrentFileTreeModel::Node::Node(Node* parent,const QString & name, const bt::Uint32 total_chunks)
49  : parent(parent),file(0),name(name),size(0),chunks(total_chunks),chunks_set(false),percentage(0.0f)
50  {
51  chunks.setAll(false);
52  }
53 
54  TorrentFileTreeModel::Node::~Node()
55  {
56  qDeleteAll(children);
57  }
58 
59  void TorrentFileTreeModel::Node::insert(const QString & path,bt::TorrentFileInterface* file,bt::Uint32 num_chunks)
60  {
61  int p = path.indexOf(bt::DirSeparator());
62  if (p == -1)
63  {
64  // the file is part of this directory
65  children.append(new Node(this,file,path,num_chunks));
66  }
67  else
68  {
69  QString subdir = path.left(p);
70  foreach (Node* n,children)
71  {
72  if (n->name == subdir)
73  {
74  n->insert(path.mid(p+1),file, num_chunks);
75  return;
76  }
77  }
78 
79  Node* n = new Node(this,subdir,num_chunks);
80  children.append(n);
81  n->insert(path.mid(p+1),file, num_chunks);
82  }
83  }
84 
85  int TorrentFileTreeModel::Node::row()
86  {
87  if (parent)
88  return parent->children.indexOf(this);
89  else
90  return 0;
91  }
92 
93  bt::Uint64 TorrentFileTreeModel::Node::fileSize(const bt::TorrentInterface* tc)
94  {
95  if (size > 0)
96  return size;
97 
98  if (!file)
99  {
100  // directory
101  foreach (Node* n,children)
102  size += n->fileSize(tc);
103  }
104  else
105  {
106  size = file->getSize();
107  }
108  return size;
109  }
110 
111  void TorrentFileTreeModel::Node::fillChunks()
112  {
113  if (chunks_set)
114  return;
115 
116  if (!file)
117  {
118  foreach(Node* n, children)
119  {
120  n->fillChunks();
121  chunks.orBitSet(n->chunks);
122  }
123  }
124  else
125  {
126  for (Uint32 i = file->getFirstChunk(); i <= file->getLastChunk(); ++i)
127  chunks.set(i, true);
128  }
129  chunks_set = true;
130  }
131 
132  void TorrentFileTreeModel::Node::updatePercentage(const BitSet & havechunks)
133  {
134  if (!chunks_set)
135  fillChunks(); // make sure we know the chunks which are part of this node
136 
137  if (file)
138  {
139  percentage = file->getDownloadPercentage();
140  }
141  else
142  {
143  if (havechunks.numOnBits() == 0 || chunks.numOnBits() == 0)
144  {
145  percentage = 0.0f;
146  }
147  else if (havechunks.allOn())
148  {
149  percentage = 100.0f;
150  }
151  else
152  {
153  // take the chunks of the node and
154  // logical and them with the chunks we have
155  BitSet tmp(chunks);
156  tmp.andBitSet(havechunks);
157 
158  percentage = 100.0f * ((float)tmp.numOnBits() / (float)chunks.numOnBits());
159  }
160  }
161 
162  if (parent)
163  parent->updatePercentage(havechunks); // update the percentage of the parent
164  }
165 
166  void TorrentFileTreeModel::Node::initPercentage(const bt::TorrentInterface* tc,const bt::BitSet & havechunks)
167  {
168  if (!chunks_set)
169  fillChunks();
170 
171  if (!tc->getStats().multi_file_torrent)
172  {
173  percentage = bt::Percentage(tc->getStats());
174  return;
175  }
176 
177  if (file)
178  {
179  percentage = file->getDownloadPercentage();
180  }
181  else
182  {
183  if (havechunks.numOnBits() == 0 || chunks.numOnBits() == 0)
184  {
185  percentage = 0.0f;
186  }
187  else if (havechunks.allOn())
188  {
189  percentage = 100.0f;
190  }
191  else
192  {
193  // take the chunks of the node and
194  // logical and them with the chunks we have
195  BitSet tmp(chunks);
196  tmp.andBitSet(havechunks);
197 
198  percentage = 100.0f * ((float)tmp.numOnBits() / (float)chunks.numOnBits());
199  }
200 
201  foreach (Node* n,children)
202  n->initPercentage(tc,havechunks); // update the percentage of the children
203  }
204  }
205 
206  bt::Uint64 TorrentFileTreeModel::Node::bytesToDownload(const bt::TorrentInterface* tc)
207  {
208  bt::Uint64 s = 0;
209 
210  if (!file)
211  {
212  // directory
213  foreach (Node* n,children)
214  s += n->bytesToDownload(tc);
215  }
216  else
217  {
218  if (!file->doNotDownload())
219  s = file->getSize();
220  }
221  return s;
222  }
223 
224  Qt::CheckState TorrentFileTreeModel::Node::checkState(const bt::TorrentInterface* tc) const
225  {
226  if (!file)
227  {
228  bool found_checked = false;
229  bool found_unchecked = false;
230  // directory
231  foreach (Node* n,children)
232  {
233  Qt::CheckState s = n->checkState(tc);
234  if (s == Qt::PartiallyChecked)
235  return s;
236  else if (s == Qt::Checked)
237  found_checked = true;
238  else
239  found_unchecked = true;
240 
241  if (found_checked && found_unchecked)
242  return Qt::PartiallyChecked;
243  }
244 
245  return found_checked ? Qt::Checked : Qt::Unchecked;
246  }
247  else
248  {
249  return file->doNotDownload() || file->getPriority() == ONLY_SEED_PRIORITY ? Qt::Unchecked : Qt::Checked;
250  }
251  }
252 
253  void TorrentFileTreeModel::Node::saveExpandedState(const QModelIndex & index,QSortFilterProxyModel* pm,QTreeView* tv,BEncoder* enc)
254  {
255  if (file)
256  return;
257 
258  enc->write("expanded");
259  enc->write((Uint32)(tv->isExpanded(pm->mapFromSource(index)) ? 1 : 0));
260 
261  int idx = 0;
262  foreach (Node* n,children)
263  {
264  if (!n->file)
265  {
266  enc->write(n->name);
267  enc->beginDict();
268  n->saveExpandedState(index.child(idx,0),pm,tv,enc);
269  enc->end();
270  }
271  ++idx;
272  }
273  }
274 
275  void TorrentFileTreeModel::Node::loadExpandedState(const QModelIndex & index,QSortFilterProxyModel* pm,QTreeView* tv,BNode* n)
276  {
277  if (file)
278  return;
279 
280  BDictNode* dict = dynamic_cast<BDictNode*>(n);
281  if (!dict)
282  return;
283 
284  BValueNode* v = dict->getValue("expanded");
285  if (v)
286  tv->setExpanded(pm->mapFromSource(index),v->data().toInt() == 1);
287 
288  int idx = 0;
289  foreach (Node* n,children)
290  {
291  if (!n->file)
292  {
293  BDictNode* d = dict->getDict(n->name);
294  if (d)
295  n->loadExpandedState(index.child(idx,0),pm,tv,d);
296  }
297  idx++;
298  }
299  }
300 
301  QString TorrentFileTreeModel::Node::path()
302  {
303  if (!parent)
304  return QString(); // the root node must not be included in the path
305 
306  if (file)
307  return name;
308  else
309  return parent->path() + name + bt::DirSeparator();
310  }
311 
312  TorrentFileTreeModel::TorrentFileTreeModel(bt::TorrentInterface* tc,DeselectMode mode,QObject* parent)
313  : TorrentFileModel(tc,mode,parent),root(0),emit_check_state_change(true)
314  {
315  if (tc->getStats().multi_file_torrent)
316  constructTree();
317  else
318  root = new Node(0,tc->getStats().torrent_name,tc->getStats().total_chunks);
319  }
320 
321 
322  TorrentFileTreeModel::~TorrentFileTreeModel()
323  {
324  delete root;
325  }
326 
327  void TorrentFileTreeModel::constructTree()
328  {
329  bt::Uint32 num_chunks = tc->getStats().total_chunks;
330  if (!root)
331  root = new Node(0,tc->getUserModifiedFileName(),num_chunks);
332 
333  for (Uint32 i = 0;i < tc->getNumFiles();++i)
334  {
335  bt::TorrentFileInterface & tf = tc->getTorrentFile(i);
336  root->insert(tf.getUserModifiedPath(),&tf,num_chunks);
337  }
338  }
339 
340  void TorrentFileTreeModel::onCodecChange()
341  {
342  delete root;
343  root = 0;
344  constructTree();
345  reset();
346  }
347 
348  int TorrentFileTreeModel::rowCount(const QModelIndex & parent) const
349  {
350  if (!parent.isValid())
351  {
352  return 1;
353  }
354  else
355  {
356  Node* n = (Node*)parent.internalPointer();
357  return n->children.count();
358  }
359  }
360 
361  int TorrentFileTreeModel::columnCount(const QModelIndex & parent) const
362  {
363  if (!parent.isValid())
364  return 2;
365  else
366  return 2;
367  }
368 
369  QVariant TorrentFileTreeModel::headerData(int section, Qt::Orientation orientation,int role) const
370  {
371  if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
372  return QVariant();
373 
374  switch (section)
375  {
376  case 0: return i18n("File");
377  case 1: return i18n("Size");
378  default:
379  return QVariant();
380  }
381  }
382 
383  QVariant TorrentFileTreeModel::data(const QModelIndex & index, int role) const
384  {
385  if (!index.isValid())
386  return QVariant();
387 
388  Node* n = (Node*)index.internalPointer();
389  if (!n)
390  return QVariant();
391 
392  if (role == Qt::DisplayRole || role == Qt::EditRole)
393  {
394  switch (index.column())
395  {
396  case 0: return n->name;
397  case 1:
398  if (tc->getStats().multi_file_torrent)
399  return BytesToString(n->fileSize(tc));
400  else
401  return BytesToString(tc->getStats().total_bytes);
402  default: return QVariant();
403  }
404  }
405  else if (role == Qt::UserRole) // sorting
406  {
407  switch (index.column())
408  {
409  case 0: return n->name;
410  case 1:
411  if (tc->getStats().multi_file_torrent)
412  return n->fileSize(tc);
413  else
414  return tc->getStats().total_bytes;
415  default: return QVariant();
416  }
417  }
418  else if (role == Qt::DecorationRole && index.column() == 0)
419  {
420  // if this is an empty folder then we are in the single file case
421  if (!n->file)
422  return n->children.count() > 0 ?
423  KIcon("folder") : KIcon(KMimeType::findByPath(tc->getStats().torrent_name)->iconName());
424  else
425  return KIcon(KMimeType::findByPath(n->file->getPath())->iconName());
426  }
427  else if (role == Qt::CheckStateRole && index.column() == 0)
428  {
429  if (tc->getStats().multi_file_torrent)
430  return n->checkState(tc);
431  }
432 
433  return QVariant();
434  }
435 
436  QModelIndex TorrentFileTreeModel::parent(const QModelIndex & index) const
437  {
438  if (!index.isValid())
439  return QModelIndex();
440 
441  Node* child = static_cast<Node*>(index.internalPointer());
442  if (!child)
443  return QModelIndex();
444 
445  Node* parent = child->parent;
446  if (!parent)
447  return QModelIndex();
448  else
449  return createIndex(parent->row(), 0, parent);
450  }
451 
452  QModelIndex TorrentFileTreeModel::index(int row,int column,const QModelIndex & parent) const
453  {
454  if (!hasIndex(row, column, parent))
455  return QModelIndex();
456 
457  Node* p = 0;
458 
459  if (!parent.isValid())
460  return createIndex(row,column,root);
461  else
462  {
463  p = static_cast<Node*>(parent.internalPointer());
464 
465  if (row >= 0 && row < p->children.count())
466  return createIndex(row,column,p->children.at(row));
467  else
468  return QModelIndex();
469  }
470  }
471 
472  bool TorrentFileTreeModel::setCheckState(const QModelIndex & index, Qt::CheckState state)
473  {
474  Node* n = static_cast<Node*>(index.internalPointer());
475  if (!n)
476  return false;
477 
478  if (!n->file)
479  {
480  bool reenable = false;
481  if (emit_check_state_change)
482  {
483  reenable = true;
484  emit_check_state_change = false;
485  }
486 
487  for (int i = 0;i < n->children.count();i++)
488  {
489  // recurse down the tree
490  setCheckState(index.child(i,0),state);
491  }
492 
493  if (reenable)
494  emit_check_state_change = true;
495  }
496  else
497  {
498  bt::TorrentFileInterface* file = n->file;
499  if (state == Qt::Checked)
500  {
501  if (file->getPriority() == ONLY_SEED_PRIORITY)
502  file->setPriority(NORMAL_PRIORITY);
503  else
504  file->setDoNotDownload(false);
505  }
506  else
507  {
508  if (mode == KEEP_FILES)
509  file->setPriority(ONLY_SEED_PRIORITY);
510  else
511  file->setDoNotDownload(true);
512  }
513  dataChanged(createIndex(index.row(),0),createIndex(index.row(),columnCount(index) - 1));
514 
515  QModelIndex parent = index.parent();
516  if (parent.isValid())
517  dataChanged(parent,parent); // parent needs to be updated to
518  }
519 
520  if (emit_check_state_change)
521  checkStateChanged();
522  return true;
523  }
524 
525  void TorrentFileTreeModel::modifyPathOfFiles(Node* n,const QString & path)
526  {
527  for (int i = 0;i < n->children.count();i++)
528  {
529  Node* c = n->children.at(i);
530  if (!c->file) // another directory, continue recursively
531  modifyPathOfFiles(c, path + c->name + bt::DirSeparator());
532  else
533  c->file->setUserModifiedPath(path + c->name);
534  }
535  }
536 
537  bool TorrentFileTreeModel::setName(const QModelIndex & index,const QString & name)
538  {
539  Node* n = static_cast<Node*>(index.internalPointer());
540  if (!n || name.isEmpty() || name.contains(bt::DirSeparator()))
541  return false;
542 
543  if (!tc->getStats().multi_file_torrent)
544  {
545  // single file case so we only need to change the user modified name
546  tc->setUserModifiedFileName(name);
547  n->name = name;
548  dataChanged(index,index);
549  return true;
550  }
551 
552  if (!n->file)
553  {
554  // we are in a directory
555  n->name = name;
556  if (!n->parent)
557  {
558  // toplevel directory name has changed
559  tc->setUserModifiedFileName(name);
560  }
561 
562  dataChanged(index,index);
563  // modify the path of all files
564  modifyPathOfFiles(n,n->path());
565  return true;
566  }
567  else
568  {
569  n->name = name;
570  n->file->setUserModifiedPath(n->path());
571  dataChanged(index,index);
572  return true;
573  }
574  }
575 
576  bool TorrentFileTreeModel::setData(const QModelIndex & index, const QVariant & value, int role)
577  {
578  if (!index.isValid())
579  return false;
580 
581  if (role == Qt::CheckStateRole)
582  return setCheckState(index, static_cast<Qt::CheckState>(value.toInt()));
583  else if (role == Qt::EditRole)
584  return setName(index,value.toString());
585 
586  return false;
587  }
588 
589  void TorrentFileTreeModel::checkAll()
590  {
591  if (tc->getStats().multi_file_torrent)
592  setData(index(0,0,QModelIndex()),Qt::Checked,Qt::CheckStateRole);
593  }
594 
595  void TorrentFileTreeModel::uncheckAll()
596  {
597  if (tc->getStats().multi_file_torrent)
598  setData(index(0,0,QModelIndex()),Qt::Unchecked,Qt::CheckStateRole);
599  }
600 
601  void TorrentFileTreeModel::invertCheck()
602  {
603  if (!tc->getStats().multi_file_torrent)
604  return;
605 
606  invertCheck(index(0,0,QModelIndex()));
607  }
608 
609  void TorrentFileTreeModel::invertCheck(const QModelIndex & idx)
610  {
611  Node* n = static_cast<Node*>(idx.internalPointer());
612  if (!n)
613  return;
614 
615  if (!n->file)
616  {
617  for (int i = 0;i < n->children.count();i++)
618  {
619  // recurse down the tree
620  invertCheck(idx.child(i,0));
621  }
622  }
623  else
624  {
625  if (n->file->doNotDownload())
626  setData(idx,Qt::Checked,Qt::CheckStateRole);
627  else
628  setData(idx,Qt::Unchecked,Qt::CheckStateRole);
629  }
630  }
631 
632  bt::Uint64 TorrentFileTreeModel::bytesToDownload()
633  {
634  if (tc->getStats().multi_file_torrent)
635  return root->bytesToDownload(tc);
636  else
637  return tc->getStats().total_bytes;
638  }
639 
640  QByteArray TorrentFileTreeModel::saveExpandedState(QSortFilterProxyModel* pm,QTreeView* tv)
641  {
642  if (!tc->getStats().multi_file_torrent)
643  return QByteArray();
644 
645  QByteArray data;
646  BEncoder enc(new BEncoderBufferOutput(data));
647  enc.beginDict();
648  root->saveExpandedState(index(0,0,QModelIndex()),pm,tv,&enc);
649  enc.end();
650  return data;
651  }
652 
653 
654  void TorrentFileTreeModel::loadExpandedState(QSortFilterProxyModel* pm,QTreeView* tv,const QByteArray & state)
655  {
656  if (!tc->getStats().multi_file_torrent)
657  return;
658 
659  BDecoder dec(state,false,0);
660  BNode* n = dec.decode();
661  if (n && n->getType() == BNode::DICT)
662  {
663  root->loadExpandedState(index(0,0,QModelIndex()),pm,tv,n);
664  }
665  delete n;
666  }
667 
668  bt::TorrentFileInterface* TorrentFileTreeModel::indexToFile(const QModelIndex & idx)
669  {
670  if (!idx.isValid())
671  return 0;
672 
673  Node* n = (Node*)idx.internalPointer();
674  if (!n)
675  return 0;
676 
677  return n->file;
678  }
679 
680  QString TorrentFileTreeModel::dirPath(const QModelIndex & idx)
681  {
682  if (!idx.isValid())
683  return QString();
684 
685  Node* n = (Node*)idx.internalPointer();
686  if (!n || n == root)
687  return QString();
688 
689  QString ret = n->name;
690  do
691  {
692  n = n->parent;
693  if (n && n->parent)
694  ret = n->name + bt::DirSeparator() + ret;
695  }while (n);
696 
697  return ret;
698  }
699 
700  void TorrentFileTreeModel::changePriority(const QModelIndexList & indexes,bt::Priority newpriority)
701  {
702  foreach (const QModelIndex &idx,indexes)
703  {
704  Node* n = (Node*)idx.internalPointer();
705  if (!n)
706  continue;
707 
708  setData(idx,newpriority,Qt::UserRole);
709  }
710  }
711 }
712 
713 #include "torrentfiletreemodel.moc"
kt::TorrentFileTreeModel::Node::path
QString path()
Definition: torrentfiletreemodel.cpp:301
kt::TorrentFileTreeModel::saveExpandedState
virtual QByteArray saveExpandedState(QSortFilterProxyModel *pm, QTreeView *tv)
Save which items are expanded.
Definition: torrentfiletreemodel.cpp:640
kt::TorrentFileModel::mode
DeselectMode mode
Definition: torrentfilemodel.h:142
kt::TorrentFileTreeModel::columnCount
virtual int columnCount(const QModelIndex &parent) const
Definition: torrentfiletreemodel.cpp:361
kt::TorrentFileTreeModel::loadExpandedState
virtual void loadExpandedState(QSortFilterProxyModel *pm, QTreeView *tv, const QByteArray &state)
Retore the expanded state of the tree.in a QTreeView.
Definition: torrentfiletreemodel.cpp:654
kt::TorrentFileTreeModel::changePriority
virtual void changePriority(const QModelIndexList &indexes, bt::Priority newpriority)
Change the priority of a bunch of items.
Definition: torrentfiletreemodel.cpp:700
kt::TorrentFileModel::tc
bt::TorrentInterface * tc
Definition: torrentfilemodel.h:141
kt::TorrentFileTreeModel::Node::~Node
~Node()
Definition: torrentfiletreemodel.cpp:54
kt::TorrentFileTreeModel::headerData
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const
Definition: torrentfiletreemodel.cpp:369
kt::TorrentFileTreeModel::dirPath
virtual QString dirPath(const QModelIndex &idx)
Get the path of a directory (root directory not included)
Definition: torrentfiletreemodel.cpp:680
kt::TorrentFileTreeModel::uncheckAll
virtual void uncheckAll()
Uncheck all files in the torrent.
Definition: torrentfiletreemodel.cpp:595
kt::TorrentFileTreeModel::Node::insert
void insert(const QString &path, bt::TorrentFileInterface *file, bt::Uint32 num_chunks)
Definition: torrentfiletreemodel.cpp:59
kt::TorrentFileTreeModel::~TorrentFileTreeModel
virtual ~TorrentFileTreeModel()
Definition: torrentfiletreemodel.cpp:322
QObject
kt::TorrentFileTreeModel::Node::name
QString name
Definition: torrentfiletreemodel.h:50
kt::TorrentFileTreeModel::onCodecChange
virtual void onCodecChange()
Codec has changed, so update the model.
Definition: torrentfiletreemodel.cpp:340
kt::TorrentFileTreeModel::parent
virtual QModelIndex parent(const QModelIndex &index) const
Definition: torrentfiletreemodel.cpp:436
kt::TorrentFileTreeModel::setData
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
Definition: torrentfiletreemodel.cpp:576
kt::TorrentFileTreeModel::Node::initPercentage
void initPercentage(const bt::TorrentInterface *tc, const bt::BitSet &havechunks)
Definition: torrentfiletreemodel.cpp:166
kt::TorrentFileTreeModel::bytesToDownload
virtual bt::Uint64 bytesToDownload()
Calculate the number of bytes to download.
Definition: torrentfiletreemodel.cpp:632
kt::TorrentFileTreeModel::Node::loadExpandedState
void loadExpandedState(const QModelIndex &index, QSortFilterProxyModel *pm, QTreeView *tv, bt::BNode *node)
Definition: torrentfiletreemodel.cpp:275
QTreeView
kt::TorrentFileModel::KEEP_FILES
Definition: torrentfilemodel.h:45
kt::TorrentFileTreeModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
Definition: torrentfiletreemodel.cpp:452
kt::TorrentFileTreeModel::Node
Definition: torrentfiletreemodel.h:46
kt::TorrentFileTreeModel::Node::fillChunks
void fillChunks()
Definition: torrentfiletreemodel.cpp:111
kt::TorrentFileTreeModel::checkAll
virtual void checkAll()
Check all the files in the torrent.
Definition: torrentfiletreemodel.cpp:589
kt::TorrentFileTreeModel::TorrentFileTreeModel
TorrentFileTreeModel(bt::TorrentInterface *tc, DeselectMode mode, QObject *parent)
Definition: torrentfiletreemodel.cpp:312
kt::TorrentFileTreeModel::Node::chunks
bt::BitSet chunks
Definition: torrentfiletreemodel.h:53
kt::TorrentFileTreeModel::Node::file
bt::TorrentFileInterface * file
Definition: torrentfiletreemodel.h:49
kt::TorrentFileModel::DeselectMode
DeselectMode
Definition: torrentfilemodel.h:43
kt::TorrentFileTreeModel::Node::parent
Node * parent
Definition: torrentfiletreemodel.h:48
kt::TorrentFileTreeModel::root
Node * root
Definition: torrentfiletreemodel.h:105
kt::TorrentFileTreeModel::invertCheck
virtual void invertCheck()
Invert the check of each file of the torrent.
Definition: torrentfiletreemodel.cpp:601
QSortFilterProxyModel
kt::TorrentFileTreeModel::Node::saveExpandedState
void saveExpandedState(const QModelIndex &index, QSortFilterProxyModel *pm, QTreeView *tv, bt::BEncoder *enc)
Definition: torrentfiletreemodel.cpp:253
kt::TorrentFileTreeModel::rowCount
virtual int rowCount(const QModelIndex &parent) const
Definition: torrentfiletreemodel.cpp:348
kt::TorrentFileTreeModel::Node::children
QList< Node * > children
Definition: torrentfiletreemodel.h:51
kt::TorrentFileTreeModel::Node::row
int row()
Definition: torrentfiletreemodel.cpp:85
kt::TorrentFileModel::checkStateChanged
void checkStateChanged()
Emitted whenever one or more items changes check state.
kt::TorrentFileTreeModel::Node::checkState
Qt::CheckState checkState(const bt::TorrentInterface *tc) const
Definition: torrentfiletreemodel.cpp:224
kt::TorrentFileTreeModel::Node::Node
Node(Node *parent, bt::TorrentFileInterface *file, const QString &name, bt::Uint32 total_chunks)
Definition: torrentfiletreemodel.cpp:41
torrentfiletreemodel.h
kt::TorrentFileTreeModel::indexToFile
virtual bt::TorrentFileInterface * indexToFile(const QModelIndex &idx)
Convert a model index to a file.
Definition: torrentfiletreemodel.cpp:668
kt::TorrentFileTreeModel::Node::bytesToDownload
bt::Uint64 bytesToDownload(const bt::TorrentInterface *tc)
Definition: torrentfiletreemodel.cpp:206
kt::TorrentFileTreeModel::emit_check_state_change
bool emit_check_state_change
Definition: torrentfiletreemodel.h:106
kt::TorrentFileTreeModel::data
virtual QVariant data(const QModelIndex &index, int role) const
Definition: torrentfiletreemodel.cpp:383
kt::TorrentFileTreeModel::Node::fileSize
bt::Uint64 fileSize(const bt::TorrentInterface *tc)
Definition: torrentfiletreemodel.cpp:93
kt::TorrentFileModel
Definition: torrentfilemodel.h:39
kt::TorrentFileTreeModel::Node::updatePercentage
void updatePercentage(const bt::BitSet &havechunks)
Definition: torrentfiletreemodel.cpp:132
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kget

Skip menu "kget"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal