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

« back to all changes in this revision

Viewing changes to src/libtomahawk/playlist/TreeView.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-2012, 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 TREEVIEW_H
 
21
#define TREEVIEW_H
 
22
 
 
23
#include <QtGui/QSortFilterProxyModel>
 
24
#include <QtGui/QTreeView>
 
25
#include <QtCore/QTimer>
 
26
 
 
27
#include "TreeProxyModel.h"
 
28
#include "ViewPage.h"
 
29
 
 
30
#include "PlaylistInterface.h"
 
31
 
 
32
#include "DllMacro.h"
 
33
 
 
34
namespace Tomahawk
 
35
{
 
36
    class ContextMenu;
 
37
};
 
38
 
 
39
class ViewHeader;
 
40
class AnimatedSpinner;
 
41
class OverlayWidget;
 
42
class TreeModel;
 
43
 
 
44
class DLLEXPORT TreeView : public QTreeView, public Tomahawk::ViewPage
 
45
{
 
46
Q_OBJECT
 
47
 
 
48
public:
 
49
    explicit TreeView( QWidget* parent = 0 );
 
50
    ~TreeView();
 
51
 
 
52
    virtual QString guid() const;
 
53
    virtual void setGuid( const QString& guid ) { m_guid = guid; }
 
54
 
 
55
    void setProxyModel( TreeProxyModel* model );
 
56
 
 
57
    TreeModel* model() const { return m_model; }
 
58
    TreeProxyModel* proxyModel() const { return m_proxyModel; }
 
59
    OverlayWidget* overlay() const { return m_overlay; }
 
60
 
 
61
    void setModel( QAbstractItemModel* model );
 
62
    void setTreeModel( TreeModel* model );
 
63
 
 
64
    void setEmptyTip( const QString& tip );
 
65
 
 
66
    virtual QWidget* widget() { return this; }
 
67
    virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->playlistInterface(); }
 
68
 
 
69
    virtual QString title() const { return m_model->title(); }
 
70
    virtual QString description() const { return m_model->description(); }
 
71
    virtual QPixmap pixmap() const { return m_model->icon(); }
 
72
 
 
73
    virtual bool showFilter() const { return true; }
 
74
    virtual bool setFilter( const QString& filter );
 
75
    virtual bool jumpToCurrentTrack();
 
76
 
 
77
    QModelIndex hoveredIndex() const { return m_hoveredIndex; }
 
78
 
 
79
    bool updatesContextView() const { return m_updateContextView; }
 
80
    void setUpdatesContextView( bool b ) { m_updateContextView = b; }
 
81
 
 
82
public slots:
 
83
    void onItemActivated( const QModelIndex& index );
 
84
 
 
85
signals:
 
86
    void modelChanged();
 
87
 
 
88
protected:
 
89
    virtual void startDrag( Qt::DropActions supportedActions );
 
90
    virtual void resizeEvent( QResizeEvent* event );
 
91
 
 
92
    virtual void keyPressEvent( QKeyEvent* event );
 
93
    void wheelEvent( QWheelEvent* event );
 
94
    void mouseMoveEvent( QMouseEvent* event );
 
95
    void mousePressEvent( QMouseEvent* event );
 
96
    void leaveEvent( QEvent* event );
 
97
 
 
98
protected slots:
 
99
    virtual void currentChanged( const QModelIndex& current, const QModelIndex& previous );
 
100
 
 
101
private slots:
 
102
    void onFilterChangeFinished();
 
103
    void onFilteringStarted();
 
104
    void onViewChanged();
 
105
    void onScrollTimeout();
 
106
 
 
107
    void onCustomContextMenu( const QPoint& pos );
 
108
    void onMenuTriggered( int action );
 
109
 
 
110
private:
 
111
    void updateHoverIndex( const QPoint& pos );
 
112
 
 
113
    ViewHeader* m_header;
 
114
    OverlayWidget* m_overlay;
 
115
    TreeModel* m_model;
 
116
    TreeProxyModel* m_proxyModel;
 
117
    AnimatedSpinner* m_loadingSpinner;
 
118
 
 
119
    bool m_updateContextView;
 
120
 
 
121
    QModelIndex m_hoveredIndex;
 
122
    QModelIndex m_contextMenuIndex;
 
123
    Tomahawk::ContextMenu* m_contextMenu;
 
124
 
 
125
    QString m_emptyTip;
 
126
    QTimer m_timer;
 
127
    mutable QString m_guid;
 
128
};
 
129
 
 
130
#endif // TREEVIEW_H