mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
Set source model on proxy model
This commit is contained in:
@@ -266,7 +266,9 @@ TomahawkWindow::setupSideBar()
|
||||
|
||||
m_sourcetree = new SourceTreeView( this );
|
||||
JobStatusView* jobsView = new JobStatusView( m_sidebar );
|
||||
JobStatusModel* sourceModel = new JobStatusModel( jobsView );
|
||||
m_jobsModel = new JobStatusSortModel( jobsView );
|
||||
m_jobsModel->setJobModel( sourceModel );
|
||||
jobsView->setModel( m_jobsModel );
|
||||
|
||||
m_queueView = new QueueView( m_sidebar );
|
||||
|
@@ -27,16 +27,8 @@
|
||||
|
||||
JobStatusSortModel::JobStatusSortModel( QObject* parent )
|
||||
: QSortFilterProxyModel( parent )
|
||||
, m_sourceModel( this )
|
||||
{
|
||||
setDynamicSortFilter( true );
|
||||
|
||||
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() ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +37,27 @@ JobStatusSortModel::~JobStatusSortModel()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
JobStatusSortModel::setJobModel( JobStatusModel* model )
|
||||
{
|
||||
setSourceModel( model );
|
||||
|
||||
m_sourceModel = 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( 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() ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
JobStatusSortModel::addJob( JobStatusItem* item )
|
||||
{
|
||||
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||
m_sourceModel.addJob( item );
|
||||
m_sourceModel->addJob( item );
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +89,7 @@ void
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +97,7 @@ void
|
||||
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() );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -75,6 +75,8 @@ public:
|
||||
JobStatusSortModel( QObject* parent = 0 );
|
||||
virtual ~JobStatusSortModel();
|
||||
|
||||
void setJobModel( JobStatusModel* model );
|
||||
|
||||
signals:
|
||||
void checkCount();
|
||||
void customDelegateJobInserted( int row, JobStatusItem* item );
|
||||
@@ -94,7 +96,7 @@ protected:
|
||||
virtual bool lessThan( const QModelIndex & left, const QModelIndex & right ) const;
|
||||
|
||||
private:
|
||||
JobStatusModel m_sourceModel;
|
||||
JobStatusModel* m_sourceModel;
|
||||
};
|
||||
|
||||
#endif // JOBSTATUSMODEL_H
|
||||
|
Reference in New Issue
Block a user