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