mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
* Moved info button handling out of the views.
This commit is contained in:
@@ -25,8 +25,6 @@
|
|||||||
#include "PlayableProxyModel.h"
|
#include "PlayableProxyModel.h"
|
||||||
#include "PlayableItem.h"
|
#include "PlayableItem.h"
|
||||||
#include "DropJob.h"
|
#include "DropJob.h"
|
||||||
#include "Artist.h"
|
|
||||||
#include "Album.h"
|
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
#include "TomahawkSettings.h"
|
#include "TomahawkSettings.h"
|
||||||
#include "audio/AudioEngine.h"
|
#include "audio/AudioEngine.h"
|
||||||
@@ -684,105 +682,6 @@ TrackView::onMenuTriggered( int action )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackView::updateHoverIndex( const QPoint& pos )
|
|
||||||
{
|
|
||||||
QModelIndex idx = indexAt( pos );
|
|
||||||
|
|
||||||
if ( idx != m_hoveredIndex )
|
|
||||||
{
|
|
||||||
m_hoveredIndex = idx;
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !m_model || m_proxyModel->style() != PlayableProxyModel::Detailed )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( idx.column() == PlayableModel::Artist || idx.column() == PlayableModel::Album || idx.column() == PlayableModel::Track )
|
|
||||||
{
|
|
||||||
if ( pos.x() > header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) - 16 &&
|
|
||||||
pos.x() < header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) )
|
|
||||||
{
|
|
||||||
setCursor( Qt::PointingHandCursor );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( cursor().shape() != Qt::ArrowCursor )
|
|
||||||
setCursor( Qt::ArrowCursor );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackView::wheelEvent( QWheelEvent* event )
|
|
||||||
{
|
|
||||||
QTreeView::wheelEvent( event );
|
|
||||||
|
|
||||||
if ( m_hoveredIndex.isValid() )
|
|
||||||
{
|
|
||||||
m_hoveredIndex = QModelIndex();
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackView::leaveEvent( QEvent* event )
|
|
||||||
{
|
|
||||||
QTreeView::leaveEvent( event );
|
|
||||||
updateHoverIndex( QPoint( -1, -1 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackView::mouseMoveEvent( QMouseEvent* event )
|
|
||||||
{
|
|
||||||
QTreeView::mouseMoveEvent( event );
|
|
||||||
updateHoverIndex( event->pos() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackView::mousePressEvent( QMouseEvent* event )
|
|
||||||
{
|
|
||||||
QTreeView::mousePressEvent( event );
|
|
||||||
|
|
||||||
if ( !m_model || m_proxyModel->style() != PlayableProxyModel::Detailed )
|
|
||||||
return;
|
|
||||||
|
|
||||||
QModelIndex idx = indexAt( event->pos() );
|
|
||||||
if ( event->pos().x() > header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) - 16 &&
|
|
||||||
event->pos().x() < header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) )
|
|
||||||
{
|
|
||||||
PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( idx ) );
|
|
||||||
switch ( idx.column() )
|
|
||||||
{
|
|
||||||
case PlayableModel::Artist:
|
|
||||||
{
|
|
||||||
ViewManager::instance()->show( Artist::get( item->query()->displayQuery()->artist() ) );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PlayableModel::Album:
|
|
||||||
{
|
|
||||||
artist_ptr artist = Artist::get( item->query()->displayQuery()->artist() );
|
|
||||||
ViewManager::instance()->show( Album::get( artist, item->query()->displayQuery()->album() ) );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PlayableModel::Track:
|
|
||||||
{
|
|
||||||
ViewManager::instance()->show( item->query()->displayQuery() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Tomahawk::playlistinterface_ptr
|
Tomahawk::playlistinterface_ptr
|
||||||
TrackView::playlistInterface() const
|
TrackView::playlistInterface() const
|
||||||
{
|
{
|
||||||
|
@@ -75,7 +75,6 @@ public:
|
|||||||
virtual bool setFilter( const QString& filter );
|
virtual bool setFilter( const QString& filter );
|
||||||
virtual bool jumpToCurrentTrack();
|
virtual bool jumpToCurrentTrack();
|
||||||
|
|
||||||
QModelIndex hoveredIndex() const { return m_hoveredIndex; }
|
|
||||||
QModelIndex contextMenuIndex() const { return m_contextMenuIndex; }
|
QModelIndex contextMenuIndex() const { return m_contextMenuIndex; }
|
||||||
void setContextMenuIndex( const QModelIndex& idx ) { m_contextMenuIndex = idx; }
|
void setContextMenuIndex( const QModelIndex& idx ) { m_contextMenuIndex = idx; }
|
||||||
|
|
||||||
@@ -112,10 +111,6 @@ protected:
|
|||||||
virtual void dragMoveEvent( QDragMoveEvent* event );
|
virtual void dragMoveEvent( QDragMoveEvent* event );
|
||||||
virtual void dropEvent( QDropEvent* event );
|
virtual void dropEvent( QDropEvent* event );
|
||||||
|
|
||||||
virtual void wheelEvent( QWheelEvent* event );
|
|
||||||
virtual void mouseMoveEvent( QMouseEvent* event );
|
|
||||||
virtual void mousePressEvent( QMouseEvent* event );
|
|
||||||
virtual void leaveEvent( QEvent* event );
|
|
||||||
virtual void paintEvent( QPaintEvent* event );
|
virtual void paintEvent( QPaintEvent* event );
|
||||||
virtual void keyPressEvent( QKeyEvent* event );
|
virtual void keyPressEvent( QKeyEvent* event );
|
||||||
|
|
||||||
@@ -153,7 +148,6 @@ private:
|
|||||||
bool m_updateContextView;
|
bool m_updateContextView;
|
||||||
bool m_autoResize;
|
bool m_autoResize;
|
||||||
|
|
||||||
QModelIndex m_hoveredIndex;
|
|
||||||
QModelIndex m_contextMenuIndex;
|
QModelIndex m_contextMenuIndex;
|
||||||
|
|
||||||
Tomahawk::query_ptr m_autoPlaying;
|
Tomahawk::query_ptr m_autoPlaying;
|
||||||
|
@@ -427,96 +427,6 @@ TreeView::jumpToCurrentTrack()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TreeView::updateHoverIndex( const QPoint& pos )
|
|
||||||
{
|
|
||||||
QModelIndex idx = indexAt( pos );
|
|
||||||
|
|
||||||
if ( idx != m_hoveredIndex )
|
|
||||||
{
|
|
||||||
m_hoveredIndex = idx;
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !m_model || m_proxyModel->style() != PlayableProxyModel::Collection )
|
|
||||||
return;
|
|
||||||
|
|
||||||
PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( idx ) );
|
|
||||||
if ( idx.column() == 0 && !item->query().isNull() )
|
|
||||||
{
|
|
||||||
if ( pos.x() > header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) - 16 &&
|
|
||||||
pos.x() < header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) )
|
|
||||||
{
|
|
||||||
setCursor( Qt::PointingHandCursor );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( cursor().shape() != Qt::ArrowCursor )
|
|
||||||
setCursor( Qt::ArrowCursor );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TreeView::wheelEvent( QWheelEvent* event )
|
|
||||||
{
|
|
||||||
QTreeView::wheelEvent( event );
|
|
||||||
|
|
||||||
if ( m_hoveredIndex.isValid() )
|
|
||||||
{
|
|
||||||
m_hoveredIndex = QModelIndex();
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TreeView::leaveEvent( QEvent* event )
|
|
||||||
{
|
|
||||||
QTreeView::leaveEvent( event );
|
|
||||||
updateHoverIndex( QPoint( -1, -1 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TreeView::mouseMoveEvent( QMouseEvent* event )
|
|
||||||
{
|
|
||||||
QTreeView::mouseMoveEvent( event );
|
|
||||||
updateHoverIndex( event->pos() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TreeView::mousePressEvent( QMouseEvent* event )
|
|
||||||
{
|
|
||||||
QTreeView::mousePressEvent( event );
|
|
||||||
|
|
||||||
if ( !m_model || m_proxyModel->style() != PlayableProxyModel::Collection )
|
|
||||||
return;
|
|
||||||
|
|
||||||
QModelIndex idx = indexAt( event->pos() );
|
|
||||||
if ( event->pos().x() > header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) - 16 &&
|
|
||||||
event->pos().x() < header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) )
|
|
||||||
{
|
|
||||||
PlayableItem* item = proxyModel()->itemFromIndex( proxyModel()->mapToSource( idx ) );
|
|
||||||
if ( item->query().isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch ( idx.column() )
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
ViewManager::instance()->show( item->query()->displayQuery() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
TreeView::guid() const
|
TreeView::guid() const
|
||||||
{
|
{
|
||||||
|
@@ -65,8 +65,6 @@ public:
|
|||||||
|
|
||||||
virtual bool jumpToCurrentTrack();
|
virtual bool jumpToCurrentTrack();
|
||||||
|
|
||||||
QModelIndex hoveredIndex() const { return m_hoveredIndex; }
|
|
||||||
|
|
||||||
bool updatesContextView() const { return m_updateContextView; }
|
bool updatesContextView() const { return m_updateContextView; }
|
||||||
void setUpdatesContextView( bool b ) { m_updateContextView = b; }
|
void setUpdatesContextView( bool b ) { m_updateContextView = b; }
|
||||||
|
|
||||||
@@ -81,10 +79,6 @@ protected:
|
|||||||
virtual void resizeEvent( QResizeEvent* event );
|
virtual void resizeEvent( QResizeEvent* event );
|
||||||
|
|
||||||
virtual void keyPressEvent( QKeyEvent* event );
|
virtual void keyPressEvent( QKeyEvent* event );
|
||||||
void wheelEvent( QWheelEvent* event );
|
|
||||||
void mouseMoveEvent( QMouseEvent* event );
|
|
||||||
void mousePressEvent( QMouseEvent* event );
|
|
||||||
void leaveEvent( QEvent* event );
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void currentChanged( const QModelIndex& current, const QModelIndex& previous );
|
virtual void currentChanged( const QModelIndex& current, const QModelIndex& previous );
|
||||||
@@ -99,8 +93,6 @@ private slots:
|
|||||||
void onMenuTriggered( int action );
|
void onMenuTriggered( int action );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateHoverIndex( const QPoint& pos );
|
|
||||||
|
|
||||||
ViewHeader* m_header;
|
ViewHeader* m_header;
|
||||||
OverlayWidget* m_overlay;
|
OverlayWidget* m_overlay;
|
||||||
TreeModel* m_model;
|
TreeModel* m_model;
|
||||||
@@ -109,7 +101,6 @@ private:
|
|||||||
|
|
||||||
bool m_updateContextView;
|
bool m_updateContextView;
|
||||||
|
|
||||||
QModelIndex m_hoveredIndex;
|
|
||||||
QModelIndex m_contextMenuIndex;
|
QModelIndex m_contextMenuIndex;
|
||||||
Tomahawk::ContextMenu* m_contextMenu;
|
Tomahawk::ContextMenu* m_contextMenu;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user