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

0001 /***************************************************************************
0002  *   Copyright (C) 2008 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 KTWEBSEEDSTAB_H
0022 #define KTWEBSEEDSTAB_H
0023 
0024 #include <QSortFilterProxyModel>
0025 #include <QWidget>
0026 
0027 #include <KSharedConfig>
0028 
0029 #include "ui_webseedstab.h"
0030 
0031 namespace bt
0032 {
0033 class TorrentInterface;
0034 }
0035 
0036 namespace kt
0037 {
0038 class WebSeedsModel;
0039 
0040 /**
0041     Tab which displays the list of webseeds of a torrent, and allows you to add or remove them.
0042 */
0043 class WebSeedsTab : public QWidget, public Ui_WebSeedsTab
0044 {
0045     Q_OBJECT
0046 public:
0047     WebSeedsTab(QWidget *parent);
0048     ~WebSeedsTab() override;
0049 
0050     /**
0051      * Switch to a different torrent.
0052      * @param tc The torrent
0053      */
0054     void changeTC(bt::TorrentInterface *tc);
0055 
0056     /// Check to see if the GUI needs to be updated
0057     void update();
0058 
0059     void saveState(KSharedConfigPtr cfg);
0060     void loadState(KSharedConfigPtr cfg);
0061 
0062 private Q_SLOTS:
0063     void addWebSeed();
0064     void removeWebSeed();
0065     void onWebSeedTextChanged(const QString &ws);
0066     void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
0067 
0068 private:
0069     void selectionChanged(const QModelIndexList &indexes);
0070 
0071 private:
0072     bt::TorrentInterface *curr_tc;
0073     WebSeedsModel *model;
0074     QSortFilterProxyModel *proxy_model;
0075 };
0076 }
0077 
0078 #endif