From be2847740ee57004807e4eb4463b0ddbcda74a25 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Mon, 9 Jul 2012 08:41:58 -0400 Subject: [PATCH] Add a lot more debugging --- src/libtomahawk/jobview/JobStatusModel.cpp | 52 +++++++++++++++++----- src/libtomahawk/jobview/JobStatusModel.h | 6 ++- src/libtomahawk/jobview/JobStatusView.cpp | 7 +-- 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/src/libtomahawk/jobview/JobStatusModel.cpp b/src/libtomahawk/jobview/JobStatusModel.cpp index 9442129ba..3c16810e7 100644 --- a/src/libtomahawk/jobview/JobStatusModel.cpp +++ b/src/libtomahawk/jobview/JobStatusModel.cpp @@ -27,17 +27,16 @@ JobStatusSortModel::JobStatusSortModel( QObject* parent ) : QSortFilterProxyModel( parent ) - , m_subModel( this ) + , m_sourceModel( this ) { setDynamicSortFilter( true ); - connect( &m_subModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SIGNAL( rowsInserted( QModelIndex, int, int ) ) ); - connect( &m_subModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SIGNAL( rowsRemoved( QModelIndex, int, int ) ) ); - connect( &m_subModel, SIGNAL( modelReset() ), this, SIGNAL( modelReset() ) ); - - connect( &m_subModel, SIGNAL( customDelegateJobInserted( int, JobStatusItem* ) ), this, SLOT( customDelegateJobInsertedSlot( int, JobStatusItem* ) ) ); - connect( &m_subModel, SIGNAL( customDelegateJobRemoved( int ) ), this, SLOT( customDelegateJobRemovedSlot( int ) ) ); - connect( &m_subModel, SIGNAL( refreshDelegates() ), this, SLOT( refreshDelegatesSlot() ) ); + 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( 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() ) ); } @@ -49,27 +48,55 @@ JobStatusSortModel::~JobStatusSortModel() void JobStatusSortModel::addJob( JobStatusItem* item ) { - m_subModel.addJob( item ); + tLog( LOGVERBOSE ) << Q_FUNC_INFO; + m_sourceModel.addJob( item ); +} + + +void +JobStatusSortModel::rowsInsertedSlot( const QModelIndex& index, int start, int end ) +{ + tLog( LOGVERBOSE ) << Q_FUNC_INFO; + emit checkCount(); +} + + +void +JobStatusSortModel::rowsRemovedSlot( const QModelIndex& index, int start, int end ) +{ + tLog( LOGVERBOSE ) << Q_FUNC_INFO; + emit checkCount(); +} + + +void +JobStatusSortModel::modelResetSlot() +{ + tLog( LOGVERBOSE ) << Q_FUNC_INFO; + emit checkCount(); } void JobStatusSortModel::customDelegateJobInsertedSlot( int row, JobStatusItem* item ) { - emit customDelegateJobInserted( mapFromSource( m_subModel.index( row ) ).row(), item ); + tLog( LOGVERBOSE ) << Q_FUNC_INFO; + emit customDelegateJobInserted( mapFromSource( m_sourceModel.index( row ) ).row(), item ); } void JobStatusSortModel::customDelegateJobRemovedSlot( int row ) { - emit customDelegateJobRemoved( mapFromSource( m_subModel.index( row ) ).row() ); + tLog( LOGVERBOSE ) << Q_FUNC_INFO; + emit customDelegateJobRemoved( mapFromSource( m_sourceModel.index( row ) ).row() ); } void JobStatusSortModel::refreshDelegatesSlot() { + tLog( LOGVERBOSE ) << Q_FUNC_INFO; emit refreshDelegates(); } @@ -77,6 +104,7 @@ 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 ); @@ -216,6 +244,7 @@ JobStatusModel::rowCount( const QModelIndex& parent ) const void JobStatusModel::itemFinished() { + tLog( LOGVERBOSE ) << Q_FUNC_INFO; JobStatusItem* item = qobject_cast< JobStatusItem* >( sender() ); Q_ASSERT( item ); @@ -293,6 +322,7 @@ JobStatusModel::itemFinished() void JobStatusModel::itemUpdated() { + tLog( LOGVERBOSE ) << Q_FUNC_INFO; JobStatusItem* item = qobject_cast< JobStatusItem* >( sender() ); Q_ASSERT( item ); diff --git a/src/libtomahawk/jobview/JobStatusModel.h b/src/libtomahawk/jobview/JobStatusModel.h index 7a5a4f65e..56188ae8a 100644 --- a/src/libtomahawk/jobview/JobStatusModel.h +++ b/src/libtomahawk/jobview/JobStatusModel.h @@ -76,12 +76,16 @@ public: virtual ~JobStatusSortModel(); signals: + void checkCount(); void customDelegateJobInserted( int row, JobStatusItem* item ); void customDelegateJobRemoved( int row ); void refreshDelegates(); public slots: void addJob( JobStatusItem* item ); + void rowsInsertedSlot( const QModelIndex& index, int start, int end ); + void rowsRemovedSlot( const QModelIndex& index, int start, int end ); + void modelResetSlot(); void customDelegateJobInsertedSlot( int row, JobStatusItem* item); void customDelegateJobRemovedSlot( int row ); void refreshDelegatesSlot(); @@ -90,7 +94,7 @@ protected: virtual bool lessThan( const QModelIndex & left, const QModelIndex & right ) const; private: - JobStatusModel m_subModel; + JobStatusModel m_sourceModel; }; #endif // JOBSTATUSMODEL_H diff --git a/src/libtomahawk/jobview/JobStatusView.cpp b/src/libtomahawk/jobview/JobStatusView.cpp index 26254ebff..c0887fa11 100644 --- a/src/libtomahawk/jobview/JobStatusView.cpp +++ b/src/libtomahawk/jobview/JobStatusView.cpp @@ -89,9 +89,9 @@ JobStatusView::setModel( JobStatusSortModel* m ) m_view->setModel( m ); m_view->setItemDelegate( new JobStatusDelegate( m_view ) ); - connect( m_view->model(), SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( checkCount() ) ); - connect( m_view->model(), SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( checkCount() ) ); - connect( m_view->model(), SIGNAL( modelReset() ), this, SLOT( checkCount() ) ); + connect( m_view->model(), SIGNAL( checkCount() ), this, SLOT( checkCount() ) ); + connect( m_view->model(), SIGNAL( checkCount() ), this, SLOT( checkCount() ) ); + connect( m_view->model(), SIGNAL( checkCount() ), this, SLOT( checkCount() ) ); connect( m_view->model(), SIGNAL( customDelegateJobInserted( int, JobStatusItem* ) ), this, SLOT( customDelegateJobInserted( int, JobStatusItem* ) ) ); connect( m_view->model(), SIGNAL( customDelegateJobRemoved( int ) ), this, SLOT( customDelegateJobRemoved( int ) ) ); connect( m_view->model(), SIGNAL( refreshDelegates() ), this, SLOT( refreshDelegates() ) ); @@ -160,6 +160,7 @@ JobStatusView::refreshDelegates() void JobStatusView::checkCount() { + tLog( LOGVERBOSE ) << Q_FUNC_INFO; m_cachedHeight = -1; if ( m_view->model()->rowCount() == 0 && !isHidden() ) emit hideWidget();