Changeset 11406


Ignore:
Timestamp:
Nov 14, 2010, 5:03:38 AM (12 years ago)
Author:
charles
Message:

(trunk qt) #3739 "filterbar should use locale info to group thousands' place (ex: 1,000 instead of 1000)" -- done.

Location:
trunk/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/filterbar.cc

    r11137 r11406  
    184184
    185185        // draw the count
    186         const int count = modelIndex.data( TorrentCountRole ).toInt();
    187         if( count >= 0 ) {
    188             const QString text = QString::number( count);
     186        QString text = modelIndex.data(TorrentCountRole).toString();
     187        if( !text.isEmpty( ) )
     188        {
    189189            const QPen pen = painter.pen( );
    190190            painter.setPen( opt.palette.color( QPalette::Disabled, QPalette::Text ) );
     
    196196
    197197        // draw the text
    198         QString text = modelIndex.data( Qt::DisplayRole ).toString();
     198        text = modelIndex.data( Qt::DisplayRole ).toString();
    199199        text = painter.fontMetrics().elidedText ( text, Qt::ElideRight, rect.width() );
    200200        s->drawItemText( &painter, rect, Qt::AlignLeft|Qt::AlignVCenter, opt.palette, true, text );
     
    320320
    321321    // update the "All" row
    322     myTrackerModel->setData( myTrackerModel->index(0,0), myTorrents.rowCount(), TorrentCountRole );
     322    myTrackerModel->setData( myTrackerModel->index(0,0), getCountString(myTorrents.rowCount()), TorrentCountRole );
    323323
    324324    // rows to update
     
    327327        const QString name = readableHostName( host );
    328328        QStandardItem * row = myTrackerModel->findItems(name).front();
    329         row->setData( torrentsPerHost[host], TorrentCountRole );
     329        row->setData( getCountString(torrentsPerHost[host]), TorrentCountRole );
    330330        row->setData( favicons.findFromHost(host), Qt::DecorationRole );
    331331    }
     
    353353        // add the row
    354354        QStandardItem * row = new QStandardItem( favicons.findFromHost( host ), readableHostName( host ) );
    355         row->setData( torrentsPerHost[host], TorrentCountRole );
     355        row->setData( getCountString(torrentsPerHost[host]), TorrentCountRole );
    356356        row->setData( favicons.findFromHost(host), Qt::DecorationRole );
    357357        row->setData( host, TrackerRole );
     
    374374    QStandardItem * row = new QStandardItem( tr( "All" ) );
    375375    row->setData( "", TrackerRole );
    376     row->setData( myTorrents.rowCount(), TorrentCountRole );
     376    row->setData( getCountString(myTorrents.rowCount()), TorrentCountRole );
    377377    model->appendRow( row );
    378378
     
    550550        QAbstractItemModel * model = myActivityCombo->model( );
    551551        QModelIndexList indices = model->match( model->index(0,0), ActivityRole, m.mode(), -1 );
    552         if( !indices.isEmpty( ) ) {
    553             const int count = myFilter.count( m );
    554             model->setData( indices.first(), count, TorrentCountRole );
    555         }
     552        if( !indices.isEmpty( ) )
     553            model->setData( indices.first(), getCountString(myFilter.count(m)), TorrentCountRole );
    556554    }
    557555
    558556    refreshTrackers( );
    559557}
     558
     559QString
     560FilterBar :: getCountString( int n ) const
     561{
     562    return n>0 ? QString("%L1").arg(n) : QString();
     563}
  • trunk/qt/filterbar.h

    r11092 r11406  
    7272        void recountSoon( );
    7373        void refreshTrackers( );
     74        QString getCountString( int n ) const;
    7475
    7576    private:
Note: See TracChangeset for help on using the changeset viewer.