~ubuntu-branches/ubuntu/trusty/tomahawk/trusty-proposed

« back to all changes in this revision

Viewing changes to src/libtomahawk/playlist/TrackView.h

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2013-03-07 21:50:13 UTC
  • Revision ID: package-import@ubuntu.com-20130307215013-6gdjkdds7i9uenvs
Tags: upstream-0.6.0+dfsg
ImportĀ upstreamĀ versionĀ 0.6.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 
2
 *
 
3
 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 
4
 *   Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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/>.
 
18
 */
 
19
 
 
20
#ifndef TRACKVIEW_H
 
21
#define TRACKVIEW_H
 
22
 
 
23
#include <QtGui/QTreeView>
 
24
#include <QtGui/QSortFilterProxyModel>
 
25
#include <QtCore/QTimer>
 
26
 
 
27
#include "ContextMenu.h"
 
28
#include "PlaylistItemDelegate.h"
 
29
#include "ViewPage.h"
 
30
 
 
31
#include "DllMacro.h"
 
32
 
 
33
class QAction;
 
34
class AnimatedSpinner;
 
35
class ViewHeader;
 
36
class PlayableModel;
 
37
class PlayableProxyModel;
 
38
class OverlayWidget;
 
39
 
 
40
class DLLEXPORT TrackView : public QTreeView, public Tomahawk::ViewPage
 
41
{
 
42
Q_OBJECT
 
43
 
 
44
public:
 
45
    explicit TrackView( QWidget* parent = 0 );
 
46
    ~TrackView();
 
47
 
 
48
    virtual QString guid() const;
 
49
    virtual void setGuid( const QString& newguid );
 
50
 
 
51
    virtual void setPlaylistItemDelegate( PlaylistItemDelegate* delegate );
 
52
    virtual void setPlayableModel( PlayableModel* model );
 
53
    virtual void setModel( QAbstractItemModel* model );
 
54
    void setProxyModel( PlayableProxyModel* model );
 
55
 
 
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; }
 
63
 
 
64
    void setEmptyTip( const QString& tip );
 
65
 
 
66
    virtual QWidget* widget() { return this; }
 
67
    virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
 
68
    void setPlaylistInterface( const Tomahawk::playlistinterface_ptr& playlistInterface );
 
69
 
 
70
    virtual QString title() const;
 
71
    virtual QString description() const;
 
72
    virtual QPixmap pixmap() const;
 
73
 
 
74
    virtual bool showFilter() const { return true; }
 
75
    virtual bool setFilter( const QString& filter );
 
76
    virtual bool jumpToCurrentTrack();
 
77
 
 
78
    QModelIndex hoveredIndex() const { return m_hoveredIndex; }
 
79
    QModelIndex contextMenuIndex() const { return m_contextMenuIndex; }
 
80
    void setContextMenuIndex( const QModelIndex& idx ) { m_contextMenuIndex = idx; }
 
81
 
 
82
    bool updatesContextView() const { return m_updateContextView; }
 
83
    void setUpdatesContextView( bool b ) { m_updateContextView = b; }
 
84
 
 
85
    bool autoResize() const { return m_autoResize; }
 
86
    void setAutoResize( bool b );
 
87
 
 
88
    // Starts playing from the beginning if resolved, or waits until a track is playable
 
89
    void startPlayingFromStart();
 
90
 
 
91
public slots:
 
92
    virtual void onItemActivated( const QModelIndex& index );
 
93
 
 
94
    void deleteSelectedItems();
 
95
 
 
96
    void playItem();
 
97
    void onMenuTriggered( int action );
 
98
 
 
99
    void onViewChanged();
 
100
    void onScrollTimeout();
 
101
 
 
102
signals:
 
103
    void itemActivated( const QModelIndex& index );
 
104
    void modelChanged();
 
105
 
 
106
protected:
 
107
    virtual void resizeEvent( QResizeEvent* event );
 
108
 
 
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 );
 
114
 
 
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 );
 
121
 
 
122
protected slots:
 
123
    virtual void currentChanged( const QModelIndex& current, const QModelIndex& previous );
 
124
 
 
125
private slots:
 
126
    void onItemResized( const QModelIndex& index );
 
127
    void onFilterChanged( const QString& filter );
 
128
 
 
129
    void onCustomContextMenu( const QPoint& pos );
 
130
 
 
131
    void autoPlayResolveFinished( const Tomahawk::query_ptr& query, int row );
 
132
 
 
133
    void verifySize();
 
134
    
 
135
private:
 
136
    void startAutoPlay( const QModelIndex& index );
 
137
    bool tryToPlayItem( const QModelIndex& index );
 
138
    void updateHoverIndex( const QPoint& pos );
 
139
 
 
140
    QString m_guid;
 
141
    PlayableModel* m_model;
 
142
    PlayableProxyModel* m_proxyModel;
 
143
    PlaylistItemDelegate* m_delegate;
 
144
    ViewHeader* m_header;
 
145
    OverlayWidget* m_overlay;
 
146
    AnimatedSpinner* m_loadingSpinner;
 
147
 
 
148
    QString m_emptyTip;
 
149
    bool m_resizing;
 
150
    bool m_dragging;
 
151
    QRect m_dropRect;
 
152
 
 
153
    bool m_updateContextView;
 
154
    bool m_autoResize;
 
155
 
 
156
    QModelIndex m_hoveredIndex;
 
157
    QModelIndex m_contextMenuIndex;
 
158
 
 
159
    Tomahawk::query_ptr m_autoPlaying;
 
160
    Tomahawk::ContextMenu* m_contextMenu;
 
161
 
 
162
    QTimer m_timer;
 
163
};
 
164
 
 
165
#endif // TRACKVIEW_H