mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 17:29:42 +01:00
TWK-736: Tooltip for currently playing song for peers
This commit is contained in:
parent
ce19d8c70b
commit
53dd69e2f3
@ -101,41 +101,48 @@ SourcesModel::data( const QModelIndex& index, int role ) const
|
||||
if ( !index.isValid() )
|
||||
return QVariant();
|
||||
|
||||
SourceTreeItem* item = itemFromIndex( index );
|
||||
if ( !item )
|
||||
return QVariant();
|
||||
|
||||
switch ( role )
|
||||
{
|
||||
case Qt::SizeHintRole:
|
||||
return QSize( 0, 18 );
|
||||
case SourceTreeItemRole:
|
||||
return QVariant::fromValue< SourceTreeItem* >( itemFromIndex( index ) );
|
||||
return QVariant::fromValue< SourceTreeItem* >( item );
|
||||
case SourceTreeItemTypeRole:
|
||||
return itemFromIndex( index )->type();
|
||||
return item->type();
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
return itemFromIndex( index )->text();
|
||||
return item->text();
|
||||
case Qt::DecorationRole:
|
||||
return itemFromIndex( index )->icon();
|
||||
return item->icon();
|
||||
case SourcesModel::SortRole:
|
||||
return itemFromIndex( index )->peerSortValue();
|
||||
return item->peerSortValue();
|
||||
case SourcesModel::IDRole:
|
||||
return itemFromIndex( index )->IDValue();
|
||||
return item->IDValue();
|
||||
case SourcesModel::LatchedOnRole:
|
||||
{
|
||||
if ( itemFromIndex( index )->type() == Collection )
|
||||
if ( item->type() == Collection )
|
||||
{
|
||||
SourceItem* cItem = qobject_cast< SourceItem* >( itemFromIndex( index ) );
|
||||
SourceItem* cItem = qobject_cast< SourceItem* >( item );
|
||||
return cItem->localLatchedOn();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case SourcesModel::LatchedRealtimeRole:
|
||||
{
|
||||
if ( itemFromIndex( index )->type() == Collection )
|
||||
if ( item->type() == Collection )
|
||||
{
|
||||
SourceItem* cItem = qobject_cast< SourceItem* >( itemFromIndex( index ) );
|
||||
SourceItem* cItem = qobject_cast< SourceItem* >( item );
|
||||
return cItem->localLatchMode() == Tomahawk::PlaylistModes::RealTime;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case Qt::ToolTipRole:
|
||||
if ( !item->tooltip().isEmpty() )
|
||||
return item->tooltip();
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -145,6 +145,16 @@ SourceItem::text() const
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
SourceItem::tooltip() const
|
||||
{
|
||||
if ( !m_source.isNull() && !m_source->currentTrack().isNull() )
|
||||
return m_source->textStatus();
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SourceItem::IDValue() const
|
||||
{
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
SourceItem( SourcesModel* model, SourceTreeItem* parent, const Tomahawk::source_ptr& source );
|
||||
|
||||
virtual QString text() const;
|
||||
virtual QString tooltip() const;
|
||||
virtual QIcon icon() const;
|
||||
virtual int peerSortValue() const;
|
||||
virtual int IDValue() const;
|
||||
|
@ -58,6 +58,7 @@ public:
|
||||
|
||||
// varies depending on the type of the item
|
||||
virtual QString text() const { return QString(); }
|
||||
virtual QString tooltip() const { return QString(); }
|
||||
virtual Qt::ItemFlags flags() const { return Qt::ItemIsSelectable | Qt::ItemIsEnabled; }
|
||||
virtual QIcon icon() const { return QIcon(); }
|
||||
virtual bool willAcceptDrag( const QMimeData* ) const { return false; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user