1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-01 03:40:16 +02:00

Add new role for getting item data

This commit is contained in:
Jeff Mitchell
2012-04-21 11:54:26 -04:00
parent eb0ed267fa
commit fda71bb583
3 changed files with 29 additions and 20 deletions

View File

@@ -101,25 +101,32 @@ JobStatusModel::data( const QModelIndex& index, int role ) const
switch ( role )
{
case Qt::DecorationRole:
return item->icon();
case Qt::ToolTipRole:
case Qt::DisplayRole:
{
if ( m_collapseCount.contains( item->type() ) )
return m_collapseCount[ item->type() ].last()->mainText();
else
return item->mainText();
}
case RightColumnRole:
{
if ( m_collapseCount.contains( item->type() ) )
return m_collapseCount[ item->type() ].count();
else
return item->rightColumnText();
}
case AllowMultiLineRole:
return item->allowMultiLine();
case Qt::DecorationRole:
return item->icon();
case Qt::ToolTipRole:
case Qt::DisplayRole:
{
if ( m_collapseCount.contains( item->type() ) )
return m_collapseCount[ item->type() ].last()->mainText();
else
return item->mainText();
}
case RightColumnRole:
{
if ( m_collapseCount.contains( item->type() ) )
return m_collapseCount[ item->type() ].count();
else
return item->rightColumnText();
}
case AllowMultiLineRole:
return item->allowMultiLine();
case JobDataRole:
return QVariant::fromValue< JobStatusItem* >( item );
}
return QVariant();

View File

@@ -35,7 +35,8 @@ public:
// DecorationRole is icon
// DisplayRole is main col
RightColumnRole = Qt::UserRole + 1,
AllowMultiLineRole = Qt::UserRole + 2
AllowMultiLineRole = Qt::UserRole + 2,
JobDataRole = Qt::UserRole + 3
};
explicit JobStatusModel( QObject* parent = 0 );

View File

@@ -409,6 +409,7 @@ TomahawkApp::registerMetaTypes()
qRegisterMetaType< QHash< QString, QMap<quint32, quint16> > >("QHash< QString, QMap<quint32, quint16> >");
qRegisterMetaType< QMap< QString, QMap< unsigned int, unsigned int > > >("QMap< QString, QMap< unsigned int, unsigned int > >");
qRegisterMetaType< PairList >("PairList");
qRegisterMetaType< JobStatusItem* >("JobStatusItem*");
qRegisterMetaType< GeneratorMode>("GeneratorMode");
qRegisterMetaType<Tomahawk::GeneratorMode>("Tomahawk::GeneratorMode");