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

« back to all changes in this revision

Viewing changes to src/sourcetree/SourceTreeView.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 SOURCETREEVIEW_H
 
21
#define SOURCETREEVIEW_H
 
22
 
 
23
#include "Typedefs.h"
 
24
#include "SourcePlaylistInterface.h"
 
25
 
 
26
#include <QTreeView>
 
27
#include <QMenu>
 
28
 
 
29
class SourceTreePopupDialog;
 
30
class CollectionModel;
 
31
class PlaylistModel;
 
32
class SourcesModel;
 
33
class SourcesProxyModel;
 
34
class SourceDelegate;
 
35
 
 
36
namespace Tomahawk
 
37
{
 
38
    class LatchManager;
 
39
}
 
40
 
 
41
class SourceTreeView : public QTreeView
 
42
{
 
43
Q_OBJECT
 
44
 
 
45
public:
 
46
    explicit SourceTreeView( QWidget* parent = 0 );
 
47
    ~SourceTreeView();
 
48
 
 
49
public slots:
 
50
    void showOfflineSources( bool offlineSourcesShown );
 
51
 
 
52
    void renamePlaylist();
 
53
 
 
54
    void update( const QModelIndex &index );
 
55
 
 
56
signals:
 
57
    void onOnline( const QModelIndex& index );
 
58
    void onOffline( const QModelIndex& index );
 
59
 
 
60
    void latchRequest( const Tomahawk::source_ptr& source );
 
61
    void unlatchRequest( const Tomahawk::source_ptr& source );
 
62
    void catchUpRequest();
 
63
    void latchModeChangeRequest( const Tomahawk::source_ptr& source, bool realtime );
 
64
 
 
65
private slots:
 
66
    void onItemExpanded( const QModelIndex& idx );
 
67
    void onItemActivated( const QModelIndex& index );
 
68
    void selectRequest( const QPersistentModelIndex& idx );
 
69
    void expandRequest( const QPersistentModelIndex& idx );
 
70
    void toggleExpandRequest( const QPersistentModelIndex& idx );
 
71
    void onItemDoubleClicked( const QModelIndex& idx );
 
72
 
 
73
    void loadPlaylist();
 
74
    void deletePlaylist( const QModelIndex& = QModelIndex() );
 
75
    void copyPlaylistLink();
 
76
    void exportPlaylist();
 
77
    void addToLocal();
 
78
 
 
79
    void latchOnOrCatchUp();
 
80
    void latchOff();
 
81
    void latchOnOrCatchUp( const Tomahawk::source_ptr& source );
 
82
    void latchOff( const Tomahawk::source_ptr& source );
 
83
    void latchModeToggled( bool checked );
 
84
 
 
85
    void onCustomContextMenu( const QPoint& pos );
 
86
    void onSelectionChanged();
 
87
 
 
88
    void onDeletePlaylistResult( bool result );
 
89
 
 
90
protected:
 
91
    void drawRow( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
 
92
    void drawBranches( QPainter *painter, const QRect &rect, const QModelIndex &index ) const;
 
93
 
 
94
    virtual void paintEvent( QPaintEvent* event );
 
95
 
 
96
    virtual void dragEnterEvent( QDragEnterEvent* event );
 
97
    virtual void dragLeaveEvent( QDragLeaveEvent* event );
 
98
    virtual void dragMoveEvent( QDragMoveEvent* event );
 
99
    virtual void dropEvent( QDropEvent* event );
 
100
    virtual void keyPressEvent( QKeyEvent* event );
 
101
 
 
102
private:
 
103
    void setupMenus();
 
104
 
 
105
    template< typename T >
 
106
    T* itemFromIndex( const QModelIndex& index ) const;
 
107
 
 
108
    SourcesModel* m_model;
 
109
    SourcesProxyModel* m_proxyModel;
 
110
    QModelIndex m_contextMenuIndex;
 
111
    SourceDelegate* m_delegate;
 
112
    Tomahawk::LatchManager* m_latchManager;
 
113
    QWeakPointer<SourceTreePopupDialog> m_popupDialog;
 
114
 
 
115
    QMenu m_playlistMenu;
 
116
    QMenu m_roPlaylistMenu;
 
117
    QMenu m_latchMenu;
 
118
    QMenu m_privacyMenu;
 
119
 
 
120
    bool m_dragging;
 
121
    QRect m_dropRect;
 
122
    QPersistentModelIndex m_dropIndex;
 
123
 
 
124
    QPersistentModelIndex m_selectedIndex;
 
125
};
 
126
 
 
127
#endif // SOURCETREEVIEW_H