mirror of
https://github.com/transmission/transmission
synced 2024-12-23 00:04:06 +00:00
(trunk, qt) minor speedups to filterbar::recount()
This commit is contained in:
parent
765ed4a0d2
commit
a8a2d5c775
2 changed files with 25 additions and 27 deletions
|
@ -472,7 +472,7 @@ FilterBar :: refreshPref( int key )
|
|||
case Prefs :: FILTER_MODE: {
|
||||
const FilterMode m = myPrefs.get<FilterMode>( key );
|
||||
QAbstractItemModel * model = myActivityCombo->model( );
|
||||
QModelIndexList indices = model->match( model->index(0,0), ActivityRole, m.mode(), -1 );
|
||||
QModelIndexList indices = model->match( model->index(0,0), ActivityRole, m.mode() );
|
||||
myActivityCombo->setCurrentIndex( indices.isEmpty() ? 0 : indices.first().row( ) );
|
||||
break;
|
||||
}
|
||||
|
@ -544,23 +544,22 @@ FilterBar :: recountSoon( )
|
|||
if( !myRecountTimer->isActive( ) )
|
||||
{
|
||||
myRecountTimer->setSingleShot( true );
|
||||
myRecountTimer->start( 500 );
|
||||
myRecountTimer->start( 800 );
|
||||
}
|
||||
}
|
||||
void
|
||||
FilterBar :: recount ( )
|
||||
FilterBar :: recount ()
|
||||
{
|
||||
// recount the activity combobox...
|
||||
for( int i=0, n=FilterMode::NUM_MODES; i<n; ++i )
|
||||
QAbstractItemModel * model = myActivityCombo->model();
|
||||
|
||||
for (int row=0, n=model->rowCount(); row<n; ++row)
|
||||
{
|
||||
const FilterMode m( i );
|
||||
QAbstractItemModel * model = myActivityCombo->model( );
|
||||
QModelIndexList indices = model->match( model->index(0,0), ActivityRole, m.mode(), -1 );
|
||||
if( !indices.isEmpty( ) )
|
||||
model->setData( indices.first(), getCountString(myFilter.count(m)), TorrentCountRole );
|
||||
QModelIndex index = model->index (row, 0);
|
||||
const int mode = index.data(ActivityRole).toInt();
|
||||
model->setData (index, getCountString(myFilter.count(mode)), TorrentCountRole);
|
||||
}
|
||||
|
||||
refreshTrackers( );
|
||||
refreshTrackers ();
|
||||
}
|
||||
|
||||
QString
|
||||
|
|
|
@ -38,35 +38,34 @@ TorrentModel :: rowCount( const QModelIndex& parent ) const
|
|||
}
|
||||
|
||||
QVariant
|
||||
TorrentModel :: data( const QModelIndex& index, int role ) const
|
||||
TorrentModel :: data (const QModelIndex& index, int role) const
|
||||
{
|
||||
QVariant var;
|
||||
const int row = index.row( );
|
||||
if( row<0 || row>=myTorrents.size() )
|
||||
return QVariant( );
|
||||
QVariant var;
|
||||
|
||||
const Torrent* t = myTorrents.at( row );
|
||||
|
||||
switch( role )
|
||||
const Torrent * t = myTorrents.value (index.row(), 0);
|
||||
if (t != 0)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
var = QString( t->name() );
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
var.setValue (t->name());
|
||||
break;
|
||||
|
||||
case Qt::DecorationRole:
|
||||
var = t->getMimeTypeIcon( );
|
||||
case Qt::DecorationRole:
|
||||
var.setValue (t->getMimeTypeIcon());
|
||||
break;
|
||||
|
||||
case TorrentRole:
|
||||
var = qVariantFromValue( t );
|
||||
case TorrentRole:
|
||||
var = qVariantFromValue(t);
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
//std::cerr << "Unhandled role: " << role << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return var;
|
||||
return var;
|
||||
}
|
||||
|
||||
/***
|
||||
|
|
Loading…
Reference in a new issue