1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-23 17:29:42 +01:00

Fix weight sorting

This commit is contained in:
Jeff Mitchell 2012-07-09 09:44:51 -04:00
parent f8d364af0f
commit c60e96b365
3 changed files with 10 additions and 9 deletions

View File

@ -47,6 +47,7 @@ JobStatusSortModel::setJobModel( JobStatusModel* model )
connect( m_sourceModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( rowsInsertedSlot( QModelIndex, int, int ) ) );
connect( m_sourceModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( rowsRemovedSlot( QModelIndex, int, int ) ) );
connect( m_sourceModel, SIGNAL( modelReset() ), this, SLOT( modelResetSlot() ) );
connect( m_sourceModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), this, SLOT( dataChangedSlot( QModelIndex, QModelIndex ) ) );
connect( m_sourceModel, SIGNAL( customDelegateJobInserted( int, JobStatusItem* ) ), this, SLOT( customDelegateJobInsertedSlot( int, JobStatusItem* ) ) );
connect( m_sourceModel, SIGNAL( customDelegateJobRemoved( int ) ), this, SLOT( customDelegateJobRemovedSlot( int ) ) );
connect( m_sourceModel, SIGNAL( refreshDelegates() ), this, SLOT( refreshDelegatesSlot() ) );
@ -56,7 +57,6 @@ JobStatusSortModel::setJobModel( JobStatusModel* model )
void
JobStatusSortModel::addJob( JobStatusItem* item )
{
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
m_sourceModel->addJob( item );
}
@ -64,7 +64,6 @@ JobStatusSortModel::addJob( JobStatusItem* item )
void
JobStatusSortModel::rowsInsertedSlot( const QModelIndex& index, int start, int end )
{
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
emit checkCount();
}
@ -72,7 +71,6 @@ JobStatusSortModel::rowsInsertedSlot( const QModelIndex& index, int start, int e
void
JobStatusSortModel::rowsRemovedSlot( const QModelIndex& index, int start, int end )
{
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
emit checkCount();
}
@ -80,15 +78,20 @@ JobStatusSortModel::rowsRemovedSlot( const QModelIndex& index, int start, int en
void
JobStatusSortModel::modelResetSlot()
{
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
emit checkCount();
}
void
JobStatusSortModel::dataChangedSlot( const QModelIndex& topLeft, const QModelIndex& bottomRight )
{
emit dataChanged( mapFromSource( topLeft ), mapFromSource( bottomRight ) );
}
void
JobStatusSortModel::customDelegateJobInsertedSlot( int row, JobStatusItem* item )
{
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
emit customDelegateJobInserted( mapFromSource( m_sourceModel->index( row ) ).row(), item );
}
@ -96,7 +99,6 @@ JobStatusSortModel::customDelegateJobInsertedSlot( int row, JobStatusItem* item
void
JobStatusSortModel::customDelegateJobRemovedSlot( int row )
{
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
emit customDelegateJobRemoved( mapFromSource( m_sourceModel->index( row ) ).row() );
}
@ -104,7 +106,7 @@ JobStatusSortModel::customDelegateJobRemovedSlot( int row )
void
JobStatusSortModel::refreshDelegatesSlot()
{
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
sort( 0 );
emit refreshDelegates();
}
@ -112,7 +114,6 @@ JobStatusSortModel::refreshDelegatesSlot()
bool
JobStatusSortModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const
{
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
QVariant leftVar = left.data( JobStatusModel::JobDataRole );
JobStatusItem* leftItem = leftVar.value< JobStatusItem* >();
QVariant rightVar = right.data( JobStatusModel::JobDataRole );

View File

@ -88,6 +88,7 @@ public slots:
void rowsInsertedSlot( const QModelIndex& index, int start, int end );
void rowsRemovedSlot( const QModelIndex& index, int start, int end );
void modelResetSlot();
void dataChangedSlot( const QModelIndex& topLeft, const QModelIndex& bottomRight );
void customDelegateJobInsertedSlot( int row, JobStatusItem* item);
void customDelegateJobRemovedSlot( int row );
void refreshDelegatesSlot();

View File

@ -160,7 +160,6 @@ JobStatusView::refreshDelegates()
void
JobStatusView::checkCount()
{
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
m_cachedHeight = -1;
if ( m_view->model()->rowCount() == 0 && !isHidden() )
emit hideWidget();