qBittorrent
peerlistwidget.h
Go to the documentation of this file.
1 /*
2  * Bittorrent Client using Qt and libtorrent.
3  * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
4  *
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.
9  *
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.
14  *
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.
18  *
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.
27  */
28 
29 #pragma once
30 
31 #include <QHash>
32 #include <QSet>
33 #include <QTreeView>
34 
35 class QHostAddress;
36 class QStandardItem;
37 class QStandardItemModel;
38 
39 class PeerListSortModel;
40 class PropertiesWidget;
41 
42 struct PeerEndpoint;
43 
44 namespace BitTorrent
45 {
46  class Torrent;
47  class PeerInfo;
48 }
49 
50 namespace Net
51 {
52  class ReverseResolution;
53 }
54 
55 class PeerListWidget final : public QTreeView
56 {
57  Q_OBJECT
58 
59 public:
61  {
63  IP,
76 
77  COL_COUNT
78  };
79 
80  explicit PeerListWidget(PropertiesWidget *parent);
81  ~PeerListWidget() override;
82 
83  void loadPeers(const BitTorrent::Torrent *torrent);
86  void clear();
87 
88 private slots:
89  void loadSettings();
90  void saveSettings() const;
91  void displayToggleColumnsMenu(const QPoint &);
92  void showPeerListMenu(const QPoint &);
93  void banSelectedPeers();
94  void copySelectedPeers();
95  void handleSortColumnChanged(int col);
96  void handleResolved(const QHostAddress &ip, const QString &hostname) const;
97 
98 private:
99  void updatePeer(const BitTorrent::Torrent *torrent, const BitTorrent::PeerInfo &peer, bool &isNewPeer);
100 
101  void wheelEvent(QWheelEvent *event) override;
102 
103  QStandardItemModel *m_listModel = nullptr;
107  QHash<PeerEndpoint, QStandardItem *> m_peerItems;
108  QHash<QHostAddress, QSet<QStandardItem *>> m_itemsByIP; // must be kept in sync with `m_peerItems`
110 };
Net::ReverseResolution * m_resolver
void wheelEvent(QWheelEvent *event) override
void displayToggleColumnsMenu(const QPoint &)
QHash< QHostAddress, QSet< QStandardItem * > > m_itemsByIP
void handleSortColumnChanged(int col)
PropertiesWidget * m_properties
PeerListSortModel * m_proxyModel
QHash< PeerEndpoint, QStandardItem * > m_peerItems
PeerListWidget(PropertiesWidget *parent)
void updatePeerCountryResolutionState()
void loadPeers(const BitTorrent::Torrent *torrent)
QStandardItemModel * m_listModel
~PeerListWidget() override
void updatePeer(const BitTorrent::Torrent *torrent, const BitTorrent::PeerInfo &peer, bool &isNewPeer)
void saveSettings() const
void updatePeerHostNameResolutionState()
void handleResolved(const QHostAddress &ip, const QString &hostname) const
void showPeerListMenu(const QPoint &)
Definition: session.h:86