mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Double-click expands artists & albums. We now show an info button for those items.
This commit is contained in:
@@ -186,6 +186,18 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
opt.palette.setColor( QPalette::Text, opt.palette.color( QPalette::HighlightedText ) );
|
opt.palette.setColor( QPalette::Text, opt.palette.color( QPalette::HighlightedText ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( m_hoveringOver == index.sibling( index.row(), 0 )
|
||||||
|
&& m_view->header()->visualIndex( index.column() ) == m_view->header()->count() - 1
|
||||||
|
&& !index.data().toString().isEmpty() )
|
||||||
|
{
|
||||||
|
QRect arrowRect( m_view->viewport()->width() - option.rect.height(), option.rect.y() + 1, option.rect.height() - 2, option.rect.height() - 2 );
|
||||||
|
|
||||||
|
QPixmap infoIcon = TomahawkUtils::defaultPixmap( TomahawkUtils::InfoIcon, TomahawkUtils::Original, arrowRect.size() );
|
||||||
|
painter->drawPixmap( arrowRect, infoIcon );
|
||||||
|
|
||||||
|
m_infoButtonRects[ index.sibling( index.row(), 0 ) ] = arrowRect;
|
||||||
|
}
|
||||||
|
|
||||||
if ( index.column() > 0 )
|
if ( index.column() > 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -213,7 +225,6 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const QPixmap cover = m_pixmaps[ index ]->currentPixmap();
|
const QPixmap cover = m_pixmaps[ index ]->currentPixmap();
|
||||||
|
|
||||||
painter->drawPixmap( r, cover );
|
painter->drawPixmap( r, cover );
|
||||||
|
|
||||||
r = option.rect.adjusted( option.rect.height(), 6, -4, -option.rect.height() + 22 );
|
r = option.rect.adjusted( option.rect.height(), 6, -4, -option.rect.height() + 22 );
|
||||||
@@ -244,9 +255,9 @@ TreeItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const Q
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool hoveringInfo = false;
|
bool hoveringInfo = false;
|
||||||
if ( m_infoButtonRects.contains( index ) )
|
if ( m_infoButtonRects.contains( index.sibling( index.row(), 0 ) ) )
|
||||||
{
|
{
|
||||||
const QRect infoRect = m_infoButtonRects[ index ];
|
const QRect infoRect = m_infoButtonRects[ index.sibling( index.row(), 0 ) ];
|
||||||
const QMouseEvent* ev = static_cast< QMouseEvent* >( event );
|
const QMouseEvent* ev = static_cast< QMouseEvent* >( event );
|
||||||
hoveringInfo = infoRect.contains( ev->pos() );
|
hoveringInfo = infoRect.contains( ev->pos() );
|
||||||
}
|
}
|
||||||
@@ -260,9 +271,9 @@ TreeItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const Q
|
|||||||
|
|
||||||
if ( m_hoveringOver != index || ( !hoveringInfo && m_hoveringOver.isValid() ) )
|
if ( m_hoveringOver != index || ( !hoveringInfo && m_hoveringOver.isValid() ) )
|
||||||
{
|
{
|
||||||
emit updateIndex( m_hoveringOver );
|
emit updateIndex( m_hoveringOver.sibling( index.row(), m_view->header()->logicalIndex( m_view->header()->count() ) ) );
|
||||||
m_hoveringOver = index;
|
m_hoveringOver = index.sibling( index.row(), 0 );
|
||||||
emit updateIndex( index );
|
emit updateIndex( index.sibling( index.row(), m_view->header()->logicalIndex( m_view->header()->count() ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
@@ -280,16 +291,17 @@ TreeItemDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const Q
|
|||||||
if ( !item )
|
if ( !item )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch ( index.column() )
|
if ( item->query() )
|
||||||
{
|
{
|
||||||
case 0:
|
ViewManager::instance()->show( item->query()->displayQuery() );
|
||||||
{
|
}
|
||||||
ViewManager::instance()->show( item->query()->displayQuery() );
|
else if ( item->artist() )
|
||||||
break;
|
{
|
||||||
}
|
ViewManager::instance()->show( item->artist() );
|
||||||
|
}
|
||||||
default:
|
else if ( item->album() )
|
||||||
break;
|
{
|
||||||
|
ViewManager::instance()->show( item->album() );
|
||||||
}
|
}
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
|
@@ -234,7 +234,7 @@ TreeView::onItemActivated( const QModelIndex& index )
|
|||||||
PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
|
PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( index ) );
|
||||||
if ( item )
|
if ( item )
|
||||||
{
|
{
|
||||||
if ( !item->artist().isNull() )
|
/* if ( !item->artist().isNull() )
|
||||||
{
|
{
|
||||||
ViewManager::instance()->show( item->artist() );
|
ViewManager::instance()->show( item->artist() );
|
||||||
}
|
}
|
||||||
@@ -242,7 +242,7 @@ TreeView::onItemActivated( const QModelIndex& index )
|
|||||||
{
|
{
|
||||||
ViewManager::instance()->show( item->album() );
|
ViewManager::instance()->show( item->album() );
|
||||||
}
|
}
|
||||||
else if ( !item->result().isNull() && item->result()->isOnline() )
|
else */ if ( !item->result().isNull() && item->result()->isOnline() )
|
||||||
{
|
{
|
||||||
AudioEngine::instance()->playItem( m_proxyModel->playlistInterface(), item->result() );
|
AudioEngine::instance()->playItem( m_proxyModel->playlistInterface(), item->result() );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user