2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2023 Vladimir Golovnev <glassez@yandex.ru>
4 * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * In addition, as a special exception, the copyright holders give permission to
21 * link this program with the OpenSSL project's "OpenSSL" library (or with
22 * modified versions of it that use the same license as the "OpenSSL" library),
23 * and distribute the linked executables. You must obey the GNU General Public
24 * License in all respects for all of the code used other than "OpenSSL". If you
25 * modify file(s), you may extend this exception to your version of the file(s),
26 * but you are not obligated to do so. If you do not wish to do so, delete this
27 * exception statement from your version.
34 #include <QtContainerFwd>
37 #include "base/bittorrent/infohash.h"
38 #include "transferlistmodel.h"
42 class TransferListSortModel
;
49 enum class CopyInfohashPolicy
55 class TransferListWidget final
: public QTreeView
58 Q_DISABLE_COPY_MOVE(TransferListWidget
)
61 TransferListWidget(QWidget
*parent
, MainWindow
*mainWindow
);
62 ~TransferListWidget() override
;
63 TransferListModel
*getSourceModel() const;
66 void setSelectionCategory(const QString
&category
);
67 void addSelectionTag(const Tag
&tag
);
68 void removeSelectionTag(const Tag
&tag
);
69 void clearSelectionTags();
70 void setSelectedTorrentsLocation();
71 void stopAllTorrents();
72 void startAllTorrents();
73 void startSelectedTorrents();
74 void forceStartSelectedTorrents();
75 void startVisibleTorrents();
76 void stopSelectedTorrents();
77 void stopVisibleTorrents();
78 void softDeleteSelectedTorrents();
79 void permDeleteSelectedTorrents();
80 void deleteSelectedTorrents(bool deleteLocalFiles
);
81 void deleteVisibleTorrents();
82 void increaseQueuePosSelectedTorrents();
83 void decreaseQueuePosSelectedTorrents();
84 void topQueuePosSelectedTorrents();
85 void bottomQueuePosSelectedTorrents();
86 void copySelectedMagnetURIs() const;
87 void copySelectedNames() const;
88 void copySelectedInfohashes(CopyInfohashPolicy policy
) const;
89 void copySelectedIDs() const;
90 void copySelectedComments() const;
91 void openSelectedTorrentsFolder() const;
92 void recheckSelectedTorrents();
93 void reannounceSelectedTorrents();
94 void setTorrentOptions();
95 void previewSelectedTorrents();
96 void hideQueuePosColumn(bool hide
);
97 void applyFilter(const QString
&name
, const TransferListModel::Column
&type
);
98 void applyStatusFilter(int filterIndex
);
99 void applyCategoryFilter(const QString
&category
);
100 void applyTagFilter(const std::optional
<Tag
> &tag
);
101 void applyTrackerFilterAll();
102 void applyTrackerFilter(const QSet
<BitTorrent::TorrentID
> &torrentIDs
);
103 void previewFile(const Path
&filePath
);
104 void renameSelectedTorrent();
107 void currentTorrentChanged(BitTorrent::Torrent
*torrent
);
110 void torrentDoubleClicked();
111 void displayListMenu();
112 void displayColumnHeaderMenu();
113 void currentChanged(const QModelIndex
¤t
, const QModelIndex
&) override
;
114 void setSelectedTorrentsSuperSeeding(bool enabled
) const;
115 void setSelectedTorrentsSequentialDownload(bool enabled
) const;
116 void setSelectedFirstLastPiecePrio(bool enabled
) const;
117 void setSelectedAutoTMMEnabled(bool enabled
);
118 void askNewCategoryForSelection();
122 void wheelEvent(QWheelEvent
*event
) override
;
123 QModelIndex
mapToSource(const QModelIndex
&index
) const;
124 QModelIndexList
mapToSource(const QModelIndexList
&indexes
) const;
125 QModelIndex
mapFromSource(const QModelIndex
&index
) const;
127 QVector
<BitTorrent::Torrent
*> getSelectedTorrents() const;
128 void askAddTagsForSelection();
129 void editTorrentTrackers();
130 void exportTorrent();
131 void confirmRemoveAllTagsForSelection();
132 TagSet
askTagsForSelection(const QString
&dialogTitle
);
133 void applyToSelectedTorrents(const std::function
<void (BitTorrent::Torrent
*const)> &fn
);
134 QVector
<BitTorrent::Torrent
*> getVisibleTorrents() const;
135 int visibleColumnsCount() const;
137 TransferListModel
*m_listModel
= nullptr;
138 TransferListSortModel
*m_sortFilterModel
= nullptr;
139 MainWindow
*m_mainWindow
= nullptr;