File indexing completed on 2024-05-05 04:59:13

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 KTIWFILETREEMODEL_H
0022 #define KTIWFILETREEMODEL_H
0023 
0024 #include "torrentfiletreemodel.h"
0025 
0026 namespace kt
0027 {
0028 
0029 /**
0030  *
0031  * @author Joris Guisson
0032  *
0033  * Expands the standard TorrentFileTreeModel to show more information.
0034  */
0035 class IWFileTreeModel : public TorrentFileTreeModel
0036 {
0037     Q_OBJECT
0038 public:
0039     IWFileTreeModel(bt::TorrentInterface *tc, QObject *parent);
0040     ~IWFileTreeModel() override;
0041 
0042     int columnCount(const QModelIndex &parent) const override;
0043     QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0044     QVariant data(const QModelIndex &index, int role) const override;
0045     bool setData(const QModelIndex &index, const QVariant &value, int role) override;
0046     void update() override;
0047 
0048     void filePercentageChanged(bt::TorrentFileInterface *file, float percentage) override;
0049     void filePreviewChanged(bt::TorrentFileInterface *file, bool preview) override;
0050 
0051 private:
0052     void update(const QModelIndex &index, bt::TorrentFileInterface *file, int col);
0053     QVariant displayData(Node *n, const QModelIndex &index) const;
0054     QVariant sortData(Node *n, const QModelIndex &index) const;
0055 
0056 private:
0057     bool preview;
0058     bool mmfile;
0059     double percentage;
0060 };
0061 }
0062 
0063 #endif