Changeset 13719


Ignore:
Timestamp:
Dec 29, 2012, 11:40:59 PM (8 years ago)
Author:
jordan
Message:

(qt) New method: Torrent.hosts(). The list is derived from the announce URLs in Torrent.trackers(). By remembering this in Torrent, the filterbar won't have to keep recomputing it.

Location:
trunk/qt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/filterbar.cc

    r13713 r13719  
    305305            break;
    306306        const Torrent * tor = index.data( TorrentModel::TorrentRole ).value<const Torrent*>();
    307         const QStringList trackers = tor->trackers( );
    308307        QSet<QString> torrentNames;
    309         foreach( QString tracker, trackers ) {
    310             const QString host = Favicons::getHost( QUrl( tracker ) );
    311             if( host.isEmpty( ) )
    312                 qWarning() << "torrent" << qPrintable(tor->name()) << "has an invalid announce URL:" << tracker;
    313             else {
    314                 newHosts.insert( host );
    315                 torrentNames.insert( readableHostName( host ) );
    316             }
    317         }
    318         foreach( QString name, torrentNames )
    319             ++torrentsPerHost[ name ];
     308        foreach (QString host, tor->hosts()) {
     309          newHosts.insert (host);
     310          torrentNames.insert (readableHostName(host));
     311        }
     312        foreach (QString name, torrentNames)
     313          ++torrentsPerHost[name];
    320314    }
    321315
  • trunk/qt/torrent.cc

    r13683 r13719  
    9090  { FAILED_EVER, TR_KEY_corruptEver, QVariant::ULongLong, STAT_EXTRA },
    9191  { TRACKERS, TR_KEY_trackers, QVariant::StringList, STAT },
     92  { HOSTS, TR_KEY_NONE, QVariant::StringList, DERIVED },
    9293  { TRACKERSTATS, TR_KEY_trackerStats, TrTypes::TrackerStatsList, STAT_EXTRA },
    9394  { MIME_ICON, TR_KEY_NONE, QVariant::Icon, DERIVED },
     
    615616      if (myValues[TRACKERS] != list)
    616617        {
     618          QStringList hosts;
     619          foreach (QString tracker, list)
     620            {
     621              const QString host = Favicons::getHost (QUrl (tracker));
     622              if (!host.isEmpty())
     623                hosts.append (host);
     624            }
     625          hosts.removeDuplicates();
     626
    617627          myValues[TRACKERS].setValue (list);
     628          myValues[HOSTS].setValue (hosts);
    618629          changed = true;
    619630        }
  • trunk/qt/torrent.h

    r13683 r13719  
    153153            FAILED_EVER,
    154154            TRACKERS,
     155            HOSTS,
    155156            TRACKERSTATS,
    156157            MIME_ICON,
     
    307308        TrackerStatsList trackerStats( ) const{ return myValues[TRACKERSTATS].value<TrackerStatsList>(); }
    308309        QStringList trackers() const { return myValues[TRACKERS].value<QStringList>(); }
     310        QStringList hosts() const { return myValues[HOSTS].value<QStringList>(); }
    309311        PeerList peers( ) const{ return myValues[PEERS].value<PeerList>(); }
    310312        const FileList& files( ) const { return myFiles; }
Note: See TracChangeset for help on using the changeset viewer.