From c60e96b365ebb783a8f32d4b793161b41965e6af Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Mon, 9 Jul 2012 09:44:51 -0400 Subject: [PATCH] Fix weight sorting --- src/libtomahawk/jobview/JobStatusModel.cpp | 17 +++++++++-------- src/libtomahawk/jobview/JobStatusModel.h | 1 + src/libtomahawk/jobview/JobStatusView.cpp | 1 - 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/libtomahawk/jobview/JobStatusModel.cpp b/src/libtomahawk/jobview/JobStatusModel.cpp index 1927946cc..42a089f28 100644 --- a/src/libtomahawk/jobview/JobStatusModel.cpp +++ b/src/libtomahawk/jobview/JobStatusModel.cpp @@ -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 ); diff --git a/src/libtomahawk/jobview/JobStatusModel.h b/src/libtomahawk/jobview/JobStatusModel.h index a0455f5b5..41c5652c7 100644 --- a/src/libtomahawk/jobview/JobStatusModel.h +++ b/src/libtomahawk/jobview/JobStatusModel.h @@ -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(); diff --git a/src/libtomahawk/jobview/JobStatusView.cpp b/src/libtomahawk/jobview/JobStatusView.cpp index c0887fa11..c845a5a08 100644 --- a/src/libtomahawk/jobview/JobStatusView.cpp +++ b/src/libtomahawk/jobview/JobStatusView.cpp @@ -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();