mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Add a lot more debugging
This commit is contained in:
@@ -27,17 +27,16 @@
|
|||||||
|
|
||||||
JobStatusSortModel::JobStatusSortModel( QObject* parent )
|
JobStatusSortModel::JobStatusSortModel( QObject* parent )
|
||||||
: QSortFilterProxyModel( parent )
|
: QSortFilterProxyModel( parent )
|
||||||
, m_subModel( this )
|
, m_sourceModel( this )
|
||||||
{
|
{
|
||||||
setDynamicSortFilter( true );
|
setDynamicSortFilter( true );
|
||||||
|
|
||||||
connect( &m_subModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SIGNAL( rowsInserted( QModelIndex, int, int ) ) );
|
connect( &m_sourceModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( rowsInsertedSlot( QModelIndex, int, int ) ) );
|
||||||
connect( &m_subModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SIGNAL( rowsRemoved( QModelIndex, int, int ) ) );
|
connect( &m_sourceModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( rowsRemovedSlot( QModelIndex, int, int ) ) );
|
||||||
connect( &m_subModel, SIGNAL( modelReset() ), this, SIGNAL( modelReset() ) );
|
connect( &m_sourceModel, SIGNAL( modelReset() ), this, SLOT( modelResetSlot() ) );
|
||||||
|
connect( &m_sourceModel, SIGNAL( customDelegateJobInserted( int, JobStatusItem* ) ), this, SLOT( customDelegateJobInsertedSlot( int, JobStatusItem* ) ) );
|
||||||
connect( &m_subModel, SIGNAL( customDelegateJobInserted( int, JobStatusItem* ) ), this, SLOT( customDelegateJobInsertedSlot( int, JobStatusItem* ) ) );
|
connect( &m_sourceModel, SIGNAL( customDelegateJobRemoved( int ) ), this, SLOT( customDelegateJobRemovedSlot( int ) ) );
|
||||||
connect( &m_subModel, SIGNAL( customDelegateJobRemoved( int ) ), this, SLOT( customDelegateJobRemovedSlot( int ) ) );
|
connect( &m_sourceModel, SIGNAL( refreshDelegates() ), this, SLOT( refreshDelegatesSlot() ) );
|
||||||
connect( &m_subModel, SIGNAL( refreshDelegates() ), this, SLOT( refreshDelegatesSlot() ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -49,27 +48,55 @@ JobStatusSortModel::~JobStatusSortModel()
|
|||||||
void
|
void
|
||||||
JobStatusSortModel::addJob( JobStatusItem* item )
|
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
|
void
|
||||||
JobStatusSortModel::customDelegateJobInsertedSlot( int row, JobStatusItem* item )
|
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
|
void
|
||||||
JobStatusSortModel::customDelegateJobRemovedSlot( int row )
|
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
|
void
|
||||||
JobStatusSortModel::refreshDelegatesSlot()
|
JobStatusSortModel::refreshDelegatesSlot()
|
||||||
{
|
{
|
||||||
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
emit refreshDelegates();
|
emit refreshDelegates();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +104,7 @@ 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 );
|
||||||
@@ -216,6 +244,7 @@ JobStatusModel::rowCount( const QModelIndex& parent ) const
|
|||||||
void
|
void
|
||||||
JobStatusModel::itemFinished()
|
JobStatusModel::itemFinished()
|
||||||
{
|
{
|
||||||
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
JobStatusItem* item = qobject_cast< JobStatusItem* >( sender() );
|
JobStatusItem* item = qobject_cast< JobStatusItem* >( sender() );
|
||||||
Q_ASSERT( item );
|
Q_ASSERT( item );
|
||||||
|
|
||||||
@@ -293,6 +322,7 @@ JobStatusModel::itemFinished()
|
|||||||
void
|
void
|
||||||
JobStatusModel::itemUpdated()
|
JobStatusModel::itemUpdated()
|
||||||
{
|
{
|
||||||
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
JobStatusItem* item = qobject_cast< JobStatusItem* >( sender() );
|
JobStatusItem* item = qobject_cast< JobStatusItem* >( sender() );
|
||||||
Q_ASSERT( item );
|
Q_ASSERT( item );
|
||||||
|
|
||||||
|
@@ -76,12 +76,16 @@ public:
|
|||||||
virtual ~JobStatusSortModel();
|
virtual ~JobStatusSortModel();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void checkCount();
|
||||||
void customDelegateJobInserted( int row, JobStatusItem* item );
|
void customDelegateJobInserted( int row, JobStatusItem* item );
|
||||||
void customDelegateJobRemoved( int row );
|
void customDelegateJobRemoved( int row );
|
||||||
void refreshDelegates();
|
void refreshDelegates();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addJob( JobStatusItem* item );
|
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 customDelegateJobInsertedSlot( int row, JobStatusItem* item);
|
||||||
void customDelegateJobRemovedSlot( int row );
|
void customDelegateJobRemovedSlot( int row );
|
||||||
void refreshDelegatesSlot();
|
void refreshDelegatesSlot();
|
||||||
@@ -90,7 +94,7 @@ protected:
|
|||||||
virtual bool lessThan( const QModelIndex & left, const QModelIndex & right ) const;
|
virtual bool lessThan( const QModelIndex & left, const QModelIndex & right ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JobStatusModel m_subModel;
|
JobStatusModel m_sourceModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // JOBSTATUSMODEL_H
|
#endif // JOBSTATUSMODEL_H
|
||||||
|
@@ -89,9 +89,9 @@ JobStatusView::setModel( JobStatusSortModel* m )
|
|||||||
m_view->setModel( m );
|
m_view->setModel( m );
|
||||||
m_view->setItemDelegate( new JobStatusDelegate( m_view ) );
|
m_view->setItemDelegate( new JobStatusDelegate( m_view ) );
|
||||||
|
|
||||||
connect( m_view->model(), SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( checkCount() ) );
|
connect( m_view->model(), SIGNAL( checkCount() ), this, SLOT( checkCount() ) );
|
||||||
connect( m_view->model(), SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( checkCount() ) );
|
connect( m_view->model(), SIGNAL( checkCount() ), 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( customDelegateJobInserted( int, JobStatusItem* ) ), this, SLOT( customDelegateJobInserted( int, JobStatusItem* ) ) );
|
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( customDelegateJobRemoved( int ) ), this, SLOT( customDelegateJobRemoved( int ) ) );
|
||||||
connect( m_view->model(), SIGNAL( refreshDelegates() ), this, SLOT( refreshDelegates() ) );
|
connect( m_view->model(), SIGNAL( refreshDelegates() ), this, SLOT( refreshDelegates() ) );
|
||||||
@@ -160,6 +160,7 @@ 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();
|
||||||
|
Reference in New Issue
Block a user