Browse Source

Use preincrement for iterators instead of postincrement

adaptive-webui-19844
Константин Гончарик 12 years ago committed by Christophe Dumez
parent
commit
abf8c179fc
  1. 2
      src/fs_utils.cpp
  2. 2
      src/properties/peerlistwidget.cpp
  3. 2
      src/properties/trackerlist.cpp
  4. 2
      src/properties/trackersadditiondlg.h
  5. 34
      src/qtlibtorrent/qbtsession.cpp
  6. 4
      src/qtlibtorrent/qtorrenthandle.cpp
  7. 6
      src/qtlibtorrent/torrentmodel.cpp
  8. 2
      src/qtlibtorrent/torrentspeedmonitor.cpp
  9. 2
      src/torrentpersistentdata.h

2
src/fs_utils.cpp

@ -215,7 +215,7 @@ QString fsutils::fixFileNames(const QString& path) @@ -215,7 +215,7 @@ QString fsutils::fixFileNames(const QString& path)
if (parts.isEmpty()) return path;
QByteArray last_part = parts.takeLast();
QList<QByteArray>::iterator it;
for (it = parts.begin(); it != parts.end(); it++) {
for (it = parts.begin(); it != parts.end(); ++it) {
// Make sure the filename is not too long
if (it->size() > MAX_FILENAME_BYTES) {
qWarning() << "Folder" << *it << "was cut because it was too long";

2
src/properties/peerlistwidget.cpp

@ -312,7 +312,7 @@ void PeerListWidget::loadPeers(const QTorrentHandle &h, bool force_hostname_reso @@ -312,7 +312,7 @@ void PeerListWidget::loadPeers(const QTorrentHandle &h, bool force_hostname_reso
h.get_peer_info(peers);
std::vector<peer_info>::const_iterator itr;
QSet<QString> old_peers_set = m_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;

2
src/properties/trackerlist.cpp

@ -313,7 +313,7 @@ void TrackerList::deleteSelectedTrackers() { @@ -313,7 +313,7 @@ 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++) {
for (it = trackers.begin(); it != trackers.end(); ++it) {
if (!urls_to_remove.contains(misc::toQString((*it).url))) {
remaining_trackers.push_back(*it);
}

2
src/properties/trackersadditiondlg.h

@ -90,7 +90,7 @@ public slots: @@ -90,7 +90,7 @@ public slots:
std::vector<libtorrent::announce_entry>::iterator itr = tor_trackers.begin();
while(itr != tor_trackers.end()) {
existingTrackers << QUrl(misc::toQString(itr->url));
itr++;
++itr;
}
// Load from current user list
QStringList tmp = trackers_list->toPlainText().split("\n");

34
src/qtlibtorrent/qbtsession.cpp

@ -213,7 +213,7 @@ void QBtSession::processBigRatios() { @@ -213,7 +213,7 @@ void QBtSession::processBigRatios() {
qDebug("Process big ratios...");
std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT;
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
const QTorrentHandle h(*torrentIT);
if (!h.is_valid()) continue;
if (h.is_seed()) {
@ -360,7 +360,7 @@ void QBtSession::configureSession() { @@ -360,7 +360,7 @@ void QBtSession::configureSession() {
// Update torrent handles
std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT;
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
QTorrentHandle h = QTorrentHandle(*torrentIT);
if (h.is_valid())
h.resolve_countries(resolve_countries);
@ -712,7 +712,7 @@ QTorrentHandle QBtSession::getTorrentHandle(const QString &hash) const { @@ -712,7 +712,7 @@ QTorrentHandle QBtSession::getTorrentHandle(const QString &hash) const {
bool QBtSession::hasActiveTorrents() const {
std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT;
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
const QTorrentHandle h(*torrentIT);
if (h.is_valid() && !h.is_paused() && !h.is_queued())
return true;
@ -723,7 +723,7 @@ bool QBtSession::hasActiveTorrents() const { @@ -723,7 +723,7 @@ bool QBtSession::hasActiveTorrents() const {
bool QBtSession::hasDownloadingTorrents() const {
std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT;
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
if (torrentIT->is_valid()) {
try {
const torrent_status::state_t state = torrentIT->status().state;
@ -803,7 +803,7 @@ void QBtSession::deleteTorrent(const QString &hash, bool delete_local_files) { @@ -803,7 +803,7 @@ void QBtSession::deleteTorrent(const QString &hash, bool delete_local_files) {
void QBtSession::pauseAllTorrents() {
std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT;
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
try {
QTorrentHandle h = QTorrentHandle(*torrentIT);
if (!h.is_paused()) {
@ -821,7 +821,7 @@ std::vector<torrent_handle> QBtSession::getTorrents() const { @@ -821,7 +821,7 @@ std::vector<torrent_handle> QBtSession::getTorrents() const {
void QBtSession::resumeAllTorrents() {
std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT;
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
try {
QTorrentHandle h = QTorrentHandle(*torrentIT);
if (h.is_paused()) {
@ -1335,7 +1335,7 @@ void QBtSession::mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr<torren @@ -1335,7 +1335,7 @@ void QBtSession::mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr<torren
#else
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++) {
for (it = new_urlseeds.begin(); it != new_urlseeds.end(); ++it) {
const QString new_url = misc::toQString(it->c_str());
if (!old_urlseeds.contains(new_url)) {
urlseeds_added = true;
@ -1359,7 +1359,7 @@ void QBtSession::exportTorrentFiles(QString path) { @@ -1359,7 +1359,7 @@ void QBtSession::exportTorrentFiles(QString path) {
QDir torrentBackup(fsutils::BTBackupLocation());
std::vector<torrent_handle> handles = s->get_torrents();
std::vector<torrent_handle>::iterator itr;
for (itr=handles.begin(); itr != handles.end(); itr++) {
for (itr=handles.begin(); itr != handles.end(); ++itr) {
const QTorrentHandle h(*itr);
if (!h.is_valid()) {
std::cerr << "Torrent Export: torrent is invalid, skipping..." << std::endl;
@ -1400,7 +1400,7 @@ void QBtSession::setMaxConnectionsPerTorrent(int max) { @@ -1400,7 +1400,7 @@ void QBtSession::setMaxConnectionsPerTorrent(int max) {
// Apply this to all session torrents
std::vector<torrent_handle> handles = s->get_torrents();
std::vector<torrent_handle>::const_iterator it;
for (it = handles.begin(); it != handles.end(); it++) {
for (it = handles.begin(); it != handles.end(); ++it) {
if (!it->is_valid())
continue;
try {
@ -1414,7 +1414,7 @@ void QBtSession::setMaxUploadsPerTorrent(int max) { @@ -1414,7 +1414,7 @@ void QBtSession::setMaxUploadsPerTorrent(int max) {
// Apply this to all session torrents
std::vector<torrent_handle> handles = s->get_torrents();
std::vector<torrent_handle>::const_iterator it;
for (it = handles.begin(); it != handles.end(); it++) {
for (it = handles.begin(); it != handles.end(); ++it) {
if (!it->is_valid())
continue;
try {
@ -1565,7 +1565,7 @@ qreal QBtSession::getRealRatio(const QString &hash) const { @@ -1565,7 +1565,7 @@ qreal QBtSession::getRealRatio(const QString &hash) const {
void QBtSession::saveTempFastResumeData() {
std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT;
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
QTorrentHandle h = QTorrentHandle(*torrentIT);
try {
if (!h.is_valid() || !h.has_metadata() /*|| h.is_seed() || h.is_paused()*/) continue;
@ -1591,7 +1591,7 @@ void QBtSession::saveFastResumeData() { @@ -1591,7 +1591,7 @@ void QBtSession::saveFastResumeData() {
s->pause();
std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT;
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
QTorrentHandle h = QTorrentHandle(*torrentIT);
if (!h.is_valid() || !h.has_metadata()) continue;
try {
@ -1727,7 +1727,7 @@ void QBtSession::setDefaultTempPath(QString temppath) { @@ -1727,7 +1727,7 @@ void QBtSession::setDefaultTempPath(QString temppath) {
// Moving all torrents to their destination folder
std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT;
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
QTorrentHandle h = QTorrentHandle(*torrentIT);
if (!h.is_valid()) continue;
h.move_storage(getSavePath(h.hash()));
@ -1737,7 +1737,7 @@ void QBtSession::setDefaultTempPath(QString temppath) { @@ -1737,7 +1737,7 @@ void QBtSession::setDefaultTempPath(QString temppath) {
// Moving all downloading torrents to temporary save path
std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT;
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
QTorrentHandle h = QTorrentHandle(*torrentIT);
if (!h.is_valid()) continue;
if (!h.is_seed()) {
@ -1812,7 +1812,7 @@ void QBtSession::setAppendLabelToSavePath(bool append) { @@ -1812,7 +1812,7 @@ void QBtSession::setAppendLabelToSavePath(bool append) {
// Move torrents storage to sub folder with label name
std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT;
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
QTorrentHandle h = QTorrentHandle(*torrentIT);
appendLabelToTorrentSavePath(h);
}
@ -1826,7 +1826,7 @@ void QBtSession::setAppendqBExtension(bool append) { @@ -1826,7 +1826,7 @@ void QBtSession::setAppendqBExtension(bool append) {
// append or remove .!qB extension for incomplete files
std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT;
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) {
QTorrentHandle h = QTorrentHandle(*torrentIT);
appendqBextensionToTorrent(h, appendqBExtension);
}
@ -2474,7 +2474,7 @@ void QBtSession::readAlerts() { @@ -2474,7 +2474,7 @@ void QBtSession::readAlerts() {
// Force reannounce on all torrents because some trackers blacklist some ports
std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator it;
for (it = torrents.begin(); it != torrents.end(); it++) {
for (it = torrents.begin(); it != torrents.end(); ++it) {
it->force_reannounce();
}
emit listenSucceeded();

4
src/qtlibtorrent/qtorrenthandle.cpp

@ -282,7 +282,7 @@ QStringList QTorrentHandle::url_seeds() const { @@ -282,7 +282,7 @@ QStringList QTorrentHandle::url_seeds() const {
try {
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++) {
for (it = existing_seeds.begin(); it != existing_seeds.end(); ++it) {
qDebug("URL Seed: %s", it->c_str());
res << misc::toQString(*it);
}
@ -582,7 +582,7 @@ QString QTorrentHandle::error() const { @@ -582,7 +582,7 @@ QString QTorrentHandle::error() const {
void QTorrentHandle::downloading_pieces(bitfield &bf) const {
std::vector<partial_piece_info> queue;
torrent_handle::get_download_queue(queue);
for (std::vector<partial_piece_info>::const_iterator it=queue.begin(); it!= queue.end(); it++) {
for (std::vector<partial_piece_info>::const_iterator it=queue.begin(); it!= queue.end(); ++it) {
bf.set_bit(it->piece_index);
}
return;

6
src/qtlibtorrent/torrentmodel.cpp

@ -206,7 +206,7 @@ void TorrentModel::populate() { @@ -206,7 +206,7 @@ void TorrentModel::populate() {
// Load the 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++) {
for (it = torrents.begin(); it != torrents.end(); ++it) {
addTorrent(QTorrentHandle(*it));
}
// Refresh timer
@ -315,7 +315,7 @@ int TorrentModel::torrentRow(const QString &hash) const @@ -315,7 +315,7 @@ int TorrentModel::torrentRow(const QString &hash) const
{
QList<TorrentModelItem*>::const_iterator it;
int row = 0;
for (it = m_torrents.constBegin(); it != m_torrents.constEnd(); it++) {
for (it = m_torrents.constBegin(); it != m_torrents.constEnd(); ++it) {
if ((*it)->hash() == hash) return row;
++row;
}
@ -396,7 +396,7 @@ TorrentStatusReport TorrentModel::getTorrentStatusReport() const @@ -396,7 +396,7 @@ TorrentStatusReport TorrentModel::getTorrentStatusReport() const
{
TorrentStatusReport report;
QList<TorrentModelItem*>::const_iterator it;
for (it = m_torrents.constBegin(); it != m_torrents.constEnd(); it++) {
for (it = m_torrents.constBegin(); it != m_torrents.constEnd(); ++it) {
switch((*it)->data(TorrentModelItem::TR_STATUS).toInt()) {
case TorrentModelItem::STATE_DOWNLOADING:
++report.nb_active;

2
src/qtlibtorrent/torrentspeedmonitor.cpp

@ -123,7 +123,7 @@ void TorrentSpeedMonitor::getSamples() @@ -123,7 +123,7 @@ void TorrentSpeedMonitor::getSamples()
{
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++) {
for (it = torrents.begin(); it != torrents.end(); ++it) {
try {
#if LIBTORRENT_VERSION_MINOR > 15
torrent_status st = it->status(0x0);

2
src/torrentpersistentdata.h

@ -67,7 +67,7 @@ public: @@ -67,7 +67,7 @@ public:
QStringList pieces_priority;
while(pp_it != pp.end()) {
pieces_priority << QString::number(*pp_it);
pp_it++;
++pp_it;
}
data["files_priority"] = pieces_priority;
all_data[hash] = data;

Loading…
Cancel
Save