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-2012, 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/QSortFilterProxyModel>
24
#include <QtGui/QTreeView>
25
#include <QtCore/QTimer>
27
#include "TreeProxyModel.h"
30
#include "PlaylistInterface.h"
40
class AnimatedSpinner;
44
class DLLEXPORT TreeView : public QTreeView, public Tomahawk::ViewPage
49
explicit TreeView( QWidget* parent = 0 );
52
virtual QString guid() const;
53
virtual void setGuid( const QString& guid ) { m_guid = guid; }
55
void setProxyModel( TreeProxyModel* model );
57
TreeModel* model() const { return m_model; }
58
TreeProxyModel* proxyModel() const { return m_proxyModel; }
59
OverlayWidget* overlay() const { return m_overlay; }
61
void setModel( QAbstractItemModel* model );
62
void setTreeModel( TreeModel* model );
64
void setEmptyTip( const QString& tip );
66
virtual QWidget* widget() { return this; }
67
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return proxyModel()->playlistInterface(); }
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(); }
73
virtual bool showFilter() const { return true; }
74
virtual bool setFilter( const QString& filter );
75
virtual bool jumpToCurrentTrack();
77
QModelIndex hoveredIndex() const { return m_hoveredIndex; }
79
bool updatesContextView() const { return m_updateContextView; }
80
void setUpdatesContextView( bool b ) { m_updateContextView = b; }
83
void onItemActivated( const QModelIndex& index );
89
virtual void startDrag( Qt::DropActions supportedActions );
90
virtual void resizeEvent( QResizeEvent* event );
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 );
99
virtual void currentChanged( const QModelIndex& current, const QModelIndex& previous );
102
void onFilterChangeFinished();
103
void onFilteringStarted();
104
void onViewChanged();
105
void onScrollTimeout();
107
void onCustomContextMenu( const QPoint& pos );
108
void onMenuTriggered( int action );
111
void updateHoverIndex( const QPoint& pos );
113
ViewHeader* m_header;
114
OverlayWidget* m_overlay;
116
TreeProxyModel* m_proxyModel;
117
AnimatedSpinner* m_loadingSpinner;
119
bool m_updateContextView;
121
QModelIndex m_hoveredIndex;
122
QModelIndex m_contextMenuIndex;
123
Tomahawk::ContextMenu* m_contextMenu;
127
mutable QString m_guid;