Changeset 13720
- Timestamp:
- Dec 30, 2012, 1:28:28 AM (10 years ago)
- Location:
- trunk/qt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt/filterbar.cc
r13719 r13720 547 547 QAbstractItemModel * model = myActivityCombo->model(); 548 548 549 int torrentsPerMode[FilterMode::NUM_MODES] = { }; 550 myFilter.countTorrentsPerMode (torrentsPerMode); 551 549 552 for (int row=0, n=model->rowCount(); row<n; ++row) 550 553 { 551 554 QModelIndex index = model->index (row, 0); 552 555 const int mode = index.data(ActivityRole).toInt(); 553 model->setData (index, getCountString( myFilter.count(mode)), TorrentCountRole);556 model->setData (index, getCountString(torrentsPerMode[mode]), TorrentCountRole); 554 557 } 555 558 -
trunk/qt/torrent-filter.cc
r12653 r13720 11 11 */ 12 12 13 #include <algorithm> 13 14 #include <iostream> 14 15 … … 206 207 } 207 208 208 int 209 TorrentFilter :: count( const FilterMode& mode ) const 210 { 211 int count = 0; 212 213 for( int row=0; ; ++row ) { 214 QModelIndex index = sourceModel()->index( row, 0 ); 215 if( !index.isValid( ) ) 216 break; 217 const Torrent * tor = index.data( TorrentModel::TorrentRole ).value<const Torrent*>(); 218 if( activityFilterAcceptsTorrent( tor, mode ) ) 219 ++count; 220 } 221 222 return count; 223 } 209 void 210 TorrentFilter :: countTorrentsPerMode (int * setmeCounts) const 211 { 212 std::fill_n (setmeCounts, FilterMode::NUM_MODES, 0); 213 214 for (int row(0); ; ++row) 215 { 216 QModelIndex index (sourceModel()->index(row, 0)); 217 if (!index.isValid()) 218 break; 219 220 const Torrent * tor (index.data( TorrentModel::TorrentRole ).value<const Torrent*>()); 221 for (int mode(0); mode<FilterMode::NUM_MODES; ++mode) 222 if (activityFilterAcceptsTorrent (tor, mode)) 223 ++setmeCounts[mode]; 224 } 225 } 226 -
trunk/qt/torrent-filter.h
r11092 r13720 49 49 50 50 public: 51 int count( const FilterMode&) const;51 void countTorrentsPerMode (int * setmeCounts) const; 52 52 53 53 private:
Note: See TracChangeset
for help on using the changeset viewer.