1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 22:26:32 +02: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( 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( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( rowsRemovedSlot( QModelIndex, int, int ) ) );
connect( m_sourceModel, SIGNAL( modelReset() ), this, SLOT( modelResetSlot() ) ); 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( customDelegateJobInserted( int, JobStatusItem* ) ), this, SLOT( customDelegateJobInsertedSlot( int, JobStatusItem* ) ) );
connect( m_sourceModel, SIGNAL( customDelegateJobRemoved( int ) ), this, SLOT( customDelegateJobRemovedSlot( int ) ) ); connect( m_sourceModel, SIGNAL( customDelegateJobRemoved( int ) ), this, SLOT( customDelegateJobRemovedSlot( int ) ) );
connect( m_sourceModel, SIGNAL( refreshDelegates() ), this, SLOT( refreshDelegatesSlot() ) ); connect( m_sourceModel, SIGNAL( refreshDelegates() ), this, SLOT( refreshDelegatesSlot() ) );
@@ -56,7 +57,6 @@ JobStatusSortModel::setJobModel( JobStatusModel* model )
void void
JobStatusSortModel::addJob( JobStatusItem* item ) JobStatusSortModel::addJob( JobStatusItem* item )
{ {
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
m_sourceModel->addJob( item ); m_sourceModel->addJob( item );
} }
@@ -64,7 +64,6 @@ JobStatusSortModel::addJob( JobStatusItem* item )
void void
JobStatusSortModel::rowsInsertedSlot( const QModelIndex& index, int start, int end ) JobStatusSortModel::rowsInsertedSlot( const QModelIndex& index, int start, int end )
{ {
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
emit checkCount(); emit checkCount();
} }
@@ -72,7 +71,6 @@ JobStatusSortModel::rowsInsertedSlot( const QModelIndex& index, int start, int e
void void
JobStatusSortModel::rowsRemovedSlot( const QModelIndex& index, int start, int end ) JobStatusSortModel::rowsRemovedSlot( const QModelIndex& index, int start, int end )
{ {
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
emit checkCount(); emit checkCount();
} }
@@ -80,15 +78,20 @@ JobStatusSortModel::rowsRemovedSlot( const QModelIndex& index, int start, int en
void void
JobStatusSortModel::modelResetSlot() JobStatusSortModel::modelResetSlot()
{ {
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
emit checkCount(); emit checkCount();
} }
void
JobStatusSortModel::dataChangedSlot( const QModelIndex& topLeft, const QModelIndex& bottomRight )
{
emit dataChanged( mapFromSource( topLeft ), mapFromSource( bottomRight ) );
}
void void
JobStatusSortModel::customDelegateJobInsertedSlot( int row, JobStatusItem* item ) JobStatusSortModel::customDelegateJobInsertedSlot( int row, JobStatusItem* item )
{ {
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
emit customDelegateJobInserted( mapFromSource( m_sourceModel->index( row ) ).row(), item ); emit customDelegateJobInserted( mapFromSource( m_sourceModel->index( row ) ).row(), item );
} }
@@ -96,7 +99,6 @@ JobStatusSortModel::customDelegateJobInsertedSlot( int row, JobStatusItem* item
void void
JobStatusSortModel::customDelegateJobRemovedSlot( int row ) JobStatusSortModel::customDelegateJobRemovedSlot( int row )
{ {
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
emit customDelegateJobRemoved( mapFromSource( m_sourceModel->index( row ) ).row() ); emit customDelegateJobRemoved( mapFromSource( m_sourceModel->index( row ) ).row() );
} }
@@ -104,7 +106,7 @@ JobStatusSortModel::customDelegateJobRemovedSlot( int row )
void void
JobStatusSortModel::refreshDelegatesSlot() JobStatusSortModel::refreshDelegatesSlot()
{ {
tLog( LOGVERBOSE ) << Q_FUNC_INFO; sort( 0 );
emit refreshDelegates(); emit refreshDelegates();
} }
@@ -112,7 +114,6 @@ JobStatusSortModel::refreshDelegatesSlot()
bool bool
JobStatusSortModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const JobStatusSortModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const
{ {
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
QVariant leftVar = left.data( JobStatusModel::JobDataRole ); QVariant leftVar = left.data( JobStatusModel::JobDataRole );
JobStatusItem* leftItem = leftVar.value< JobStatusItem* >(); JobStatusItem* leftItem = leftVar.value< JobStatusItem* >();
QVariant rightVar = right.data( JobStatusModel::JobDataRole ); QVariant rightVar = right.data( JobStatusModel::JobDataRole );

View File

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

View File

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