mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
Try harder to make artist name hover disappear, not perfect yet
This commit is contained in:
parent
d442c2158a
commit
5c700394a8
@ -157,6 +157,7 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
// If the user is hovering over an artist rect, draw a background so she knows it's clickable
|
||||
QRect r = textRect;
|
||||
r.setTop( r.bottom() - painter->fontMetrics().height() );
|
||||
r.adjust( 4, 0, -4, -1 );
|
||||
if ( m_hoveringOver == index )
|
||||
TomahawkUtils::drawQueryBackground( painter, opt.palette, r, 1.5 );
|
||||
|
||||
@ -183,7 +184,8 @@ AlbumItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const
|
||||
|
||||
if ( event->type() != QEvent::MouseButtonRelease &&
|
||||
event->type() != QEvent::MouseMove &&
|
||||
event->type() != QEvent::MouseButtonPress )
|
||||
event->type() != QEvent::MouseButtonPress &&
|
||||
event->type() != QEvent::Leave )
|
||||
return false;
|
||||
|
||||
if ( m_artistNameRects.contains( index ) )
|
||||
@ -202,6 +204,7 @@ AlbumItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const
|
||||
emit updateIndex( index );
|
||||
}
|
||||
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
else if ( event->type() == QEvent::MouseButtonRelease )
|
||||
@ -212,21 +215,29 @@ AlbumItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const
|
||||
|
||||
ViewManager::instance()->show( item->album()->artist() );
|
||||
|
||||
event->accept();
|
||||
return true;
|
||||
} else if ( event->type() == QEvent::MouseButtonPress )
|
||||
{
|
||||
// Stop the whole album from having a down click action as we just want the artist name to be clicked
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
whitespaceMouseEvent();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
AlbumItemDelegate::whitespaceMouseEvent()
|
||||
{
|
||||
if ( m_hoveringOver.isValid() )
|
||||
{
|
||||
QModelIndex old = m_hoveringOver;
|
||||
m_hoveringOver = QPersistentModelIndex();
|
||||
emit updateIndex( old );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ Q_OBJECT
|
||||
public:
|
||||
AlbumItemDelegate( QAbstractItemView* parent = 0, AlbumProxyModel* proxy = 0 );
|
||||
|
||||
void whitespaceMouseEvent();
|
||||
|
||||
protected:
|
||||
void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||
QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||
|
@ -43,6 +43,7 @@ AlbumView::AlbumView( QWidget* parent )
|
||||
: QListView( parent )
|
||||
, m_model( 0 )
|
||||
, m_proxyModel( 0 )
|
||||
, m_delegate( 0 )
|
||||
, m_loadingSpinner( new LoadingSpinner( this ) )
|
||||
{
|
||||
setDragEnabled( true );
|
||||
@ -79,9 +80,9 @@ void
|
||||
AlbumView::setProxyModel( AlbumProxyModel* model )
|
||||
{
|
||||
m_proxyModel = model;
|
||||
AlbumItemDelegate* del = new AlbumItemDelegate( this, m_proxyModel );
|
||||
connect( del, SIGNAL( updateIndex( QModelIndex ) ), this, SLOT( update( QModelIndex ) ) );
|
||||
setItemDelegate( del );
|
||||
m_delegate = new AlbumItemDelegate( this, m_proxyModel );
|
||||
connect( m_delegate, SIGNAL( updateIndex( QModelIndex ) ), this, SLOT( update( QModelIndex ) ) );
|
||||
setItemDelegate( m_delegate );
|
||||
|
||||
QListView::setModel( m_proxyModel );
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
class AlbumModel;
|
||||
class LoadingSpinner;
|
||||
class AlbumItemDelegate;
|
||||
|
||||
class DLLEXPORT AlbumView : public QListView, public Tomahawk::ViewPage
|
||||
{
|
||||
@ -75,6 +76,7 @@ private slots:
|
||||
private:
|
||||
AlbumModel* m_model;
|
||||
AlbumProxyModel* m_proxyModel;
|
||||
AlbumItemDelegate* m_delegate;
|
||||
LoadingSpinner* m_loadingSpinner;
|
||||
|
||||
QTimer m_timer;
|
||||
|
@ -54,4 +54,4 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
class QPaintEvent;
|
||||
class QPaintEvent;
|
||||
|
Loading…
x
Reference in New Issue
Block a user