File indexing completed on 2024-05-12 04:59:20

0001 /***************************************************************************
0002  *   Copyright (C) 2007 by Joris Guisson                                   *
0003  *   joris.guisson@gmail.com                                               *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
0019  ***************************************************************************/
0020 #ifndef KT_CHUNKDOWNLOADVIEW_HH
0021 #define KT_CHUNKDOWNLOADVIEW_HH
0022 
0023 #include <KSharedConfig>
0024 #include <QTreeWidget>
0025 
0026 #include "ui_chunkdownloadview.h"
0027 #include <interfaces/chunkdownloadinterface.h>
0028 
0029 namespace bt
0030 {
0031 class TorrentInterface;
0032 }
0033 
0034 namespace kt
0035 {
0036 class ChunkDownloadModel;
0037 
0038 /**
0039  * View which shows a list of downloading chunks, of a torrent.
0040  * */
0041 class ChunkDownloadView : public QWidget, public Ui_ChunkDownloadView
0042 {
0043     Q_OBJECT
0044 public:
0045     ChunkDownloadView(QWidget *parent);
0046     ~ChunkDownloadView() override;
0047 
0048     /// A peer has been added
0049     void downloadAdded(bt::ChunkDownloadInterface *cd);
0050 
0051     /// A download has been removed
0052     void downloadRemoved(bt::ChunkDownloadInterface *cd);
0053 
0054     /// Check to see if the GUI needs to be updated
0055     void update();
0056 
0057     /// Change the torrent to display
0058     void changeTC(bt::TorrentInterface *tc);
0059 
0060     /// Remove all items
0061     void removeAll();
0062 
0063     void saveState(KSharedConfigPtr cfg);
0064     void loadState(KSharedConfigPtr cfg);
0065 
0066 private:
0067     bt::TorrentInterface *curr_tc;
0068     ChunkDownloadModel *model;
0069 };
0070 }
0071 
0072 #endif