Remove incorrect assertions
[qBittorrent.git] / src / gui / transferlistwidget.h
blob88a00662b625f4d8580862d90ffa36b0b454d513
1 /*
2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * In addition, as a special exception, the copyright holders give permission to
20 * link this program with the OpenSSL project's "OpenSSL" library (or with
21 * modified versions of it that use the same license as the "OpenSSL" library),
22 * and distribute the linked executables. You must obey the GNU General Public
23 * License in all respects for all of the code used other than "OpenSSL". If you
24 * modify file(s), you may extend this exception to your version of the file(s),
25 * but you are not obligated to do so. If you do not wish to do so, delete this
26 * exception statement from your version.
29 #pragma once
31 #include <functional>
33 #include <QtContainerFwd>
34 #include <QTreeView>
36 #include "base/bittorrent/infohash.h"
37 #include "transferlistmodel.h"
39 class MainWindow;
40 class Path;
41 class TransferListSortModel;
43 namespace BitTorrent
45 class Torrent;
48 enum class CopyInfohashPolicy
50 Version1,
51 Version2
54 class TransferListWidget final : public QTreeView
56 Q_OBJECT
57 Q_DISABLE_COPY_MOVE(TransferListWidget)
59 public:
60 TransferListWidget(QWidget *parent, MainWindow *mainWindow);
61 ~TransferListWidget() override;
62 TransferListModel *getSourceModel() const;
64 public slots:
65 void setSelectionCategory(const QString &category);
66 void addSelectionTag(const QString &tag);
67 void removeSelectionTag(const QString &tag);
68 void clearSelectionTags();
69 void setSelectedTorrentsLocation();
70 void pauseAllTorrents();
71 void resumeAllTorrents();
72 void startSelectedTorrents();
73 void forceStartSelectedTorrents();
74 void startVisibleTorrents();
75 void pauseSelectedTorrents();
76 void pauseVisibleTorrents();
77 void softDeleteSelectedTorrents();
78 void permDeleteSelectedTorrents();
79 void deleteSelectedTorrents(bool deleteLocalFiles);
80 void deleteVisibleTorrents();
81 void increaseQueuePosSelectedTorrents();
82 void decreaseQueuePosSelectedTorrents();
83 void topQueuePosSelectedTorrents();
84 void bottomQueuePosSelectedTorrents();
85 void copySelectedMagnetURIs() const;
86 void copySelectedNames() const;
87 void copySelectedInfohashes(CopyInfohashPolicy policy) const;
88 void copySelectedIDs() const;
89 void copySelectedComments() const;
90 void openSelectedTorrentsFolder() const;
91 void recheckSelectedTorrents();
92 void reannounceSelectedTorrents();
93 void setTorrentOptions();
94 void previewSelectedTorrents();
95 void hideQueuePosColumn(bool hide);
96 void applyFilter(const QString &name, const TransferListModel::Column &type);
97 void applyStatusFilter(int f);
98 void applyCategoryFilter(const QString &category);
99 void applyTagFilter(const QString &tag);
100 void applyTrackerFilterAll();
101 void applyTrackerFilter(const QSet<BitTorrent::TorrentID> &torrentIDs);
102 void previewFile(const Path &filePath);
103 void renameSelectedTorrent();
105 signals:
106 void currentTorrentChanged(BitTorrent::Torrent *torrent);
108 private slots:
109 void torrentDoubleClicked();
110 void displayListMenu();
111 void displayColumnHeaderMenu();
112 void currentChanged(const QModelIndex &current, const QModelIndex&) override;
113 void setSelectedTorrentsSuperSeeding(bool enabled) const;
114 void setSelectedTorrentsSequentialDownload(bool enabled) const;
115 void setSelectedFirstLastPiecePrio(bool enabled) const;
116 void setSelectedAutoTMMEnabled(bool enabled);
117 void askNewCategoryForSelection();
118 void saveSettings();
120 private:
121 void wheelEvent(QWheelEvent *event) override;
122 QModelIndex mapToSource(const QModelIndex &index) const;
123 QModelIndexList mapToSource(const QModelIndexList &indexes) const;
124 QModelIndex mapFromSource(const QModelIndex &index) const;
125 bool loadSettings();
126 QVector<BitTorrent::Torrent *> getSelectedTorrents() const;
127 void askAddTagsForSelection();
128 void editTorrentTrackers();
129 void exportTorrent();
130 void confirmRemoveAllTagsForSelection();
131 QStringList askTagsForSelection(const QString &dialogTitle);
132 void applyToSelectedTorrents(const std::function<void (BitTorrent::Torrent *const)> &fn);
133 QVector<BitTorrent::Torrent *> getVisibleTorrents() const;
134 int visibleColumnsCount() const;
136 TransferListModel *m_listModel = nullptr;
137 TransferListSortModel *m_sortFilterModel = nullptr;
138 MainWindow *m_mainWindow = nullptr;