mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
Set source model on proxy model
This commit is contained in:
@@ -266,7 +266,9 @@ TomahawkWindow::setupSideBar()
|
|||||||
|
|
||||||
m_sourcetree = new SourceTreeView( this );
|
m_sourcetree = new SourceTreeView( this );
|
||||||
JobStatusView* jobsView = new JobStatusView( m_sidebar );
|
JobStatusView* jobsView = new JobStatusView( m_sidebar );
|
||||||
|
JobStatusModel* sourceModel = new JobStatusModel( jobsView );
|
||||||
m_jobsModel = new JobStatusSortModel( jobsView );
|
m_jobsModel = new JobStatusSortModel( jobsView );
|
||||||
|
m_jobsModel->setJobModel( sourceModel );
|
||||||
jobsView->setModel( m_jobsModel );
|
jobsView->setModel( m_jobsModel );
|
||||||
|
|
||||||
m_queueView = new QueueView( m_sidebar );
|
m_queueView = new QueueView( m_sidebar );
|
||||||
|
@@ -27,16 +27,8 @@
|
|||||||
|
|
||||||
JobStatusSortModel::JobStatusSortModel( QObject* parent )
|
JobStatusSortModel::JobStatusSortModel( QObject* parent )
|
||||||
: QSortFilterProxyModel( parent )
|
: QSortFilterProxyModel( parent )
|
||||||
, m_sourceModel( this )
|
|
||||||
{
|
{
|
||||||
setDynamicSortFilter( true );
|
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
|
void
|
||||||
JobStatusSortModel::addJob( JobStatusItem* item )
|
JobStatusSortModel::addJob( JobStatusItem* item )
|
||||||
{
|
{
|
||||||
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
m_sourceModel.addJob( item );
|
m_sourceModel->addJob( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -81,7 +89,7 @@ void
|
|||||||
JobStatusSortModel::customDelegateJobInsertedSlot( int row, JobStatusItem* item )
|
JobStatusSortModel::customDelegateJobInsertedSlot( int row, JobStatusItem* item )
|
||||||
{
|
{
|
||||||
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
|
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 )
|
JobStatusSortModel::customDelegateJobRemovedSlot( int row )
|
||||||
{
|
{
|
||||||
tLog( LOGVERBOSE ) << Q_FUNC_INFO;
|
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:
|
case Qt::DecorationRole:
|
||||||
return item->icon();
|
return item->icon();
|
||||||
|
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
|
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
{
|
{
|
||||||
if ( m_collapseCount.contains( item->type() ) )
|
if ( m_collapseCount.contains( item->type() ) )
|
||||||
@@ -213,7 +221,7 @@ JobStatusModel::data( const QModelIndex& index, int role ) const
|
|||||||
else
|
else
|
||||||
return item->mainText();
|
return item->mainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
case RightColumnRole:
|
case RightColumnRole:
|
||||||
{
|
{
|
||||||
if ( m_collapseCount.contains( item->type() ) )
|
if ( m_collapseCount.contains( item->type() ) )
|
||||||
@@ -221,7 +229,7 @@ JobStatusModel::data( const QModelIndex& index, int role ) const
|
|||||||
else
|
else
|
||||||
return item->rightColumnText();
|
return item->rightColumnText();
|
||||||
}
|
}
|
||||||
|
|
||||||
case AllowMultiLineRole:
|
case AllowMultiLineRole:
|
||||||
return item->allowMultiLine();
|
return item->allowMultiLine();
|
||||||
|
|
||||||
|
@@ -55,7 +55,7 @@ signals:
|
|||||||
public slots:
|
public slots:
|
||||||
/// Takes ownership of job
|
/// Takes ownership of job
|
||||||
void addJob( JobStatusItem* item );
|
void addJob( JobStatusItem* item );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void itemUpdated();
|
void itemUpdated();
|
||||||
void itemFinished();
|
void itemFinished();
|
||||||
@@ -75,6 +75,8 @@ public:
|
|||||||
JobStatusSortModel( QObject* parent = 0 );
|
JobStatusSortModel( QObject* parent = 0 );
|
||||||
virtual ~JobStatusSortModel();
|
virtual ~JobStatusSortModel();
|
||||||
|
|
||||||
|
void setJobModel( JobStatusModel* model );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void checkCount();
|
void checkCount();
|
||||||
void customDelegateJobInserted( int row, JobStatusItem* item );
|
void customDelegateJobInserted( int row, JobStatusItem* item );
|
||||||
@@ -92,9 +94,9 @@ public slots:
|
|||||||
|
|
||||||
protected:
|
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_sourceModel;
|
JobStatusModel* m_sourceModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // JOBSTATUSMODEL_H
|
#endif // JOBSTATUSMODEL_H
|
||||||
|
Reference in New Issue
Block a user