~ubuntu-branches/ubuntu/natty/transmission/natty

« back to all changes in this revision

Viewing changes to qt/details.cc

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Klimonda
  • Date: 2009-12-08 10:49:11 UTC
  • mfrom: (1.1.29 upstream) (2.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20091208104911-06gio45n2nla3vpg
Tags: 1.80~b1-0ubuntu1
* New upstream release (LP: #460620), rebased on debian unstable
  remaining changes:
  - debian/control:
    + Added replaces & provides clutch (now included as part of transmission).
      Can be removed in lucid+1
    + Added quilt, liblaunchpad-integration-dev and lsb-release to Build-Depends
  - debian/rules:
    + create a po template during package build.
  - debian/patches/01_lpi.patch:
    + integrate transmission with launchpad
  - debian/patches/20_add_x-ubuntu-gettext-domain.diff:
    + add x-ubuntu-gettext-domain to .desktop file.
  - debian/transmission-daemon.default:
    - remove --auth from OPTIONS
* Fixes bugs:
  - tray menu shows wrong status for "main window" when started minimized
    (LP: #451415)
* Refreshed patches:
  - dont_build_libevent.patch
  - 99_autoreconf.patch
* Removed patches:
  - 21_onPortTested.diff, 23_tr_torrentNext.diff and
    24_tr_torrentDeleteLocalData_do_move.diff
* debian/patches/21_fix_inhibition.patch:
  - The right value for suspend inhibition is 4
* debian/control:
  - Build-Depend on libgconf2-dev to enable magnet link registration and on
    libcanberra-gtk-dev for notification sound.
* debian/watch:
  - make it detect beta versions, to be removed after 1.80 is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * This file Copyright (C) 2009 Charles Kerr <charles@transmissionbt.com>
 
2
 * This file Copyright (C) 2009 Mnemosyne LLC
3
3
 *
4
4
 * This file is licensed by the GPL version 2.  Works owned by the
5
5
 * Transmission project are granted a special exemption to clause 2(b)
7
7
 * This exemption does not extend to derived works not owned by
8
8
 * the Transmission project.
9
9
 *
10
 
 * $Id: details.cc 8764 2009-06-30 22:27:22Z charles $
 
10
 * $Id: details.cc 9671 2009-12-05 02:19:24Z charles $
11
11
 */
12
12
 
13
13
#include <cassert>
16
16
 
17
17
#include <QCheckBox>
18
18
#include <QComboBox>
19
 
#include <QEvent>
20
 
#include <QHeaderView>
21
 
#include <QResizeEvent>
 
19
#include <QDateTime>
22
20
#include <QDialogButtonBox>
23
21
#include <QDoubleSpinBox>
 
22
#include <QEvent>
24
23
#include <QFont>
25
24
#include <QFontMetrics>
26
25
#include <QHBoxLayout>
27
 
#include <QVBoxLayout>
 
26
#include <QHBoxLayout>
 
27
#include <QHeaderView>
28
28
#include <QLabel>
29
29
#include <QLocale>
30
30
#include <QPushButton>
 
31
#include <QRadioButton>
 
32
#include <QResizeEvent>
31
33
#include <QSpinBox>
32
 
#include <QRadioButton>
33
34
#include <QStyle>
34
35
#include <QTabWidget>
 
36
#include <QTextBrowser>
35
37
#include <QTreeView>
36
 
#include <QTextBrowser>
37
 
#include <QDateTime>
38
38
#include <QTreeWidget>
39
39
#include <QTreeWidgetItem>
40
40
#include <QVBoxLayout>
41
 
#include <QHBoxLayout>
42
41
 
43
42
#include <libtransmission/transmission.h>
44
43
 
211
210
void
212
211
Details :: refresh( )
213
212
{
214
 
    int i;
215
213
    QLocale locale;
216
214
    const int n = myIds.size( );
217
215
    const bool single = n == 1;
256
254
    int64_t haveUnverified = 0;
257
255
    int64_t verifiedPieces = 0;
258
256
    foreach( const Torrent * t, torrents ) {
259
 
        haveTotal += t->haveTotal( );
260
 
        haveUnverified += t->haveUnverified( );
261
 
        const uint64_t v = t->haveVerified( );
262
 
        haveVerified += v;
263
 
        verifiedPieces += v / t->pieceSize( );
264
 
        sizeWhenDone += t->sizeWhenDone( );
265
 
        leftUntilDone += t->leftUntilDone( );
 
257
        if( t->hasMetadata( ) ) {
 
258
            haveTotal += t->haveTotal( );
 
259
            haveUnverified += t->haveUnverified( );
 
260
            const uint64_t v = t->haveVerified( );
 
261
            haveVerified += v;
 
262
            verifiedPieces += v / t->pieceSize( );
 
263
            sizeWhenDone += t->sizeWhenDone( );
 
264
            leftUntilDone += t->leftUntilDone( );
 
265
        }
266
266
    }
267
267
    if( !haveVerified && !haveUnverified )
268
268
        string = none;
331
331
    myRunTimeLabel->setText( string );
332
332
 
333
333
 
 
334
    // myETALabel
 
335
    string.clear( );
 
336
    if( torrents.empty( ) )
 
337
        string = none;
 
338
    else {
 
339
        int baseline = torrents[0]->getETA( );
 
340
        foreach( const Torrent * t, torrents ) {
 
341
            if( baseline != t->getETA( ) ) {
 
342
                string = mixed;
 
343
                break;
 
344
            }
 
345
        }
 
346
        if( string.isEmpty( ) ) {
 
347
            if( baseline < 0 )
 
348
                string = tr( "Unknown" );
 
349
            else
 
350
                string = Utils::timeToString( baseline );
 
351
       } 
 
352
    }
 
353
    myETALabel->setText( string );
 
354
 
 
355
 
334
356
    // myLastActivityLabel
335
357
    if( torrents.empty( ) )
336
358
        string = none;
678
700
    ///  Peers tab
679
701
    ///
680
702
 
681
 
    i = 0;
682
 
    foreach( const Torrent * t, torrents ) i += t->seeders( );
683
 
    mySeedersLabel->setText( locale.toString( i ) );
684
 
 
685
 
    i = 0;
686
 
    foreach( const Torrent * t, torrents ) i += t->leechers( );
687
 
    myLeechersLabel->setText( locale.toString( i ) );
688
 
 
689
 
    i = 0;
690
 
    foreach( const Torrent * t, torrents ) i += t->timesCompleted( );
691
 
    myTimesCompletedLabel->setText( locale.toString( i ) );
692
 
 
693
703
    QMap<QString,QTreeWidgetItem*> peers2;
694
704
    QList<QTreeWidgetItem*> newItems;
695
705
    foreach( const Torrent * t, torrents )
805
815
    hig->addRow( tr( "Ratio:" ), myRatioLabel = new SqueezeLabel );
806
816
    hig->addRow( tr( "State:" ), myStateLabel = new SqueezeLabel );
807
817
    hig->addRow( tr( "Running time:" ), myRunTimeLabel = new SqueezeLabel );
 
818
    hig->addRow( tr( "Remaining time:" ), myETALabel = new SqueezeLabel );
808
819
    hig->addRow( tr( "Last activity:" ), myLastActivityLabel = new SqueezeLabel );
809
820
    hig->addRow( tr( "Error:" ), myErrorLabel = new SqueezeLabel );
810
821
    hig->addSectionDivider( );
1050
1061
    myPeerTree->setColumnWidth( COL_CLIENT, size.width( ) );
1051
1062
    myPeerTree->setAlternatingRowColors( true );
1052
1063
 
1053
 
    QHBoxLayout * h = new QHBoxLayout;
1054
 
    h->setSpacing( HIG :: PAD );
1055
 
    v->addLayout( h );
1056
 
 
1057
 
    QLabel * l = new QLabel( "Seeders:" );
1058
 
    l->setStyleSheet( "font: bold" );
1059
 
    h->addWidget( l );
1060
 
    l = mySeedersLabel = new QLabel( "a" );
1061
 
    h->addWidget( l );
1062
 
    h->addStretch( 1 );
1063
 
    
1064
 
    l = new QLabel( "Leechers:" );
1065
 
    l->setStyleSheet( "font: bold" );
1066
 
    h->addWidget( l );
1067
 
    l = myLeechersLabel = new QLabel( "b" );
1068
 
    h->addWidget( l );
1069
 
    h->addStretch( 1 );
1070
 
    
1071
 
    l = new QLabel( "Times Completed:" );
1072
 
    l->setStyleSheet( "font: bold" );
1073
 
    h->addWidget( l );
1074
 
    l = myTimesCompletedLabel = new QLabel( "c" );
1075
 
    h->addWidget( l );
1076
 
 
1077
1064
    return top;
1078
1065
}
1079
1066