Changeset 13713
- Timestamp:
- Dec 29, 2012, 1:20:22 AM (10 years ago)
- Location:
- trunk/qt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt/filterbar.cc
r13706 r13713 473 473 const FilterMode m = myPrefs.get<FilterMode>( key ); 474 474 QAbstractItemModel * model = myActivityCombo->model( ); 475 QModelIndexList indices = model->match( model->index(0,0), ActivityRole, m.mode() , -1);475 QModelIndexList indices = model->match( model->index(0,0), ActivityRole, m.mode() ); 476 476 myActivityCombo->setCurrentIndex( indices.isEmpty() ? 0 : indices.first().row( ) ); 477 477 break; … … 545 545 { 546 546 myRecountTimer->setSingleShot( true ); 547 myRecountTimer->start( 500 ); 548 } 549 } 550 void 551 FilterBar :: recount ( ) 552 { 553 // recount the activity combobox... 554 for( int i=0, n=FilterMode::NUM_MODES; i<n; ++i ) 555 { 556 const FilterMode m( i ); 557 QAbstractItemModel * model = myActivityCombo->model( ); 558 QModelIndexList indices = model->match( model->index(0,0), ActivityRole, m.mode(), -1 ); 559 if( !indices.isEmpty( ) ) 560 model->setData( indices.first(), getCountString(myFilter.count(m)), TorrentCountRole ); 561 } 562 563 refreshTrackers( ); 547 myRecountTimer->start( 800 ); 548 } 549 } 550 void 551 FilterBar :: recount () 552 { 553 QAbstractItemModel * model = myActivityCombo->model(); 554 555 for (int row=0, n=model->rowCount(); row<n; ++row) 556 { 557 QModelIndex index = model->index (row, 0); 558 const int mode = index.data(ActivityRole).toInt(); 559 model->setData (index, getCountString(myFilter.count(mode)), TorrentCountRole); 560 } 561 562 refreshTrackers (); 564 563 } 565 564 -
trunk/qt/torrent-model.cc
r13683 r13713 39 39 40 40 QVariant 41 TorrentModel :: data( const QModelIndex& index, int role ) const 42 { 43 QVariant var; 44 const int row = index.row( ); 45 if( row<0 || row>=myTorrents.size() ) 46 return QVariant( ); 47 48 const Torrent* t = myTorrents.at( row ); 49 50 switch( role ) 51 { 52 case Qt::DisplayRole: 53 var = QString( t->name() ); 54 break; 55 56 case Qt::DecorationRole: 57 var = t->getMimeTypeIcon( ); 58 break; 59 60 case TorrentRole: 61 var = qVariantFromValue( t ); 62 break; 63 64 default: 41 TorrentModel :: data (const QModelIndex& index, int role) const 42 { 43 QVariant var; 44 45 const Torrent * t = myTorrents.value (index.row(), 0); 46 if (t != 0) 47 { 48 switch (role) 49 { 50 case Qt::DisplayRole: 51 var.setValue (t->name()); 52 break; 53 54 case Qt::DecorationRole: 55 var.setValue (t->getMimeTypeIcon()); 56 break; 57 58 case TorrentRole: 59 var = qVariantFromValue(t); 60 break; 61 62 default: 65 63 //std::cerr << "Unhandled role: " << role << std::endl; 66 64 break; 67 } 68 69 return var; 65 } 66 } 67 68 return var; 70 69 } 71 70
Note: See TracChangeset
for help on using the changeset viewer.