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 #include "GUI/InfoDialog/InfoDialogContainer.h"
35 
36 #include "Helper/Set.h"
37 
38 #include <QPoint>
39 #include <QDrag>
40 #include <QList>
41 #include <QMenu>
42 #include <QPainter>
43 #include <QModelIndex>
44 #include <QMouseEvent>
45 #include <QScrollBar>
46 #include <QProgressBar>
47 #include <QContextMenuEvent>
48 
49 class SayonaraLoadingBar;
50 class LibraryContextMenu;
51 class PlaylistItemModel;
53 class BookmarksMenu;
54 
55 class PlaylistView :
56  public SearchableListView,
57  public InfoDialogContainer
58 {
59  Q_OBJECT
60 
61 signals:
62  void sig_double_clicked(int row);
63  void sig_left_tab_clicked();
64  void sig_right_tab_clicked();
65  void sig_time_changed();
66 
67 public:
68  PlaylistView(PlaylistPtr pl, QWidget* parent=nullptr);
69  virtual ~PlaylistView();
70 
71  void fill(PlaylistPtr pl);
72 
73  void goto_row(int row);
74  void scroll_up();
75  void scroll_down();
76 
77  int get_num_rows();
78  void remove_cur_selected_rows();
79 
85  void dropEventFromOutside(QDropEvent* event);
86 
87 
88 public slots:
89  void clear();
90 
91 
92 private:
93  QDrag* _drag=nullptr;
94  QPoint _drag_pos;
95 
96  LibraryContextMenu* _rc_menu=nullptr;
97 
98  PlaylistItemModel* _model=nullptr;
99  PlaylistItemDelegate* _delegate=nullptr;
100  SayonaraLoadingBar* _progress=nullptr;
101  BookmarksMenu* _bookmarks_menu=nullptr;
102  QAction* _bookmarks_action=nullptr;
103 
104  int _async_drop_index;
105 
106 
107 private:
108 
109  void set_delegate_max_width(int n_items);
110 
111  // d & d
112  void clear_drag_drop_lines(int row);
113  int calc_drag_drop_line(QPoint pos);
114  void handle_drop(QDropEvent* event);
115  void handle_inner_drag_drop(int row, bool copy);
116 
117 
118  // overloaded stuff
119  void contextMenuEvent(QContextMenuEvent* e) override;
120 
125  void dragLeaveEvent(QDragLeaveEvent* event) override;
126  void dragEnterEvent(QDragEnterEvent* event) override;
127  void dragMoveEvent(QDragMoveEvent* event) override;
128  void dropEvent(QDropEvent* event) override;
129 
130  void mousePressEvent(QMouseEvent* event) override;
131  void mouseMoveEvent(QMouseEvent* event) override;
132  void mouseDoubleClickEvent(QMouseEvent* event) override;
133 
134  void keyPressEvent(QKeyEvent *event) override;
135  void resizeEvent(QResizeEvent *e) override;
136  void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected ) override;
137 
138  MetaDataList::Interpretation get_metadata_interpretation() const override;
139  MetaDataList get_data_for_info_dialog() const override;
140 
141 
142 private slots:
143  void handle_async_drop(bool success);
144  void rating_changed(int rating);
145 };
146 
147 
148 #endif /* PlaylistView_H_ */
An interface used to abstract the usage of the info dialog. An implementing class has to return the i...
Definition: InfoDialogContainer.h:38
void dropEventFromOutside(QDropEvent *event)
called from GUI_Playlist when data has not been dropped directly into the view widget. Insert on first row then
Definition: PlaylistItemDelegate.h:33
Definition: MetaDataList.h:44
Definition: BookmarksMenu.h:35
Definition: PlaylistView.h:55
Definition: SearchableListView.h:36
The SayonaraLoadingBar class.
Definition: SayonaraLoadingBar.h:35
Definition: PlaylistItemModel.h:43
Context menu used for Library and playlist windows.
Definition: LibraryContextMenu.h:37