Code clean up

This commit is contained in:
Christophe Dumez
2010-11-13 21:15:52 +00:00
parent 9c13ed2635
commit 126e2e7c75
31 changed files with 279 additions and 309 deletions

View File

@@ -195,8 +195,8 @@ void PeerListWidget::banSelectedPeers(QStringList peer_ips) {
if(ret) return;
foreach(const QString &ip, peer_ips) {
qDebug("Banning peer %s...", ip.toLocal8Bit().data());
properties->getBTSession()->addConsoleMessage(tr("Manually banning peer %1...").arg(ip));
properties->getBTSession()->banIP(ip);
QBtSession::instance()->addConsoleMessage(tr("Manually banning peer %1...").arg(ip));
QBtSession::instance()->banIP(ip);
}
// Refresh list
loadPeers(properties->getCurrentTorrent());

View File

@@ -49,14 +49,15 @@
#include "torrentfilesmodel.h"
#include "peerlistwidget.h"
#include "trackerlist.h"
#include "GUI.h"
#include "mainwindow.h"
#include "downloadedpiecesbar.h"
#include "pieceavailabilitybar.h"
#include "qinisettings.h"
#include "proptabbar.h"
PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferListWidget *transferList, QBtSession* BTSession):
QWidget(parent), transferList(transferList), main_window(main_window), BTSession(BTSession) {
PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, TransferListWidget *transferList):
QWidget(parent), transferList(transferList), main_window(main_window) {
setupUi(this);
state = VISIBLE;
setEnabled(false);
@@ -79,8 +80,8 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &)));
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
connect(stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData()));
connect(BTSession, SIGNAL(savePathChanged(QTorrentHandle&)), this, SLOT(updateSavePath(QTorrentHandle&)));
connect(BTSession, SIGNAL(metadataReceived(QTorrentHandle&)), this, SLOT(updateTorrentInfos(QTorrentHandle&)));
connect(QBtSession::instance(), SIGNAL(savePathChanged(QTorrentHandle&)), this, SLOT(updateSavePath(QTorrentHandle&)));
connect(QBtSession::instance(), SIGNAL(metadataReceived(QTorrentHandle&)), this, SLOT(updateTorrentInfos(QTorrentHandle&)));
// Downloaded pieces progress bar
downloaded_pieces = new DownloadedPiecesBar(this);
@@ -196,10 +197,6 @@ QTorrentHandle PropertiesWidget::getCurrentTorrent() const {
return h;
}
QBtSession* PropertiesWidget::getBTSession() const {
return BTSession;
}
void PropertiesWidget::updateSavePath(QTorrentHandle& _h) {
if(h.is_valid() && h == _h) {
QString p;
@@ -341,7 +338,7 @@ void PropertiesWidget::loadDynamicData() {
// Update next announce time
reannounce_lbl->setText(h.next_announce());
// Update ratio info
const double ratio = BTSession->getRealRatio(h.hash());
const double ratio = QBtSession::instance()->getRealRatio(h.hash());
if(ratio > 100.)
shareRatio->setText(QString::fromUtf8(""));
else
@@ -720,7 +717,7 @@ void PropertiesWidget::renameSelectedFile() {
}
QDir savePath(misc::expandPath(save_path_dir));
// Actually move storage
if(!BTSession->useTemporaryFolder() || h.is_seed()) {
if(!QBtSession::instance()->useTemporaryFolder() || h.is_seed()) {
if(!savePath.exists()) savePath.mkpath(savePath.absolutePath());
h.move_storage(savePath.absolutePath());
}

View File

@@ -38,14 +38,13 @@
class TransferListWidget;
class QTimer;
class QBtSession;
class TorrentFilesModel;
class PropListDelegate;
class QAction;
class torrent_file;
class PeerListWidget;
class TrackerList;
class GUI;
class MainWindow;
class DownloadedPiecesBar;
class PieceAvailabilityBar;
class PropTabBar;
@@ -58,10 +57,9 @@ public:
enum SlideState {REDUCED, VISIBLE};
public:
PropertiesWidget(QWidget *parent, GUI* main_window, TransferListWidget *transferList, QBtSession* BTSession);
PropertiesWidget(QWidget *parent, MainWindow* main_window, TransferListWidget *transferList);
~PropertiesWidget();
QTorrentHandle getCurrentTorrent() const;
QBtSession* getBTSession() const;
TrackerList* getTrackerList() const { return trackerList; }
PeerListWidget* getPeerList() const { return peersList; }
QTreeView* getFilesList() const { return filesList; }
@@ -97,10 +95,9 @@ public slots:
private:
TransferListWidget *transferList;
GUI *main_window;
MainWindow *main_window;
QTorrentHandle h;
QTimer *refreshTimer;
QBtSession* BTSession;
SlideState state;
TorrentFilesModel *PropListModel;
PropListDelegate *PropDelegate;

View File

@@ -200,7 +200,7 @@ void TrackerList::loadStickyItems(const QTorrentHandle &h) {
++nb_pex;
}
// load DHT information
if(properties->getBTSession()->isDHTEnabled() && h.has_metadata() && !h.priv()) {
if(QBtSession::instance()->isDHTEnabled() && h.has_metadata() && !h.priv()) {
dht_item->setText(COL_STATUS, tr("Working"));
} else {
dht_item->setText(COL_STATUS, tr("Disabled"));
@@ -210,13 +210,13 @@ void TrackerList::loadStickyItems(const QTorrentHandle &h) {
dht_item->setText(COL_MSG, tr("This torrent is private"));
}
// Load PeX Information
if(properties->getBTSession()->isPexEnabled())
if(QBtSession::instance()->isPexEnabled())
pex_item->setText(COL_STATUS, tr("Working"));
else
pex_item->setText(COL_STATUS, tr("Disabled"));
pex_item->setText(COL_PEERS, QString::number(nb_pex));
// Load LSD Information
if(properties->getBTSession()->isLSDEnabled())
if(QBtSession::instance()->isLSDEnabled())
lsd_item->setText(COL_STATUS, tr("Working"));
else
lsd_item->setText(COL_STATUS, tr("Disabled"));
@@ -229,7 +229,7 @@ void TrackerList::loadTrackers() {
if(!h.is_valid()) return;
loadStickyItems(h);
// Load actual trackers information
QHash<QString, TrackerInfos> trackers_data = properties->getBTSession()->getTrackersInfo(h.hash());
QHash<QString, TrackerInfos> trackers_data = QBtSession::instance()->getTrackersInfo(h.hash());
QStringList old_trackers_urls = tracker_items.keys();
const std::vector<announce_entry> trackers = h.trackers();
for(std::vector<announce_entry>::const_iterator it = trackers.begin(); it != trackers.end(); it++) {
@@ -300,8 +300,6 @@ void TrackerList::askForTrackers(){
h.force_reannounce();
// Reload tracker list
loadTrackers();
// XXX: I don't think this is necessary now
//BTSession->saveTrackerFile(h.hash());
}
}
@@ -336,8 +334,6 @@ void TrackerList::deleteSelectedTrackers(){
h.force_reannounce();
// Reload Trackers
loadTrackers();
//XXX: I don't think this is necessary
//BTSession->saveTrackerFile(h.hash());
}
void TrackerList::showTrackerListMenu(QPoint) {