Sayonara Player
PlaylistView.h
1 /* PlaylistView.h */
2 
3 /* Copyright (C) 2011-2016 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 /*
23  * PlaylistView.h
24  *
25  * Created on: Jun 27, 2011
26  * Author: Lucio Carreras
27  */
28 
29 #ifndef PLAYLISTVIEW_H_
30 #define PLAYLISTVIEW_H_
31 
32 #include "Components/Playlist/Playlist.h"
33 #include "GUI/Helper/SearchableWidget/SearchableListView.h"
34 
35 #include <QPoint>
36 #include <QDrag>
37 #include <QList>
38 #include <QMenu>
39 #include <QPainter>
40 #include <QModelIndex>
41 #include <QMouseEvent>
42 #include <QScrollBar>
43 
44 
45 class LibraryContextMenu;
46 class PlaylistItemModel;
49 {
50 
51  Q_OBJECT
52 
53 signals:
54  void context_menu_emitted(const QPoint&);
55 
56  void sig_info_clicked();
57  void sig_remove_clicked();
58  void sig_edit_clicked();
59  void sig_lyrics_clicked();
60 
61  void sig_double_clicked(int);
62  void sig_no_focus();
63  void sig_left_clicked();
64  void sig_right_clicked();
65 
66 
67 
68 public:
69  PlaylistView(PlaylistPtr pl, QWidget* parent=nullptr);
70  virtual ~PlaylistView();
71 
72  void set_context_menu_actions(int actions);
73 
74  void fill(PlaylistPtr pl);
75 
76  void scroll_up();
77  void scroll_down();
78 
79  void dropEventFromOutside(QDropEvent* event);
80  void set_current_track(int row);
81  int get_num_rows();
82  void remove_cur_selected_rows();
83 
84 
85 public slots:
86  void clear();
87 
88 
89 private:
90  QDrag* _drag=nullptr;
91  QPoint _drag_pos;
92 
93  bool _inner_drag_drop;
94 
95  LibraryContextMenu* _rc_menu=nullptr;
96 
97  PlaylistItemModel* _model=nullptr;
98  PlaylistItemDelegate* _delegate=nullptr;
99 
100 
101 private:
102 
103  void set_delegate_max_width(int n_items);
104  void init_rc_menu();
105 
106  // Selections
107  void goto_row(int row);
108 
109 
110  // d & d
111  void clear_drag_drop_lines(int row);
112  int calc_drag_drop_line(QPoint pos);
113  void handle_drop(QDropEvent* event, bool from_outside=false);
114 
115  // overloaded stuff
116  void dragLeaveEvent(QDragLeaveEvent* event) override;
117  void dragEnterEvent(QDragEnterEvent* event) override;
118  void dragMoveEvent(QDragMoveEvent* event) override;
119  void dropEvent(QDropEvent* event) override;
120 
121  void mousePressEvent(QMouseEvent* event) override;
122  void mouseReleaseEvent(QMouseEvent* event) override;
123  void mouseMoveEvent(QMouseEvent* event) override;
124 
125  void keyPressEvent(QKeyEvent *event) override;
126  void resizeEvent(QResizeEvent *e) override;
127  void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected ) override;
128 
129  void init_shortcuts();
130 
131 
132 private slots:
133  void row_pressed(const QModelIndex&);
134  void row_double_clicked(const QModelIndex&);
135  void row_released(const QModelIndex&);
136  void _sl_look_changed();
137 };
138 
139 #endif /* PlaylistView_H_ */
Definition: PlaylistItemDelegate.h:33
Definition: PlaylistView.h:48
Definition: SearchableListView.h:35
Definition: PlaylistItemModel.h:43
Definition: LibraryContextMenu.h:33