Coding style clean up

This commit is contained in:
Christophe Dumez
2012-02-20 19:30:53 +02:00
parent 9acac03f14
commit a8a7b61ea9
77 changed files with 2194 additions and 2194 deletions

View File

@@ -59,7 +59,7 @@ public:
QString getIP() const {
QHostAddress ip(lineIP->text());
if(!ip.isNull()) {
if (!ip.isNull()) {
// QHostAddress::toString() cleans up the IP for libtorrent
return ip.toString();
}
@@ -73,11 +73,11 @@ public:
static libtorrent::asio::ip::tcp::endpoint askForPeerEndpoint() {
libtorrent::asio::ip::tcp::endpoint ep;
PeerAdditionDlg dlg;
if(dlg.exec() == QDialog::Accepted) {
if (dlg.exec() == QDialog::Accepted) {
QString ip = dlg.getIP();
boost::system::error_code ec;
libtorrent::address addr = libtorrent::address::from_string(qPrintable(ip), ec);
if(ec) {
if (ec) {
qDebug("Unable to parse the provided IP: %s", qPrintable(ip));
return ep;
}
@@ -90,7 +90,7 @@ public:
protected slots:
void validateInput() {
if(getIP().isEmpty()) {
if (getIP().isEmpty()) {
QMessageBox::warning(this, tr("Invalid IP"),
tr("The IP you provided is invalid."),
QMessageBox::Ok);

View File

@@ -92,30 +92,30 @@ PeerListWidget::~PeerListWidget() {
delete proxyModel;
delete listModel;
delete listDelegate;
if(resolver)
if (resolver)
delete resolver;
}
void PeerListWidget::updatePeerHostNameResolutionState() {
if(Preferences().resolvePeerHostNames()) {
if(!resolver) {
if (Preferences().resolvePeerHostNames()) {
if (!resolver) {
resolver = new ReverseResolution(this);
connect(resolver, SIGNAL(ip_resolved(QString,QString)), this, SLOT(handleResolved(QString,QString)));
loadPeers(properties->getCurrentTorrent(), true);
}
} else {
if(resolver) {
if (resolver) {
delete resolver;
}
}
}
void PeerListWidget::updatePeerCountryResolutionState() {
if(Preferences().resolvePeerCountries() != display_flags) {
if (Preferences().resolvePeerCountries() != display_flags) {
display_flags = !display_flags;
if(display_flags) {
if (display_flags) {
const QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid()) return;
if (!h.is_valid()) return;
loadPeers(h);
}
}
@@ -125,17 +125,17 @@ void PeerListWidget::showPeerListMenu(QPoint) {
QMenu menu;
bool empty_menu = true;
QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid()) return;
if (!h.is_valid()) return;
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
QStringList selectedPeerIPs;
foreach(const QModelIndex &index, selectedIndexes) {
foreach (const QModelIndex &index, selectedIndexes) {
int row = proxyModel->mapToSource(index).row();
QString myip = listModel->data(listModel->index(row, PeerListDelegate::IP_HIDDEN)).toString();
selectedPeerIPs << myip;
}
// Add Peer Action
QAction *addPeerAct = 0;
if(!h.is_queued() && !h.is_checking()) {
if (!h.is_queued() && !h.is_checking()) {
addPeerAct = menu.addAction(IconProvider::instance()->getIcon("user-group-new"), tr("Add a new peer..."));
empty_menu = false;
}
@@ -144,7 +144,7 @@ void PeerListWidget::showPeerListMenu(QPoint) {
QAction *dlLimitAct = 0;
QAction *banAct = 0;
QAction *copyIPAct = 0;
if(!selectedPeerIPs.isEmpty()) {
if (!selectedPeerIPs.isEmpty()) {
copyIPAct = menu.addAction(IconProvider::instance()->getIcon("edit-copy"), tr("Copy IP"));
menu.addSeparator();
dlLimitAct = menu.addAction(QIcon(":/Icons/skin/download.png"), tr("Limit download rate..."));
@@ -153,12 +153,12 @@ void PeerListWidget::showPeerListMenu(QPoint) {
banAct = menu.addAction(IconProvider::instance()->getIcon("user-group-delete"), tr("Ban peer permanently"));
empty_menu = false;
}
if(empty_menu) return;
if (empty_menu) return;
QAction *act = menu.exec(QCursor::pos());
if(act == 0) return;
if(act == addPeerAct) {
if (act == 0) return;
if (act == addPeerAct) {
libtorrent::asio::ip::tcp::endpoint ep = PeerAdditionDlg::askForPeerEndpoint();
if(ep != libtorrent::asio::ip::tcp::endpoint()) {
if (ep != libtorrent::asio::ip::tcp::endpoint()) {
try {
h.connect_peer(ep);
QMessageBox::information(0, tr("Peer addition"), tr("The peer was added to this torrent."));
@@ -170,19 +170,19 @@ void PeerListWidget::showPeerListMenu(QPoint) {
}
return;
}
if(act == upLimitAct) {
if (act == upLimitAct) {
limitUpRateSelectedPeers(selectedPeerIPs);
return;
}
if(act == dlLimitAct) {
if (act == dlLimitAct) {
limitDlRateSelectedPeers(selectedPeerIPs);
return;
}
if(act == banAct) {
if (act == banAct) {
banSelectedPeers(selectedPeerIPs);
return;
}
if(act == copyIPAct) {
if (act == copyIPAct) {
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
QApplication::clipboard()->setText(selectedPeerIPs.join("\r\n"));
#else
@@ -196,8 +196,8 @@ void PeerListWidget::banSelectedPeers(QStringList peer_ips) {
int ret = QMessageBox::question(this, tr("Are you sure? -- qBittorrent"), tr("Are you sure you want to ban permanently the selected peers?"),
tr("&Yes"), tr("&No"),
QString(), 0, 1);
if(ret) return;
foreach(const QString &ip, peer_ips) {
if (ret) return;
foreach (const QString &ip, peer_ips) {
qDebug("Banning peer %s...", ip.toLocal8Bit().data());
QBtSession::instance()->addConsoleMessage(tr("Manually banning peer %1...").arg(ip));
QBtSession::instance()->banIP(ip);
@@ -207,22 +207,22 @@ void PeerListWidget::banSelectedPeers(QStringList peer_ips) {
}
void PeerListWidget::limitUpRateSelectedPeers(QStringList peer_ips) {
if(peer_ips.empty()) return;
if (peer_ips.empty()) return;
QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid()) return;
if (!h.is_valid()) return;
bool ok=false;
int cur_limit = -1;
#if LIBTORRENT_VERSION_MINOR > 15
libtorrent::asio::ip::tcp::endpoint first_ep = peerEndpoints.value(peer_ips.first(),
libtorrent::asio::ip::tcp::endpoint());
if(first_ep != libtorrent::asio::ip::tcp::endpoint())
if (first_ep != libtorrent::asio::ip::tcp::endpoint())
cur_limit = h.get_peer_upload_limit(first_ep);
#endif
long limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Upload rate limiting"), cur_limit, Preferences().getGlobalUploadLimit()*1024.);
if(!ok) return;
foreach(const QString &ip, peer_ips) {
if (!ok) return;
foreach (const QString &ip, peer_ips) {
libtorrent::asio::ip::tcp::endpoint ep = peerEndpoints.value(ip, libtorrent::asio::ip::tcp::endpoint());
if(ep != libtorrent::asio::ip::tcp::endpoint()) {
if (ep != libtorrent::asio::ip::tcp::endpoint()) {
qDebug("Settings Upload limit of %.1f Kb/s to peer %s", limit/1024., ip.toLocal8Bit().data());
try {
h.set_peer_upload_limit(ep, limit);
@@ -237,20 +237,20 @@ void PeerListWidget::limitUpRateSelectedPeers(QStringList peer_ips) {
void PeerListWidget::limitDlRateSelectedPeers(QStringList peer_ips) {
QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid()) return;
if (!h.is_valid()) return;
bool ok=false;
int cur_limit = -1;
#if LIBTORRENT_VERSION_MINOR > 15
libtorrent::asio::ip::tcp::endpoint first_ep = peerEndpoints.value(peer_ips.first(),
libtorrent::asio::ip::tcp::endpoint());
if(first_ep != libtorrent::asio::ip::tcp::endpoint())
if (first_ep != libtorrent::asio::ip::tcp::endpoint())
cur_limit = h.get_peer_download_limit(first_ep);
#endif
long limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Download rate limiting"), cur_limit, Preferences().getGlobalDownloadLimit()*1024.);
if(!ok) return;
foreach(const QString &ip, peer_ips) {
if (!ok) return;
foreach (const QString &ip, peer_ips) {
libtorrent::asio::ip::tcp::endpoint ep = peerEndpoints.value(ip, libtorrent::asio::ip::tcp::endpoint());
if(ep != libtorrent::asio::ip::tcp::endpoint()) {
if (ep != libtorrent::asio::ip::tcp::endpoint()) {
qDebug("Settings Download limit of %.1f Kb/s to peer %s", limit/1024., ip.toLocal8Bit().data());
try {
h.set_peer_download_limit(ep, limit);
@@ -270,7 +270,7 @@ void PeerListWidget::clear() {
peerEndpoints.clear();
missingFlags.clear();
int nbrows = listModel->rowCount();
if(nbrows > 0) {
if (nbrows > 0) {
qDebug("Cleared %d peers", nbrows);
listModel->removeRows(0, nbrows);
}
@@ -287,24 +287,24 @@ void PeerListWidget::saveSettings() const {
}
void PeerListWidget::loadPeers(const QTorrentHandle &h, bool force_hostname_resolution) {
if(!h.is_valid()) return;
if (!h.is_valid()) return;
boost::system::error_code ec;
std::vector<peer_info> peers;
h.get_peer_info(peers);
std::vector<peer_info>::iterator itr;
QSet<QString> old_peers_set = peerItems.keys().toSet();
for(itr = peers.begin(); itr != peers.end(); itr++) {
for (itr = peers.begin(); itr != peers.end(); itr++) {
peer_info peer = *itr;
QString peer_ip = misc::toQString(peer.ip.address().to_string(ec));
if(ec) continue;
if(peerItems.contains(peer_ip)) {
if (ec) continue;
if (peerItems.contains(peer_ip)) {
// Update existing peer
updatePeer(peer_ip, peer);
old_peers_set.remove(peer_ip);
if(force_hostname_resolution) {
if(resolver) {
if (force_hostname_resolution) {
if (resolver) {
const QString host = resolver->getHostFromCache(peer.ip);
if(host.isNull()) {
if (host.isNull()) {
resolver->resolve(peer.ip);
} else {
qDebug("Got peer IP from cache");
@@ -334,20 +334,20 @@ QStandardItem* PeerListWidget::addPeer(QString ip, peer_info peer) {
// Adding Peer to peer list
listModel->insertRow(row);
QString host;
if(resolver) {
if (resolver) {
host = resolver->getHostFromCache(peer.ip);
}
if(host.isNull())
if (host.isNull())
listModel->setData(listModel->index(row, PeerListDelegate::IP), ip);
else
listModel->setData(listModel->index(row, PeerListDelegate::IP), host);
listModel->setData(listModel->index(row, PeerListDelegate::IP_HIDDEN), ip);
// Resolve peer host name is asked
if(resolver && host.isNull())
if (resolver && host.isNull())
resolver->resolve(peer.ip);
if(display_flags) {
if (display_flags) {
const QIcon ico = GeoIPManager::CountryISOCodeToIcon(peer.country);
if(!ico.isNull()) {
if (!ico.isNull()) {
listModel->setData(listModel->index(row, PeerListDelegate::IP), ico, Qt::DecorationRole);
const QString country_name = GeoIPManager::CountryISOCodeToName(peer.country);
listModel->setData(listModel->index(row, PeerListDelegate::IP), country_name, Qt::ToolTipRole);
@@ -368,9 +368,9 @@ QStandardItem* PeerListWidget::addPeer(QString ip, peer_info peer) {
void PeerListWidget::updatePeer(QString ip, peer_info peer) {
QStandardItem *item = peerItems.value(ip);
int row = item->row();
if(display_flags) {
if (display_flags) {
const QIcon ico = GeoIPManager::CountryISOCodeToIcon(peer.country);
if(!ico.isNull()) {
if (!ico.isNull()) {
listModel->setData(listModel->index(row, PeerListDelegate::IP), ico, Qt::DecorationRole);
const QString country_name = GeoIPManager::CountryISOCodeToName(peer.country);
listModel->setData(listModel->index(row, PeerListDelegate::IP), country_name, Qt::ToolTipRole);
@@ -388,7 +388,7 @@ void PeerListWidget::updatePeer(QString ip, peer_info peer) {
void PeerListWidget::handleResolved(const QString &ip, const QString &hostname) {
QStandardItem *item = peerItems.value(ip, 0);
if(item) {
if (item) {
qDebug("Resolved %s -> %s", qPrintable(ip), qPrintable(hostname));
item->setData(hostname, Qt::DisplayRole);
//listModel->setData(listModel->index(item->row(), IP), hostname, Qt::DisplayRole);
@@ -397,7 +397,7 @@ void PeerListWidget::handleResolved(const QString &ip, const QString &hostname)
void PeerListWidget::handleSortColumnChanged(int col)
{
if(col == 0) {
if (col == 0) {
qDebug("Sorting by decoration");
proxyModel->setSortRole(Qt::ToolTipRole);
} else {

View File

@@ -140,7 +140,7 @@ void PropertiesWidget::showPiecesAvailability(bool show) {
avail_pieces_lbl->setVisible(show);
pieces_availability->setVisible(show);
avail_average_lbl->setVisible(show);
if(show || (!show && !downloaded_pieces->isVisible()))
if (show || (!show && !downloaded_pieces->isVisible()))
line_2->setVisible(show);
}
@@ -148,12 +148,12 @@ void PropertiesWidget::showPiecesDownloaded(bool show) {
downloaded_pieces_lbl->setVisible(show);
downloaded_pieces->setVisible(show);
progress_lbl->setVisible(show);
if(show || (!show && !pieces_availability->isVisible()))
if (show || (!show && !pieces_availability->isVisible()))
line_2->setVisible(show);
}
void PropertiesWidget::setVisibility(bool visible) {
if(!visible && state == VISIBLE) {
if (!visible && state == VISIBLE) {
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
stackedProperties->setVisible(false);
slideSizes = hSplitter->sizes();
@@ -165,7 +165,7 @@ void PropertiesWidget::setVisibility(bool visible) {
return;
}
if(visible && state == REDUCED) {
if (visible && state == REDUCED) {
stackedProperties->setVisible(true);
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
hSplitter->handle(1)->setDisabled(false);
@@ -212,13 +212,13 @@ QTorrentHandle PropertiesWidget::getCurrentTorrent() const {
}
void PropertiesWidget::updateSavePath(const QTorrentHandle& _h) {
if(h.is_valid() && h == _h) {
if (h.is_valid() && h == _h) {
QString p;
if(h.has_metadata() && h.num_files() == 1) {
if (h.has_metadata() && h.num_files() == 1) {
p = h.firstFileSavePath();
} else {
p = TorrentPersistentData::getSavePath(h.hash());
if(p.isEmpty())
if (p.isEmpty())
p = h.save_path();
}
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
@@ -229,7 +229,7 @@ void PropertiesWidget::updateSavePath(const QTorrentHandle& _h) {
}
void PropertiesWidget::updateTorrentInfos(const QTorrentHandle& _h) {
if(h.is_valid() && h == _h) {
if (h.is_valid() && h == _h) {
loadTorrentInfos(h);
}
}
@@ -237,7 +237,7 @@ void PropertiesWidget::updateTorrentInfos(const QTorrentHandle& _h) {
void PropertiesWidget::loadTorrentInfos(const QTorrentHandle &_h) {
clear();
h = _h;
if(!h.is_valid()) {
if (!h.is_valid()) {
clear();
return;
}
@@ -250,7 +250,7 @@ void PropertiesWidget::loadTorrentInfos(const QTorrentHandle &_h) {
// Hash
hash_lbl->setText(h.hash());
PropListModel->model()->clear();
if(h.has_metadata()) {
if (h.has_metadata()) {
// Creation date
lbl_creationDate->setText(h.creation_date());
// Pieces size
@@ -273,7 +273,7 @@ void PropertiesWidget::readSettings() {
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
// Restore splitter sizes
QStringList sizes_str = settings.value(QString::fromUtf8("TorrentProperties/SplitterSizes"), QString()).toString().split(",");
if(sizes_str.size() == 2) {
if (sizes_str.size() == 2) {
slideSizes << sizes_str.first().toInt();
slideSizes << sizes_str.last().toInt();
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
@@ -284,7 +284,7 @@ void PropertiesWidget::readSettings() {
}
const int current_tab = settings.value("TorrentProperties/CurrentTab", -1).toInt();
m_tabBar->setCurrentIndex(current_tab);
if(!settings.value("TorrentProperties/Visible", false).toBool()) {
if (!settings.value("TorrentProperties/Visible", false).toBool()) {
setVisibility(false);
}
}
@@ -295,12 +295,12 @@ void PropertiesWidget::saveSettings() {
// Splitter sizes
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
QList<int> sizes;
if(state == VISIBLE)
if (state == VISIBLE)
sizes = hSplitter->sizes();
else
sizes = slideSizes;
qDebug("Sizes: %d", sizes.size());
if(sizes.size() == 2) {
if (sizes.size() == 2) {
settings.setValue(QString::fromUtf8("TorrentProperties/SplitterSizes"), QVariant(QString::number(sizes.first())+','+QString::number(sizes.last())));
}
settings.setValue("TorrentProperties/FilesListState", filesList->header()->saveState());
@@ -316,27 +316,27 @@ void PropertiesWidget::reloadPreferences() {
void PropertiesWidget::loadDynamicData() {
// Refresh only if the torrent handle is valid and if visible
if(!h.is_valid() || main_window->getCurrentTabWidget() != transferList || state != VISIBLE) return;
if (!h.is_valid() || main_window->getCurrentTabWidget() != transferList || state != VISIBLE) return;
try {
// Transfer infos
if(stackedProperties->currentIndex() == PropTabBar::MAIN_TAB) {
if (stackedProperties->currentIndex() == PropTabBar::MAIN_TAB) {
wasted->setText(misc::friendlyUnit(h.total_failed_bytes()+h.total_redundant_bytes()));
upTotal->setText(misc::friendlyUnit(h.all_time_upload()) + " ("+misc::friendlyUnit(h.total_payload_upload())+" "+tr("this session")+")");
dlTotal->setText(misc::friendlyUnit(h.all_time_download()) + " ("+misc::friendlyUnit(h.total_payload_download())+" "+tr("this session")+")");
if(h.upload_limit() <= 0)
if (h.upload_limit() <= 0)
lbl_uplimit->setText(QString::fromUtf8(""));
else
lbl_uplimit->setText(misc::friendlyUnit(h.upload_limit())+tr("/s", "/second (i.e. per second)"));
if(h.download_limit() <= 0)
if (h.download_limit() <= 0)
lbl_dllimit->setText(QString::fromUtf8(""));
else
lbl_dllimit->setText(misc::friendlyUnit(h.download_limit())+tr("/s", "/second (i.e. per second)"));
QString elapsed_txt = misc::userFriendlyDuration(h.active_time());
if(h.is_seed()) {
if (h.is_seed()) {
elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(misc::userFriendlyDuration(h.seeding_time()))+")";
}
lbl_elapsed->setText(elapsed_txt);
if(h.connections_limit() > 0)
if (h.connections_limit() > 0)
lbl_connections->setText(QString::number(h.num_connections())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit()))+")");
else
lbl_connections->setText(QString::number(h.num_connections()));
@@ -344,18 +344,18 @@ void PropertiesWidget::loadDynamicData() {
reannounce_lbl->setText(h.next_announce());
// Update ratio info
const qreal ratio = QBtSession::instance()->getRealRatio(h.hash());
if(ratio > QBtSession::MAX_RATIO)
if (ratio > QBtSession::MAX_RATIO)
shareRatio->setText(QString::fromUtf8(""));
else
shareRatio->setText(QString(QByteArray::number(ratio, 'f', 2)));
if(!h.is_seed()) {
if (!h.is_seed()) {
showPiecesDownloaded(true);
// Downloaded pieces
bitfield bf(h.get_torrent_info().num_pieces(), 0);
h.downloading_pieces(bf);
downloaded_pieces->setProgress(h.pieces(), bf);
// Pieces availability
if(h.has_metadata() && !h.is_paused() && !h.is_queued() && !h.is_checking()) {
if (h.has_metadata() && !h.is_paused() && !h.is_queued() && !h.is_checking()) {
showPiecesAvailability(true);
std::vector<int> avail;
h.piece_availability(avail);
@@ -366,7 +366,7 @@ void PropertiesWidget::loadDynamicData() {
}
// Progress
qreal progress = h.progress()*100.;
if(progress > 99.94 && progress < 100.)
if (progress > 99.94 && progress < 100.)
progress = 99.9;
progress_lbl->setText(QString::number(progress, 'f', 1)+"%");
} else {
@@ -375,19 +375,19 @@ void PropertiesWidget::loadDynamicData() {
}
return;
}
if(stackedProperties->currentIndex() == PropTabBar::TRACKERS_TAB) {
if (stackedProperties->currentIndex() == PropTabBar::TRACKERS_TAB) {
// Trackers
trackerList->loadTrackers();
return;
}
if(stackedProperties->currentIndex() == PropTabBar::PEERS_TAB) {
if (stackedProperties->currentIndex() == PropTabBar::PEERS_TAB) {
// Load peers
peersList->loadPeers(h);
return;
}
if(stackedProperties->currentIndex() == PropTabBar::FILES_TAB) {
if (stackedProperties->currentIndex() == PropTabBar::FILES_TAB) {
// Files progress
if(h.is_valid() && h.has_metadata()) {
if (h.is_valid() && h.has_metadata()) {
qDebug("Updating priorities in files tab");
filesList->setUpdatesEnabled(false);
std::vector<size_type> fp;
@@ -405,16 +405,16 @@ void PropertiesWidget::loadUrlSeeds(){
qDebug("Loading URL seeds");
const QStringList hc_seeds = h.url_seeds();
// Add url seeds
foreach(const QString &hc_seed, hc_seeds){
foreach (const QString &hc_seed, hc_seeds){
qDebug("Loading URL seed: %s", qPrintable(hc_seed));
new QListWidgetItem(hc_seed, listWebSeeds);
}
}
void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
if(!index.isValid()) return;
if(!h.is_valid() || !h.has_metadata()) return;
if(PropListModel->getType(index) == TorrentFileItem::TFILE) {
if (!index.isValid()) return;
if (!h.is_valid() || !h.has_metadata()) return;
if (PropListModel->getType(index) == TorrentFileItem::TFILE) {
int i = PropListModel->getFileIndex(index);
const QDir saveDir(h.save_path());
const QString filename = h.filepath_at(i);
@@ -422,7 +422,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
qDebug("Trying to open file at %s", qPrintable(file_path));
// Flush data
h.flush_cache();
if(QFile::exists(file_path)) {
if (QFile::exists(file_path)) {
QDesktopServices::openUrl(QUrl::fromLocalFile(file_path));
} else {
QMessageBox::warning(this, tr("I/O Error"), tr("This file does not exist yet."));
@@ -442,7 +442,7 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
qDebug("Trying to open folder at %s", qPrintable(file_path));
// Flush data
h.flush_cache();
if(QFile::exists(file_path)) {
if (QFile::exists(file_path)) {
QDesktopServices::openUrl(QUrl::fromLocalFile(file_path));
} else {
QMessageBox::warning(this, tr("I/O Error"), tr("This folder does not exist yet."));
@@ -454,15 +454,15 @@ void PropertiesWidget::displayFilesListMenu(const QPoint&){
QMenu myFilesLlistMenu;
QModelIndexList selectedRows = filesList->selectionModel()->selectedRows(0);
QAction *actRename = 0;
if(selectedRows.size() == 1) {
if (selectedRows.size() == 1) {
actRename = myFilesLlistMenu.addAction(IconProvider::instance()->getIcon("edit-rename"), tr("Rename..."));
myFilesLlistMenu.addSeparator();
}
QMenu subMenu;
#if LIBTORRENT_VERSION_MINOR > 15
if(!h.status(0x0).is_seeding) {
if (!h.status(0x0).is_seeding) {
#else
if(!static_cast<torrent_handle>(h).is_seed()) {
if (!static_cast<torrent_handle>(h).is_seed()) {
#endif
subMenu.setTitle(tr("Priority"));
subMenu.addAction(actionNot_downloaded);
@@ -473,24 +473,24 @@ void PropertiesWidget::displayFilesListMenu(const QPoint&){
}
// Call menu
const QAction *act = myFilesLlistMenu.exec(QCursor::pos());
if(act) {
if(act == actRename) {
if (act) {
if (act == actRename) {
renameSelectedFile();
} else {
int prio = 1;
if(act == actionHigh) {
if (act == actionHigh) {
prio = prio::HIGH;
} else {
if(act == actionMaximum) {
if (act == actionMaximum) {
prio = prio::MAXIMUM;
} else {
if(act == actionNot_downloaded) {
if (act == actionNot_downloaded) {
prio = prio::IGNORED;
}
}
}
qDebug("Setting files priority");
foreach(QModelIndex index, selectedRows) {
foreach (QModelIndex index, selectedRows) {
qDebug("Setting priority(%d) for file at row %d", prio, index.row());
PropListModel->setData(PropListModel->index(index.row(), PRIORITY, index.parent()), prio);
}
@@ -510,36 +510,36 @@ void PropertiesWidget::renameSelectedFile() {
tr("New name:"), QLineEdit::Normal,
index.data().toString(), &ok);
if (ok && !new_name_last.isEmpty()) {
if(!misc::isValidFileSystemName(new_name_last)) {
if (!misc::isValidFileSystemName(new_name_last)) {
QMessageBox::warning(this, tr("The file could not be renamed"),
tr("This file name contains forbidden characters, please choose a different one."),
QMessageBox::Ok);
return;
}
if(PropListModel->getType(index) == TorrentFileItem::TFILE) {
if (PropListModel->getType(index) == TorrentFileItem::TFILE) {
// File renaming
const int file_index = PropListModel->getFileIndex(index);
if(!h.is_valid() || !h.has_metadata()) return;
if (!h.is_valid() || !h.has_metadata()) return;
QString old_name = h.filepath_at(file_index).replace("\\", "/");
if(old_name.endsWith(".!qB") && !new_name_last.endsWith(".!qB")) {
if (old_name.endsWith(".!qB") && !new_name_last.endsWith(".!qB")) {
new_name_last += ".!qB";
}
QStringList path_items = old_name.split("/");
path_items.removeLast();
path_items << new_name_last;
QString new_name = path_items.join("/");
if(old_name == new_name) {
if (old_name == new_name) {
qDebug("Name did not change");
return;
}
new_name = QDir::cleanPath(new_name);
// Check if that name is already used
for(int i=0; i<h.num_files(); ++i) {
if(i == file_index) continue;
for (int i=0; i<h.num_files(); ++i) {
if (i == file_index) continue;
#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
if(h.filepath_at(i).compare(new_name, Qt::CaseSensitive) == 0) {
if (h.filepath_at(i).compare(new_name, Qt::CaseSensitive) == 0) {
#else
if(h.filepath_at(i).compare(new_name, Qt::CaseInsensitive) == 0) {
if (h.filepath_at(i).compare(new_name, Qt::CaseInsensitive) == 0) {
#endif
// Display error message
QMessageBox::warning(this, tr("The file could not be renamed"),
@@ -552,9 +552,9 @@ void PropertiesWidget::renameSelectedFile() {
qDebug("Renaming %s to %s", qPrintable(old_name), qPrintable(new_name));
h.rename_file(file_index, new_name);
// Force recheck
if(force_recheck) h.force_recheck();
if (force_recheck) h.force_recheck();
// Rename if torrent files model too
if(new_name_last.endsWith(".!qB"))
if (new_name_last.endsWith(".!qB"))
new_name_last.chop(4);
PropListModel->setData(index, new_name_last);
} else {
@@ -570,15 +570,15 @@ void PropertiesWidget::renameSelectedFile() {
path_items.removeLast();
path_items << new_name_last;
QString new_path = path_items.join("/");
if(!new_path.endsWith("/")) new_path += "/";
if (!new_path.endsWith("/")) new_path += "/";
// Check for overwriting
const int num_files = h.num_files();
for(int i=0; i<num_files; ++i) {
for (int i=0; i<num_files; ++i) {
const QString current_name = h.filepath_at(i);
#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
if(current_name.startsWith(new_path, Qt::CaseSensitive)) {
if (current_name.startsWith(new_path, Qt::CaseSensitive)) {
#else
if(current_name.startsWith(new_path, Qt::CaseInsensitive)) {
if (current_name.startsWith(new_path, Qt::CaseInsensitive)) {
#endif
QMessageBox::warning(this, tr("The folder could not be renamed"),
tr("This name is already in use in this folder. Please use a different name."),
@@ -588,12 +588,12 @@ void PropertiesWidget::renameSelectedFile() {
}
bool force_recheck = false;
// Replace path in all files
for(int i=0; i<num_files; ++i) {
for (int i=0; i<num_files; ++i) {
const QString current_name = h.filepath_at(i);
if(current_name.startsWith(old_path)) {
if (current_name.startsWith(old_path)) {
QString new_name = current_name;
new_name.replace(0, old_path.length(), new_path);
if(!force_recheck && QDir(h.save_path()).exists(new_name))
if (!force_recheck && QDir(h.save_path()).exists(new_name))
force_recheck = true;
new_name = QDir::cleanPath(new_name);
qDebug("Rename %s to %s", qPrintable(current_name), qPrintable(new_name));
@@ -601,7 +601,7 @@ void PropertiesWidget::renameSelectedFile() {
}
}
// Force recheck
if(force_recheck) h.force_recheck();
if (force_recheck) h.force_recheck();
// Rename folder in torrent files model too
PropListModel->setData(index, new_name_last);
// Remove old folder
@@ -622,9 +622,9 @@ void PropertiesWidget::askWebSeed(){
const QString url_seed = QInputDialog::getText(this, tr("New url seed", "New HTTP source"),
tr("New url seed:"), QLineEdit::Normal,
QString::fromUtf8("http://www."), &ok);
if(!ok) return;
if (!ok) return;
qDebug("Adding %s web seed", qPrintable(url_seed));
if(!listWebSeeds->findItems(url_seed, Qt::MatchFixedString).empty()) {
if (!listWebSeeds->findItems(url_seed, Qt::MatchFixedString).empty()) {
QMessageBox::warning(this, tr("qBittorrent"),
tr("This url seed is already in the list."),
QMessageBox::Ok);
@@ -638,12 +638,12 @@ void PropertiesWidget::askWebSeed(){
void PropertiesWidget::deleteSelectedUrlSeeds(){
const QList<QListWidgetItem *> selectedItems = listWebSeeds->selectedItems();
bool change = false;
foreach(const QListWidgetItem *item, selectedItems){
foreach (const QListWidgetItem *item, selectedItems){
QString url_seed = item->text();
h.remove_url_seed(url_seed);
change = true;
}
if(change){
if (change){
// Refresh list
loadUrlSeeds();
}
@@ -658,45 +658,45 @@ bool PropertiesWidget::applyPriorities() {
qDebug("prioritize files: %d", priorities[0]);
h.prioritize_files(priorities);
// Restore first/last piece first option if necessary
if(first_last_piece_first)
if (first_last_piece_first)
h.prioritize_first_last_piece(true);
return true;
}
void PropertiesWidget::on_changeSavePathButton_clicked() {
if(!h.is_valid()) return;
if (!h.is_valid()) return;
QString new_path;
if(h.has_metadata() && h.num_files() == 1) {
if (h.has_metadata() && h.num_files() == 1) {
new_path = QFileDialog::getSaveFileName(this, tr("Choose save path"), h.firstFileSavePath());
} else {
const QDir saveDir(TorrentPersistentData::getSavePath(h.hash()));
new_path = QFileDialog::getExistingDirectory(this, tr("Choose save path"), saveDir.absolutePath(),
QFileDialog::DontConfirmOverwrite|QFileDialog::ShowDirsOnly|QFileDialog::HideNameFilterDetails);
}
if(!new_path.isEmpty()){
if (!new_path.isEmpty()){
// Check if savePath exists
QString save_path_dir = new_path.replace("\\", "/");
QString new_file_name;
if(h.has_metadata() && h.num_files() == 1) {
if (h.has_metadata() && h.num_files() == 1) {
new_file_name = misc::fileName(save_path_dir); // New file name
save_path_dir = misc::branchPath(save_path_dir, true); // Skip file name
}
QDir savePath(misc::expandPath(save_path_dir));
// Actually move storage
if(!QBtSession::instance()->useTemporaryFolder() || h.is_seed()) {
if(!savePath.exists()) savePath.mkpath(savePath.absolutePath());
if (!QBtSession::instance()->useTemporaryFolder() || h.is_seed()) {
if (!savePath.exists()) savePath.mkpath(savePath.absolutePath());
h.move_storage(savePath.absolutePath());
}
// Update save_path in dialog
QString display_path;
if(h.has_metadata() && h.num_files() == 1) {
if (h.has_metadata() && h.num_files() == 1) {
// Rename the file
Q_ASSERT(!new_file_name.isEmpty());
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
if(h.filename_at(0).compare(new_file_name, Qt::CaseInsensitive) != 0) {
if (h.filename_at(0).compare(new_file_name, Qt::CaseInsensitive) != 0) {
#else
if(h.filename_at(0).compare(new_file_name, Qt::CaseSensitive) != 0) {
if (h.filename_at(0).compare(new_file_name, Qt::CaseSensitive) != 0) {
#endif
qDebug("Renaming single file to %s", qPrintable(new_file_name));
h.rename_file(0, new_file_name);
@@ -715,7 +715,7 @@ void PropertiesWidget::on_changeSavePathButton_clicked() {
}
void PropertiesWidget::filteredFilesChanged() {
if(h.is_valid()) {
if (h.is_valid()) {
applyPriorities();
}
}

View File

@@ -80,7 +80,7 @@ public:
newopt.rect = opt.rect;
// We don't want to display 100% unless
// the torrent is really complete
if(progress > 99.94 && progress < 100.)
if (progress > 99.94 && progress < 100.)
progress = 99.9;
newopt.text = QString(QByteArray::number(progress, 'f', 1))+QString::fromUtf8("%");
newopt.progress = (int)progress;
@@ -158,16 +158,16 @@ public:
}
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */, const QModelIndex &index) const {
if(index.column() != PRIORITY) return 0;
if(properties) {
if (index.column() != PRIORITY) return 0;
if (properties) {
QTorrentHandle h = properties->getCurrentTorrent();
#if LIBTORRENT_VERSION_MINOR > 15
if(!h.is_valid() || !h.has_metadata() || h.status(0x0).is_seeding) return 0;
if (!h.is_valid() || !h.has_metadata() || h.status(0x0).is_seeding) return 0;
#else
if(!h.is_valid() || !h.has_metadata() || static_cast<libtorrent::torrent_handle>(h).is_seed()) return 0;
if (!h.is_valid() || !h.has_metadata() || static_cast<libtorrent::torrent_handle>(h).is_seed()) return 0;
#endif
}
if(index.data().toInt() <= 0) {
if (index.data().toInt() <= 0) {
// IGNORED or MIXED
return 0;
}

View File

@@ -87,7 +87,7 @@ PropTabBar::PropTabBar(QWidget *parent) :
// SIGNAL/SLOT
connect(m_btnGroup, SIGNAL(buttonClicked(int)), SLOT(setCurrentIndex(int)));
// Disable buttons focus
foreach(QAbstractButton *btn, m_btnGroup->buttons()) {
foreach (QAbstractButton *btn, m_btnGroup->buttons()) {
btn->setFocusPolicy(Qt::NoFocus);
}
}
@@ -103,11 +103,11 @@ int PropTabBar::currentIndex() const
void PropTabBar::setCurrentIndex(int index)
{
if(index >= m_btnGroup->buttons().size())
if (index >= m_btnGroup->buttons().size())
index = 0;
// If asked to hide or if the currently selected tab is clicked
if(index < 0 || m_currentIndex == index) {
if(m_currentIndex >= 0) {
if (index < 0 || m_currentIndex == index) {
if (m_currentIndex >= 0) {
m_btnGroup->button(m_currentIndex)->setStyleSheet(DEFAULT_BUTTON_CSS);
m_currentIndex = -1;
emit visibilityToggled(false);
@@ -115,7 +115,7 @@ void PropTabBar::setCurrentIndex(int index)
return;
}
// Unselect previous tab
if(m_currentIndex >= 0) {
if (m_currentIndex >= 0) {
m_btnGroup->button(m_currentIndex)->setStyleSheet(DEFAULT_BUTTON_CSS);
} else {
// Nothing was selected, show!

View File

@@ -83,8 +83,8 @@ TrackerList::~TrackerList() {
QList<QTreeWidgetItem*> TrackerList::getSelectedTrackerItems() const {
QList<QTreeWidgetItem*> selected_items = selectedItems();
QList<QTreeWidgetItem*> selected_trackers;
foreach(QTreeWidgetItem *item, selectedItems()) {
if(indexOfTopLevelItem(item) >= NB_STICKY_ITEM) { // Ignore STICKY ITEMS
foreach (QTreeWidgetItem *item, selectedItems()) {
if (indexOfTopLevelItem(item) >= NB_STICKY_ITEM) { // Ignore STICKY ITEMS
selected_trackers << item;
}
}
@@ -94,37 +94,37 @@ QList<QTreeWidgetItem*> TrackerList::getSelectedTrackerItems() const {
void TrackerList::setRowColor(int row, QColor color) {
unsigned int nbColumns = columnCount();
QTreeWidgetItem *item = topLevelItem(row);
for(unsigned int i=0; i<nbColumns; ++i) {
for (unsigned int i=0; i<nbColumns; ++i) {
item->setData(i, Qt::ForegroundRole, color);
}
}
void TrackerList::moveSelectionUp() {
QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid()) {
if (!h.is_valid()) {
clear();
return;
}
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
if(selected_items.isEmpty()) return;
if (selected_items.isEmpty()) return;
bool change = false;
foreach(QTreeWidgetItem *item, selected_items){
foreach (QTreeWidgetItem *item, selected_items){
int index = indexOfTopLevelItem(item);
if(index > NB_STICKY_ITEM) {
if (index > NB_STICKY_ITEM) {
insertTopLevelItem(index-1, takeTopLevelItem(index));
change = true;
}
}
if(!change) return;
if (!change) return;
// Restore selection
QItemSelectionModel *selection = selectionModel();
foreach(QTreeWidgetItem *item, selected_items) {
foreach (QTreeWidgetItem *item, selected_items) {
selection->select(indexFromItem(item), QItemSelectionModel::Rows|QItemSelectionModel::Select);
}
setSelectionModel(selection);
// Update torrent trackers
std::vector<announce_entry> trackers;
for(int i=NB_STICKY_ITEM; i<topLevelItemCount(); ++i) {
for (int i=NB_STICKY_ITEM; i<topLevelItemCount(); ++i) {
QString tracker_url = topLevelItem(i)->data(COL_URL, Qt::DisplayRole).toString();
announce_entry e(tracker_url.toStdString());
e.tier = i-NB_STICKY_ITEM;
@@ -137,30 +137,30 @@ void TrackerList::moveSelectionUp() {
void TrackerList::moveSelectionDown() {
QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid()) {
if (!h.is_valid()) {
clear();
return;
}
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
if(selected_items.isEmpty()) return;
if (selected_items.isEmpty()) return;
bool change = false;
for(int i=selectedItems().size()-1; i>= 0; --i) {
for (int i=selectedItems().size()-1; i>= 0; --i) {
int index = indexOfTopLevelItem(selected_items.at(i));
if(index < topLevelItemCount()-1) {
if (index < topLevelItemCount()-1) {
insertTopLevelItem(index+1, takeTopLevelItem(index));
change = true;
}
}
if(!change) return;
if (!change) return;
// Restore selection
QItemSelectionModel *selection = selectionModel();
foreach(QTreeWidgetItem *item, selected_items) {
foreach (QTreeWidgetItem *item, selected_items) {
selection->select(indexFromItem(item), QItemSelectionModel::Rows|QItemSelectionModel::Select);
}
setSelectionModel(selection);
// Update torrent trackers
std::vector<announce_entry> trackers;
for(int i=NB_STICKY_ITEM; i<topLevelItemCount(); ++i) {
for (int i=NB_STICKY_ITEM; i<topLevelItemCount(); ++i) {
QString tracker_url = topLevelItem(i)->data(COL_URL, Qt::DisplayRole).toString();
announce_entry e(tracker_url.toStdString());
e.tier = i-NB_STICKY_ITEM;
@@ -192,32 +192,32 @@ void TrackerList::loadStickyItems(const QTorrentHandle &h) {
std::vector<peer_info> peers;
h.get_peer_info(peers);
std::vector<peer_info>::iterator it;
for(it=peers.begin(); it!=peers.end(); it++) {
if(it->source & peer_info::dht)
for (it=peers.begin(); it!=peers.end(); it++) {
if (it->source & peer_info::dht)
++nb_dht;
if(it->source & peer_info::lsd)
if (it->source & peer_info::lsd)
++nb_lsd;
if(it->source & peer_info::pex)
if (it->source & peer_info::pex)
++nb_pex;
}
// load DHT information
if(QBtSession::instance()->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"));
}
dht_item->setText(COL_PEERS, QString::number(nb_dht));
if(h.has_metadata() && h.priv()) {
if (h.has_metadata() && h.priv()) {
dht_item->setText(COL_MSG, tr("This torrent is private"));
}
// Load PeX Information
if(QBtSession::instance()->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(QBtSession::instance()->isLSDEnabled())
if (QBtSession::instance()->isLSDEnabled())
lsd_item->setText(COL_STATUS, tr("Working"));
else
lsd_item->setText(COL_STATUS, tr("Disabled"));
@@ -227,16 +227,16 @@ void TrackerList::loadStickyItems(const QTorrentHandle &h) {
void TrackerList::loadTrackers() {
// Load trackers from torrent handle
QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid()) return;
if (!h.is_valid()) return;
loadStickyItems(h);
// Load actual trackers information
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++) {
for (std::vector<announce_entry>::const_iterator it = trackers.begin(); it != trackers.end(); it++) {
QString tracker_url = misc::toQString(it->url);
QTreeWidgetItem *item = tracker_items.value(tracker_url, 0);
if(!item) {
if (!item) {
item = new QTreeWidgetItem();
item->setText(COL_TIER, QString::number(it->tier));
item->setText(COL_URL, tracker_url);
@@ -247,15 +247,15 @@ void TrackerList::loadTrackers() {
}
TrackerInfos data = trackers_data.value(tracker_url, TrackerInfos(tracker_url));
QString error_message = data.last_message.trimmed();
if(it->verified) {
if (it->verified) {
item->setText(COL_STATUS, tr("Working"));
item->setText(COL_MSG, "");
} else {
if(it->updating && it->fails == 0) {
if (it->updating && it->fails == 0) {
item->setText(COL_STATUS, tr("Updating..."));
item->setText(COL_MSG, "");
} else {
if(it->fails > 0) {
if (it->fails > 0) {
item->setText(COL_STATUS, tr("Not working"));
item->setText(COL_MSG, error_message);
} else {
@@ -267,7 +267,7 @@ void TrackerList::loadTrackers() {
item->setText(COL_PEERS, QString::number(trackers_data.value(tracker_url, TrackerInfos(tracker_url)).num_peers));
}
// Remove old trackers
foreach(const QString &tracker, old_trackers_urls) {
foreach (const QString &tracker, old_trackers_urls) {
delete tracker_items.take(tracker);
}
}
@@ -275,11 +275,11 @@ void TrackerList::loadTrackers() {
// Ask the user for new trackers and add them to the torrent
void TrackerList::askForTrackers(){
QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid()) return;
if (!h.is_valid()) return;
QStringList trackers = TrackersAdditionDlg::askForTrackers(h);
if(!trackers.empty()) {
foreach(const QString& tracker, trackers) {
if(tracker.trimmed().isEmpty()) continue;
if (!trackers.empty()) {
foreach (const QString& tracker, trackers) {
if (tracker.trimmed().isEmpty()) continue;
announce_entry url(tracker.toStdString());
url.tier = 0;
h.add_tracker(url);
@@ -293,14 +293,14 @@ void TrackerList::askForTrackers(){
void TrackerList::deleteSelectedTrackers(){
QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid()) {
if (!h.is_valid()) {
clear();
return;
}
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
if(selected_items.isEmpty()) return;
if (selected_items.isEmpty()) return;
QStringList urls_to_remove;
foreach(QTreeWidgetItem *item, selected_items){
foreach (QTreeWidgetItem *item, selected_items){
QString tracker_url = item->data(COL_URL, Qt::DisplayRole).toString();
urls_to_remove << tracker_url;
tracker_items.remove(tracker_url);
@@ -310,8 +310,8 @@ void TrackerList::deleteSelectedTrackers(){
std::vector<announce_entry> remaining_trackers;
std::vector<announce_entry> trackers = h.trackers();
std::vector<announce_entry>::iterator it;
for(it = trackers.begin(); it != trackers.end(); it++) {
if(!urls_to_remove.contains(misc::toQString((*it).url))) {
for (it = trackers.begin(); it != trackers.end(); it++) {
if (!urls_to_remove.contains(misc::toQString((*it).url))) {
remaining_trackers.push_back(*it);
}
}
@@ -323,28 +323,28 @@ void TrackerList::deleteSelectedTrackers(){
void TrackerList::showTrackerListMenu(QPoint) {
QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid()) return;
if (!h.is_valid()) return;
//QList<QTreeWidgetItem*> selected_items = getSelectedTrackerItems();
QMenu menu;
// Add actions
QAction *addAct = menu.addAction(IconProvider::instance()->getIcon("list-add"), tr("Add a new tracker..."));
QAction *delAct = 0;
if(!getSelectedTrackerItems().isEmpty()) {
if (!getSelectedTrackerItems().isEmpty()) {
delAct = menu.addAction(IconProvider::instance()->getIcon("list-remove"), tr("Remove tracker"));
}
menu.addSeparator();
QAction *reannounceAct = menu.addAction(IconProvider::instance()->getIcon("view-refresh"), tr("Force reannounce"));
QAction *act = menu.exec(QCursor::pos());
if(act == 0) return;
if(act == addAct) {
if (act == 0) return;
if (act == addAct) {
askForTrackers();
return;
}
if(act == delAct) {
if (act == delAct) {
deleteSelectedTrackers();
return;
}
if(act == reannounceAct) {
if (act == reannounceAct) {
properties->getCurrentTorrent().force_reannounce();
return;
}
@@ -352,7 +352,7 @@ void TrackerList::showTrackerListMenu(QPoint) {
void TrackerList::loadSettings() {
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
if(!header()->restoreState(settings.value("TorrentProperties/Trackers/TrackerListState").toByteArray())) {
if (!header()->restoreState(settings.value("TorrentProperties/Trackers/TrackerListState").toByteArray())) {
setColumnWidth(0, 30);
setColumnWidth(1, 300);
}

View File

@@ -94,18 +94,18 @@ public slots:
}
// Load from current user list
QStringList tmp = trackers_list->toPlainText().split("\n");
foreach(const QString &user_url_str, tmp) {
foreach (const QString &user_url_str, tmp) {
QUrl user_url(user_url_str);
if(!existingTrackers.contains(user_url))
if (!existingTrackers.contains(user_url))
existingTrackers << user_url;
}
// Add new trackers to the list
if(!trackers_list->toPlainText().isEmpty() && !trackers_list->toPlainText().endsWith("\n"))
if (!trackers_list->toPlainText().isEmpty() && !trackers_list->toPlainText().endsWith("\n"))
trackers_list->insertPlainText("\n");
int nb = 0;
while (!list_file.atEnd()) {
const QByteArray line = list_file.readLine().trimmed();
if(line.isEmpty()) continue;
if (line.isEmpty()) continue;
QUrl url(line);
if (!existingTrackers.contains(url)) {
trackers_list->insertPlainText(line + "\n");
@@ -119,7 +119,7 @@ public slots:
setCursor(Qt::ArrowCursor);
uTorrentListButton->setEnabled(true);
// Display information message if necessary
if(nb == 0) {
if (nb == 0) {
QMessageBox::information(this, tr("No change"), tr("No additional trackers were found."), QMessageBox::Ok);
}
sender()->deleteLater();
@@ -138,7 +138,7 @@ public:
static QStringList askForTrackers(QTorrentHandle h) {
QStringList trackers;
TrackersAdditionDlg dlg(h);
if(dlg.exec() == QDialog::Accepted) {
if (dlg.exec() == QDialog::Accepted) {
return dlg.newTrackers();
}
return trackers;