mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-16 19:14:06 +02:00
RETHINK MUSIC COMMIT #1!!1!!11! Implement a way to set a custom delegate in job view items
This commit is contained in:
@@ -40,3 +40,8 @@ bool JobStatusItem::collapseItem() const
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStyledItemDelegate* JobStatusItem::customDelegate() const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
class QStyledItemDelegate;
|
||||||
class QPixmap;
|
class QPixmap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,6 +57,8 @@ public:
|
|||||||
virtual bool collapseItem() const;
|
virtual bool collapseItem() const;
|
||||||
virtual bool allowMultiLine() const;
|
virtual bool allowMultiLine() const;
|
||||||
|
|
||||||
|
virtual QStyledItemDelegate* customDelegate() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/// Ask for an update
|
/// Ask for an update
|
||||||
void statusChanged();
|
void statusChanged();
|
||||||
|
@@ -60,9 +60,12 @@ JobStatusModel::addJob( JobStatusItem* item )
|
|||||||
}
|
}
|
||||||
qDebug() << "Adding item:" << 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 );
|
m_items.append( item );
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
if ( item->customDelegate() )
|
||||||
|
emit customDelegateJobInserted( currentEndRow, item->customDelegate() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -23,7 +23,9 @@
|
|||||||
|
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
|
||||||
|
class QStyledItemDelegate;
|
||||||
class JobStatusItem;
|
class JobStatusItem;
|
||||||
|
|
||||||
class DLLEXPORT JobStatusModel : public QAbstractListModel
|
class DLLEXPORT JobStatusModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -45,6 +47,9 @@ public:
|
|||||||
/// Takes ownership of job
|
/// Takes ownership of job
|
||||||
void addJob( JobStatusItem* item );
|
void addJob( JobStatusItem* item );
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void customDelegateJobInserted( int row, QStyledItemDelegate* delegate );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void itemUpdated();
|
void itemUpdated();
|
||||||
void itemFinished();
|
void itemFinished();
|
||||||
|
@@ -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( rowsInserted( QModelIndex, int, int ) ), this, SLOT( checkCount() ) );
|
||||||
connect( m_view->model(), SIGNAL( rowsRemoved( 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( 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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@ class QAbstractItemModel;
|
|||||||
class QListView;
|
class QListView;
|
||||||
class JobStatusModel;
|
class JobStatusModel;
|
||||||
class StreamConnection;
|
class StreamConnection;
|
||||||
|
class QStyledItemDelegate;
|
||||||
|
|
||||||
class DLLEXPORT JobStatusView : public AnimatedWidget
|
class DLLEXPORT JobStatusView : public AnimatedWidget
|
||||||
{
|
{
|
||||||
@@ -51,6 +52,7 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void checkCount();
|
void checkCount();
|
||||||
|
void customDelegateJobInserted( int row, QStyledItemDelegate* delegate );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QListView* m_view;
|
QListView* m_view;
|
||||||
|
Reference in New Issue
Block a user