Changeset 11406
- Timestamp:
- Nov 14, 2010, 5:03:38 AM (12 years ago)
- Location:
- trunk/qt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt/filterbar.cc
r11137 r11406 184 184 185 185 // 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 { 189 189 const QPen pen = painter.pen( ); 190 190 painter.setPen( opt.palette.color( QPalette::Disabled, QPalette::Text ) ); … … 196 196 197 197 // draw the text 198 QStringtext = modelIndex.data( Qt::DisplayRole ).toString();198 text = modelIndex.data( Qt::DisplayRole ).toString(); 199 199 text = painter.fontMetrics().elidedText ( text, Qt::ElideRight, rect.width() ); 200 200 s->drawItemText( &painter, rect, Qt::AlignLeft|Qt::AlignVCenter, opt.palette, true, text ); … … 320 320 321 321 // 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 ); 323 323 324 324 // rows to update … … 327 327 const QString name = readableHostName( host ); 328 328 QStandardItem * row = myTrackerModel->findItems(name).front(); 329 row->setData( torrentsPerHost[host], TorrentCountRole );329 row->setData( getCountString(torrentsPerHost[host]), TorrentCountRole ); 330 330 row->setData( favicons.findFromHost(host), Qt::DecorationRole ); 331 331 } … … 353 353 // add the row 354 354 QStandardItem * row = new QStandardItem( favicons.findFromHost( host ), readableHostName( host ) ); 355 row->setData( torrentsPerHost[host], TorrentCountRole );355 row->setData( getCountString(torrentsPerHost[host]), TorrentCountRole ); 356 356 row->setData( favicons.findFromHost(host), Qt::DecorationRole ); 357 357 row->setData( host, TrackerRole ); … … 374 374 QStandardItem * row = new QStandardItem( tr( "All" ) ); 375 375 row->setData( "", TrackerRole ); 376 row->setData( myTorrents.rowCount(), TorrentCountRole );376 row->setData( getCountString(myTorrents.rowCount()), TorrentCountRole ); 377 377 model->appendRow( row ); 378 378 … … 550 550 QAbstractItemModel * model = myActivityCombo->model( ); 551 551 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 ); 556 554 } 557 555 558 556 refreshTrackers( ); 559 557 } 558 559 QString 560 FilterBar :: getCountString( int n ) const 561 { 562 return n>0 ? QString("%L1").arg(n) : QString(); 563 } -
trunk/qt/filterbar.h
r11092 r11406 72 72 void recountSoon( ); 73 73 void refreshTrackers( ); 74 QString getCountString( int n ) const; 74 75 75 76 private:
Note: See TracChangeset
for help on using the changeset viewer.