mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-24 09:49:42 +01:00
* Mark-up tracks in the sidebar when hovered.
This commit is contained in:
parent
7de07aabbf
commit
3721ef2975
src/sourcetree
@ -263,6 +263,12 @@ SourceDelegate::paintCollection( QPainter* painter, const QStyleOptionViewItem&
|
||||
m_lockRects.remove( index );
|
||||
}
|
||||
|
||||
if ( m_trackHovered == index )
|
||||
{
|
||||
QFont font = painter->font();
|
||||
font.setUnderline( true );
|
||||
painter->setFont( font );
|
||||
}
|
||||
textRect.adjust( 0, 0, 0, 2 );
|
||||
text = painter->fontMetrics().elidedText( desc, Qt::ElideRight, textRect.width() - 8 );
|
||||
QTextOption to( Qt::AlignVCenter );
|
||||
@ -626,6 +632,22 @@ SourceDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QSt
|
||||
const QRect trackRect = m_trackRects[ index ];
|
||||
const QMouseEvent* ev = static_cast< QMouseEvent* >( event );
|
||||
hoveringTrack = trackRect.contains( ev->pos() );
|
||||
|
||||
if ( hoveringTrack )
|
||||
{
|
||||
if ( m_trackHovered != index )
|
||||
{
|
||||
m_trackHovered = index;
|
||||
QMetaObject::invokeMethod( m_parent, "update", Qt::QueuedConnection, Q_ARG( QModelIndex, index ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !hoveringTrack )
|
||||
{
|
||||
if ( m_trackHovered.isValid() )
|
||||
QMetaObject::invokeMethod( m_parent, "update", Qt::QueuedConnection, Q_ARG( QModelIndex, m_trackHovered ) );
|
||||
|
||||
m_trackHovered = QPersistentModelIndex();
|
||||
}
|
||||
|
||||
bool lockRectContainsClick = false, headphonesRectContainsClick = false;
|
||||
@ -806,7 +828,7 @@ SourceDelegate::hovered( const QModelIndex& index, const QMimeData* mimeData )
|
||||
{
|
||||
if ( !index.isValid() )
|
||||
{
|
||||
foreach ( AnimationHelper *helper, m_expandedMap )
|
||||
foreach ( AnimationHelper* helper, m_expandedMap )
|
||||
{
|
||||
helper->collapse();
|
||||
}
|
||||
@ -815,14 +837,14 @@ SourceDelegate::hovered( const QModelIndex& index, const QMimeData* mimeData )
|
||||
|
||||
if ( !m_expandedMap.contains( index ) )
|
||||
{
|
||||
foreach ( AnimationHelper *helper, m_expandedMap )
|
||||
foreach ( AnimationHelper* helper, m_expandedMap )
|
||||
{
|
||||
helper->collapse();
|
||||
}
|
||||
|
||||
m_newDropHoverIndex = index;
|
||||
m_dropMimeData->clear();
|
||||
foreach ( const QString &mimeDataFormat, mimeData->formats() )
|
||||
foreach ( const QString& mimeDataFormat, mimeData->formats() )
|
||||
{
|
||||
m_dropMimeData->setData( mimeDataFormat, mimeData->data( mimeDataFormat ) );
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
SourceDelegate( QAbstractItemView* parent = 0 );
|
||||
~SourceDelegate();
|
||||
|
||||
void hovered( const QModelIndex &index, const QMimeData *mimeData );
|
||||
void hovered( const QModelIndex& index, const QMimeData* mimeData );
|
||||
void dragLeaveEvent();
|
||||
|
||||
SourceTreeItem::DropType hoveredDropType() const;
|
||||
@ -69,7 +69,7 @@ private:
|
||||
mutable int m_iconHeight;
|
||||
QModelIndex m_dropHoverIndex;
|
||||
QModelIndex m_newDropHoverIndex;
|
||||
QMimeData *m_dropMimeData;
|
||||
QMimeData* m_dropMimeData;
|
||||
mutable SourceTreeItem::DropType m_hoveredDropType; // Hack to keep easily track of the current highlighted DropType in paint()
|
||||
QMap< QModelIndex, AnimationHelper* > m_expandedMap;
|
||||
QPixmap m_headphonesOn, m_headphonesOff, m_realtimeLocked, m_realtimeUnlocked, m_nowPlayingSpeaker, m_nowPlayingSpeakerDark, m_collaborativeOn;
|
||||
@ -78,6 +78,7 @@ private:
|
||||
QMap< int, QString > m_dropTypeTextMap;
|
||||
QMap< int, QPixmap > m_dropTypeImageMap;
|
||||
|
||||
mutable QPersistentModelIndex m_trackHovered;
|
||||
mutable QHash< QPersistentModelIndex, QRect > m_trackRects;
|
||||
mutable QHash< QPersistentModelIndex, QRect > m_headphoneRects;
|
||||
mutable QHash< QPersistentModelIndex, QRect > m_lockRects;
|
||||
|
Loading…
x
Reference in New Issue
Block a user