Changeset 14499


Ignore:
Timestamp:
Apr 18, 2015, 2:41:06 PM (6 years ago)
Author:
mikedld
Message:

Use C++11 range-based for loops (Qt client)

Location:
trunk/qt
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/app.cc

    r14466 r14499  
    7878  {
    7979    const QString filename = name + QLatin1Char ('_') + localeName;
    80     foreach (const QString& directory, searchDirectories)
     80    for (const QString& directory: searchDirectories)
    8181    {
    8282      if (translator.load (filename, directory))
     
    135135      QList<int> sizes;
    136136      sizes << 16 << 22 << 24 << 32 << 48 << 64 << 72 << 96 << 128 << 192 << 256;
    137       foreach (int size, sizes)
     137      for (const int size: sizes)
    138138        icon.addPixmap (QPixmap (QString::fromLatin1 (":/icons/transmission-%1.png").arg (size)));
    139139    }
     
    181181  {
    182182    bool delegated = false;
    183     for (int i=0, n=filenames.size (); i<n; ++i)
     183    for (const QString& filename: filenames)
    184184      {
    185185        QDBusMessage request = QDBusMessage::createMethodCall (DBUS_SERVICE,
     
    188188                                                               QString::fromUtf8 ("AddMetainfo"));
    189189        QList<QVariant> arguments;
    190         AddData a (filenames[i]);
     190        AddData a (filename);
    191191        switch (a.type)
    192192          {
     
    268268  QList<int> initKeys;
    269269  initKeys << Prefs::DIR_WATCH;
    270   foreach (int key, initKeys)
     270  for (const int key: initKeys)
    271271    refreshPref (key);
    272272  connect (myPrefs, SIGNAL (changed (int)), this, SLOT (refreshPref (const int)));
     
    319319    }
    320320
    321   for (QStringList::const_iterator it=filenames.begin (), end=filenames.end (); it!=end; ++it)
    322     addTorrent (*it);
     321  for (const QString& filename: filenames)
     322    addTorrent (filename);
    323323
    324324  // register as the dbus handler for Transmission
     
    347347    return;
    348348
    349   foreach (int id, torrents)
     349  for (const int id: torrents)
    350350    {
    351351      Torrent * tor = myModel->getTorrentFromId (id);
  • trunk/qt/column-resizer.cc

    r14460 r14499  
    1717{
    1818  int
    19   itemColumnSpan (QGridLayout * layout, const QLayoutItem * item)
     19  itemColumnSpan (const QGridLayout * layout, const QLayoutItem * item)
    2020  {
    2121    for (int i = 0, count = layout->count (); i < count; ++i)
     
    6161{
    6262  int maxWidth = 0;
    63   foreach (QGridLayout * layout, myLayouts)
     63  for (const QGridLayout * const layout: myLayouts)
    6464    {
    6565      for (int i = 0, count = layout->rowCount (); i < count; ++i)
     
    7272    }
    7373
    74   foreach (QGridLayout * layout, myLayouts)
     74  for (QGridLayout * const layout: myLayouts)
    7575    layout->setColumnMinimumWidth (0, maxWidth);
    7676}
  • trunk/qt/details.cc

    r14468 r14499  
    199199  initKeys << Prefs::SHOW_TRACKER_SCRAPES
    200200           << Prefs::SHOW_BACKUP_TRACKERS;
    201   foreach (int key, initKeys)
     201  for (const int key: initKeys)
    202202    refreshPref (key);
    203203
     
    226226
    227227  // stop listening to the old torrents
    228   foreach (int id, myIds)
     228  for (const int id: myIds)
    229229    {
    230230      const Torrent * tor = myModel.getTorrentFromId (id);
     
    238238
    239239  // listen to the new torrents
    240   foreach (int id, myIds)
     240  for (const int id: myIds)
    241241    {
    242242      const Torrent * tor = myModel.getTorrentFromId (id);
     
    306306    {
    307307      QSet<int> infos;
    308       foreach (int id, myIds)
     308      for (const int id: myIds)
    309309        {
    310310          const Torrent * tor = myModel.getTorrentFromId (id);
     
    376376
    377377  // build a list of torrents
    378   foreach (int id, myIds)
     378  for (const int id: myIds)
    379379    {
    380380      const Torrent * tor = myModel.getTorrentFromId (id);
     
    398398      bool allFinished = true;
    399399      const tr_torrent_activity baseline = torrents[0]->getActivity ();
    400       foreach (const Torrent * t, torrents)
     400      for (const Torrent * const t: torrents)
    401401        {
    402402          const tr_torrent_activity activity = t->getActivity ();
     
    436436      int64_t verifiedPieces = 0;
    437437
    438       foreach (const Torrent * t, torrents)
     438      for (const Torrent * const t: torrents)
    439439        {
    440440          if (t->hasMetadata ())
     
    507507      uint64_t d = 0;
    508508      uint64_t f = 0;
    509       foreach (const Torrent * t, torrents)
     509      for (const Torrent * const t: torrents)
    510510        {
    511511          d += t->downloadedEver ();
     
    530530      uint64_t u = 0;
    531531      uint64_t d = 0;
    532       foreach (const Torrent * t, torrents)
     532      for (const Torrent * const t: torrents)
    533533        {
    534534          u += t->uploadedEver ();
     
    552552      bool allPaused = true;
    553553      QDateTime baseline = torrents[0]->lastStarted ();
    554       foreach (const Torrent * t, torrents)
     554      for (const Torrent * const t: torrents)
    555555        {
    556556          if (baseline != t->lastStarted ())
     
    579579    {
    580580      int baseline = torrents[0]->getETA ();
    581       foreach (const Torrent * t, torrents)
     581      for (const Torrent * const t: torrents)
    582582        {
    583583          if (baseline != t->getETA ())
     
    607607    {
    608608      QDateTime latest = torrents[0]->lastActivity ();
    609       foreach (const Torrent * t, torrents)
     609      for (const Torrent * const t: torrents)
    610610        {
    611611          const QDateTime dt = t->lastActivity ();
     
    632632    {
    633633      string = torrents[0]->getError ();
    634       foreach (const Torrent * t, torrents)
     634      for (const Torrent * const t: torrents)
    635635        {
    636636          if (string != t->getError ())
     
    660660      uint64_t size = 0;
    661661      uint32_t pieceSize = torrents[0]->pieceSize ();
    662       foreach (const Torrent * t, torrents)
     662      for (const Torrent * const t: torrents)
    663663        {
    664664          pieces += t->pieceCount ();
     
    685685    {
    686686      string = torrents[0]->hashString ();
    687       foreach (const Torrent * t, torrents)
     687      for (const Torrent * const t: torrents)
    688688        {
    689689          if (string != t->hashString ())
     
    703703      string = b ? tr ("Private to this tracker -- DHT and PEX disabled")
    704704                 : tr ("Public torrent");
    705       foreach (const Torrent * t, torrents)
     705      for (const Torrent * const t: torrents)
    706706        {
    707707          if (b != t->isPrivate ())
     
    720720    {
    721721      string = torrents[0]->comment ();
    722       foreach (const Torrent * t, torrents)
     722      for (const Torrent * const t: torrents)
    723723        {
    724724          if (string != t->comment ())
     
    743743      const QString creator = torrents[0]->creator ();
    744744      const QString date = torrents[0]->dateCreated ().toString ();
    745       foreach (const Torrent * t, torrents)
     745      for (const Torrent * const t: torrents)
    746746        {
    747747          mixed_creator |= (creator != t->creator ());
     
    767767    {
    768768      string = torrents[0]->getPath ();
    769       foreach (const Torrent * t, torrents)
     769      for (const Torrent * const t: torrents)
    770770        {
    771771          if (string != t->getPath ())
     
    789789      bool baselineFlag;
    790790      int baselineInt;
    791       const Torrent * tor;
    792       const Torrent * baseline = *torrents.begin ();
     791      const Torrent& baseline = *torrents.front ();
    793792
    794793      // mySessionLimitCheck
    795794      uniform = true;
    796       baselineFlag = baseline->honorsSessionLimits ();
    797       foreach (tor, torrents) if (baselineFlag != tor->honorsSessionLimits ()) { uniform = false; break; }
     795      baselineFlag = baseline.honorsSessionLimits ();
     796      for (const Torrent * const tor: torrents) if (baselineFlag != tor->honorsSessionLimits ()) { uniform = false; break; }
    798797      ui.sessionLimitCheck->setChecked (uniform && baselineFlag);
    799798
    800799      // mySingleDownCheck
    801800      uniform = true;
    802       baselineFlag = baseline->downloadIsLimited ();
    803       foreach (tor, torrents) if (baselineFlag != tor->downloadIsLimited ()) { uniform = false; break; }
     801      baselineFlag = baseline.downloadIsLimited ();
     802      for (const Torrent * const tor: torrents) if (baselineFlag != tor->downloadIsLimited ()) { uniform = false; break; }
    804803      ui.singleDownCheck->setChecked (uniform && baselineFlag);
    805804
    806805      // mySingleUpCheck
    807806      uniform = true;
    808       baselineFlag = baseline->uploadIsLimited ();
    809       foreach (tor, torrents) if (baselineFlag != tor->uploadIsLimited ()) { uniform = false; break; }
     807      baselineFlag = baseline.uploadIsLimited ();
     808      for (const Torrent * const tor: torrents) if (baselineFlag != tor->uploadIsLimited ()) { uniform = false; break; }
    810809      ui.singleUpCheck->setChecked (uniform && baselineFlag);
    811810
    812811      // myBandwidthPriorityCombo
    813812      uniform = true;
    814       baselineInt = baseline->getBandwidthPriority ();
    815       foreach (tor, torrents) if (baselineInt != tor->getBandwidthPriority ()) { uniform = false; break; }
     813      baselineInt = baseline.getBandwidthPriority ();
     814      for (const Torrent * const tor: torrents) if (baselineInt != tor->getBandwidthPriority ()) { uniform = false; break; }
    816815      if (uniform)
    817816        i = ui.bandwidthPriorityCombo->findData (baselineInt);
     
    820819      setIfIdle (ui.bandwidthPriorityCombo, i);
    821820
    822       setIfIdle (ui.singleDownSpin, int (tor->downloadLimit ().KBps ()));
    823       setIfIdle (ui.singleUpSpin, int (tor->uploadLimit ().KBps ()));
    824       setIfIdle (ui.peerLimitSpin, tor->peerLimit ());
     821      setIfIdle (ui.singleDownSpin, int (baseline.downloadLimit ().KBps ()));
     822      setIfIdle (ui.singleUpSpin, int (baseline.uploadLimit ().KBps ()));
     823      setIfIdle (ui.peerLimitSpin, baseline.peerLimit ());
    825824    }
    826825
    827826  if (!torrents.empty ())
    828827    {
    829       const Torrent * tor;
     828      const Torrent& baseline = *torrents.front ();
    830829
    831830      // ratio
    832831      bool uniform = true;
    833       int baselineInt = torrents[0]->seedRatioMode ();
    834       foreach (tor, torrents) if (baselineInt != tor->seedRatioMode ()) { uniform = false; break; }
     832      int baselineInt = baseline.seedRatioMode ();
     833      for (const Torrent * const tor: torrents) if (baselineInt != tor->seedRatioMode ()) { uniform = false; break; }
    835834
    836835      setIfIdle (ui.ratioCombo, uniform ? ui.ratioCombo->findData (baselineInt) : -1);
    837836      ui.ratioSpin->setVisible (uniform && (baselineInt == TR_RATIOLIMIT_SINGLE));
    838837
    839       setIfIdle (ui.ratioSpin, tor->seedRatioLimit ());
     838      setIfIdle (ui.ratioSpin, baseline.seedRatioLimit ());
    840839
    841840      // idle
    842841      uniform = true;
    843       baselineInt = torrents[0]->seedIdleMode ();
    844       foreach (tor, torrents) if (baselineInt != tor->seedIdleMode ()) { uniform = false; break; }
     842      baselineInt = baseline.seedIdleMode ();
     843      for (const Torrent * const tor: torrents) if (baselineInt != tor->seedIdleMode ()) { uniform = false; break; }
    845844
    846845      setIfIdle (ui.idleCombo, uniform ? ui.idleCombo->findData (baselineInt) : -1);
    847846      ui.idleSpin->setVisible (uniform && (baselineInt == TR_RATIOLIMIT_SINGLE));
    848847
    849       setIfIdle (ui.idleSpin, tor->seedIdleLimit ());
     848      setIfIdle (ui.idleSpin, baseline.seedIdleLimit ());
    850849      onIdleLimitChanged ();
    851850    }
     
    863862  QMap<QString,QTreeWidgetItem*> peers2;
    864863  QList<QTreeWidgetItem*> newItems;
    865   foreach (const Torrent * t, torrents)
     864  for (const Torrent * const t: torrents)
    866865    {
    867866      const QString idStr (QString::number (t->id ()));
    868867      PeerList peers = t->peers ();
    869868
    870       foreach (const Peer& peer, peers)
     869      for (const Peer& peer: peers)
    871870        {
    872871          const QString key = idStr + QLatin1Char (':') + peer.address;
     
    893892
    894893          QString codeTip;
    895           foreach (QChar ch, code)
     894          for (const QChar ch: code)
    896895            {
    897896              QString txt;
     
    930929
    931930  ui.peersView->addTopLevelItems (newItems);
    932   foreach (QString key, myPeers.keys ())
     931  for (const QString& key: myPeers.keys ())
    933932    {
    934933      if (!peers2.contains (key)) // old peer has disconnected
     
    10791078      QSet<int> ids;
    10801079
    1081       foreach (int id, myIds)
     1080      for (const int id: myIds)
    10821081        if (myTrackerModel->find (id,url) == -1)
    10831082          ids.insert (id);
     
    11401139  QModelIndexList selectedRows = selectionModel->selectedRows ();
    11411140  QMap<int,int> torrentId_to_trackerIds;
    1142   foreach (QModelIndex i, selectedRows)
     1141  for (const QModelIndex& i: selectedRows)
    11431142    {
    11441143      const TrackerInfo inf = ui.trackersView->model ()->data (i, TrackerModel::TrackerRole).value<TrackerInfo> ();
     
    11471146
    11481147  // batch all of a tracker's torrents into one command
    1149   foreach (int id, torrentId_to_trackerIds.uniqueKeys ())
     1148  for (const int id: torrentId_to_trackerIds.uniqueKeys ())
    11501149    {
    11511150      QSet<int> ids;
     
    13161315    return;
    13171316
    1318   foreach (const int id, myIds)
     1317  for (const int id: myIds)
    13191318    {
    13201319      const Torrent * const tor = myModel.getTorrentFromId (id);
  • trunk/qt/favicon.cc

    r14466 r14499  
    6666
    6767      QStringList files = cacheDir.entryList (QDir::Files|QDir::Readable);
    68       foreach (QString file, files)
     68      for (const QString& file: files)
    6969        {
    7070          QPixmap pixmap;
     
    127127      QStringList suffixes;
    128128      suffixes << QLatin1String ("ico") << QLatin1String ("png") << QLatin1String ("gif") << QLatin1String ("jpg");
    129       foreach (QString suffix, suffixes)
     129      for (const QString& suffix: suffixes)
    130130        myNAM->get (QNetworkRequest (path + suffix));
    131131    }
  • trunk/qt/file-tree.cc

    r14466 r14499  
    176176    }
    177177
    178   foreach(const FileTreeItem * i, myChildren)
     178  for (const FileTreeItem * const i: myChildren)
    179179    i->getSubtreeWantedSize(have, total);
    180180}
     
    303303    }
    304304
    305   foreach (const FileTreeItem * child, myChildren)
     305  for (const FileTreeItem * const child: myChildren)
    306306    i |= child->priority();
    307307
     
    320320    }
    321321
    322   foreach (FileTreeItem * child, myChildren)
     322  for (FileTreeItem * const child: myChildren)
    323323    child->setSubtreePriority (i, ids);
    324324}
     
    346346
    347347  int wanted(-1);
    348   foreach (const FileTreeItem * child, myChildren)
     348  for (const FileTreeItem * const child: myChildren)
    349349    {
    350350      const int childWanted = child->isSubtreeWanted();
     
    374374    }
    375375
    376   foreach (FileTreeItem * child, myChildren)
     376  for (FileTreeItem * const child: myChildren)
    377377    child->setSubtreeWanted (b, ids);
    378378}
     
    986986        {
    987987        case Qt::Key_Space:
    988           foreach (const QModelIndex& i, selectionModel ()->selectedRows (COL_WANTED))
     988          for (const QModelIndex& i: selectionModel ()->selectedRows (COL_WANTED))
    989989            clicked (i);
    990990          break;
     
    992992        case Qt::Key_Enter:
    993993        case Qt::Key_Return:
    994           foreach (const QModelIndex& i, selectionModel ()->selectedRows (COL_PRIORITY))
     994          for (const QModelIndex& i: selectionModel ()->selectedRows (COL_PRIORITY))
    995995            clicked (i);
    996996          break;
     
    10041004FileTreeView::update (const FileList& files, bool updateFields)
    10051005{
    1006   foreach (const TrFile file, files)
     1006  for (const TrFile& file: files)
    10071007    {
    10081008      QList<QModelIndex> added;
    10091009      myModel.addFile (file.index, file.filename, file.wanted, file.priority, file.size, file.have, added, updateFields);
    1010       foreach (QModelIndex i, added)
     1010      for (const QModelIndex& i: added)
    10111011        expand (myProxy->mapFromSource(i));
    10121012    }
  • trunk/qt/filterbar.cc

    r14468 r14499  
    443443      const Torrent * tor = index.data (TorrentModel::TorrentRole).value<const Torrent*> ();
    444444      QSet<QString> torrentNames;
    445       foreach (QString host, tor->hosts ())
     445      for (const QString& host: tor->hosts ())
    446446        {
    447447          newHosts.insert (host);
    448448          torrentNames.insert (readableHostName (host));
    449449        }
    450       foreach (QString name, torrentNames)
     450      for (const QString& name: torrentNames)
    451451        ++torrentsPerHost[name];
    452452    }
     
    457457
    458458  // rows to update
    459   foreach (QString host, oldHosts & newHosts)
     459  for (const QString& host: oldHosts & newHosts)
    460460    {
    461461      const QString name = readableHostName (host);
     
    468468
    469469  // rows to remove
    470   foreach (QString host, oldHosts - newHosts)
     470  for (const QString& host: oldHosts - newHosts)
    471471    {
    472472      const QString name = readableHostName (host);
     
    478478  // rows to add
    479479  bool anyAdded = false;
    480   foreach (QString host, newHosts - oldHosts)
     480  for (const QString& host: newHosts - oldHosts)
    481481    {
    482482      const QString name = readableHostName (host);
     
    584584  initKeys << Prefs::FILTER_MODE
    585585           << Prefs::FILTER_TRACKERS;
    586   foreach (int key, initKeys)
     586  for (const int key: initKeys)
    587587      refreshPref (key);
    588588}
  • trunk/qt/mainwin.cc

    r14467 r14499  
    261261           << Prefs::RATIO
    262262           << Prefs::RATIO_ENABLED;
    263   foreach (int key, initKeys)
     263  for (const int key: initKeys)
    264264    refreshPref (key);
    265265
     
    382382    connect (a, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs (bool)));
    383383    sub->addSeparator ();
    384     foreach (int i, stockSpeeds)
     384    for (const int i: stockSpeeds)
    385385      {
    386386        a = sub->addAction (Formatter::speedToString (Speed::fromKBps (i)));
     
    404404    connect (a, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs (bool)));
    405405    sub->addSeparator ();
    406     foreach (int i, stockSpeeds)
     406    for (const int i: stockSpeeds)
    407407      {
    408408        a = sub->addAction (Formatter::speedToString (Speed::fromKBps (i)));
     
    427427    connect (a, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs (bool)));
    428428    sub->addSeparator ();
    429     foreach (double i, stockRatios)
     429    for (const double i: stockRatios)
    430430      {
    431431        a = sub->addAction (Formatter::ratioToString (i));
     
    812812  QSet<int> ids;
    813813
    814   foreach (QModelIndex index, ui.listView->selectionModel ()->selectedRows ())
     814  for (const QModelIndex& index: ui.listView->selectionModel ()->selectedRows ())
    815815    {
    816816      const Torrent * tor (index.data (TorrentModel::TorrentRole).value<const Torrent*> ());
     
    11651165    }
    11661166
    1167   foreach (const QString& filename, filenames)
     1167  for (const QString& filename: filenames)
    11681168    addTorrent (filename, showOptions);
    11691169}
     
    11951195  int count;
    11961196
    1197   foreach (QModelIndex index, ui.listView->selectionModel ()->selectedRows ())
     1197  for (const QModelIndex& index: ui.listView->selectionModel ()->selectedRows ())
    11981198    {
    11991199      const Torrent * tor (index.data (TorrentModel::TorrentRole).value<const Torrent*> ());
     
    14091409  else if (event->mimeData()->hasUrls())
    14101410    {
    1411       foreach (QUrl url, event->mimeData()->urls())
     1411      for (const QUrl& url: event->mimeData()->urls())
    14121412        list.append(url.toLocalFile());
    14131413    }
    14141414
    1415   foreach (QString entry, list)
     1415  for (const QString& entry: list)
    14161416    {
    14171417      QString key = entry.trimmed();
  • trunk/qt/make-dialog.cc

    r14466 r14499  
    133133  int tier = 0;
    134134  QVector<tr_tracker_info> trackers;
    135   foreach (QString line, ui.trackersEdit->toPlainText ().split (QLatin1Char ('\n')))
    136     {
    137       line = line.trimmed ();
    138       if (line.isEmpty ())
     135  for (const QString& line: ui.trackersEdit->toPlainText ().split (QLatin1Char ('\n')))
     136    {
     137      const QString announceUrl = line.trimmed ();
     138      if (announceUrl.isEmpty ())
    139139        {
    140140          ++tier;
     
    143143        {
    144144          tr_tracker_info tmp;
    145           tmp.announce = tr_strdup (line.toUtf8 ().constData ());
     145          tmp.announce = tr_strdup (announceUrl.toUtf8 ().constData ());
    146146          tmp.tier = tier;
    147147          trackers.append (tmp);
  • trunk/qt/options.cc

    r14466 r14499  
    215215OptionsDialog::onPriorityChanged (const QSet<int>& fileIndices, int priority)
    216216{
    217   foreach (int i, fileIndices)
     217  for (const int i: fileIndices)
    218218    myPriorities[i] = priority;
    219219}
     
    222222OptionsDialog::onWantedChanged (const QSet<int>& fileIndices, bool isWanted)
    223223{
    224   foreach (int i, fileIndices)
     224  for (const int i: fileIndices)
    225225    myWanted[i] = isWanted;
    226226}
     
    335335  myVerifyTimer.stop ();
    336336
    337   for (int i = 0, n = myFiles.size (); i < n; ++i)
    338     myFiles[i].have = 0;
     337  for (TrFile& f: myFiles)
     338    f.have = 0;
    339339
    340340  ui.filesView->update (myFiles);
     
    433433    {
    434434      uint64_t have = 0;
    435       foreach (const TrFile& f, myFiles)
     435      for (const TrFile& f: myFiles)
    436436        have += f.have;
    437437
  • trunk/qt/prefs-dialog.cc

    r14470 r14499  
    561561       << Prefs::INCOMPLETE_DIR_ENABLED
    562562       << Prefs::SCRIPT_TORRENT_DONE_FILENAME;
    563   foreach (int key, keys)
     563  for (const int key: keys)
    564564    refreshPref (key);
    565565
     
    568568  if (!myIsServer)
    569569    {
    570       foreach (QWidget * w, myUnsupportedWhenRemote)
     570      for (QWidget * const w: myUnsupportedWhenRemote)
    571571        {
    572572          w->setToolTip (tr ("Not supported by remote sessions"));
     
    618618          const bool whitelist (myPrefs.getBool (Prefs::RPC_WHITELIST_ENABLED));
    619619          const bool auth (myPrefs.getBool (Prefs::RPC_AUTH_REQUIRED));
    620           foreach (QWidget * w, myWebWhitelistWidgets)
     620          for (QWidget * const w: myWebWhitelistWidgets)
    621621            w->setEnabled (enabled && whitelist);
    622           foreach (QWidget * w, myWebAuthWidgets)
     622          for (QWidget * const w: myWebAuthWidgets)
    623623            w->setEnabled (enabled && auth);
    624           foreach (QWidget * w, myWebWidgets)
     624          for (QWidget * const w: myWebWidgets)
    625625            w->setEnabled (enabled);
    626626          break;
     
    630630        {
    631631          const bool enabled = myPrefs.getBool (key);
    632           foreach (QWidget * w, mySchedWidgets)
     632          for (QWidget * const w: mySchedWidgets)
    633633            w->setEnabled (enabled);
    634634          break;
     
    638638        {
    639639          const bool enabled = myPrefs.getBool (key);
    640           foreach (QWidget * w, myBlockWidgets)
     640          for (QWidget * const w: myBlockWidgets)
    641641            w->setEnabled (enabled);
    642642          break;
  • trunk/qt/relocate.cc

    r14418 r14499  
    4141
    4242  QString path;
    43   foreach (int id, myIds)
     43  for (const int id: myIds)
    4444    {
    4545      const Torrent * tor = model.getTorrentFromId (id);
  • trunk/qt/rpc-client.cc

    r14466 r14499  
    138138#ifdef DEBUG_HTTP
    139139      std::cerr << "sending " << "POST " << qPrintable (myUrl.path ()) << std::endl;
    140       foreach (const QByteArray& b, request.rawHeaderList ())
     140      for (const QByteArray& b: request.rawHeaderList ())
    141141        std::cerr << b.constData ()
    142142                  << ": "
     
    183183#ifdef DEBUG_HTTP
    184184  std::cerr << "http response header: " << std::endl;
    185   foreach (const QByteArray& b, reply->rawHeaderList ())
     185  for (const QByteArray& b: reply->rawHeaderList ())
    186186    std::cerr << b.constData ()
    187187              << ": "
  • trunk/qt/session-dialog.cc

    r14394 r14499  
    3535  const bool useAuth = ui.authCheck->isChecked ();
    3636
    37   foreach (QWidget * w, myRemoteWidgets)
     37  for (QWidget * const w: myRemoteWidgets)
    3838    w->setEnabled (isRemote);
    3939
    40   foreach (QWidget * w, myAuthWidgets)
     40  for (QWidget * const w: myAuthWidgets)
    4141    w->setEnabled (isRemote && useAuth);
    4242}
  • trunk/qt/session.cc

    r14466 r14499  
    6767  {
    6868    tr_variantListReserve (list, keys.size ());
    69     foreach (tr_quark key, keys)
     69    for (const tr_quark key: keys)
    7070      tr_variantListAddQuark (list, key);
    7171  }
     
    391391      {
    392392        tr_variant * idList (tr_variantDictAddList (args, TR_KEY_ids, ids.size ()));
    393         foreach (int i, ids)
     393        for (const int i: ids)
    394394          tr_variantListAddInt (idList, i);
    395395      }
     
    437437  addOptionalIds (&args, ids);
    438438  tr_variant * list (tr_variantDictAddList (&args, key, value.size ()));
    439   foreach (const QString& str, value)
     439  for (const QString& str: value)
    440440    tr_variantListAddStr (list, str.toUtf8 ().constData ());
    441441
     
    450450  addOptionalIds (&args, ids);
    451451  tr_variant * list (tr_variantDictAddList (&args, key, value.size ()));
    452   foreach (int i, value)
     452  for (const int i: value)
    453453    tr_variantListAddInt (list, i);
    454454
  • trunk/qt/torrent-filter.cc

    r14468 r14499  
    3333           << Prefs::FILTER_TRACKERS
    3434           << Prefs::FILTER_TEXT;
    35   foreach (int key, initKeys)
     35  for (const int key: initKeys)
    3636    refreshPref (key);
    3737}
  • trunk/qt/torrent-model.cc

    r14468 r14499  
    2424  myIdToRow.clear ();
    2525  myIdToTorrent.clear ();
    26   foreach (Torrent * tor, myTorrents) delete tor;
     26  qDeleteAll (myTorrents);
    2727  myTorrents.clear ();
    2828
     
    190190      beginInsertRows (QModelIndex(), oldCount, newCount - 1);
    191191
    192       foreach (Torrent * tor, newTorrents)
     192      for (Torrent * const tor: newTorrents)
    193193        {
    194194          addTorrent (tor);
     
    206206      QSet<int> removedIds (oldIds);
    207207      removedIds -= newIds;
    208       foreach (int id, removedIds)
     208      for (const int id: removedIds)
    209209        removeTorrent (id);
    210210    }
     
    221221      beginRemoveRows (QModelIndex(), row, row);
    222222      // make the myIdToRow map consistent with list view/model
    223       for (QMap<int,int>::iterator i = myIdToRow.begin(); i != myIdToRow.end(); ++i)
     223      for (auto i = myIdToRow.begin(); i != myIdToRow.end(); ++i)
    224224        if (i.value() > row)
    225225          --i.value();
     
    242242  size_t upCount=0, downCount=0;
    243243
    244   foreach (const Torrent * const tor, myTorrents)
     244  for (const Torrent * const tor: myTorrents)
    245245    {
    246246      upSpeed += tor->uploadSpeed ();
     
    263263
    264264  ids.reserve (myTorrents.size());
    265   foreach (const Torrent * tor, myTorrents)
     265  for (const Torrent * const tor: myTorrents)
    266266    ids.insert (tor->id());
    267267
     
    272272TorrentModel::hasTorrent (const QString& hashString) const
    273273{
    274   foreach (const Torrent * tor, myTorrents)
     274  for (const Torrent * const tor: myTorrents)
    275275    if (tor->hashString () == hashString)
    276276      return true;
  • trunk/qt/torrent.cc

    r14468 r14499  
    358358Torrent::hasFileSubstring (const QString& substr) const
    359359{
    360   foreach (const TrFile file, myFiles)
     360  for (const TrFile& file: myFiles)
    361361    if (file.filename.contains (substr, Qt::CaseInsensitive))
    362362      return true;
     
    368368Torrent::hasTrackerSubstring (const QString& substr) const
    369369{
    370   foreach (QString s, myValues[TRACKERS].toStringList())
     370  for (const QString& s: myValues[TRACKERS].toStringList())
    371371    if (s.contains (substr, Qt::CaseInsensitive))
    372372      return true;
     
    614614        {
    615615          QStringList hosts;
    616           foreach (QString tracker, list)
     616          for (const QString& tracker: list)
    617617            {
    618618              const QString host = Favicons::getHost (QUrl (tracker));
  • trunk/qt/tracker-model.cc

    r14404 r14499  
    8282  // build a list of the TrackerInfos
    8383  QVector<TrackerInfo> trackers;
    84   foreach (int id, ids)
     84  for (const int id: ids)
    8585    {
    8686      const Torrent * tor = torrentModel.getTorrentFromId (id);
     
    8888        {
    8989          const TrackerStatsList trackerList = tor->trackerStats ();
    90           foreach (const TrackerStat& st, trackerList)
     90          for (const TrackerStat& st: trackerList)
    9191            {
    9292              TrackerInfo trackerInfo;
  • trunk/qt/utils.cc

    r14467 r14499  
    126126        "abw", "csv", "doc", "dvi", "htm", "html", "ini", "log", "odp",
    127127        "ods", "odt", "pdf", "ppt", "ps",  "rtf", "tex", "txt", "xml" };
    128       for (int i=0, n=sizeof(doc_types)/sizeof(doc_types[0]); i<n; ++i)
    129         suffixes[DOCUMENT] << QString::fromLatin1(doc_types[i]);
     128      for (const char * t: doc_types)
     129        suffixes[DOCUMENT] << QString::fromLatin1(t);
    130130      fileIcons[DOCUMENT] = QIcon::fromTheme (QString::fromLatin1("text-x-generic"), fallback);
    131131
    132132      const char * pic_types[] = {
    133133        "bmp", "gif", "jpg", "jpeg", "pcx", "png", "psd", "ras", "tga", "tiff" };
    134       for (int i=0, n=sizeof(pic_types)/sizeof(pic_types[0]); i<n; ++i)
    135         suffixes[PICTURE] << QString::fromLatin1(pic_types[i]);
     134      for (const char * t: pic_types)
     135        suffixes[PICTURE] << QString::fromLatin1(t);
    136136      fileIcons[PICTURE]  = QIcon::fromTheme (QString::fromLatin1("image-x-generic"), fallback);
    137137
     
    139139        "3gp", "asf", "avi", "mkv", "mov", "mpeg", "mpg", "mp4",
    140140        "ogm", "ogv", "qt", "rm", "wmv" };
    141       for (int i=0, n=sizeof(vid_types)/sizeof(vid_types[0]); i<n; ++i)
    142         suffixes[VIDEO] << QString::fromLatin1(vid_types[i]);
     141      for (const char * t: vid_types)
     142        suffixes[VIDEO] << QString::fromLatin1(t);
    143143      fileIcons[VIDEO] = QIcon::fromTheme (QString::fromLatin1("video-x-generic"), fallback);
    144144
    145145      const char * arc_types[] = {
    146146        "7z", "ace", "bz2", "cbz", "gz", "gzip", "lzma", "rar", "sft", "tar", "zip" };
    147       for (int i=0, n=sizeof(arc_types)/sizeof(arc_types[0]); i<n; ++i)
    148         suffixes[ARCHIVE] << QString::fromLatin1(arc_types[i]);
     147      for (const char * t: arc_types)
     148        suffixes[ARCHIVE] << QString::fromLatin1(t);
    149149      fileIcons[ARCHIVE]  = QIcon::fromTheme (QString::fromLatin1("package-x-generic"), fallback);
    150150
     
    152152        "aac", "ac3", "aiff", "ape", "au", "flac", "m3u", "m4a", "mid", "midi", "mp2",
    153153        "mp3", "mpc", "nsf", "oga", "ogg", "ra", "ram", "shn", "voc", "wav", "wma" };
    154       for (int i=0, n=sizeof(aud_types)/sizeof(aud_types[0]); i<n; ++i)
    155         suffixes[AUDIO] << QString::fromLatin1(aud_types[i]);
     154      for (const char * t: aud_types)
     155        suffixes[AUDIO] << QString::fromLatin1(t);
    156156      fileIcons[AUDIO] = QIcon::fromTheme (QString::fromLatin1("audio-x-generic"), fallback);
    157157
    158158      const char * exe_types[] = { "bat", "cmd", "com", "exe" };
    159       for (int i=0, n=sizeof(exe_types)/sizeof(exe_types[0]); i<n; ++i)
    160         suffixes[APP] << QString::fromLatin1(exe_types[i]);
     159      for (const char * t: exe_types)
     160        suffixes[APP] << QString::fromLatin1(t);
    161161      fileIcons[APP] = QIcon::fromTheme (QString::fromLatin1("application-x-executable"), fallback);
    162162    }
  • trunk/qt/utils.h

    r14464 r14499  
    5555      if (s.length() != 40)
    5656        return false;
    57       foreach (QChar ch, s) if (!isxdigit (ch.unicode())) return false;
     57      for (const QChar ch: s) if (!isxdigit (ch.unicode())) return false;
    5858      return true;
    5959    }
  • trunk/qt/watchdir.cc

    r14394 r14499  
    104104  // get the list of files currently in the watch directory
    105105  QSet<QString> files;
    106   foreach (QString str, dir.entryList (QDir::Readable|QDir::Files))
     106  for (const QString& str: dir.entryList (QDir::Readable|QDir::Files))
    107107    files.insert (str);
    108108
     
    110110  const QSet<QString> newFiles (files - myWatchDirFiles);
    111111  const QString torrentSuffix = QString::fromUtf8 (".torrent");
    112   foreach (QString name, newFiles)
     112  for (const QString& name: newFiles)
    113113    {
    114114      if (name.endsWith (torrentSuffix, Qt::CaseInsensitive))
     
    148148    return;
    149149
    150   foreach (const QString& path, myWatcher->directories ())
     150  for (const QString& path: myWatcher->directories ())
    151151    watcherActivated (path);
    152152}
Note: See TracChangeset for help on using the changeset viewer.