diff --git a/src/libtomahawk/jobview/JobStatusItem.cpp b/src/libtomahawk/jobview/JobStatusItem.cpp index 092f140d4..129e76318 100644 --- a/src/libtomahawk/jobview/JobStatusItem.cpp +++ b/src/libtomahawk/jobview/JobStatusItem.cpp @@ -40,3 +40,8 @@ bool JobStatusItem::collapseItem() const { return false; } + +QStyledItemDelegate* JobStatusItem::customDelegate() const +{ + return 0; +} diff --git a/src/libtomahawk/jobview/JobStatusItem.h b/src/libtomahawk/jobview/JobStatusItem.h index a8190f269..e81aad32e 100644 --- a/src/libtomahawk/jobview/JobStatusItem.h +++ b/src/libtomahawk/jobview/JobStatusItem.h @@ -21,6 +21,7 @@ #include +class QStyledItemDelegate; class QPixmap; /** @@ -56,6 +57,8 @@ public: virtual bool collapseItem() const; virtual bool allowMultiLine() const; + virtual QStyledItemDelegate* customDelegate() const; + signals: /// Ask for an update void statusChanged(); diff --git a/src/libtomahawk/jobview/JobStatusModel.cpp b/src/libtomahawk/jobview/JobStatusModel.cpp index 88aa23274..81c664f15 100644 --- a/src/libtomahawk/jobview/JobStatusModel.cpp +++ b/src/libtomahawk/jobview/JobStatusModel.cpp @@ -60,9 +60,12 @@ JobStatusModel::addJob( JobStatusItem* item ) } qDebug() << "Adding item:" << item; - beginInsertRows( QModelIndex(), m_items.count(), m_items.count() ); + int currentEndRow = m_items.count(); + beginInsertRows( QModelIndex(), currentEndRow, currentEndRow ); m_items.append( item ); endInsertRows(); + if ( item->customDelegate() ) + emit customDelegateJobInserted( currentEndRow, item->customDelegate() ); } diff --git a/src/libtomahawk/jobview/JobStatusModel.h b/src/libtomahawk/jobview/JobStatusModel.h index 539189337..fe592e547 100644 --- a/src/libtomahawk/jobview/JobStatusModel.h +++ b/src/libtomahawk/jobview/JobStatusModel.h @@ -23,7 +23,9 @@ #include +class QStyledItemDelegate; class JobStatusItem; + class DLLEXPORT JobStatusModel : public QAbstractListModel { Q_OBJECT @@ -45,6 +47,9 @@ public: /// Takes ownership of job void addJob( JobStatusItem* item ); +signals: + void customDelegateJobInserted( int row, QStyledItemDelegate* delegate ); + private slots: void itemUpdated(); void itemFinished(); diff --git a/src/libtomahawk/jobview/JobStatusView.cpp b/src/libtomahawk/jobview/JobStatusView.cpp index 4b10f09e2..2b838feda 100644 --- a/src/libtomahawk/jobview/JobStatusView.cpp +++ b/src/libtomahawk/jobview/JobStatusView.cpp @@ -86,6 +86,17 @@ JobStatusView::setModel( JobStatusModel* m ) 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( customDelegateJobInserted( int, QStyledItemDelegate* ) ), this, SLOT( customDelegateJobInserted( int, QStyledItemDelegate* ) ) ); +} + + +void +JobStatusView::customDelegateJobInserted( int row, QStyledItemDelegate* delegate ) +{ + if ( !delegate ) + return; + + m_view->setItemDelegateForRow( row, delegate ); } diff --git a/src/libtomahawk/jobview/JobStatusView.h b/src/libtomahawk/jobview/JobStatusView.h index 5d07c16b7..466cae125 100644 --- a/src/libtomahawk/jobview/JobStatusView.h +++ b/src/libtomahawk/jobview/JobStatusView.h @@ -28,6 +28,7 @@ class QAbstractItemModel; class QListView; class JobStatusModel; class StreamConnection; +class QStyledItemDelegate; class DLLEXPORT JobStatusView : public AnimatedWidget { @@ -51,6 +52,7 @@ public: private slots: void checkCount(); + void customDelegateJobInserted( int row, QStyledItemDelegate* delegate ); private: QListView* m_view;