Changeset 13982


Ignore:
Timestamp:
Feb 7, 2013, 9:07:16 PM (8 years ago)
Author:
jordan
Message:

(qt) experiment with making the statusbar's speed/ratio, the desktop icon's tooltip, and the delegate's shortTransferString() all behave the same wrt when to show which transfer speeds

Location:
trunk/qt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/mainwin.cc

    r13978 r13982  
    747747TrMainWindow :: refreshTrayIcon ()
    748748{
    749   const QString idle = tr ("Idle");
    750   const Speed u (myModel.getUploadSpeed ());
    751   const Speed d (myModel.getDownloadSpeed ());
    752 
    753   myTrayIcon.setToolTip (tr ("Transmission\nUp: %1\nDown: %2")
    754                          .arg (u.isZero () ? idle : Formatter::speedToString (u))
    755                          .arg (d.isZero () ? idle : Formatter::speedToString (d)));
     749  Speed upSpeed, downSpeed;
     750  size_t upCount, downCount;
     751  QString tip;
     752
     753  myModel.getTransferSpeed (upSpeed, upCount, downSpeed, downCount);
     754
     755  if (!upCount && !downCount)
     756    {
     757      tip = tr ("Idle");
     758    }
     759  else if (downCount)
     760    {
     761      tip  = tr( "%1   %2" ).arg(Formatter::downloadSpeedToString(downSpeed))
     762                            .arg(Formatter::uploadSpeedToString(upSpeed));
     763    }
     764  else if (upCount)
     765    {
     766      tip = Formatter::uploadSpeedToString(upSpeed);
     767    }
     768
     769  myTrayIcon.setToolTip (tip);
    756770}
    757771
     
    759773TrMainWindow :: refreshStatusBar ()
    760774{
    761   myUploadSpeedLabel->setText (Formatter::uploadSpeedToString(myModel.getUploadSpeed()));
    762 
    763   myDownloadSpeedLabel->setText (Formatter::downloadSpeedToString(myModel.getDownloadSpeed()));
     775  Speed upSpeed, downSpeed;
     776  size_t upCount, downCount;
     777  myModel.getTransferSpeed (upSpeed, upCount, downSpeed, downCount);
     778
     779  myUploadSpeedLabel->setText (Formatter::uploadSpeedToString(upSpeed));
     780  myUploadSpeedLabel->setVisible (downCount || upCount);
     781  myDownloadSpeedLabel->setText (Formatter::downloadSpeedToString(downSpeed));
     782  myDownloadSpeedLabel->setVisible (downCount);
    764783
    765784  myNetworkLabel->setVisible (!mySession.isServer ());
  • trunk/qt/torrent-model.cc

    r13718 r13982  
    231231}
    232232
    233 Speed
    234 TorrentModel :: getUploadSpeed( ) const
    235 {
    236     Speed up;
    237     foreach( const Torrent * tor, myTorrents )
    238         up += tor->uploadSpeed( );
    239     return up;
    240 }
    241 
    242 Speed
    243 TorrentModel :: getDownloadSpeed( ) const
    244 {
    245     Speed down;
    246     foreach( const Torrent * tor, myTorrents )
    247         down += tor->downloadSpeed( );
    248     return down;
     233void
     234TorrentModel :: getTransferSpeed (Speed   & uploadSpeed,
     235                                  size_t  & uploadPeerCount,
     236                                  Speed   & downloadSpeed,
     237                                  size_t  & downloadPeerCount)
     238{
     239  Speed upSpeed, downSpeed;
     240  size_t upCount=0, downCount=0;
     241
     242  foreach (const Torrent * const tor, myTorrents)
     243    {
     244      upSpeed += tor->uploadSpeed ();
     245      upCount += tor->peersWeAreUploadingTo ();
     246      downSpeed += tor->downloadSpeed ();
     247      downCount += tor->webseedsWeAreDownloadingFrom();
     248      downCount += tor->peersWeAreDownloadingFrom();
     249    }
     250
     251  uploadSpeed = upSpeed;
     252  uploadPeerCount = upCount;
     253  downloadSpeed = downSpeed;
     254  downloadPeerCount = downCount;
    249255}
    250256
  • trunk/qt/torrent-model.h

    r13718 r13982  
    5858
    5959    public:
    60         Speed getUploadSpeed( ) const;
    61         Speed getDownloadSpeed( ) const;
     60        void getTransferSpeed (Speed   & uploadSpeed,
     61                               size_t  & uploadPeerCount,
     62                               Speed   & downloadSpeed,
     63                               size_t  & downloadPeerCount);
    6264
    6365    signals:
Note: See TracChangeset for help on using the changeset viewer.