Browse Source

Coding style for many files

adaptive-webui-19844
thalieht 7 years ago
parent
commit
ae1634623e
  1. 26
      src/gui/properties/downloadedpiecesbar.cpp
  2. 10
      src/gui/properties/downloadedpiecesbar.h
  3. 1
      src/gui/properties/peerlistdelegate.h
  4. 12
      src/gui/properties/peerlistwidget.cpp
  5. 8
      src/gui/properties/peersadditiondlg.cpp
  6. 7
      src/gui/properties/peersadditiondlg.h
  7. 14
      src/gui/properties/pieceavailabilitybar.cpp
  8. 8
      src/gui/properties/pieceavailabilitybar.h
  9. 2
      src/gui/properties/piecesbar.h
  10. 615
      src/gui/properties/propertieswidget.cpp
  11. 80
      src/gui/properties/propertieswidget.h
  12. 108
      src/gui/properties/propertieswidget.ui
  13. 94
      src/gui/properties/proplistdelegate.cpp
  14. 13
      src/gui/properties/proplistdelegate.h
  15. 169
      src/gui/properties/proptabbar.cpp
  16. 36
      src/gui/properties/proptabbar.h
  17. 28
      src/gui/properties/speedplotview.cpp
  18. 10
      src/gui/properties/speedplotview.h
  19. 2
      src/gui/properties/speedwidget.cpp
  20. 4
      src/gui/properties/speedwidget.h
  21. 12
      src/gui/properties/trackerlist.cpp
  22. 34
      src/gui/properties/trackersadditiondlg.cpp
  23. 6
      src/gui/properties/trackersadditiondlg.h

26
src/gui/properties/downloadedpiecesbar.cpp

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#include "downloadedpiecesbar.h" #include "downloadedpiecesbar.h"
@ -127,24 +125,24 @@ bool DownloadedPiecesBar::updateImage(QImage &image)
return true; return true;
} }
QVector<float> scaled_pieces = bitfieldToFloatVector(m_pieces, image2.width()); QVector<float> scaledPieces = bitfieldToFloatVector(m_pieces, image2.width());
QVector<float> scaled_pieces_dl = bitfieldToFloatVector(m_downloadedPieces, image2.width()); QVector<float> scaledPiecesDl = bitfieldToFloatVector(m_downloadedPieces, image2.width());
// filling image // filling image
for (int x = 0; x < scaled_pieces.size(); ++x) { for (int x = 0; x < scaledPieces.size(); ++x) {
float pieces2_val = scaled_pieces.at(x); float piecesToValue = scaledPieces.at(x);
float pieces2_val_dl = scaled_pieces_dl.at(x); float piecesToValueDl = scaledPiecesDl.at(x);
if (pieces2_val_dl != 0) { if (piecesToValueDl != 0) {
float fill_ratio = pieces2_val + pieces2_val_dl; float fillRatio = piecesToValue + piecesToValueDl;
float ratio = pieces2_val_dl / fill_ratio; float ratio = piecesToValueDl / fillRatio;
QRgb mixedColor = mixTwoColors(pieceColor().rgb(), m_dlPieceColor.rgb(), ratio); QRgb mixedColor = mixTwoColors(pieceColor().rgb(), m_dlPieceColor.rgb(), ratio);
mixedColor = mixTwoColors(backgroundColor().rgb(), mixedColor, fill_ratio); mixedColor = mixTwoColors(backgroundColor().rgb(), mixedColor, fillRatio);
image2.setPixel(x, 0, mixedColor); image2.setPixel(x, 0, mixedColor);
} }
else { else {
image2.setPixel(x, 0, pieceColors()[pieces2_val * 255]); image2.setPixel(x, 0, pieceColors()[piecesToValue * 255]);
} }
} }
image = image2; image = image2;

10
src/gui/properties/downloadedpiecesbar.h

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,20 +24,18 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#ifndef DOWNLOADEDPIECESBAR_H #ifndef DOWNLOADEDPIECESBAR_H
#define DOWNLOADEDPIECESBAR_H #define DOWNLOADEDPIECESBAR_H
#include <QWidget>
#include <QBitArray> #include <QBitArray>
#include <QVector> #include <QVector>
#include <QWidget>
#include "piecesbar.h" #include "piecesbar.h"
class DownloadedPiecesBar: public PiecesBar class DownloadedPiecesBar : public PiecesBar
{ {
using base = PiecesBar; using base = PiecesBar;
Q_OBJECT Q_OBJECT

1
src/gui/properties/peerlistdelegate.h

@ -61,7 +61,6 @@ public:
COL_COUNT COL_COUNT
}; };
public:
PeerListDelegate(QObject *parent) : QItemDelegate(parent) {} PeerListDelegate(QObject *parent) : QItemDelegate(parent) {}
~PeerListDelegate() {} ~PeerListDelegate() {}

12
src/gui/properties/peerlistwidget.cpp

@ -231,8 +231,8 @@ void PeerListWidget::showPeerListMenu(const QPoint &)
addPeerAct = menu.addAction(GuiIconProvider::instance()->getIcon("user-group-new"), tr("Add a new peer...")); addPeerAct = menu.addAction(GuiIconProvider::instance()->getIcon("user-group-new"), tr("Add a new peer..."));
emptyMenu = false; emptyMenu = false;
} }
QAction *banAct = 0; QAction *banAct = nullptr;
QAction *copyPeerAct = 0; QAction *copyPeerAct = nullptr;
if (!selectionModel()->selectedRows().isEmpty()) { if (!selectionModel()->selectedRows().isEmpty()) {
copyPeerAct = menu.addAction(GuiIconProvider::instance()->getIcon("edit-copy"), tr("Copy IP:port")); copyPeerAct = menu.addAction(GuiIconProvider::instance()->getIcon("edit-copy"), tr("Copy IP:port"));
menu.addSeparator(); menu.addSeparator();
@ -241,7 +241,8 @@ void PeerListWidget::showPeerListMenu(const QPoint &)
} }
if (emptyMenu) return; if (emptyMenu) return;
QAction *act = menu.exec(QCursor::pos()); QAction *act = menu.exec(QCursor::pos());
if (act == 0) return; if (!act) return;
if (act == addPeerAct) { if (act == addPeerAct) {
QList<BitTorrent::PeerAddress> peersList = PeersAdditionDlg::askForPeers(this); QList<BitTorrent::PeerAddress> peersList = PeersAdditionDlg::askForPeers(this);
int peerCount = 0; int peerCount = 0;
@ -249,7 +250,7 @@ void PeerListWidget::showPeerListMenu(const QPoint &)
if (torrent->connectPeer(addr)) { if (torrent->connectPeer(addr)) {
qDebug("Adding peer %s...", qUtf8Printable(addr.ip.toString())); qDebug("Adding peer %s...", qUtf8Printable(addr.ip.toString()));
Logger::instance()->addMessage(tr("Manually adding peer '%1'...").arg(addr.ip.toString())); Logger::instance()->addMessage(tr("Manually adding peer '%1'...").arg(addr.ip.toString()));
peerCount++; ++peerCount;
} }
else { else {
Logger::instance()->addMessage(tr("The peer '%1' could not be added to this torrent.").arg(addr.ip.toString()), Log::WARNING); Logger::instance()->addMessage(tr("The peer '%1' could not be added to this torrent.").arg(addr.ip.toString()), Log::WARNING);
@ -277,8 +278,7 @@ void PeerListWidget::banSelectedPeers()
int ret = QMessageBox::question(this, tr("Ban peer permanently"), tr("Are you sure you want to ban permanently the selected peers?"), int ret = QMessageBox::question(this, tr("Ban peer permanently"), tr("Are you sure you want to ban permanently the selected peers?"),
tr("&Yes"), tr("&No"), tr("&Yes"), tr("&No"),
QString(), 0, 1); QString(), 0, 1);
if (ret) if (ret) return;
return;
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); QModelIndexList selectedIndexes = selectionModel()->selectedRows();
foreach (const QModelIndex &index, selectedIndexes) { foreach (const QModelIndex &index, selectedIndexes) {

8
src/gui/properties/peersadditiondlg.cpp

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,14 +24,12 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#include "peersadditiondlg.h" #include "peersadditiondlg.h"
#include <QMessageBox>
#include <QHostAddress> #include <QHostAddress>
#include <QMessageBox>
#include "ui_peersadditiondlg.h" #include "ui_peersadditiondlg.h"

7
src/gui/properties/peersadditiondlg.h

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#ifndef PEERADDITION_H #ifndef PEERADDITION_H
@ -42,7 +40,7 @@ namespace Ui
class addPeersDialog; class addPeersDialog;
} }
class PeersAdditionDlg: public QDialog class PeersAdditionDlg : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -60,7 +58,6 @@ private:
Ui::addPeersDialog *m_ui; Ui::addPeersDialog *m_ui;
QList<BitTorrent::PeerAddress> m_peersList; QList<BitTorrent::PeerAddress> m_peersList;
}; };
#endif // PEERADDITION_H #endif // PEERADDITION_H

14
src/gui/properties/pieceavailabilitybar.cpp

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#include "pieceavailabilitybar.h" #include "pieceavailabilitybar.h"
@ -134,12 +132,12 @@ bool PieceAvailabilityBar::updateImage(QImage &image)
return true; return true;
} }
QVector<float> scaled_pieces = intToFloatVector(m_pieces, image2.width()); QVector<float> scaledPieces = intToFloatVector(m_pieces, image2.width());
// filling image // filling image
for (int x = 0; x < scaled_pieces.size(); ++x) { for (int x = 0; x < scaledPieces.size(); ++x) {
float pieces2_val = scaled_pieces.at(x); float piecesToValue = scaledPieces.at(x);
image2.setPixel(x, 0, pieceColors()[pieces2_val * 255]); image2.setPixel(x, 0, pieceColors()[piecesToValue * 255]);
} }
image = image2; image = image2;
return true; return true;

8
src/gui/properties/pieceavailabilitybar.h

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#ifndef PIECEAVAILABILITYBAR_H #ifndef PIECEAVAILABILITYBAR_H
@ -33,7 +31,7 @@
#include "piecesbar.h" #include "piecesbar.h"
class PieceAvailabilityBar: public PiecesBar class PieceAvailabilityBar : public PiecesBar
{ {
using base = PiecesBar; using base = PiecesBar;
Q_OBJECT Q_OBJECT

2
src/gui/properties/piecesbar.h

@ -41,7 +41,7 @@ namespace BitTorrent
class TorrentHandle; class TorrentHandle;
} }
class PiecesBar: public QWidget class PiecesBar : public QWidget
{ {
using base = QWidget; using base = QWidget;
Q_OBJECT Q_OBJECT

615
src/gui/properties/propertieswidget.cpp

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#include "propertieswidget.h" #include "propertieswidget.h"
@ -67,23 +65,23 @@
#include "ui_propertieswidget.h" #include "ui_propertieswidget.h"
PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *main_window, TransferListWidget *transferList) PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, TransferListWidget *transferList)
: QWidget(parent) : QWidget(parent)
, m_ui(new Ui::PropertiesWidget()) , m_ui(new Ui::PropertiesWidget())
, transferList(transferList) , m_transferList(transferList)
, main_window(main_window) , m_mainWindow(mainWindow)
, m_torrent(nullptr) , m_torrent(nullptr)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
setAutoFillBackground(true); setAutoFillBackground(true);
state = VISIBLE; m_state = VISIBLE;
// Set Properties list model // Set Properties list model
PropListModel = new TorrentContentFilterModel(); m_propListModel = new TorrentContentFilterModel();
m_ui->filesList->setModel(PropListModel); m_ui->filesList->setModel(m_propListModel);
PropDelegate = new PropListDelegate(this); m_propListDelegate = new PropListDelegate(this);
m_ui->filesList->setItemDelegate(PropDelegate); m_ui->filesList->setItemDelegate(m_propListDelegate);
m_ui->filesList->setSortingEnabled(true); m_ui->filesList->setSortingEnabled(true);
// Torrent content filtering // Torrent content filtering
m_contentFilterLine = new LineEdit(this); m_contentFilterLine = new LineEdit(this);
@ -94,17 +92,17 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *main_window, Tra
// SIGNAL/SLOTS // SIGNAL/SLOTS
connect(m_ui->filesList, SIGNAL(clicked(const QModelIndex&)), m_ui->filesList, SLOT(edit(const QModelIndex&))); connect(m_ui->filesList, SIGNAL(clicked(const QModelIndex&)), m_ui->filesList, SLOT(edit(const QModelIndex&)));
connect(m_ui->selectAllButton, SIGNAL(clicked()), PropListModel, SLOT(selectAll())); connect(m_ui->selectAllButton, SIGNAL(clicked()), m_propListModel, SLOT(selectAll()));
connect(m_ui->selectNoneButton, SIGNAL(clicked()), PropListModel, SLOT(selectNone())); connect(m_ui->selectNoneButton, SIGNAL(clicked()), m_propListModel, SLOT(selectNone()));
connect(m_ui->filesList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&))); connect(m_ui->filesList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&)));
connect(m_ui->filesList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(openDoubleClickedFile(const QModelIndex&))); connect(m_ui->filesList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(openDoubleClickedFile(const QModelIndex&)));
connect(PropListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged())); connect(m_propListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
connect(m_ui->listWebSeeds, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayWebSeedListMenu(const QPoint&))); connect(m_ui->listWebSeeds, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayWebSeedListMenu(const QPoint&)));
connect(transferList, SIGNAL(currentTorrentChanged(BitTorrent::TorrentHandle * const)), this, SLOT(loadTorrentInfos(BitTorrent::TorrentHandle * const))); connect(transferList, SIGNAL(currentTorrentChanged(BitTorrent::TorrentHandle *const)), this, SLOT(loadTorrentInfos(BitTorrent::TorrentHandle *const)));
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged())); connect(m_propListDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
connect(m_ui->stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData())); connect(m_ui->stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData()));
connect(BitTorrent::Session::instance(), SIGNAL(torrentSavePathChanged(BitTorrent::TorrentHandle * const)), this, SLOT(updateSavePath(BitTorrent::TorrentHandle * const))); connect(BitTorrent::Session::instance(), SIGNAL(torrentSavePathChanged(BitTorrent::TorrentHandle *const)), this, SLOT(updateSavePath(BitTorrent::TorrentHandle *const)));
connect(BitTorrent::Session::instance(), SIGNAL(torrentMetadataLoaded(BitTorrent::TorrentHandle * const)), this, SLOT(updateTorrentInfos(BitTorrent::TorrentHandle * const))); connect(BitTorrent::Session::instance(), SIGNAL(torrentMetadataLoaded(BitTorrent::TorrentHandle *const)), this, SLOT(updateTorrentInfos(BitTorrent::TorrentHandle *const)));
connect(m_ui->filesList->header(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(saveSettings())); connect(m_ui->filesList->header(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(saveSettings()));
connect(m_ui->filesList->header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(saveSettings())); connect(m_ui->filesList->header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(saveSettings()));
connect(m_ui->filesList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSettings())); connect(m_ui->filesList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSettings()));
@ -114,39 +112,39 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *main_window, Tra
// Downloaded pieces progress bar // Downloaded pieces progress bar
m_ui->tempProgressBarArea->setVisible(false); m_ui->tempProgressBarArea->setVisible(false);
downloaded_pieces = new DownloadedPiecesBar(this); m_downloadedPieces = new DownloadedPiecesBar(this);
m_ui->groupBarLayout->addWidget(downloaded_pieces, 0, 1); m_ui->groupBarLayout->addWidget(m_downloadedPieces, 0, 1);
downloaded_pieces->setFixedHeight(barHeight); m_downloadedPieces->setFixedHeight(barHeight);
downloaded_pieces->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); m_downloadedPieces->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
// Pieces availability bar // Pieces availability bar
m_ui->tempAvailabilityBarArea->setVisible(false); m_ui->tempAvailabilityBarArea->setVisible(false);
pieces_availability = new PieceAvailabilityBar(this); m_piecesAvailability = new PieceAvailabilityBar(this);
m_ui->groupBarLayout->addWidget(pieces_availability, 1, 1); m_ui->groupBarLayout->addWidget(m_piecesAvailability, 1, 1);
pieces_availability->setFixedHeight(barHeight); m_piecesAvailability->setFixedHeight(barHeight);
pieces_availability->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); m_piecesAvailability->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
// Tracker list // Tracker list
trackerList = new TrackerList(this); m_trackerList = new TrackerList(this);
m_ui->trackerUpButton->setIcon(GuiIconProvider::instance()->getIcon("go-up")); m_ui->trackerUpButton->setIcon(GuiIconProvider::instance()->getIcon("go-up"));
m_ui->trackerUpButton->setIconSize(Utils::Misc::smallIconSize()); m_ui->trackerUpButton->setIconSize(Utils::Misc::smallIconSize());
m_ui->trackerDownButton->setIcon(GuiIconProvider::instance()->getIcon("go-down")); m_ui->trackerDownButton->setIcon(GuiIconProvider::instance()->getIcon("go-down"));
m_ui->trackerDownButton->setIconSize(Utils::Misc::smallIconSize()); m_ui->trackerDownButton->setIconSize(Utils::Misc::smallIconSize());
connect(m_ui->trackerUpButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionUp())); connect(m_ui->trackerUpButton, SIGNAL(clicked()), m_trackerList, SLOT(moveSelectionUp()));
connect(m_ui->trackerDownButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionDown())); connect(m_ui->trackerDownButton, SIGNAL(clicked()), m_trackerList, SLOT(moveSelectionDown()));
m_ui->horizontalLayout_trackers->insertWidget(0, trackerList); m_ui->horizontalLayout_trackers->insertWidget(0, m_trackerList);
connect(trackerList->header(), SIGNAL(sectionMoved(int,int,int)), trackerList, SLOT(saveSettings())); connect(m_trackerList->header(), SIGNAL(sectionMoved(int,int,int)), m_trackerList, SLOT(saveSettings()));
connect(trackerList->header(), SIGNAL(sectionResized(int,int,int)), trackerList, SLOT(saveSettings())); connect(m_trackerList->header(), SIGNAL(sectionResized(int,int,int)), m_trackerList, SLOT(saveSettings()));
connect(trackerList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), trackerList, SLOT(saveSettings())); connect(m_trackerList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), m_trackerList, SLOT(saveSettings()));
// Peers list // Peers list
peersList = new PeerListWidget(this); m_peerList = new PeerListWidget(this);
m_ui->peerpage_layout->addWidget(peersList); m_ui->peerpage_layout->addWidget(m_peerList);
connect(peersList->header(), SIGNAL(sectionMoved(int,int,int)), peersList, SLOT(saveSettings())); connect(m_peerList->header(), SIGNAL(sectionMoved(int,int,int)), m_peerList, SLOT(saveSettings()));
connect(peersList->header(), SIGNAL(sectionResized(int,int,int)), peersList, SLOT(saveSettings())); connect(m_peerList->header(), SIGNAL(sectionResized(int,int,int)), m_peerList, SLOT(saveSettings()));
connect(peersList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), peersList, SLOT(saveSettings())); connect(m_peerList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), m_peerList, SLOT(saveSettings()));
// Speed widget // Speed widget
speedWidget = new SpeedWidget(this); m_speedWidget = new SpeedWidget(this);
m_ui->speed_layout->addWidget(speedWidget); m_ui->speedLayout->addWidget(m_speedWidget);
// Tab bar // Tab bar
m_tabBar = new PropTabBar(); m_tabBar = new PropTabBar();
m_tabBar->setContentsMargins(0, 5, 0, 0); m_tabBar->setContentsMargins(0, 5, 0, 0);
@ -156,79 +154,79 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *main_window, Tra
connect(m_tabBar, SIGNAL(visibilityToggled(bool)), SLOT(setVisibility(bool))); connect(m_tabBar, SIGNAL(visibilityToggled(bool)), SLOT(setVisibility(bool)));
connect(m_tabBar, SIGNAL(visibilityToggled(bool)), this, SLOT(saveSettings())); connect(m_tabBar, SIGNAL(visibilityToggled(bool)), this, SLOT(saveSettings()));
// Dynamic data refresher // Dynamic data refresher
refreshTimer = new QTimer(this); m_refreshTimer = new QTimer(this);
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(loadDynamicData())); connect(m_refreshTimer, SIGNAL(timeout()), this, SLOT(loadDynamicData()));
refreshTimer->start(3000); // 3sec m_refreshTimer->start(3000); // 3sec
editHotkeyFile = new QShortcut(Qt::Key_F2, m_ui->filesList, 0, 0, Qt::WidgetShortcut); m_editHotkeyFile = new QShortcut(Qt::Key_F2, m_ui->filesList, 0, 0, Qt::WidgetShortcut);
connect(editHotkeyFile, SIGNAL(activated()), SLOT(renameSelectedFile())); connect(m_editHotkeyFile, SIGNAL(activated()), SLOT(renameSelectedFile()));
editHotkeyWeb = new QShortcut(Qt::Key_F2, m_ui->listWebSeeds, 0, 0, Qt::WidgetShortcut); m_editHotkeyWeb = new QShortcut(Qt::Key_F2, m_ui->listWebSeeds, 0, 0, Qt::WidgetShortcut);
connect(editHotkeyWeb, SIGNAL(activated()), SLOT(editWebSeed())); connect(m_editHotkeyWeb, SIGNAL(activated()), SLOT(editWebSeed()));
connect(m_ui->listWebSeeds, SIGNAL(doubleClicked(QModelIndex)), SLOT(editWebSeed())); connect(m_ui->listWebSeeds, SIGNAL(doubleClicked(QModelIndex)), SLOT(editWebSeed()));
deleteHotkeyWeb = new QShortcut(QKeySequence::Delete, m_ui->listWebSeeds, 0, 0, Qt::WidgetShortcut); m_deleteHotkeyWeb = new QShortcut(QKeySequence::Delete, m_ui->listWebSeeds, 0, 0, Qt::WidgetShortcut);
connect(deleteHotkeyWeb, SIGNAL(activated()), SLOT(deleteSelectedUrlSeeds())); connect(m_deleteHotkeyWeb, SIGNAL(activated()), SLOT(deleteSelectedUrlSeeds()));
openHotkeyFile = new QShortcut(Qt::Key_Return, m_ui->filesList, 0, 0, Qt::WidgetShortcut); m_openHotkeyFile = new QShortcut(Qt::Key_Return, m_ui->filesList, 0, 0, Qt::WidgetShortcut);
connect(openHotkeyFile, SIGNAL(activated()), SLOT(openSelectedFile())); connect(m_openHotkeyFile, SIGNAL(activated()), SLOT(openSelectedFile()));
} }
PropertiesWidget::~PropertiesWidget() PropertiesWidget::~PropertiesWidget()
{ {
qDebug() << Q_FUNC_INFO << "ENTER"; qDebug() << Q_FUNC_INFO << "ENTER";
delete refreshTimer; delete m_refreshTimer;
delete trackerList; delete m_trackerList;
delete peersList; delete m_peerList;
delete speedWidget; delete m_speedWidget;
delete downloaded_pieces; delete m_downloadedPieces;
delete pieces_availability; delete m_piecesAvailability;
delete PropListModel; delete m_propListModel;
delete PropDelegate; delete m_propListDelegate;
delete m_tabBar; delete m_tabBar;
delete editHotkeyFile; delete m_editHotkeyFile;
delete editHotkeyWeb; delete m_editHotkeyWeb;
delete deleteHotkeyWeb; delete m_deleteHotkeyWeb;
delete openHotkeyFile; delete m_openHotkeyFile;
delete m_ui; delete m_ui;
qDebug() << Q_FUNC_INFO << "EXIT"; qDebug() << Q_FUNC_INFO << "EXIT";
} }
void PropertiesWidget::showPiecesAvailability(bool show) void PropertiesWidget::showPiecesAvailability(bool show)
{ {
m_ui->avail_pieces_lbl->setVisible(show); m_ui->labelPiecesAvailability->setVisible(show);
pieces_availability->setVisible(show); m_piecesAvailability->setVisible(show);
m_ui->avail_average_lbl->setVisible(show); m_ui->labelAverageAvailabilityVal->setVisible(show);
if (show || !downloaded_pieces->isVisible()) if (show || !m_downloadedPieces->isVisible())
m_ui->line_2->setVisible(show); m_ui->lineBelowBars->setVisible(show);
} }
void PropertiesWidget::showPiecesDownloaded(bool show) void PropertiesWidget::showPiecesDownloaded(bool show)
{ {
m_ui->downloaded_pieces_lbl->setVisible(show); m_ui->labelDownloadedPieces->setVisible(show);
downloaded_pieces->setVisible(show); m_downloadedPieces->setVisible(show);
m_ui->progress_lbl->setVisible(show); m_ui->labelProgressVal->setVisible(show);
if (show || !pieces_availability->isVisible()) if (show || !m_piecesAvailability->isVisible())
m_ui->line_2->setVisible(show); m_ui->lineBelowBars->setVisible(show);
} }
void PropertiesWidget::setVisibility(bool visible) void PropertiesWidget::setVisibility(bool visible)
{ {
if (!visible && (state == VISIBLE)) { if (!visible && (m_state == VISIBLE)) {
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget()); QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
m_ui->stackedProperties->setVisible(false); m_ui->stackedProperties->setVisible(false);
slideSizes = hSplitter->sizes(); m_slideSizes = hSplitter->sizes();
hSplitter->handle(1)->setVisible(false); hSplitter->handle(1)->setVisible(false);
hSplitter->handle(1)->setDisabled(true); hSplitter->handle(1)->setDisabled(true);
QList<int> sizes = QList<int>() << hSplitter->geometry().height() - 30 << 30; QList<int> sizes = QList<int>() << hSplitter->geometry().height() - 30 << 30;
hSplitter->setSizes(sizes); hSplitter->setSizes(sizes);
state = REDUCED; m_state = REDUCED;
return; return;
} }
if (visible && (state == REDUCED)) { if (visible && (m_state == REDUCED)) {
m_ui->stackedProperties->setVisible(true); m_ui->stackedProperties->setVisible(true);
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget()); QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
hSplitter->handle(1)->setDisabled(false); hSplitter->handle(1)->setDisabled(false);
hSplitter->handle(1)->setVisible(true); hSplitter->handle(1)->setVisible(true);
hSplitter->setSizes(slideSizes); hSplitter->setSizes(m_slideSizes);
state = VISIBLE; m_state = VISIBLE;
// Force refresh // Force refresh
loadDynamicData(); loadDynamicData();
} }
@ -237,39 +235,39 @@ void PropertiesWidget::setVisibility(bool visible)
void PropertiesWidget::clear() void PropertiesWidget::clear()
{ {
qDebug("Clearing torrent properties"); qDebug("Clearing torrent properties");
m_ui->save_path->clear(); m_ui->labelSavePathVal->clear();
m_ui->lbl_creationDate->clear(); m_ui->labelCreatedOnVal->clear();
m_ui->label_total_pieces_val->clear(); m_ui->labelTotalPiecesVal->clear();
m_ui->hash_lbl->clear(); m_ui->labelHashVal->clear();
m_ui->comment_text->clear(); m_ui->labelCommentVal->clear();
m_ui->progress_lbl->clear(); m_ui->labelProgressVal->clear();
trackerList->clear(); m_ui->labelAverageAvailabilityVal->clear();
downloaded_pieces->clear(); m_ui->labelWastedVal->clear();
pieces_availability->clear(); m_ui->labelUpTotalVal->clear();
m_ui->avail_average_lbl->clear(); m_ui->labelDlTotalVal->clear();
m_ui->wasted->clear(); m_ui->labelUpLimitVal->clear();
m_ui->upTotal->clear(); m_ui->labelDlLimitVal->clear();
m_ui->dlTotal->clear(); m_ui->labelElapsedVal->clear();
peersList->clear(); m_ui->labelConnectionsVal->clear();
m_ui->lbl_uplimit->clear(); m_ui->labelReannounceInVal->clear();
m_ui->lbl_dllimit->clear(); m_ui->labelShareRatioVal->clear();
m_ui->lbl_elapsed->clear();
m_ui->lbl_connections->clear();
m_ui->reannounce_lbl->clear();
m_ui->shareRatio->clear();
m_ui->listWebSeeds->clear(); m_ui->listWebSeeds->clear();
m_ui->labelETAVal->clear();
m_ui->labelSeedsVal->clear();
m_ui->labelPeersVal->clear();
m_ui->labelDlSpeedVal->clear();
m_ui->labelUpSpeedVal->clear();
m_ui->labelTotalSizeVal->clear();
m_ui->labelCompletedOnVal->clear();
m_ui->labelLastSeenCompleteVal->clear();
m_ui->labelCreatedByVal->clear();
m_ui->labelAddedOnVal->clear();
m_trackerList->clear();
m_downloadedPieces->clear();
m_piecesAvailability->clear();
m_peerList->clear();
m_contentFilterLine->clear(); m_contentFilterLine->clear();
PropListModel->model()->clear(); m_propListModel->model()->clear();
m_ui->label_eta_val->clear();
m_ui->label_seeds_val->clear();
m_ui->label_peers_val->clear();
m_ui->label_dl_speed_val->clear();
m_ui->label_upload_speed_val->clear();
m_ui->label_total_size_val->clear();
m_ui->label_completed_on_val->clear();
m_ui->label_last_complete_val->clear();
m_ui->label_created_by_val->clear();
m_ui->label_added_on_val->clear();
} }
BitTorrent::TorrentHandle *PropertiesWidget::getCurrentTorrent() const BitTorrent::TorrentHandle *PropertiesWidget::getCurrentTorrent() const
@ -277,26 +275,41 @@ BitTorrent::TorrentHandle *PropertiesWidget::getCurrentTorrent() const
return m_torrent; return m_torrent;
} }
TrackerList *PropertiesWidget::getTrackerList() const
{
return m_trackerList;
}
PeerListWidget *PropertiesWidget::getPeerList() const
{
return m_peerList;
}
QTreeView *PropertiesWidget::getFilesList() const QTreeView *PropertiesWidget::getFilesList() const
{ {
return m_ui->filesList; return m_ui->filesList;
} }
SpeedWidget *PropertiesWidget::getSpeedWidget() const
{
return m_speedWidget;
}
void PropertiesWidget::updateSavePath(BitTorrent::TorrentHandle *const torrent) void PropertiesWidget::updateSavePath(BitTorrent::TorrentHandle *const torrent)
{ {
if (m_torrent == torrent) if (torrent == m_torrent)
m_ui->save_path->setText(Utils::Fs::toNativePath(m_torrent->savePath())); m_ui->labelSavePathVal->setText(Utils::Fs::toNativePath(m_torrent->savePath()));
} }
void PropertiesWidget::loadTrackers(BitTorrent::TorrentHandle *const torrent) void PropertiesWidget::loadTrackers(BitTorrent::TorrentHandle *const torrent)
{ {
if (torrent == m_torrent) if (torrent == m_torrent)
trackerList->loadTrackers(); m_trackerList->loadTrackers();
} }
void PropertiesWidget::updateTorrentInfos(BitTorrent::TorrentHandle *const torrent) void PropertiesWidget::updateTorrentInfos(BitTorrent::TorrentHandle *const torrent)
{ {
if (m_torrent == torrent) if (torrent == m_torrent)
loadTorrentInfos(m_torrent); loadTorrentInfos(m_torrent);
} }
@ -304,36 +317,36 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::TorrentHandle *const torrent
{ {
clear(); clear();
m_torrent = torrent; m_torrent = torrent;
downloaded_pieces->setTorrent(m_torrent); m_downloadedPieces->setTorrent(m_torrent);
pieces_availability->setTorrent(m_torrent); m_piecesAvailability->setTorrent(m_torrent);
if (!m_torrent) return; if (!m_torrent) return;
// Save path // Save path
updateSavePath(m_torrent); updateSavePath(m_torrent);
// Hash // Hash
m_ui->hash_lbl->setText(m_torrent->hash()); m_ui->labelHashVal->setText(m_torrent->hash());
PropListModel->model()->clear(); m_propListModel->model()->clear();
if (m_torrent->hasMetadata()) { if (m_torrent->hasMetadata()) {
// Creation date // Creation date
m_ui->lbl_creationDate->setText(m_torrent->creationDate().toString(Qt::DefaultLocaleShortDate)); m_ui->labelCreatedOnVal->setText(m_torrent->creationDate().toString(Qt::DefaultLocaleShortDate));
m_ui->label_total_size_val->setText(Utils::Misc::friendlyUnit(m_torrent->totalSize())); m_ui->labelTotalSizeVal->setText(Utils::Misc::friendlyUnit(m_torrent->totalSize()));
// Comment // Comment
m_ui->comment_text->setText(Utils::Misc::parseHtmlLinks(m_torrent->comment().toHtmlEscaped())); m_ui->labelCommentVal->setText(Utils::Misc::parseHtmlLinks(m_torrent->comment().toHtmlEscaped()));
// URL seeds // URL seeds
loadUrlSeeds(); loadUrlSeeds();
m_ui->label_created_by_val->setText(m_torrent->creator().toHtmlEscaped()); m_ui->labelCreatedByVal->setText(m_torrent->creator().toHtmlEscaped());
// List files in torrent // List files in torrent
PropListModel->model()->setupModelData(m_torrent->info()); m_propListModel->model()->setupModelData(m_torrent->info());
if (PropListModel->model()->rowCount() == 1) if (m_propListModel->model()->rowCount() == 1)
m_ui->filesList->setExpanded(PropListModel->index(0, 0), true); m_ui->filesList->setExpanded(m_propListModel->index(0, 0), true);
// Load file priorities // Load file priorities
PropListModel->model()->updateFilesPriorities(m_torrent->filePriorities()); m_propListModel->model()->updateFilesPriorities(m_torrent->filePriorities());
} }
// Load dynamic data // Load dynamic data
loadDynamicData(); loadDynamicData();
@ -343,12 +356,12 @@ void PropertiesWidget::readSettings()
{ {
const Preferences *const pref = Preferences::instance(); const Preferences *const pref = Preferences::instance();
// Restore splitter sizes // Restore splitter sizes
QStringList sizes_str = pref->getPropSplitterSizes().split(","); QStringList sizesStr = pref->getPropSplitterSizes().split(",");
if (sizes_str.size() == 2) { if (sizesStr.size() == 2) {
slideSizes << sizes_str.first().toInt(); m_slideSizes << sizesStr.first().toInt();
slideSizes << sizes_str.last().toInt(); m_slideSizes << sizesStr.last().toInt();
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget()); QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
hSplitter->setSizes(slideSizes); hSplitter->setSizes(m_slideSizes);
} }
const int current_tab = pref->getPropCurTab(); const int current_tab = pref->getPropCurTab();
const bool visible = pref->getPropVisible(); const bool visible = pref->getPropVisible();
@ -363,14 +376,14 @@ void PropertiesWidget::readSettings()
void PropertiesWidget::saveSettings() void PropertiesWidget::saveSettings()
{ {
Preferences *const pref = Preferences::instance(); Preferences *const pref = Preferences::instance();
pref->setPropVisible(state == VISIBLE); pref->setPropVisible(m_state == VISIBLE);
// Splitter sizes // Splitter sizes
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget()); QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
QList<int> sizes; QList<int> sizes;
if (state == VISIBLE) if (m_state == VISIBLE)
sizes = hSplitter->sizes(); sizes = hSplitter->sizes();
else else
sizes = slideSizes; sizes = m_slideSizes;
qDebug("Sizes: %d", sizes.size()); qDebug("Sizes: %d", sizes.size());
if (sizes.size() == 2) if (sizes.size() == 2)
pref->setPropSplitterSizes(QString::number(sizes.first()) + ',' + QString::number(sizes.last())); pref->setPropSplitterSizes(QString::number(sizes.first()) + ',' + QString::number(sizes.last()));
@ -382,118 +395,112 @@ void PropertiesWidget::saveSettings()
void PropertiesWidget::reloadPreferences() void PropertiesWidget::reloadPreferences()
{ {
// Take program preferences into consideration // Take program preferences into consideration
peersList->updatePeerHostNameResolutionState(); m_peerList->updatePeerHostNameResolutionState();
peersList->updatePeerCountryResolutionState(); m_peerList->updatePeerCountryResolutionState();
} }
void PropertiesWidget::loadDynamicData() void PropertiesWidget::loadDynamicData()
{ {
// Refresh only if the torrent handle is valid and if visible // Refresh only if the torrent handle is valid and visible
if (!m_torrent || (main_window->currentTabWidget() != transferList) || (state != VISIBLE)) return; if (!m_torrent || (m_mainWindow->currentTabWidget() != m_transferList) || (m_state != VISIBLE)) return;
// Transfer infos // Transfer infos
switch (m_ui->stackedProperties->currentIndex()) { switch (m_ui->stackedProperties->currentIndex()) {
case PropTabBar::MAIN_TAB: { case PropTabBar::MainTab: {
m_ui->wasted->setText(Utils::Misc::friendlyUnit(m_torrent->wastedSize())); m_ui->labelWastedVal->setText(Utils::Misc::friendlyUnit(m_torrent->wastedSize()));
m_ui->upTotal->setText(tr("%1 (%2 this session)").arg(Utils::Misc::friendlyUnit(m_torrent->totalUpload())) m_ui->labelUpTotalVal->setText(tr("%1 (%2 this session)").arg(Utils::Misc::friendlyUnit(m_torrent->totalUpload()))
.arg(Utils::Misc::friendlyUnit(m_torrent->totalPayloadUpload()))); .arg(Utils::Misc::friendlyUnit(m_torrent->totalPayloadUpload())));
m_ui->dlTotal->setText(tr("%1 (%2 this session)").arg(Utils::Misc::friendlyUnit(m_torrent->totalDownload())) m_ui->labelDlTotalVal->setText(tr("%1 (%2 this session)").arg(Utils::Misc::friendlyUnit(m_torrent->totalDownload()))
.arg(Utils::Misc::friendlyUnit(m_torrent->totalPayloadDownload()))); .arg(Utils::Misc::friendlyUnit(m_torrent->totalPayloadDownload())));
m_ui->lbl_uplimit->setText(m_torrent->uploadLimit() <= 0 ? QString::fromUtf8(C_INFINITY) : Utils::Misc::friendlyUnit(m_torrent->uploadLimit(), true)); m_ui->labelUpLimitVal->setText(m_torrent->uploadLimit() <= 0 ? QString::fromUtf8(C_INFINITY) : Utils::Misc::friendlyUnit(m_torrent->uploadLimit(), true));
m_ui->lbl_dllimit->setText(m_torrent->downloadLimit() <= 0 ? QString::fromUtf8(C_INFINITY) : Utils::Misc::friendlyUnit(m_torrent->downloadLimit(), true)); m_ui->labelDlLimitVal->setText(m_torrent->downloadLimit() <= 0 ? QString::fromUtf8(C_INFINITY) : Utils::Misc::friendlyUnit(m_torrent->downloadLimit(), true));
QString elapsed_txt; QString elapsedString;
if (m_torrent->isSeed()) if (m_torrent->isSeed())
elapsed_txt = tr("%1 (seeded for %2)", "e.g. 4m39s (seeded for 3m10s)") elapsedString = tr("%1 (seeded for %2)", "e.g. 4m39s (seeded for 3m10s)")
.arg(Utils::Misc::userFriendlyDuration(m_torrent->activeTime())) .arg(Utils::Misc::userFriendlyDuration(m_torrent->activeTime()))
.arg(Utils::Misc::userFriendlyDuration(m_torrent->seedingTime())); .arg(Utils::Misc::userFriendlyDuration(m_torrent->seedingTime()));
else else
elapsed_txt = Utils::Misc::userFriendlyDuration(m_torrent->activeTime()); elapsedString = Utils::Misc::userFriendlyDuration(m_torrent->activeTime());
m_ui->lbl_elapsed->setText(elapsed_txt); m_ui->labelElapsedVal->setText(elapsedString);
m_ui->lbl_connections->setText(tr("%1 (%2 max)", "%1 and %2 are numbers, e.g. 3 (10 max)") m_ui->labelConnectionsVal->setText(tr("%1 (%2 max)", "%1 and %2 are numbers, e.g. 3 (10 max)")
.arg(m_torrent->connectionsCount()) .arg(m_torrent->connectionsCount())
.arg(m_torrent->connectionsLimit() < 0 ? QString::fromUtf8(C_INFINITY) : QString::number(m_torrent->connectionsLimit()))); .arg(m_torrent->connectionsLimit() < 0 ? QString::fromUtf8(C_INFINITY) : QString::number(m_torrent->connectionsLimit())));
m_ui->label_eta_val->setText(Utils::Misc::userFriendlyDuration(m_torrent->eta())); m_ui->labelETAVal->setText(Utils::Misc::userFriendlyDuration(m_torrent->eta()));
// Update next announce time // Update next announce time
m_ui->reannounce_lbl->setText(Utils::Misc::userFriendlyDuration(m_torrent->nextAnnounce())); m_ui->labelReannounceInVal->setText(Utils::Misc::userFriendlyDuration(m_torrent->nextAnnounce()));
// Update ratio info // Update ratio info
const qreal ratio = m_torrent->realRatio(); const qreal ratio = m_torrent->realRatio();
m_ui->shareRatio->setText(ratio > BitTorrent::TorrentHandle::MAX_RATIO ? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(ratio, 2)); m_ui->labelShareRatioVal->setText(ratio > BitTorrent::TorrentHandle::MAX_RATIO ? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(ratio, 2));
m_ui->label_seeds_val->setText(tr("%1 (%2 total)", "%1 and %2 are numbers, e.g. 3 (10 total)") m_ui->labelSeedsVal->setText(tr("%1 (%2 total)", "%1 and %2 are numbers, e.g. 3 (10 total)")
.arg(QString::number(m_torrent->seedsCount())) .arg(QString::number(m_torrent->seedsCount()))
.arg(QString::number(m_torrent->totalSeedsCount()))); .arg(QString::number(m_torrent->totalSeedsCount())));
m_ui->label_peers_val->setText(tr("%1 (%2 total)", "%1 and %2 are numbers, e.g. 3 (10 total)") m_ui->labelPeersVal->setText(tr("%1 (%2 total)", "%1 and %2 are numbers, e.g. 3 (10 total)")
.arg(QString::number(m_torrent->leechsCount())) .arg(QString::number(m_torrent->leechsCount()))
.arg(QString::number(m_torrent->totalLeechersCount()))); .arg(QString::number(m_torrent->totalLeechersCount())));
m_ui->label_dl_speed_val->setText(tr("%1 (%2 avg.)", "%1 and %2 are speed rates, e.g. 200KiB/s (100KiB/s avg.)") m_ui->labelDlSpeedVal->setText(tr("%1 (%2 avg.)", "%1 and %2 are speed rates, e.g. 200KiB/s (100KiB/s avg.)")
.arg(Utils::Misc::friendlyUnit(m_torrent->downloadPayloadRate(), true)) .arg(Utils::Misc::friendlyUnit(m_torrent->downloadPayloadRate(), true))
.arg(Utils::Misc::friendlyUnit(m_torrent->totalDownload() / (1 + m_torrent->activeTime() - m_torrent->finishedTime()), true))); .arg(Utils::Misc::friendlyUnit(m_torrent->totalDownload() / (1 + m_torrent->activeTime() - m_torrent->finishedTime()), true)));
m_ui->label_upload_speed_val->setText(tr("%1 (%2 avg.)", "%1 and %2 are speed rates, e.g. 200KiB/s (100KiB/s avg.)") m_ui->labelUpSpeedVal->setText(tr("%1 (%2 avg.)", "%1 and %2 are speed rates, e.g. 200KiB/s (100KiB/s avg.)")
.arg(Utils::Misc::friendlyUnit(m_torrent->uploadPayloadRate(), true)) .arg(Utils::Misc::friendlyUnit(m_torrent->uploadPayloadRate(), true))
.arg(Utils::Misc::friendlyUnit(m_torrent->totalUpload() / (1 + m_torrent->activeTime()), true))); .arg(Utils::Misc::friendlyUnit(m_torrent->totalUpload() / (1 + m_torrent->activeTime()), true)));
m_ui->label_last_complete_val->setText(m_torrent->lastSeenComplete().isValid() ? m_torrent->lastSeenComplete().toString(Qt::DefaultLocaleShortDate) : tr("Never")); m_ui->labelLastSeenCompleteVal->setText(m_torrent->lastSeenComplete().isValid() ? m_torrent->lastSeenComplete().toString(Qt::DefaultLocaleShortDate) : tr("Never"));
m_ui->label_completed_on_val->setText(m_torrent->completedTime().isValid() ? m_torrent->completedTime().toString(Qt::DefaultLocaleShortDate) : ""); m_ui->labelCompletedOnVal->setText(m_torrent->completedTime().isValid() ? m_torrent->completedTime().toString(Qt::DefaultLocaleShortDate) : "");
m_ui->label_added_on_val->setText(m_torrent->addedTime().toString(Qt::DefaultLocaleShortDate)); m_ui->labelAddedOnVal->setText(m_torrent->addedTime().toString(Qt::DefaultLocaleShortDate));
if (m_torrent->hasMetadata()) { if (m_torrent->hasMetadata()) {
m_ui->label_total_pieces_val->setText(tr("%1 x %2 (have %3)", "(torrent pieces) eg 152 x 4MB (have 25)").arg(m_torrent->piecesCount()).arg(Utils::Misc::friendlyUnit(m_torrent->pieceLength())).arg(m_torrent->piecesHave())); m_ui->labelTotalPiecesVal->setText(tr("%1 x %2 (have %3)", "(torrent pieces) eg 152 x 4MB (have 25)").arg(m_torrent->piecesCount()).arg(Utils::Misc::friendlyUnit(m_torrent->pieceLength())).arg(m_torrent->piecesHave()));
if (!m_torrent->isSeed() && !m_torrent->isPaused() && !m_torrent->isQueued() && !m_torrent->isChecking()) {
// Pieces availability
showPiecesAvailability(true);
m_piecesAvailability->setAvailability(m_torrent->pieceAvailability());
m_ui->labelAverageAvailabilityVal->setText(Utils::String::fromDouble(m_torrent->distributedCopies(), 3));
}
else {
showPiecesAvailability(false);
}
if (!m_torrent->isSeed() && !m_torrent->isPaused() && !m_torrent->isQueued() && !m_torrent->isChecking()) { // Progress
// Pieces availability qreal progress = m_torrent->progress() * 100.;
showPiecesAvailability(true); m_ui->labelProgressVal->setText(Utils::String::fromDouble(progress, 1) + "%");
pieces_availability->setAvailability(m_torrent->pieceAvailability()); m_downloadedPieces->setProgress(m_torrent->pieces(), m_torrent->downloadingPieces());
m_ui->avail_average_lbl->setText(Utils::String::fromDouble(m_torrent->distributedCopies(), 3));
} }
else { else {
showPiecesAvailability(false); showPiecesAvailability(false);
} }
// Progress
qreal progress = m_torrent->progress() * 100.;
m_ui->progress_lbl->setText(Utils::String::fromDouble(progress, 1) + "%");
downloaded_pieces->setProgress(m_torrent->pieces(), m_torrent->downloadingPieces());
} }
else {
showPiecesAvailability(false);
}
break; break;
} case PropTabBar::TrackersTab:
case PropTabBar::TRACKERS_TAB: {
// Trackers // Trackers
trackerList->loadTrackers(); m_trackerList->loadTrackers();
break; break;
} case PropTabBar::PeersTab:
case PropTabBar::PEERS_TAB: {
// Load peers // Load peers
peersList->loadPeers(m_torrent); m_peerList->loadPeers(m_torrent);
break; break;
} case PropTabBar::FilesTab:
case PropTabBar::FILES_TAB: {
// Files progress // Files progress
if (m_torrent->hasMetadata()) { if (m_torrent->hasMetadata()) {
qDebug("Updating priorities in files tab"); qDebug("Updating priorities in files tab");
m_ui->filesList->setUpdatesEnabled(false); m_ui->filesList->setUpdatesEnabled(false);
PropListModel->model()->updateFilesProgress(m_torrent->filesProgress()); m_propListModel->model()->updateFilesProgress(m_torrent->filesProgress());
PropListModel->model()->updateFilesAvailability(m_torrent->availableFileFractions()); m_propListModel->model()->updateFilesAvailability(m_torrent->availableFileFractions());
// XXX: We don't update file priorities regularly for performance // XXX: We don't update file priorities regularly for performance
// reasons. This means that priorities will not be updated if // reasons. This means that priorities will not be updated if
// set from the Web UI. // set from the Web UI.
@ -501,8 +508,6 @@ void PropertiesWidget::loadDynamicData()
m_ui->filesList->setUpdatesEnabled(true); m_ui->filesList->setUpdatesEnabled(true);
} }
break; break;
}
default:; default:;
} }
} }
@ -511,19 +516,19 @@ void PropertiesWidget::loadUrlSeeds()
{ {
m_ui->listWebSeeds->clear(); m_ui->listWebSeeds->clear();
qDebug("Loading URL seeds"); qDebug("Loading URL seeds");
const QList<QUrl> hc_seeds = m_torrent->urlSeeds(); const QList<QUrl> hcSeeds = m_torrent->urlSeeds();
// Add url seeds // Add url seeds
foreach (const QUrl &hc_seed, hc_seeds) { foreach (const QUrl &hcSeed, hcSeeds) {
qDebug("Loading URL seed: %s", qUtf8Printable(hc_seed.toString())); qDebug("Loading URL seed: %s", qUtf8Printable(hcSeed.toString()));
new QListWidgetItem(hc_seed.toString(), m_ui->listWebSeeds); new QListWidgetItem(hcSeed.toString(), m_ui->listWebSeeds);
} }
} }
void PropertiesWidget::openDoubleClickedFile(const QModelIndex &index) void PropertiesWidget::openDoubleClickedFile(const QModelIndex &index)
{ {
if (!index.isValid()) return; if (!index.isValid() || !m_torrent || !m_torrent->hasMetadata()) return;
if (!m_torrent || !m_torrent->hasMetadata()) return;
if (PropListModel->itemType(index) == TorrentContentModelItem::FileType) if (m_propListModel->itemType(index) == TorrentContentModelItem::FileType)
openFile(index); openFile(index);
else else
openFolder(index, false); openFolder(index, false);
@ -531,48 +536,48 @@ void PropertiesWidget::openDoubleClickedFile(const QModelIndex &index)
void PropertiesWidget::openFile(const QModelIndex &index) void PropertiesWidget::openFile(const QModelIndex &index)
{ {
int i = PropListModel->getFileIndex(index); int i = m_propListModel->getFileIndex(index);
const QDir saveDir(m_torrent->savePath(true)); const QDir saveDir(m_torrent->savePath(true));
const QString filename = m_torrent->filePath(i); const QString filename = m_torrent->filePath(i);
const QString file_path = Utils::Fs::expandPath(saveDir.absoluteFilePath(filename)); const QString filePath = Utils::Fs::expandPath(saveDir.absoluteFilePath(filename));
qDebug("Trying to open file at %s", qUtf8Printable(file_path)); qDebug("Trying to open file at %s", qUtf8Printable(filePath));
// Flush data // Flush data
m_torrent->flushCache(); m_torrent->flushCache();
Utils::Misc::openPath(file_path); Utils::Misc::openPath(filePath);
} }
void PropertiesWidget::openFolder(const QModelIndex &index, bool containing_folder) void PropertiesWidget::openFolder(const QModelIndex &index, bool containingFolder)
{ {
QString absolute_path; QString absolutePath;
// FOLDER // FOLDER
if (PropListModel->itemType(index) == TorrentContentModelItem::FolderType) { if (m_propListModel->itemType(index) == TorrentContentModelItem::FolderType) {
// Generate relative path to selected folder // Generate relative path to selected folder
QStringList path_items; QStringList pathItems;
path_items << index.data().toString(); pathItems << index.data().toString();
QModelIndex parent = PropListModel->parent(index); QModelIndex parent = m_propListModel->parent(index);
while (parent.isValid()) { while (parent.isValid()) {
path_items.prepend(parent.data().toString()); pathItems.prepend(parent.data().toString());
parent = PropListModel->parent(parent); parent = m_propListModel->parent(parent);
} }
if (path_items.isEmpty()) if (pathItems.isEmpty())
return; return;
const QDir saveDir(m_torrent->savePath(true)); const QDir saveDir(m_torrent->savePath(true));
const QString relative_path = path_items.join("/"); const QString relativePath = pathItems.join("/");
absolute_path = Utils::Fs::expandPath(saveDir.absoluteFilePath(relative_path)); absolutePath = Utils::Fs::expandPath(saveDir.absoluteFilePath(relativePath));
} }
else { else {
int i = PropListModel->getFileIndex(index); int i = m_propListModel->getFileIndex(index);
const QDir saveDir(m_torrent->savePath(true)); const QDir saveDir(m_torrent->savePath(true));
const QString relative_path = m_torrent->filePath(i); const QString relativePath = m_torrent->filePath(i);
absolute_path = Utils::Fs::expandPath(saveDir.absoluteFilePath(relative_path)); absolutePath = Utils::Fs::expandPath(saveDir.absoluteFilePath(relativePath));
} }
// Flush data // Flush data
m_torrent->flushCache(); m_torrent->flushCache();
if (containing_folder) if (containingFolder)
Utils::Misc::openFolderSelect(absolute_path); Utils::Misc::openFolderSelect(absolutePath);
else else
Utils::Misc::openPath(absolute_path); Utils::Misc::openPath(absolutePath);
} }
void PropertiesWidget::displayFilesListMenu(const QPoint &) void PropertiesWidget::displayFilesListMenu(const QPoint &)
@ -580,8 +585,8 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &)
if (!m_torrent) return; if (!m_torrent) return;
QModelIndexList selectedRows = m_ui->filesList->selectionModel()->selectedRows(0); QModelIndexList selectedRows = m_ui->filesList->selectionModel()->selectedRows(0);
if (selectedRows.empty()) if (selectedRows.empty()) return;
return;
QMenu myFilesLlistMenu; QMenu myFilesLlistMenu;
QAction *actOpen = nullptr; QAction *actOpen = nullptr;
QAction *actOpenContainingFolder = nullptr; QAction *actOpenContainingFolder = nullptr;
@ -606,35 +611,33 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &)
// The selected torrent might have disappeared during exec() // The selected torrent might have disappeared during exec()
// from the current view thus leaving invalid indices. // from the current view thus leaving invalid indices.
const QModelIndex index = *(selectedRows.begin()); const QModelIndex index = *(selectedRows.begin());
if (!index.isValid()) if (!index.isValid() || !act) return;
return;
if (act) { if (act == actOpen) {
if (act == actOpen) { openDoubleClickedFile(index);
openDoubleClickedFile(index); }
} else if (act == actOpenContainingFolder) {
else if (act == actOpenContainingFolder) { openFolder(index, true);
openFolder(index, true); }
} else if (act == actRename) {
else if (act == actRename) { renameSelectedFile();
renameSelectedFile(); }
} else {
else { int prio = prio::NORMAL;
int prio = prio::NORMAL; if (act == m_ui->actionHigh)
if (act == m_ui->actionHigh) prio = prio::HIGH;
prio = prio::HIGH; else if (act == m_ui->actionMaximum)
else if (act == m_ui->actionMaximum) prio = prio::MAXIMUM;
prio = prio::MAXIMUM; else if (act == m_ui->actionNot_downloaded)
else if (act == m_ui->actionNot_downloaded) prio = prio::IGNORED;
prio = prio::IGNORED;
qDebug("Setting files priority");
qDebug("Setting files priority"); foreach (QModelIndex index, selectedRows) {
foreach (QModelIndex index, selectedRows) { qDebug("Setting priority(%d) for file at row %d", prio, index.row());
qDebug("Setting priority(%d) for file at row %d", prio, index.row()); m_propListModel->setData(m_propListModel->index(index.row(), PRIORITY, index.parent()), prio);
PropListModel->setData(PropListModel->index(index.row(), PRIORITY, index.parent()), prio);
}
// Save changes
filteredFilesChanged();
} }
// Save changes
filteredFilesChanged();
} }
} }
@ -657,16 +660,16 @@ void PropertiesWidget::displayWebSeedListMenu(const QPoint &)
} }
const QAction *act = seedMenu.exec(QCursor::pos()); const QAction *act = seedMenu.exec(QCursor::pos());
if (act) { if (!act) return;
if (act == actAdd)
askWebSeed(); if (act == actAdd)
else if (act == actDel) askWebSeed();
deleteSelectedUrlSeeds(); else if (act == actDel)
else if (act == actCpy) deleteSelectedUrlSeeds();
copySelectedWebSeedsToClipboard(); else if (act == actCpy)
else if (act == actEdit) copySelectedWebSeedsToClipboard();
editWebSeed(); else if (act == actEdit)
} editWebSeed();
} }
void PropertiesWidget::renameSelectedFile() void PropertiesWidget::renameSelectedFile()
@ -692,9 +695,9 @@ void PropertiesWidget::renameSelectedFile()
return; return;
} }
if (PropListModel->itemType(modelIndex) == TorrentContentModelItem::FileType) { if (m_propListModel->itemType(modelIndex) == TorrentContentModelItem::FileType) {
// renaming a file // renaming a file
const int fileIndex = PropListModel->getFileIndex(modelIndex); const int fileIndex = m_propListModel->getFileIndex(modelIndex);
if (newName.endsWith(QB_EXT)) if (newName.endsWith(QB_EXT))
newName.chop(QB_EXT.size()); newName.chop(QB_EXT.size());
@ -722,16 +725,16 @@ void PropertiesWidget::renameSelectedFile()
qDebug("Renaming %s to %s", qUtf8Printable(oldFilePath), qUtf8Printable(newFilePath)); qDebug("Renaming %s to %s", qUtf8Printable(oldFilePath), qUtf8Printable(newFilePath));
m_torrent->renameFile(fileIndex, newFilePath); m_torrent->renameFile(fileIndex, newFilePath);
PropListModel->setData(modelIndex, newName); m_propListModel->setData(modelIndex, newName);
} }
else { else {
// renaming a folder // renaming a folder
QStringList pathItems; QStringList pathItems;
pathItems << modelIndex.data().toString(); pathItems << modelIndex.data().toString();
QModelIndex parent = PropListModel->parent(modelIndex); QModelIndex parent = m_propListModel->parent(modelIndex);
while (parent.isValid()) { while (parent.isValid()) {
pathItems.prepend(parent.data().toString()); pathItems.prepend(parent.data().toString());
parent = PropListModel->parent(parent); parent = m_propListModel->parent(parent);
} }
const QString oldPath = pathItems.join("/"); const QString oldPath = pathItems.join("/");
pathItems.removeLast(); pathItems.removeLast();
@ -773,7 +776,7 @@ void PropertiesWidget::renameSelectedFile()
// Force recheck // Force recheck
if (forceRecheck) m_torrent->forceRecheck(); if (forceRecheck) m_torrent->forceRecheck();
// Rename folder in torrent files model too // Rename folder in torrent files model too
PropListModel->setData(modelIndex, newName); m_propListModel->setData(modelIndex, newName);
// Remove old folder // Remove old folder
const QDir oldFolder(m_torrent->savePath(true) + "/" + oldPath); const QDir oldFolder(m_torrent->savePath(true) + "/" + oldPath);
int timeout = 10; int timeout = 10;
@ -830,52 +833,48 @@ void PropertiesWidget::deleteSelectedUrlSeeds()
void PropertiesWidget::copySelectedWebSeedsToClipboard() const void PropertiesWidget::copySelectedWebSeedsToClipboard() const
{ {
const QList<QListWidgetItem *> selected_items = m_ui->listWebSeeds->selectedItems(); const QList<QListWidgetItem *> selectedItems = m_ui->listWebSeeds->selectedItems();
if (selected_items.isEmpty()) if (selectedItems.isEmpty()) return;
return;
QStringList urls_to_copy; QStringList urlsToCopy;
foreach (QListWidgetItem *item, selected_items) foreach (QListWidgetItem *item, selectedItems)
urls_to_copy << item->text(); urlsToCopy << item->text();
QApplication::clipboard()->setText(urls_to_copy.join("\n")); QApplication::clipboard()->setText(urlsToCopy.join("\n"));
} }
void PropertiesWidget::editWebSeed() void PropertiesWidget::editWebSeed()
{ {
const QList<QListWidgetItem *> selected_items = m_ui->listWebSeeds->selectedItems(); const QList<QListWidgetItem *> selectedItems = m_ui->listWebSeeds->selectedItems();
if (selected_items.size() != 1) if (selectedItems.size() != 1) return;
return;
const QListWidgetItem *selected_item = selected_items.last(); const QListWidgetItem *selectedItem = selectedItems.last();
const QString old_seed = selected_item->text(); const QString oldSeed = selectedItem->text();
bool result; bool result;
const QString new_seed = AutoExpandableDialog::getText(this, tr("Web seed editing"), const QString newSeed = AutoExpandableDialog::getText(this, tr("Web seed editing"),
tr("Web seed URL:"), QLineEdit::Normal, tr("Web seed URL:"), QLineEdit::Normal,
old_seed, &result); oldSeed, &result);
if (!result) if (!result) return;
return;
if (!m_ui->listWebSeeds->findItems(new_seed, Qt::MatchFixedString).empty()) { if (!m_ui->listWebSeeds->findItems(newSeed, Qt::MatchFixedString).empty()) {
QMessageBox::warning(this, tr("qBittorrent"), QMessageBox::warning(this, tr("qBittorrent"),
tr("This URL seed is already in the list."), tr("This URL seed is already in the list."),
QMessageBox::Ok); QMessageBox::Ok);
return; return;
} }
m_torrent->removeUrlSeeds(QList<QUrl>() << old_seed); m_torrent->removeUrlSeeds(QList<QUrl>() << oldSeed);
m_torrent->addUrlSeeds(QList<QUrl>() << new_seed); m_torrent->addUrlSeeds(QList<QUrl>() << newSeed);
loadUrlSeeds(); loadUrlSeeds();
} }
bool PropertiesWidget::applyPriorities() void PropertiesWidget::applyPriorities()
{ {
qDebug("Saving files priorities"); qDebug("Saving files priorities");
const QVector<int> priorities = PropListModel->model()->getFilePriorities(); const QVector<int> priorities = m_propListModel->model()->getFilePriorities();
// Prioritize the files // Prioritize the files
qDebug("prioritize files: %d", priorities[0]); qDebug("prioritize files: %d", priorities[0]);
m_torrent->prioritizeFiles(priorities); m_torrent->prioritizeFiles(priorities);
return true;
} }
void PropertiesWidget::filteredFilesChanged() void PropertiesWidget::filteredFilesChanged()
@ -886,10 +885,10 @@ void PropertiesWidget::filteredFilesChanged()
void PropertiesWidget::filterText(const QString &filter) void PropertiesWidget::filterText(const QString &filter)
{ {
PropListModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::WildcardUnix)); m_propListModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::WildcardUnix));
if (filter.isEmpty()) { if (filter.isEmpty()) {
m_ui->filesList->collapseAll(); m_ui->filesList->collapseAll();
m_ui->filesList->expand(PropListModel->index(0, 0)); m_ui->filesList->expand(m_propListModel->index(0, 0));
} }
else { else {
m_ui->filesList->expandAll(); m_ui->filesList->expandAll();

80
src/gui/properties/propertieswidget.h

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#ifndef PROPERTIESWIDGET_H #ifndef PROPERTIESWIDGET_H
@ -36,32 +34,30 @@
#include "base/bittorrent/torrenthandle.h" #include "base/bittorrent/torrenthandle.h"
class TransferListWidget;
class TorrentContentFilterModel;
class PropListDelegate;
class torrent_file;
class PeerListWidget;
class TrackerList;
class SpeedWidget;
class MainWindow;
class DownloadedPiecesBar;
class PieceAvailabilityBar;
class PropTabBar;
class LineEdit;
QT_BEGIN_NAMESPACE
class QAction; class QAction;
class QPushButton; class QPushButton;
class QTimer; class QTimer;
class QTreeView; class QTreeView;
QT_END_NAMESPACE
class DownloadedPiecesBar;
class LineEdit;
class MainWindow;
class PeerListWidget;
class PieceAvailabilityBar;
class PropListDelegate;
class PropTabBar;
class SpeedWidget;
class torrent_file;
class TorrentContentFilterModel;
class TrackerList;
class TransferListWidget;
namespace Ui namespace Ui
{ {
class PropertiesWidget; class PropertiesWidget;
} }
class PropertiesWidget: public QWidget class PropertiesWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(PropertiesWidget) Q_DISABLE_COPY(PropertiesWidget)
@ -73,13 +69,13 @@ public:
VISIBLE VISIBLE
}; };
PropertiesWidget(QWidget *parent, MainWindow *main_window, TransferListWidget *transferList); PropertiesWidget(QWidget *parent, MainWindow *mainWindow, TransferListWidget *transferList);
~PropertiesWidget(); ~PropertiesWidget();
BitTorrent::TorrentHandle *getCurrentTorrent() const; BitTorrent::TorrentHandle *getCurrentTorrent() const;
TrackerList *getTrackerList() const { return trackerList; } TrackerList *getTrackerList() const;
PeerListWidget *getPeerList() const { return peersList; } PeerListWidget *getPeerList() const;
QTreeView *getFilesList() const; QTreeView *getFilesList() const;
SpeedWidget *getSpeedWidget() const { return speedWidget; } SpeedWidget *getSpeedWidget() const;
public slots: public slots:
void setVisibility(bool visible); void setVisibility(bool visible);
@ -93,7 +89,7 @@ public slots:
protected: protected:
QPushButton *getButtonFromIndex(int index); QPushButton *getButtonFromIndex(int index);
bool applyPriorities(); void applyPriorities();
protected slots: protected slots:
void loadTorrentInfos(BitTorrent::TorrentHandle *const torrent); void loadTorrentInfos(BitTorrent::TorrentHandle *const torrent);
@ -113,28 +109,28 @@ protected slots:
private: private:
void openFile(const QModelIndex &index); void openFile(const QModelIndex &index);
void openFolder(const QModelIndex &index, bool containing_folder); void openFolder(const QModelIndex &index, bool containingFolder);
Ui::PropertiesWidget *m_ui; Ui::PropertiesWidget *m_ui;
TransferListWidget *transferList; TransferListWidget *m_transferList;
MainWindow *main_window; MainWindow *m_mainWindow;
BitTorrent::TorrentHandle *m_torrent; BitTorrent::TorrentHandle *m_torrent;
QTimer *refreshTimer; QTimer *m_refreshTimer;
SlideState state; SlideState m_state;
TorrentContentFilterModel *PropListModel; TorrentContentFilterModel *m_propListModel;
PropListDelegate *PropDelegate; PropListDelegate *m_propListDelegate;
PeerListWidget *peersList; PeerListWidget *m_peerList;
TrackerList *trackerList; TrackerList *m_trackerList;
SpeedWidget *speedWidget; SpeedWidget *m_speedWidget;
QList<int> slideSizes; QList<int> m_slideSizes;
DownloadedPiecesBar *downloaded_pieces; DownloadedPiecesBar *m_downloadedPieces;
PieceAvailabilityBar *pieces_availability; PieceAvailabilityBar *m_piecesAvailability;
PropTabBar *m_tabBar; PropTabBar *m_tabBar;
LineEdit *m_contentFilterLine; LineEdit *m_contentFilterLine;
QShortcut *editHotkeyFile; QShortcut *m_editHotkeyFile;
QShortcut *editHotkeyWeb; QShortcut *m_editHotkeyWeb;
QShortcut *deleteHotkeyWeb; QShortcut *m_deleteHotkeyWeb;
QShortcut *openHotkeyFile; QShortcut *m_openHotkeyFile;
private slots: private slots:
void filterText(const QString &filter); void filterText(const QString &filter);

108
src/gui/properties/propertieswidget.ui

@ -67,7 +67,7 @@
<number>4</number> <number>4</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="downloaded_pieces_lbl"> <widget class="QLabel" name="labelDownloadedPieces">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -83,7 +83,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QLabel" name="progress_lbl"> <widget class="QLabel" name="labelProgressVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -96,7 +96,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="avail_pieces_lbl"> <widget class="QLabel" name="labelPiecesAvailability">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -112,7 +112,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="2">
<widget class="QLabel" name="avail_average_lbl"> <widget class="QLabel" name="labelAverageAvailabilityVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -142,7 +142,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="Line" name="line_2"> <widget class="Line" name="lineBelowBars">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@ -161,7 +161,7 @@
<number>4</number> <number>4</number>
</property> </property>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QLabel" name="label_dl_speed_val"> <widget class="QLabel" name="labelDlSpeedVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -174,7 +174,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item row="2" column="2">
<widget class="QLabel" name="label_upload_speed"> <widget class="QLabel" name="labelUpSpeed">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -190,7 +190,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="3" colspan="4"> <item row="2" column="3" colspan="4">
<widget class="QLabel" name="label_upload_speed_val"> <widget class="QLabel" name="labelUpSpeedVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -203,7 +203,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="4"> <item row="2" column="4">
<widget class="QLabel" name="label_peers"> <widget class="QLabel" name="labelPeers">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -219,7 +219,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="4"> <item row="0" column="4">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="labelConnections">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -235,7 +235,7 @@
</widget> </widget>
</item> </item>
<item row="4" column="3"> <item row="4" column="3">
<widget class="QLabel" name="reannounce_lbl"> <widget class="QLabel" name="labelReannounceInVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -248,7 +248,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="3"> <item row="0" column="3">
<widget class="QLabel" name="label_eta_val"> <widget class="QLabel" name="labelETAVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -261,7 +261,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="labelDlLimit">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -277,7 +277,7 @@
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="lbl_ratio"> <widget class="QLabel" name="labelRatio">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -293,7 +293,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="5"> <item row="0" column="5">
<widget class="QLabel" name="lbl_connections"> <widget class="QLabel" name="labelConnectionsVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -306,7 +306,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="5"> <item row="2" column="5">
<widget class="QLabel" name="label_peers_val"> <widget class="QLabel" name="labelPeersVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -319,7 +319,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="labelDownloaded">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -335,7 +335,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="2"> <item row="3" column="2">
<widget class="QLabel" name="label"> <widget class="QLabel" name="labelUpLimit">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -351,7 +351,7 @@
</widget> </widget>
</item> </item>
<item row="4" column="4"> <item row="4" column="4">
<widget class="QLabel" name="label_last_complete"> <widget class="QLabel" name="labelLastSeenComplete">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -367,7 +367,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QLabel" name="lbl_dllimit"> <widget class="QLabel" name="labelDlLimitVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -380,7 +380,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="3" colspan="4"> <item row="1" column="3" colspan="4">
<widget class="QLabel" name="upTotal"> <widget class="QLabel" name="labelUpTotalVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -393,7 +393,7 @@
</widget> </widget>
</item> </item>
<item row="4" column="2"> <item row="4" column="2">
<widget class="QLabel" name="label_10"> <widget class="QLabel" name="labelReannounceIn">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -409,7 +409,7 @@
</widget> </widget>
</item> </item>
<item row="4" column="5"> <item row="4" column="5">
<widget class="QLabel" name="label_last_complete_val"> <widget class="QLabel" name="labelLastSeenCompleteVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -422,7 +422,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="4"> <item row="1" column="4">
<widget class="QLabel" name="label_seeds"> <widget class="QLabel" name="labelSeeds">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -438,7 +438,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_dl_speed"> <widget class="QLabel" name="labelDlSpeed">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -454,7 +454,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLabel" name="dlTotal"> <widget class="QLabel" name="labelDlTotalVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -467,7 +467,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="5"> <item row="3" column="5">
<widget class="QLabel" name="wasted"> <widget class="QLabel" name="labelWastedVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -480,7 +480,7 @@
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="1">
<widget class="QLabel" name="shareRatio"> <widget class="QLabel" name="labelShareRatioVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -493,7 +493,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="2">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="labelUploaded">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -509,7 +509,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="5"> <item row="1" column="5">
<widget class="QLabel" name="label_seeds_val"> <widget class="QLabel" name="labelSeedsVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -522,7 +522,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="lbl_elapsed"> <widget class="QLabel" name="labelElapsedVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -535,7 +535,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="labelTimeActive">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -551,7 +551,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="3"> <item row="3" column="3">
<widget class="QLabel" name="lbl_uplimit"> <widget class="QLabel" name="labelUpLimitVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -564,7 +564,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QLabel" name="label_eta"> <widget class="QLabel" name="labelETA">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -580,7 +580,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="4"> <item row="3" column="4">
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="labelWasted">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -611,7 +611,7 @@
<number>2</number> <number>2</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_total_size"> <widget class="QLabel" name="labelTotalSize">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -627,7 +627,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="label_total_size_val"> <widget class="QLabel" name="labelTotalSizeVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -640,7 +640,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QLabel" name="label_total_pieces"> <widget class="QLabel" name="labelTotalPieces">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -656,7 +656,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="3"> <item row="0" column="3">
<widget class="QLabel" name="label_total_pieces_val"> <widget class="QLabel" name="labelTotalPiecesVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -669,7 +669,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="4"> <item row="0" column="4">
<widget class="QLabel" name="label_created_by"> <widget class="QLabel" name="labelCreatedBy">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -685,7 +685,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="5"> <item row="0" column="5">
<widget class="QLabel" name="label_created_by_val"> <widget class="QLabel" name="labelCreatedByVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -698,7 +698,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_added_on"> <widget class="QLabel" name="labelAddedOn">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -714,7 +714,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLabel" name="label_added_on_val"> <widget class="QLabel" name="labelAddedOnVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -727,7 +727,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="2">
<widget class="QLabel" name="label_completed_on"> <widget class="QLabel" name="labelCompletedOn">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -743,7 +743,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="3"> <item row="1" column="3">
<widget class="QLabel" name="label_completed_on_val"> <widget class="QLabel" name="labelCompletedOnVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -756,7 +756,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="4"> <item row="1" column="4">
<widget class="QLabel" name="label_9"> <widget class="QLabel" name="labelCreatedOn">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -772,7 +772,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="5"> <item row="1" column="5">
<widget class="QLabel" name="lbl_creationDate"> <widget class="QLabel" name="labelCreatedOnVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -785,7 +785,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="hash_lbl2"> <widget class="QLabel" name="labelHash">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -801,7 +801,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="1" colspan="5"> <item row="2" column="1" colspan="5">
<widget class="QLabel" name="hash_lbl"> <widget class="QLabel" name="labelHashVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -817,7 +817,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="savePath_lbl"> <widget class="QLabel" name="labelSavePath">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -833,7 +833,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="1" colspan="5"> <item row="3" column="1" colspan="5">
<widget class="QLabel" name="save_path"> <widget class="QLabel" name="labelSavePathVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -852,7 +852,7 @@
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="comment_lbl2"> <widget class="QLabel" name="labelComment">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -868,7 +868,7 @@
</widget> </widget>
</item> </item>
<item row="4" column="1" colspan="5"> <item row="4" column="1" colspan="5">
<widget class="QLabel" name="comment_text"> <widget class="QLabel" name="labelCommentVal">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -1062,7 +1062,7 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="pageSpeed"> <widget class="QWidget" name="pageSpeed">
<layout class="QVBoxLayout" name="speed_layout"> <layout class="QVBoxLayout" name="speedLayout">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>

94
src/gui/properties/proplistdelegate.cpp

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#include "proplistdelegate.h" #include "proplistdelegate.h"
@ -83,53 +81,53 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong())); QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong()));
break; break;
case PROGRESS: { case PROGRESS: {
if (index.data().toDouble() < 0) if (index.data().toDouble() < 0)
break; break;
QStyleOptionProgressBar newopt; QStyleOptionProgressBar newopt;
qreal progress = index.data().toDouble() * 100.; qreal progress = index.data().toDouble() * 100.;
newopt.rect = opt.rect; newopt.rect = opt.rect;
newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%"); newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + "%");
newopt.progress = int(progress); newopt.progress = int(progress);
newopt.maximum = 100; newopt.maximum = 100;
newopt.minimum = 0; newopt.minimum = 0;
newopt.textVisible = true; newopt.textVisible = true;
if (index.sibling(index.row(), PRIORITY).data().toInt() == prio::IGNORED) { if (index.sibling(index.row(), PRIORITY).data().toInt() == prio::IGNORED) {
newopt.state &= ~QStyle::State_Enabled; newopt.state &= ~QStyle::State_Enabled;
newopt.palette = progressBarDisabledPalette(); newopt.palette = progressBarDisabledPalette();
} }
else { else {
newopt.state |= QStyle::State_Enabled; newopt.state |= QStyle::State_Enabled;
} }
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter); QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
#else #else
// XXX: To avoid having the progress text on the right of the bar // XXX: To avoid having the progress text on the right of the bar
QProxyStyle("fusion").drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0); QProxyStyle("fusion").drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
#endif #endif
}
break;
case PRIORITY: {
QString text = "";
switch (index.data().toInt()) {
case prio::MIXED:
text = tr("Mixed", "Mixed (priorities");
break;
case prio::IGNORED:
text = tr("Not downloaded");
break;
case prio::HIGH:
text = tr("High", "High (priority)");
break;
case prio::MAXIMUM:
text = tr("Maximum", "Maximum (priority)");
break;
default:
text = tr("Normal", "Normal (priority)");
break;
} }
QItemDelegate::drawDisplay(painter, opt, option.rect, text); break;
case PRIORITY: {
QString text = "";
switch (index.data().toInt()) {
case prio::MIXED:
text = tr("Mixed", "Mixed (priorities");
break;
case prio::IGNORED:
text = tr("Not downloaded");
break;
case prio::HIGH:
text = tr("High", "High (priority)");
break;
case prio::MAXIMUM:
text = tr("Maximum", "Maximum (priority)");
break;
default:
text = tr("Normal", "Normal (priority)");
break;
}
QItemDelegate::drawDisplay(painter, opt, option.rect, text);
} }
break; break;
case AVAILABILITY: { case AVAILABILITY: {
@ -174,16 +172,16 @@ void PropListDelegate::setEditorData(QWidget *editor, const QModelIndex &index)
QWidget *PropListDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const QWidget *PropListDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const
{ {
if (index.column() != PRIORITY) return 0; if (index.column() != PRIORITY) return nullptr;
if (m_properties) { if (m_properties) {
BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent(); BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent();
if (!torrent || !torrent->hasMetadata() || torrent->isSeed()) if (!torrent || !torrent->hasMetadata() || torrent->isSeed())
return 0; return nullptr;
} }
if (index.data().toInt() == prio::MIXED) if (index.data().toInt() == prio::MIXED)
return 0; return nullptr;
QComboBox *editor = new QComboBox(parent); QComboBox *editor = new QComboBox(parent);
editor->setFocusPolicy(Qt::StrongFocus); editor->setFocusPolicy(Qt::StrongFocus);

13
src/gui/properties/proplistdelegate.h

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#ifndef PROPLISTDELEGATE_H #ifndef PROPLISTDELEGATE_H
@ -33,10 +31,10 @@
#include <QItemDelegate> #include <QItemDelegate>
class QPainter; class QAbstractItemModel;
class QModelIndex; class QModelIndex;
class QPainter;
class QStyleOptionViewItem; class QStyleOptionViewItem;
class QAbstractItemModel;
class PropertiesWidget; class PropertiesWidget;
// Defines for properties list columns // Defines for properties list columns
@ -50,7 +48,7 @@ enum PropColumn
AVAILABILITY AVAILABILITY
}; };
class PropListDelegate: public QItemDelegate class PropListDelegate : public QItemDelegate
{ {
Q_OBJECT Q_OBJECT
@ -72,5 +70,4 @@ private:
PropertiesWidget *m_properties; PropertiesWidget *m_properties;
}; };
#endif #endif // PROPLISTDELEGATE_H

169
src/gui/properties/proptabbar.cpp

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2010 Christophe Dumez * Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,120 +24,121 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#include "proptabbar.h"
#include <QButtonGroup> #include <QButtonGroup>
#include <QKeySequence>
#include <QPushButton> #include <QPushButton>
#include <QSpacerItem> #include <QSpacerItem>
#include <QKeySequence>
#include "proptabbar.h"
#include "guiiconprovider.h" #include "guiiconprovider.h"
PropTabBar::PropTabBar(QWidget *parent) : PropTabBar::PropTabBar(QWidget *parent)
QHBoxLayout(parent), m_currentIndex(-1) : QHBoxLayout(parent)
, m_currentIndex(-1)
{ {
setAlignment(Qt::AlignLeft | Qt::AlignCenter); setAlignment(Qt::AlignLeft | Qt::AlignCenter);
setSpacing(3); setSpacing(3);
m_btnGroup = new QButtonGroup(this); m_btnGroup = new QButtonGroup(this);
// General tab // General tab
QPushButton *main_infos_button = new QPushButton( QPushButton *mainInfosButton = new QPushButton(
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
GuiIconProvider::instance()->getIcon("document-properties"), GuiIconProvider::instance()->getIcon("document-properties"),
#endif #endif
tr("General"), parent); tr("General"), parent);
main_infos_button->setShortcut(Qt::ALT + Qt::Key_G); mainInfosButton->setShortcut(Qt::ALT + Qt::Key_G);
addWidget(main_infos_button); addWidget(mainInfosButton);
m_btnGroup->addButton(main_infos_button, MAIN_TAB); m_btnGroup->addButton(mainInfosButton, MainTab);
// Trackers tab // Trackers tab
QPushButton *trackers_button = new QPushButton( QPushButton *trackersButton = new QPushButton(
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
GuiIconProvider::instance()->getIcon("network-server"), GuiIconProvider::instance()->getIcon("network-server"),
#endif #endif
tr("Trackers"), parent); tr("Trackers"), parent);
trackers_button->setShortcut(Qt::ALT + Qt::Key_C); trackersButton->setShortcut(Qt::ALT + Qt::Key_C);
addWidget(trackers_button); addWidget(trackersButton);
m_btnGroup->addButton(trackers_button, TRACKERS_TAB); m_btnGroup->addButton(trackersButton, TrackersTab);
// Peers tab // Peers tab
QPushButton *peers_button = new QPushButton( QPushButton *peersButton = new QPushButton(
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
GuiIconProvider::instance()->getIcon("edit-find-user"), GuiIconProvider::instance()->getIcon("edit-find-user"),
#endif #endif
tr("Peers"), parent); tr("Peers"), parent);
peers_button->setShortcut(Qt::ALT + Qt::Key_R); peersButton->setShortcut(Qt::ALT + Qt::Key_R);
addWidget(peers_button); addWidget(peersButton);
m_btnGroup->addButton(peers_button, PEERS_TAB); m_btnGroup->addButton(peersButton, PeersTab);
// URL seeds tab // URL seeds tab
QPushButton *urlseeds_button = new QPushButton( QPushButton *URLSeedsButton = new QPushButton(
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
GuiIconProvider::instance()->getIcon("network-server"), GuiIconProvider::instance()->getIcon("network-server"),
#endif #endif
tr("HTTP Sources"), parent); tr("HTTP Sources"), parent);
urlseeds_button->setShortcut(Qt::ALT + Qt::Key_B); URLSeedsButton->setShortcut(Qt::ALT + Qt::Key_B);
addWidget(urlseeds_button); addWidget(URLSeedsButton);
m_btnGroup->addButton(urlseeds_button, URLSEEDS_TAB); m_btnGroup->addButton(URLSeedsButton, URLSeedsTab);
// Files tab // Files tab
QPushButton *files_button = new QPushButton( QPushButton *filesButton = new QPushButton(
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
GuiIconProvider::instance()->getIcon("inode-directory"), GuiIconProvider::instance()->getIcon("inode-directory"),
#endif #endif
tr("Content"), parent); tr("Content"), parent);
files_button->setShortcut(Qt::ALT + Qt::Key_Z); filesButton->setShortcut(Qt::ALT + Qt::Key_Z);
addWidget(files_button); addWidget(filesButton);
m_btnGroup->addButton(files_button, FILES_TAB); m_btnGroup->addButton(filesButton, FilesTab);
// Spacer // Spacer
addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed)); addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
// Speed tab // Speed tab
QPushButton *speed_button = new QPushButton( QPushButton *speedButton = new QPushButton(
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
GuiIconProvider::instance()->getIcon("office-chart-line"), GuiIconProvider::instance()->getIcon("office-chart-line"),
#endif #endif
tr("Speed"), parent); tr("Speed"), parent);
speed_button->setShortcut(Qt::ALT + Qt::Key_D); speedButton->setShortcut(Qt::ALT + Qt::Key_D);
addWidget(speed_button); addWidget(speedButton);
m_btnGroup->addButton(speed_button, SPEED_TAB); m_btnGroup->addButton(speedButton, SpeedTab);
// SIGNAL/SLOT // SIGNAL/SLOT
connect(m_btnGroup, SIGNAL(buttonClicked(int)), SLOT(setCurrentIndex(int))); connect(m_btnGroup, SIGNAL(buttonClicked(int)), SLOT(setCurrentIndex(int)));
// Disable buttons focus // Disable buttons focus
foreach (QAbstractButton *btn, m_btnGroup->buttons()) { foreach (QAbstractButton *btn, m_btnGroup->buttons())
btn->setFocusPolicy(Qt::NoFocus); btn->setFocusPolicy(Qt::NoFocus);
}
} }
PropTabBar::~PropTabBar() { PropTabBar::~PropTabBar()
delete m_btnGroup; {
delete m_btnGroup;
} }
int PropTabBar::currentIndex() const int PropTabBar::currentIndex() const
{ {
return m_currentIndex; return m_currentIndex;
} }
void PropTabBar::setCurrentIndex(int index) void PropTabBar::setCurrentIndex(int index)
{ {
if (index >= m_btnGroup->buttons().size()) if (index >= m_btnGroup->buttons().size())
index = 0; index = 0;
// If asked to hide or if the currently selected tab is clicked // If asked to hide or if the currently selected tab is clicked
if (index < 0 || m_currentIndex == index) { if (index < 0 || m_currentIndex == index) {
if (m_currentIndex >= 0) {
m_btnGroup->button(m_currentIndex)->setDown(false);
m_currentIndex = -1;
emit visibilityToggled(false);
}
return;
}
// Unselect previous tab
if (m_currentIndex >= 0) { if (m_currentIndex >= 0) {
m_btnGroup->button(m_currentIndex)->setDown(false); m_btnGroup->button(m_currentIndex)->setDown(false);
m_currentIndex = -1; }
emit visibilityToggled(false); else {
// Nothing was selected, show!
emit visibilityToggled(true);
} }
return; // Select the new button
} m_btnGroup->button(index)->setDown(true);
// Unselect previous tab m_currentIndex = index;
if (m_currentIndex >= 0) { // Emit the signal
m_btnGroup->button(m_currentIndex)->setDown(false); emit tabChanged(index);
} else {
// Nothing was selected, show!
emit visibilityToggled(true);
}
// Select the new button
m_btnGroup->button(index)->setDown(true);
m_currentIndex = index;
// Emit the signal
emit tabChanged(index);
} }

36
src/gui/properties/proptabbar.h

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2010 Christophe Dumez * Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#ifndef PROPTABBAR_H #ifndef PROPTABBAR_H
@ -33,9 +31,7 @@
#include <QHBoxLayout> #include <QHBoxLayout>
QT_BEGIN_NAMESPACE
class QButtonGroup; class QButtonGroup;
QT_END_NAMESPACE
class PropTabBar : public QHBoxLayout class PropTabBar : public QHBoxLayout
{ {
@ -43,24 +39,30 @@ class PropTabBar : public QHBoxLayout
Q_DISABLE_COPY(PropTabBar) Q_DISABLE_COPY(PropTabBar)
public: public:
enum PropertyTab {MAIN_TAB, TRACKERS_TAB, PEERS_TAB, URLSEEDS_TAB, FILES_TAB, SPEED_TAB}; enum PropertyTab
{
MainTab,
TrackersTab,
PeersTab,
URLSeedsTab,
FilesTab,
SpeedTab
};
public: explicit PropTabBar(QWidget *parent = nullptr);
explicit PropTabBar(QWidget *parent = 0); ~PropTabBar();
~PropTabBar(); int currentIndex() const;
int currentIndex() const;
signals: signals:
void tabChanged(int index); void tabChanged(int index);
void visibilityToggled(bool visible); void visibilityToggled(bool visible);
public slots: public slots:
void setCurrentIndex(int index); void setCurrentIndex(int index);
private: private:
QButtonGroup *m_btnGroup; QButtonGroup *m_btnGroup;
int m_currentIndex; int m_currentIndex;
}; };
#endif // PROPTABBAR_H #endif // PROPTABBAR_H

28
src/gui/properties/speedplotview.cpp

@ -191,20 +191,20 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
Utils::Misc::friendlyUnit(0, true) Utils::Misc::friendlyUnit(0, true)
}; };
int yAxeWidth = 0; int yAxisWidth = 0;
for (const QString &label : speedLabels) for (const QString &label : speedLabels)
if (fontMetrics.width(label) > yAxeWidth) if (fontMetrics.width(label) > yAxisWidth)
yAxeWidth = fontMetrics.width(label); yAxisWidth = fontMetrics.width(label);
int i = 0; int i = 0;
for (const QString &label : speedLabels) { for (const QString &label : speedLabels) {
QRectF labelRect(rect.topLeft() + QPointF(-yAxeWidth, (i++) * 0.25 * rect.height() - fontMetrics.height()), QRectF labelRect(rect.topLeft() + QPointF(-yAxisWidth, (i++) * 0.25 * rect.height() - fontMetrics.height()),
QSizeF(2 * yAxeWidth, fontMetrics.height())); QSizeF(2 * yAxisWidth, fontMetrics.height()));
painter.drawText(labelRect, label, Qt::AlignRight | Qt::AlignTop); painter.drawText(labelRect, label, Qt::AlignRight | Qt::AlignTop);
} }
// draw grid lines // draw grid lines
rect.adjust(yAxeWidth + 4, 0, 0, 0); rect.adjust(yAxisWidth + 4, 0, 0, 0);
QPen gridPen; QPen gridPen;
gridPen.setStyle(Qt::DashLine); gridPen.setStyle(Qt::DashLine);
@ -236,18 +236,16 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
boost::circular_buffer<PointData> &queue = getCurrentData(); boost::circular_buffer<PointData> &queue = getCurrentData();
for (int id = UP; id < NB_GRAPHS; ++id) { for (int id = UP; id < NB_GRAPHS; ++id) {
if (!m_properties[static_cast<GraphID>(id)].enable) if (!m_properties[static_cast<GraphID>(id)].enable)
continue; continue;
QVector<QPoint> points; QVector<QPoint> points;
for (int i = int(queue.size()) - 1, j = 0; i >= 0 && j <= m_viewablePointsCount; --i, ++j) { for (int i = int(queue.size()) - 1, j = 0; i >= 0 && j <= m_viewablePointsCount; --i, ++j) {
int new_x = rect.right() - j * xTickSize; int newX = rect.right() - j * xTickSize;
int new_y = rect.bottom() - queue[i].y[id] * yMultiplier; int newY = rect.bottom() - queue[i].y[id] * yMultiplier;
points.push_back(QPoint(new_x, new_y)); points.push_back(QPoint(newX, newY));
} }
painter.setPen(m_properties[static_cast<GraphID>(id)].pen); painter.setPen(m_properties[static_cast<GraphID>(id)].pen);
@ -260,7 +258,6 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
double legendHeight = 0; double legendHeight = 0;
int legendWidth = 0; int legendWidth = 0;
for (const auto &property : m_properties) { for (const auto &property : m_properties) {
if (!property.enable) if (!property.enable)
continue; continue;
@ -276,7 +273,6 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
i = 0; i = 0;
for (const auto &property : m_properties) { for (const auto &property : m_properties) {
if (!property.enable) if (!property.enable)
continue; continue;
@ -293,10 +289,12 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
SpeedPlotView::GraphProperties::GraphProperties() SpeedPlotView::GraphProperties::GraphProperties()
: enable(false) : enable(false)
{} {
}
SpeedPlotView::GraphProperties::GraphProperties(const QString &name, const QPen &pen, bool enable) SpeedPlotView::GraphProperties::GraphProperties(const QString &name, const QPen &pen, bool enable)
: name(name) : name(name)
, pen(pen) , pen(pen)
, enable(enable) , enable(enable)
{} {
}

10
src/gui/properties/speedplotview.h

@ -55,6 +55,7 @@ public:
DHT_DOWN, DHT_DOWN,
TRACKER_UP, TRACKER_UP,
TRACKER_DOWN, TRACKER_DOWN,
NB_GRAPHS NB_GRAPHS
}; };
@ -82,7 +83,7 @@ public:
void replot(); void replot();
protected: protected:
virtual void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event) override;
private: private:
enum PeriodInSeconds enum PeriodInSeconds
@ -110,6 +111,9 @@ private:
bool enable; bool enable;
}; };
int maxYValue();
boost::circular_buffer<PointData> &getCurrentData();
boost::circular_buffer<PointData> m_data5Min; boost::circular_buffer<PointData> m_data5Min;
boost::circular_buffer<PointData> m_data30Min; boost::circular_buffer<PointData> m_data30Min;
boost::circular_buffer<PointData> m_data6Hour; boost::circular_buffer<PointData> m_data6Hour;
@ -120,10 +124,6 @@ private:
int m_counter30Min; int m_counter30Min;
int m_counter6Hour; int m_counter6Hour;
int maxYValue();
boost::circular_buffer<PointData> &getCurrentData();
}; };
#endif // SPEEDPLOTVIEW_H #endif // SPEEDPLOTVIEW_H

2
src/gui/properties/speedwidget.cpp

@ -38,10 +38,10 @@
#include <libtorrent/session_status.hpp> #include <libtorrent/session_status.hpp>
#include "propertieswidget.h"
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "base/bittorrent/sessionstatus.h" #include "base/bittorrent/sessionstatus.h"
#include "base/preferences.h" #include "base/preferences.h"
#include "propertieswidget.h"
ComboBoxMenuButton::ComboBoxMenuButton(QWidget *parent, QMenu *menu) ComboBoxMenuButton::ComboBoxMenuButton(QWidget *parent, QMenu *menu)
: QComboBox(parent) : QComboBox(parent)

4
src/gui/properties/speedwidget.h

@ -29,8 +29,8 @@
#ifndef SPEEDWIDGET_H #ifndef SPEEDWIDGET_H
#define SPEEDWIDGET_H #define SPEEDWIDGET_H
#include <QWidget>
#include <QComboBox> #include <QComboBox>
#include <QWidget>
#include "speedplotview.h" #include "speedplotview.h"
@ -44,6 +44,7 @@ class PropertiesWidget;
class ComboBoxMenuButton : public QComboBox class ComboBoxMenuButton : public QComboBox
{ {
Q_OBJECT Q_OBJECT
public: public:
ComboBoxMenuButton(QWidget *parent, QMenu *menu); ComboBoxMenuButton(QWidget *parent, QMenu *menu);
virtual void showPopup(); virtual void showPopup();
@ -56,6 +57,7 @@ private:
class SpeedWidget : public QWidget class SpeedWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
SpeedWidget(PropertiesWidget *parent); SpeedWidget(PropertiesWidget *parent);
~SpeedWidget(); ~SpeedWidget();

12
src/gui/properties/trackerlist.cpp

@ -399,13 +399,13 @@ void TrackerList::copyTrackerUrl()
QList<QTreeWidgetItem *> selectedTrackerItems = getSelectedTrackerItems(); QList<QTreeWidgetItem *> selectedTrackerItems = getSelectedTrackerItems();
if (selectedTrackerItems.isEmpty()) return; if (selectedTrackerItems.isEmpty()) return;
QStringList URLsToCopy; QStringList urlsToCopy;
foreach (QTreeWidgetItem *item, selectedTrackerItems) { foreach (QTreeWidgetItem *item, selectedTrackerItems) {
QString trackerURL = item->data(COL_URL, Qt::DisplayRole).toString(); QString trackerURL = item->data(COL_URL, Qt::DisplayRole).toString();
qDebug() << QString("Copy: ") + trackerURL; qDebug() << QString("Copy: ") + trackerURL;
URLsToCopy << trackerURL; urlsToCopy << trackerURL;
} }
QApplication::clipboard()->setText(URLsToCopy.join("\n")); QApplication::clipboard()->setText(urlsToCopy.join("\n"));
} }
@ -420,10 +420,10 @@ void TrackerList::deleteSelectedTrackers()
QList<QTreeWidgetItem *> selectedTrackerItems = getSelectedTrackerItems(); QList<QTreeWidgetItem *> selectedTrackerItems = getSelectedTrackerItems();
if (selectedTrackerItems.isEmpty()) return; if (selectedTrackerItems.isEmpty()) return;
QStringList URLsToRemove; QStringList urlsToRemove;
foreach (QTreeWidgetItem *item, selectedTrackerItems) { foreach (QTreeWidgetItem *item, selectedTrackerItems) {
QString trackerURL = item->data(COL_URL, Qt::DisplayRole).toString(); QString trackerURL = item->data(COL_URL, Qt::DisplayRole).toString();
URLsToRemove << trackerURL; urlsToRemove << trackerURL;
m_trackerItems.remove(trackerURL); m_trackerItems.remove(trackerURL);
delete item; delete item;
} }
@ -432,7 +432,7 @@ void TrackerList::deleteSelectedTrackers()
QList<BitTorrent::TrackerEntry> remainingTrackers; QList<BitTorrent::TrackerEntry> remainingTrackers;
QList<BitTorrent::TrackerEntry> trackers = torrent->trackers(); QList<BitTorrent::TrackerEntry> trackers = torrent->trackers();
foreach (const BitTorrent::TrackerEntry &entry, trackers) { foreach (const BitTorrent::TrackerEntry &entry, trackers) {
if (!URLsToRemove.contains(entry.url())) if (!urlsToRemove.contains(entry.url()))
remainingTrackers.push_back(entry); remainingTrackers.push_back(entry);
} }

34
src/gui/properties/trackersadditiondlg.cpp

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,22 +24,20 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#include "trackersadditiondlg.h" #include "trackersadditiondlg.h"
#include <QStringList>
#include <QMessageBox>
#include <QFile> #include <QFile>
#include <QMessageBox>
#include <QStringList>
#include <QUrl> #include <QUrl>
#include "base/utils/misc.h"
#include "base/utils/fs.h"
#include "base/net/downloadmanager.h"
#include "base/net/downloadhandler.h"
#include "base/bittorrent/trackerentry.h"
#include "base/bittorrent/torrenthandle.h" #include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/trackerentry.h"
#include "base/net/downloadhandler.h"
#include "base/net/downloadmanager.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "guiiconprovider.h" #include "guiiconprovider.h"
#include "ui_trackersadditiondlg.h" #include "ui_trackersadditiondlg.h"
@ -75,14 +73,14 @@ void TrackersAdditionDlg::on_uTorrentListButton_clicked()
Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(m_ui->list_url->text(), true); Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(m_ui->list_url->text(), true);
connect(handler, SIGNAL(downloadFinished(QString, QString)), this, SLOT(parseUTorrentList(QString, QString))); connect(handler, SIGNAL(downloadFinished(QString, QString)), this, SLOT(parseUTorrentList(QString, QString)));
connect(handler, SIGNAL(downloadFailed(QString, QString)), this, SLOT(getTrackerError(QString, QString))); connect(handler, SIGNAL(downloadFailed(QString, QString)), this, SLOT(getTrackerError(QString, QString)));
//Just to show that it takes times // Just to show that it takes times
setCursor(Qt::WaitCursor); setCursor(Qt::WaitCursor);
} }
void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path) void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path)
{ {
QFile list_file(path); QFile listFile(path);
if (!list_file.open(QFile::ReadOnly)) { if (!listFile.open(QFile::ReadOnly)) {
QMessageBox::warning(this, tr("I/O Error"), tr("Error while trying to open the downloaded file."), QMessageBox::Ok); QMessageBox::warning(this, tr("I/O Error"), tr("Error while trying to open the downloaded file."), QMessageBox::Ok);
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
m_ui->uTorrentListButton->setEnabled(true); m_ui->uTorrentListButton->setEnabled(true);
@ -94,8 +92,8 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path
QList<BitTorrent::TrackerEntry> existingTrackers = m_torrent->trackers(); QList<BitTorrent::TrackerEntry> existingTrackers = m_torrent->trackers();
// Load from current user list // Load from current user list
QStringList tmp = m_ui->trackers_list->toPlainText().split("\n"); QStringList tmp = m_ui->trackers_list->toPlainText().split("\n");
foreach (const QString &user_url, tmp) { foreach (const QString &userURL, tmp) {
BitTorrent::TrackerEntry userTracker(user_url); BitTorrent::TrackerEntry userTracker(userURL);
if (!existingTrackers.contains(userTracker)) if (!existingTrackers.contains(userTracker))
existingTrackers << userTracker; existingTrackers << userTracker;
} }
@ -104,8 +102,8 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path
if (!m_ui->trackers_list->toPlainText().isEmpty() && !m_ui->trackers_list->toPlainText().endsWith("\n")) if (!m_ui->trackers_list->toPlainText().isEmpty() && !m_ui->trackers_list->toPlainText().endsWith("\n"))
m_ui->trackers_list->insertPlainText("\n"); m_ui->trackers_list->insertPlainText("\n");
int nb = 0; int nb = 0;
while (!list_file.atEnd()) { while (!listFile.atEnd()) {
const QString line = list_file.readLine().trimmed(); const QString line = listFile.readLine().trimmed();
if (line.isEmpty()) continue; if (line.isEmpty()) continue;
BitTorrent::TrackerEntry newTracker(line); BitTorrent::TrackerEntry newTracker(line);
if (!existingTrackers.contains(newTracker)) { if (!existingTrackers.contains(newTracker)) {
@ -114,7 +112,7 @@ void TrackersAdditionDlg::parseUTorrentList(const QString &, const QString &path
} }
} }
// Clean up // Clean up
list_file.close(); listFile.close();
Utils::Fs::forceRemove(path); Utils::Fs::forceRemove(path);
//To restore the cursor ... //To restore the cursor ...
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);

6
src/gui/properties/trackersadditiondlg.h

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#ifndef TRACKERSADDITION_H #ifndef TRACKERSADDITION_H
@ -67,4 +65,4 @@ private:
BitTorrent::TorrentHandle *const m_torrent; BitTorrent::TorrentHandle *const m_torrent;
}; };
#endif #endif // TRACKERSADDITION_H

Loading…
Cancel
Save