1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
3
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
4
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
6
* Tomahawk is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* Tomahawk is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
23
#include <QtGui/QTreeView>
24
#include <QtGui/QSortFilterProxyModel>
25
#include <QtCore/QTimer>
27
#include "ContextMenu.h"
28
#include "PlaylistItemDelegate.h"
34
class AnimatedSpinner;
37
class PlayableProxyModel;
40
class DLLEXPORT TrackView : public QTreeView, public Tomahawk::ViewPage
45
explicit TrackView( QWidget* parent = 0 );
48
virtual QString guid() const;
49
virtual void setGuid( const QString& newguid );
51
virtual void setPlaylistItemDelegate( PlaylistItemDelegate* delegate );
52
virtual void setPlayableModel( PlayableModel* model );
53
virtual void setModel( QAbstractItemModel* model );
54
void setProxyModel( PlayableProxyModel* model );
56
virtual PlayableModel* model() const { return m_model; }
57
PlayableProxyModel* proxyModel() const { return m_proxyModel; }
58
PlaylistItemDelegate* delegate() const { return m_delegate; }
59
ViewHeader* header() const { return m_header; }
60
OverlayWidget* overlay() const { return m_overlay; }
61
Tomahawk::ContextMenu* contextMenu() const { return m_contextMenu; }
62
AnimatedSpinner* loadingSpinner() const { return m_loadingSpinner; }
64
void setEmptyTip( const QString& tip );
66
virtual QWidget* widget() { return this; }
67
virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
68
void setPlaylistInterface( const Tomahawk::playlistinterface_ptr& playlistInterface );
70
virtual QString title() const;
71
virtual QString description() const;
72
virtual QPixmap pixmap() const;
74
virtual bool showFilter() const { return true; }
75
virtual bool setFilter( const QString& filter );
76
virtual bool jumpToCurrentTrack();
78
QModelIndex hoveredIndex() const { return m_hoveredIndex; }
79
QModelIndex contextMenuIndex() const { return m_contextMenuIndex; }
80
void setContextMenuIndex( const QModelIndex& idx ) { m_contextMenuIndex = idx; }
82
bool updatesContextView() const { return m_updateContextView; }
83
void setUpdatesContextView( bool b ) { m_updateContextView = b; }
85
bool autoResize() const { return m_autoResize; }
86
void setAutoResize( bool b );
88
// Starts playing from the beginning if resolved, or waits until a track is playable
89
void startPlayingFromStart();
92
virtual void onItemActivated( const QModelIndex& index );
94
void deleteSelectedItems();
97
void onMenuTriggered( int action );
100
void onScrollTimeout();
103
void itemActivated( const QModelIndex& index );
107
virtual void resizeEvent( QResizeEvent* event );
109
virtual void startDrag( Qt::DropActions supportedActions );
110
virtual void dragEnterEvent( QDragEnterEvent* event );
111
virtual void dragLeaveEvent( QDragLeaveEvent* /*event*/ ) { m_dragging = false; setDirtyRegion( m_dropRect ); }
112
virtual void dragMoveEvent( QDragMoveEvent* event );
113
virtual void dropEvent( QDropEvent* event );
115
void wheelEvent( QWheelEvent* event );
116
void mouseMoveEvent( QMouseEvent* event );
117
void mousePressEvent( QMouseEvent* event );
118
void leaveEvent( QEvent* event );
119
void paintEvent( QPaintEvent* event );
120
void keyPressEvent( QKeyEvent* event );
123
virtual void currentChanged( const QModelIndex& current, const QModelIndex& previous );
126
void onItemResized( const QModelIndex& index );
127
void onFilterChanged( const QString& filter );
129
void onCustomContextMenu( const QPoint& pos );
131
void autoPlayResolveFinished( const Tomahawk::query_ptr& query, int row );
136
void startAutoPlay( const QModelIndex& index );
137
bool tryToPlayItem( const QModelIndex& index );
138
void updateHoverIndex( const QPoint& pos );
141
PlayableModel* m_model;
142
PlayableProxyModel* m_proxyModel;
143
PlaylistItemDelegate* m_delegate;
144
ViewHeader* m_header;
145
OverlayWidget* m_overlay;
146
AnimatedSpinner* m_loadingSpinner;
153
bool m_updateContextView;
156
QModelIndex m_hoveredIndex;
157
QModelIndex m_contextMenuIndex;
159
Tomahawk::query_ptr m_autoPlaying;
160
Tomahawk::ContextMenu* m_contextMenu;
165
#endif // TRACKVIEW_H