mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 17:29:42 +01:00
Set source model on proxy model
This commit is contained in:
parent
be2847740e
commit
f8d364af0f
@ -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() );
|
||||
}
|
||||
|
||||
|
||||
@ -203,9 +211,9 @@ JobStatusModel::data( const QModelIndex& index, int role ) const
|
||||
{
|
||||
case Qt::DecorationRole:
|
||||
return item->icon();
|
||||
|
||||
|
||||
case Qt::ToolTipRole:
|
||||
|
||||
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
if ( m_collapseCount.contains( item->type() ) )
|
||||
@ -213,7 +221,7 @@ JobStatusModel::data( const QModelIndex& index, int role ) const
|
||||
else
|
||||
return item->mainText();
|
||||
}
|
||||
|
||||
|
||||
case RightColumnRole:
|
||||
{
|
||||
if ( m_collapseCount.contains( item->type() ) )
|
||||
@ -221,7 +229,7 @@ JobStatusModel::data( const QModelIndex& index, int role ) const
|
||||
else
|
||||
return item->rightColumnText();
|
||||
}
|
||||
|
||||
|
||||
case AllowMultiLineRole:
|
||||
return item->allowMultiLine();
|
||||
|
||||
|
@ -55,7 +55,7 @@ signals:
|
||||
public slots:
|
||||
/// Takes ownership of job
|
||||
void addJob( JobStatusItem* item );
|
||||
|
||||
|
||||
private slots:
|
||||
void itemUpdated();
|
||||
void itemFinished();
|
||||
@ -75,6 +75,8 @@ public:
|
||||
JobStatusSortModel( QObject* parent = 0 );
|
||||
virtual ~JobStatusSortModel();
|
||||
|
||||
void setJobModel( JobStatusModel* model );
|
||||
|
||||
signals:
|
||||
void checkCount();
|
||||
void customDelegateJobInserted( int row, JobStatusItem* item );
|
||||
@ -92,9 +94,9 @@ public slots:
|
||||
|
||||
protected:
|
||||
virtual bool lessThan( const QModelIndex & left, const QModelIndex & right ) const;
|
||||
|
||||
|
||||
private:
|
||||
JobStatusModel m_sourceModel;
|
||||
JobStatusModel* m_sourceModel;
|
||||
};
|
||||
|
||||
#endif // JOBSTATUSMODEL_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user