1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-13 20:39:57 +01:00

RETHINK MUSIC COMMIT #1!!1!!11! Implement a way to set a custom delegate in job view items

This commit is contained in:
Jeff Mitchell 2012-04-21 10:39:21 -04:00
parent 53e97e75da
commit c84cfc8bf0
6 changed files with 30 additions and 1 deletions

View File

@ -40,3 +40,8 @@ bool JobStatusItem::collapseItem() const
{
return false;
}
QStyledItemDelegate* JobStatusItem::customDelegate() const
{
return 0;
}

View File

@ -21,6 +21,7 @@
#include <QObject>
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();

View File

@ -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() );
}

View File

@ -23,7 +23,9 @@
#include <QModelIndex>
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();

View File

@ -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 );
}

View File

@ -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;