mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Itr cache
This commit is contained in:
parent
ae09bee193
commit
bb11d11a72
@ -214,8 +214,10 @@ QString fsutils::fixFileNames(const QString& path)
|
|||||||
QList<QByteArray> parts = raw_path.split('/');
|
QList<QByteArray> parts = raw_path.split('/');
|
||||||
if (parts.isEmpty()) return path;
|
if (parts.isEmpty()) return path;
|
||||||
QByteArray last_part = parts.takeLast();
|
QByteArray last_part = parts.takeLast();
|
||||||
QList<QByteArray>::iterator it;
|
|
||||||
for (it = parts.begin(); it != parts.end(); ++it) {
|
QList<QByteArray>::iterator it = parts.begin();
|
||||||
|
QList<QByteArray>::iterator itend = parts.end();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
// Make sure the filename is not too long
|
// Make sure the filename is not too long
|
||||||
if (it->size() > MAX_FILENAME_BYTES) {
|
if (it->size() > MAX_FILENAME_BYTES) {
|
||||||
qWarning() << "Folder" << *it << "was cut because it was too long";
|
qWarning() << "Folder" << *it << "was cut because it was too long";
|
||||||
|
@ -310,9 +310,11 @@ void PeerListWidget::loadPeers(const QTorrentHandle &h, bool force_hostname_reso
|
|||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
std::vector<peer_info> peers;
|
std::vector<peer_info> peers;
|
||||||
h.get_peer_info(peers);
|
h.get_peer_info(peers);
|
||||||
std::vector<peer_info>::const_iterator itr;
|
|
||||||
QSet<QString> old_peers_set = m_peerItems.keys().toSet();
|
QSet<QString> old_peers_set = m_peerItems.keys().toSet();
|
||||||
for (itr = peers.begin(); itr != peers.end(); ++itr) {
|
|
||||||
|
std::vector<peer_info>::const_iterator itr = peers.begin();
|
||||||
|
std::vector<peer_info>::const_iterator itrend = peers.end();
|
||||||
|
for ( ; itr != itrend; ++itr) {
|
||||||
peer_info peer = *itr;
|
peer_info peer = *itr;
|
||||||
QString peer_ip = misc::toQString(peer.ip.address().to_string(ec));
|
QString peer_ip = misc::toQString(peer.ip.address().to_string(ec));
|
||||||
if (ec) continue;
|
if (ec) continue;
|
||||||
|
@ -312,8 +312,10 @@ void TrackerList::deleteSelectedTrackers() {
|
|||||||
// Iterate of trackers and remove selected ones
|
// Iterate of trackers and remove selected ones
|
||||||
std::vector<announce_entry> remaining_trackers;
|
std::vector<announce_entry> remaining_trackers;
|
||||||
std::vector<announce_entry> trackers = h.trackers();
|
std::vector<announce_entry> trackers = h.trackers();
|
||||||
std::vector<announce_entry>::iterator it;
|
|
||||||
for (it = trackers.begin(); it != trackers.end(); ++it) {
|
std::vector<announce_entry>::iterator it = trackers.begin();
|
||||||
|
std::vector<announce_entry>::iterator itend = trackers.end();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
if (!urls_to_remove.contains(misc::toQString((*it).url))) {
|
if (!urls_to_remove.contains(misc::toQString((*it).url))) {
|
||||||
remaining_trackers.push_back(*it);
|
remaining_trackers.push_back(*it);
|
||||||
}
|
}
|
||||||
|
@ -87,8 +87,10 @@ public slots:
|
|||||||
QList<QUrl> existingTrackers;
|
QList<QUrl> existingTrackers;
|
||||||
// Load from torrent handle
|
// Load from torrent handle
|
||||||
std::vector<libtorrent::announce_entry> tor_trackers = h.trackers();
|
std::vector<libtorrent::announce_entry> tor_trackers = h.trackers();
|
||||||
|
|
||||||
std::vector<libtorrent::announce_entry>::iterator itr = tor_trackers.begin();
|
std::vector<libtorrent::announce_entry>::iterator itr = tor_trackers.begin();
|
||||||
while(itr != tor_trackers.end()) {
|
std::vector<libtorrent::announce_entry>::iterator itrend = tor_trackers.end();
|
||||||
|
while(itr != itrend) {
|
||||||
existingTrackers << QUrl(misc::toQString(itr->url));
|
existingTrackers << QUrl(misc::toQString(itr->url));
|
||||||
++itr;
|
++itr;
|
||||||
}
|
}
|
||||||
|
@ -212,8 +212,10 @@ void QBtSession::preAllocateAllFiles(bool b) {
|
|||||||
void QBtSession::processBigRatios() {
|
void QBtSession::processBigRatios() {
|
||||||
qDebug("Process big ratios...");
|
qDebug("Process big ratios...");
|
||||||
std::vector<torrent_handle> torrents = s->get_torrents();
|
std::vector<torrent_handle> torrents = s->get_torrents();
|
||||||
std::vector<torrent_handle>::iterator torrentIT;
|
|
||||||
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
|
std::vector<torrent_handle>::iterator torrentIT = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::iterator torrentITend = torrents.end();
|
||||||
|
for ( ; torrentIT != torrentITend; ++torrentIT) {
|
||||||
const QTorrentHandle h(*torrentIT);
|
const QTorrentHandle h(*torrentIT);
|
||||||
if (!h.is_valid()) continue;
|
if (!h.is_valid()) continue;
|
||||||
if (h.is_seed()) {
|
if (h.is_seed()) {
|
||||||
@ -359,8 +361,10 @@ void QBtSession::configureSession() {
|
|||||||
}
|
}
|
||||||
// Update torrent handles
|
// Update torrent handles
|
||||||
std::vector<torrent_handle> torrents = s->get_torrents();
|
std::vector<torrent_handle> torrents = s->get_torrents();
|
||||||
std::vector<torrent_handle>::iterator torrentIT;
|
|
||||||
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
|
std::vector<torrent_handle>::iterator torrentIT = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::iterator torrentITend = torrents.end();
|
||||||
|
for ( ; torrentIT != torrentITend; ++torrentIT) {
|
||||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||||
if (h.is_valid())
|
if (h.is_valid())
|
||||||
h.resolve_countries(resolve_countries);
|
h.resolve_countries(resolve_countries);
|
||||||
@ -711,8 +715,10 @@ QTorrentHandle QBtSession::getTorrentHandle(const QString &hash) const {
|
|||||||
|
|
||||||
bool QBtSession::hasActiveTorrents() const {
|
bool QBtSession::hasActiveTorrents() const {
|
||||||
std::vector<torrent_handle> torrents = s->get_torrents();
|
std::vector<torrent_handle> torrents = s->get_torrents();
|
||||||
std::vector<torrent_handle>::iterator torrentIT;
|
|
||||||
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
|
std::vector<torrent_handle>::iterator torrentIT = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::iterator torrentITend = torrents.end();
|
||||||
|
for ( ; torrentIT != torrentITend; ++torrentIT) {
|
||||||
const QTorrentHandle h(*torrentIT);
|
const QTorrentHandle h(*torrentIT);
|
||||||
if (h.is_valid() && !h.is_paused() && !h.is_queued())
|
if (h.is_valid() && !h.is_paused() && !h.is_queued())
|
||||||
return true;
|
return true;
|
||||||
@ -722,8 +728,10 @@ bool QBtSession::hasActiveTorrents() const {
|
|||||||
|
|
||||||
bool QBtSession::hasDownloadingTorrents() const {
|
bool QBtSession::hasDownloadingTorrents() const {
|
||||||
std::vector<torrent_handle> torrents = s->get_torrents();
|
std::vector<torrent_handle> torrents = s->get_torrents();
|
||||||
std::vector<torrent_handle>::iterator torrentIT;
|
|
||||||
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
|
std::vector<torrent_handle>::iterator torrentIT = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::iterator torrentITend = torrents.end();
|
||||||
|
for ( ; torrentIT != torrentITend; ++torrentIT) {
|
||||||
if (torrentIT->is_valid()) {
|
if (torrentIT->is_valid()) {
|
||||||
try {
|
try {
|
||||||
const torrent_status::state_t state = torrentIT->status().state;
|
const torrent_status::state_t state = torrentIT->status().state;
|
||||||
@ -802,8 +810,10 @@ void QBtSession::deleteTorrent(const QString &hash, bool delete_local_files) {
|
|||||||
|
|
||||||
void QBtSession::pauseAllTorrents() {
|
void QBtSession::pauseAllTorrents() {
|
||||||
std::vector<torrent_handle> torrents = s->get_torrents();
|
std::vector<torrent_handle> torrents = s->get_torrents();
|
||||||
std::vector<torrent_handle>::iterator torrentIT;
|
|
||||||
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
|
std::vector<torrent_handle>::iterator torrentIT = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::iterator torrentITend = torrents.end();
|
||||||
|
for ( ; torrentIT != torrentITend; ++torrentIT) {
|
||||||
try {
|
try {
|
||||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||||
if (!h.is_paused()) {
|
if (!h.is_paused()) {
|
||||||
@ -820,8 +830,10 @@ std::vector<torrent_handle> QBtSession::getTorrents() const {
|
|||||||
|
|
||||||
void QBtSession::resumeAllTorrents() {
|
void QBtSession::resumeAllTorrents() {
|
||||||
std::vector<torrent_handle> torrents = s->get_torrents();
|
std::vector<torrent_handle> torrents = s->get_torrents();
|
||||||
std::vector<torrent_handle>::iterator torrentIT;
|
|
||||||
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
|
std::vector<torrent_handle>::iterator torrentIT = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::iterator torrentITend = torrents.end();
|
||||||
|
for ( ; torrentIT != torrentITend; ++torrentIT) {
|
||||||
try {
|
try {
|
||||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||||
if (h.is_paused()) {
|
if (h.is_paused()) {
|
||||||
@ -1324,8 +1336,10 @@ void QBtSession::mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr<torren
|
|||||||
const QStringList old_urlseeds = h_ex.url_seeds();
|
const QStringList old_urlseeds = h_ex.url_seeds();
|
||||||
#if LIBTORRENT_VERSION_MINOR > 15
|
#if LIBTORRENT_VERSION_MINOR > 15
|
||||||
std::vector<web_seed_entry> new_urlseeds = t->web_seeds();
|
std::vector<web_seed_entry> new_urlseeds = t->web_seeds();
|
||||||
std::vector<web_seed_entry>::iterator it;
|
|
||||||
for (it = new_urlseeds.begin(); it != new_urlseeds.end(); it++) {
|
std::vector<web_seed_entry>::iterator it = new_urlseeds.begin();
|
||||||
|
std::vector<web_seed_entry>::iterator itend = new_urlseeds.end();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
const QString new_url = misc::toQString(it->url.c_str());
|
const QString new_url = misc::toQString(it->url.c_str());
|
||||||
if (!old_urlseeds.contains(new_url)) {
|
if (!old_urlseeds.contains(new_url)) {
|
||||||
urlseeds_added = true;
|
urlseeds_added = true;
|
||||||
@ -1334,8 +1348,10 @@ void QBtSession::mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr<torren
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
std::vector<std::string> new_urlseeds = t->url_seeds();
|
std::vector<std::string> new_urlseeds = t->url_seeds();
|
||||||
std::vector<std::string>::iterator it;
|
|
||||||
for (it = new_urlseeds.begin(); it != new_urlseeds.end(); ++it) {
|
std::vector<std::string>::iterator it = new_urlseeds.begin();
|
||||||
|
std::vector<std::string>::iterator itend = new_urlseeds.end();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
const QString new_url = misc::toQString(it->c_str());
|
const QString new_url = misc::toQString(it->c_str());
|
||||||
if (!old_urlseeds.contains(new_url)) {
|
if (!old_urlseeds.contains(new_url)) {
|
||||||
urlseeds_added = true;
|
urlseeds_added = true;
|
||||||
@ -1358,8 +1374,10 @@ void QBtSession::exportTorrentFiles(QString path) {
|
|||||||
}
|
}
|
||||||
QDir torrentBackup(fsutils::BTBackupLocation());
|
QDir torrentBackup(fsutils::BTBackupLocation());
|
||||||
std::vector<torrent_handle> handles = s->get_torrents();
|
std::vector<torrent_handle> handles = s->get_torrents();
|
||||||
std::vector<torrent_handle>::iterator itr;
|
|
||||||
for (itr=handles.begin(); itr != handles.end(); ++itr) {
|
std::vector<torrent_handle>::iterator itr=handles.begin();
|
||||||
|
std::vector<torrent_handle>::iterator itrend=handles.end();
|
||||||
|
for ( ; itr != itrend; ++itr) {
|
||||||
const QTorrentHandle h(*itr);
|
const QTorrentHandle h(*itr);
|
||||||
if (!h.is_valid()) {
|
if (!h.is_valid()) {
|
||||||
std::cerr << "Torrent Export: torrent is invalid, skipping..." << std::endl;
|
std::cerr << "Torrent Export: torrent is invalid, skipping..." << std::endl;
|
||||||
@ -1399,8 +1417,10 @@ void QBtSession::setMaxConnectionsPerTorrent(int max) {
|
|||||||
qDebug() << Q_FUNC_INFO << max;
|
qDebug() << Q_FUNC_INFO << max;
|
||||||
// Apply this to all session torrents
|
// Apply this to all session torrents
|
||||||
std::vector<torrent_handle> handles = s->get_torrents();
|
std::vector<torrent_handle> handles = s->get_torrents();
|
||||||
std::vector<torrent_handle>::const_iterator it;
|
|
||||||
for (it = handles.begin(); it != handles.end(); ++it) {
|
std::vector<torrent_handle>::const_iterator it = handles.begin();
|
||||||
|
std::vector<torrent_handle>::const_iterator itend = handles.end();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
if (!it->is_valid())
|
if (!it->is_valid())
|
||||||
continue;
|
continue;
|
||||||
try {
|
try {
|
||||||
@ -1413,8 +1433,10 @@ void QBtSession::setMaxUploadsPerTorrent(int max) {
|
|||||||
qDebug() << Q_FUNC_INFO << max;
|
qDebug() << Q_FUNC_INFO << max;
|
||||||
// Apply this to all session torrents
|
// Apply this to all session torrents
|
||||||
std::vector<torrent_handle> handles = s->get_torrents();
|
std::vector<torrent_handle> handles = s->get_torrents();
|
||||||
std::vector<torrent_handle>::const_iterator it;
|
|
||||||
for (it = handles.begin(); it != handles.end(); ++it) {
|
std::vector<torrent_handle>::const_iterator it = handles.begin();
|
||||||
|
std::vector<torrent_handle>::const_iterator itend = handles.end();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
if (!it->is_valid())
|
if (!it->is_valid())
|
||||||
continue;
|
continue;
|
||||||
try {
|
try {
|
||||||
@ -1564,8 +1586,10 @@ qreal QBtSession::getRealRatio(const QString &hash) const {
|
|||||||
// Called periodically
|
// Called periodically
|
||||||
void QBtSession::saveTempFastResumeData() {
|
void QBtSession::saveTempFastResumeData() {
|
||||||
std::vector<torrent_handle> torrents = s->get_torrents();
|
std::vector<torrent_handle> torrents = s->get_torrents();
|
||||||
std::vector<torrent_handle>::iterator torrentIT;
|
|
||||||
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
|
std::vector<torrent_handle>::iterator torrentIT = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::iterator torrentITend = torrents.end();
|
||||||
|
for ( ; torrentIT != torrentITend; ++torrentIT) {
|
||||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||||
try {
|
try {
|
||||||
if (!h.is_valid() || !h.has_metadata() /*|| h.is_seed() || h.is_paused()*/) continue;
|
if (!h.is_valid() || !h.has_metadata() /*|| h.is_seed() || h.is_paused()*/) continue;
|
||||||
@ -1590,8 +1614,10 @@ void QBtSession::saveFastResumeData() {
|
|||||||
// Pause session
|
// Pause session
|
||||||
s->pause();
|
s->pause();
|
||||||
std::vector<torrent_handle> torrents = s->get_torrents();
|
std::vector<torrent_handle> torrents = s->get_torrents();
|
||||||
std::vector<torrent_handle>::iterator torrentIT;
|
|
||||||
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
|
std::vector<torrent_handle>::iterator torrentIT = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::iterator torrentITend = torrents.end();
|
||||||
|
for ( ; torrentIT != torrentITend; ++torrentIT) {
|
||||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||||
if (!h.is_valid() || !h.has_metadata()) continue;
|
if (!h.is_valid() || !h.has_metadata()) continue;
|
||||||
try {
|
try {
|
||||||
@ -1726,8 +1752,10 @@ void QBtSession::setDefaultTempPath(QString temppath) {
|
|||||||
// Disabling temp dir
|
// Disabling temp dir
|
||||||
// Moving all torrents to their destination folder
|
// Moving all torrents to their destination folder
|
||||||
std::vector<torrent_handle> torrents = s->get_torrents();
|
std::vector<torrent_handle> torrents = s->get_torrents();
|
||||||
std::vector<torrent_handle>::iterator torrentIT;
|
|
||||||
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
|
std::vector<torrent_handle>::iterator torrentIT = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::iterator torrentITend = torrents.end();
|
||||||
|
for ( ; torrentIT != torrentITend; ++torrentIT) {
|
||||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||||
if (!h.is_valid()) continue;
|
if (!h.is_valid()) continue;
|
||||||
h.move_storage(getSavePath(h.hash()));
|
h.move_storage(getSavePath(h.hash()));
|
||||||
@ -1736,8 +1764,10 @@ void QBtSession::setDefaultTempPath(QString temppath) {
|
|||||||
qDebug("Enabling default temp path...");
|
qDebug("Enabling default temp path...");
|
||||||
// Moving all downloading torrents to temporary save path
|
// Moving all downloading torrents to temporary save path
|
||||||
std::vector<torrent_handle> torrents = s->get_torrents();
|
std::vector<torrent_handle> torrents = s->get_torrents();
|
||||||
std::vector<torrent_handle>::iterator torrentIT;
|
|
||||||
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
|
std::vector<torrent_handle>::iterator torrentIT = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::iterator torrentITend = torrents.end();
|
||||||
|
for ( ; torrentIT != torrentITend; ++torrentIT) {
|
||||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||||
if (!h.is_valid()) continue;
|
if (!h.is_valid()) continue;
|
||||||
if (!h.is_seed()) {
|
if (!h.is_seed()) {
|
||||||
@ -1811,8 +1841,10 @@ void QBtSession::setAppendLabelToSavePath(bool append) {
|
|||||||
if (appendLabelToSavePath) {
|
if (appendLabelToSavePath) {
|
||||||
// Move torrents storage to sub folder with label name
|
// Move torrents storage to sub folder with label name
|
||||||
std::vector<torrent_handle> torrents = s->get_torrents();
|
std::vector<torrent_handle> torrents = s->get_torrents();
|
||||||
std::vector<torrent_handle>::iterator torrentIT;
|
|
||||||
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
|
std::vector<torrent_handle>::iterator torrentIT = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::iterator torrentITend = torrents.end();
|
||||||
|
for ( ; torrentIT != torrentITend; ++torrentIT) {
|
||||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||||
appendLabelToTorrentSavePath(h);
|
appendLabelToTorrentSavePath(h);
|
||||||
}
|
}
|
||||||
@ -1825,8 +1857,10 @@ void QBtSession::setAppendqBExtension(bool append) {
|
|||||||
appendqBExtension = !appendqBExtension;
|
appendqBExtension = !appendqBExtension;
|
||||||
// append or remove .!qB extension for incomplete files
|
// append or remove .!qB extension for incomplete files
|
||||||
std::vector<torrent_handle> torrents = s->get_torrents();
|
std::vector<torrent_handle> torrents = s->get_torrents();
|
||||||
std::vector<torrent_handle>::iterator torrentIT;
|
|
||||||
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
|
std::vector<torrent_handle>::iterator torrentIT = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::iterator torrentITend = torrents.end();
|
||||||
|
for ( ; torrentIT != torrentITend; ++torrentIT) {
|
||||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||||
appendqBextensionToTorrent(h, appendqBExtension);
|
appendqBextensionToTorrent(h, appendqBExtension);
|
||||||
}
|
}
|
||||||
@ -2473,8 +2507,10 @@ void QBtSession::readAlerts() {
|
|||||||
qDebug() << "Sucessfully listening on" << p->endpoint.address().to_string(ec).c_str() << "/" << p->endpoint.port();
|
qDebug() << "Sucessfully listening on" << p->endpoint.address().to_string(ec).c_str() << "/" << p->endpoint.port();
|
||||||
// Force reannounce on all torrents because some trackers blacklist some ports
|
// Force reannounce on all torrents because some trackers blacklist some ports
|
||||||
std::vector<torrent_handle> torrents = s->get_torrents();
|
std::vector<torrent_handle> torrents = s->get_torrents();
|
||||||
std::vector<torrent_handle>::iterator it;
|
|
||||||
for (it = torrents.begin(); it != torrents.end(); ++it) {
|
std::vector<torrent_handle>::iterator it = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::iterator itend = torrents.end();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
it->force_reannounce();
|
it->force_reannounce();
|
||||||
}
|
}
|
||||||
emit listenSucceeded();
|
emit listenSucceeded();
|
||||||
|
@ -281,8 +281,10 @@ QStringList QTorrentHandle::url_seeds() const {
|
|||||||
QStringList res;
|
QStringList res;
|
||||||
try {
|
try {
|
||||||
const std::set<std::string> existing_seeds = torrent_handle::url_seeds();
|
const std::set<std::string> existing_seeds = torrent_handle::url_seeds();
|
||||||
std::set<std::string>::const_iterator it;
|
|
||||||
for (it = existing_seeds.begin(); it != existing_seeds.end(); ++it) {
|
std::set<std::string>::const_iterator it = existing_seeds.begin();
|
||||||
|
std::set<std::string>::const_iterator itend = existing_seeds.end();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
qDebug("URL Seed: %s", it->c_str());
|
qDebug("URL Seed: %s", it->c_str());
|
||||||
res << misc::toQString(*it);
|
res << misc::toQString(*it);
|
||||||
}
|
}
|
||||||
@ -582,7 +584,10 @@ QString QTorrentHandle::error() const {
|
|||||||
void QTorrentHandle::downloading_pieces(bitfield &bf) const {
|
void QTorrentHandle::downloading_pieces(bitfield &bf) const {
|
||||||
std::vector<partial_piece_info> queue;
|
std::vector<partial_piece_info> queue;
|
||||||
torrent_handle::get_download_queue(queue);
|
torrent_handle::get_download_queue(queue);
|
||||||
for (std::vector<partial_piece_info>::const_iterator it=queue.begin(); it!= queue.end(); ++it) {
|
|
||||||
|
std::vector<partial_piece_info>::const_iterator it = queue.begin();
|
||||||
|
std::vector<partial_piece_info>::const_iterator itend = queue.end();
|
||||||
|
for ( ; it!= itend; ++it) {
|
||||||
bf.set_bit(it->piece_index);
|
bf.set_bit(it->piece_index);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -205,8 +205,10 @@ TorrentModel::TorrentModel(QObject *parent) :
|
|||||||
void TorrentModel::populate() {
|
void TorrentModel::populate() {
|
||||||
// Load the torrents
|
// Load the torrents
|
||||||
std::vector<torrent_handle> torrents = QBtSession::instance()->getSession()->get_torrents();
|
std::vector<torrent_handle> torrents = QBtSession::instance()->getSession()->get_torrents();
|
||||||
std::vector<torrent_handle>::const_iterator it;
|
|
||||||
for (it = torrents.begin(); it != torrents.end(); ++it) {
|
std::vector<torrent_handle>::const_iterator it = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::const_iterator itend = torrents.end();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
addTorrent(QTorrentHandle(*it));
|
addTorrent(QTorrentHandle(*it));
|
||||||
}
|
}
|
||||||
// Refresh timer
|
// Refresh timer
|
||||||
@ -313,9 +315,11 @@ bool TorrentModel::setData(const QModelIndex &index, const QVariant &value, int
|
|||||||
|
|
||||||
int TorrentModel::torrentRow(const QString &hash) const
|
int TorrentModel::torrentRow(const QString &hash) const
|
||||||
{
|
{
|
||||||
QList<TorrentModelItem*>::const_iterator it;
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
for (it = m_torrents.constBegin(); it != m_torrents.constEnd(); ++it) {
|
|
||||||
|
QList<TorrentModelItem*>::const_iterator it = m_torrents.constBegin();
|
||||||
|
QList<TorrentModelItem*>::const_iterator itend = m_torrents.constEnd();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
if ((*it)->hash() == hash) return row;
|
if ((*it)->hash() == hash) return row;
|
||||||
++row;
|
++row;
|
||||||
}
|
}
|
||||||
@ -395,8 +399,10 @@ void TorrentModel::forceModelRefresh()
|
|||||||
TorrentStatusReport TorrentModel::getTorrentStatusReport() const
|
TorrentStatusReport TorrentModel::getTorrentStatusReport() const
|
||||||
{
|
{
|
||||||
TorrentStatusReport report;
|
TorrentStatusReport report;
|
||||||
QList<TorrentModelItem*>::const_iterator it;
|
|
||||||
for (it = m_torrents.constBegin(); it != m_torrents.constEnd(); ++it) {
|
QList<TorrentModelItem*>::const_iterator it = m_torrents.constBegin();
|
||||||
|
QList<TorrentModelItem*>::const_iterator itend = m_torrents.constEnd();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
switch((*it)->data(TorrentModelItem::TR_STATUS).toInt()) {
|
switch((*it)->data(TorrentModelItem::TR_STATUS).toInt()) {
|
||||||
case TorrentModelItem::STATE_DOWNLOADING:
|
case TorrentModelItem::STATE_DOWNLOADING:
|
||||||
++report.nb_active;
|
++report.nb_active;
|
||||||
|
@ -122,8 +122,10 @@ qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const
|
|||||||
void TorrentSpeedMonitor::getSamples()
|
void TorrentSpeedMonitor::getSamples()
|
||||||
{
|
{
|
||||||
const std::vector<torrent_handle> torrents = m_session->getSession()->get_torrents();
|
const std::vector<torrent_handle> torrents = m_session->getSession()->get_torrents();
|
||||||
std::vector<torrent_handle>::const_iterator it;
|
|
||||||
for (it = torrents.begin(); it != torrents.end(); ++it) {
|
std::vector<torrent_handle>::const_iterator it = torrents.begin();
|
||||||
|
std::vector<torrent_handle>::const_iterator itend = torrents.end();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
try {
|
try {
|
||||||
#if LIBTORRENT_VERSION_MINOR > 15
|
#if LIBTORRENT_VERSION_MINOR > 15
|
||||||
torrent_status st = it->status(0x0);
|
torrent_status st = it->status(0x0);
|
||||||
|
@ -63,9 +63,11 @@ public:
|
|||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||||
std::vector<int>::const_iterator pp_it = pp.begin();
|
|
||||||
QStringList pieces_priority;
|
QStringList pieces_priority;
|
||||||
while(pp_it != pp.end()) {
|
|
||||||
|
std::vector<int>::const_iterator pp_it = pp.begin();
|
||||||
|
std::vector<int>::const_iterator pp_itend = pp.end();
|
||||||
|
while(pp_it != pp_itend) {
|
||||||
pieces_priority << QString::number(*pp_it);
|
pieces_priority << QString::number(*pp_it);
|
||||||
++pp_it;
|
++pp_it;
|
||||||
}
|
}
|
||||||
@ -206,8 +208,9 @@ public:
|
|||||||
static bool hasPerTorrentRatioLimit() {
|
static bool hasPerTorrentRatioLimit() {
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||||
QHash<QString, QVariant>::ConstIterator it;
|
QHash<QString, QVariant>::ConstIterator it = all_data.constBegin();
|
||||||
for (it = all_data.constBegin(); it != all_data.constEnd(); it++) {
|
QHash<QString, QVariant>::ConstIterator itend = all_data.constEnd();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
if (it.value().toHash().value("max_ratio", USE_GLOBAL_RATIO).toReal() >= 0) {
|
if (it.value().toHash().value("max_ratio", USE_GLOBAL_RATIO).toReal() >= 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user