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 PlaylistView :
54  public SearchableListView,
55  public InfoDialogContainer
56 {
57  Q_OBJECT
58 
59 signals:
60  void sig_double_clicked(int row);
61  void sig_left_tab_clicked();
62  void sig_right_tab_clicked();
63  void sig_time_changed();
64 
65 public:
66  PlaylistView(PlaylistPtr pl, QWidget* parent=nullptr);
67  virtual ~PlaylistView();
68 
69  void fill(PlaylistPtr pl);
70 
71  void goto_row(int row);
72  void scroll_up();
73  void scroll_down();
74 
75  int get_num_rows();
76  void remove_cur_selected_rows();
77 
83  void dropEventFromOutside(QDropEvent* event);
84 
85 
86 public slots:
87  void clear();
88 
89 
90 private:
91  QDrag* _drag=nullptr;
92  QPoint _drag_pos;
93 
94  LibraryContextMenu* _rc_menu=nullptr;
95 
96  PlaylistItemModel* _model=nullptr;
97  PlaylistItemDelegate* _delegate=nullptr;
98  SayonaraLoadingBar* _progress=nullptr;
99 
100  int _async_drop_index;
101 
102 
103 private:
104 
105  void set_delegate_max_width(int n_items);
106 
107  // d & d
108  void clear_drag_drop_lines(int row);
109  int calc_drag_drop_line(QPoint pos);
110  void handle_drop(QDropEvent* event);
111  void handle_inner_drag_drop(int row, bool copy);
112 
113 
114  // overloaded stuff
115  void contextMenuEvent(QContextMenuEvent* e) override;
116 
121  void dragLeaveEvent(QDragLeaveEvent* event) override;
122  void dragEnterEvent(QDragEnterEvent* event) override;
123  void dragMoveEvent(QDragMoveEvent* event) override;
124  void dropEvent(QDropEvent* event) override;
125 
126  void mousePressEvent(QMouseEvent* event) override;
127  void mouseMoveEvent(QMouseEvent* event) override;
128  void mouseDoubleClickEvent(QMouseEvent* event) override;
129 
130  void keyPressEvent(QKeyEvent *event) override;
131  void resizeEvent(QResizeEvent *e) override;
132  void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected ) override;
133 
134  MetaDataList::Interpretation get_metadata_interpretation() const override;
135  MetaDataList get_data_for_info_dialog() const override;
136 
137 
138 private slots:
139  void handle_async_drop(bool success);
140  void rating_changed(int rating);
141 };
142 
143 
144 #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:16
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: PlaylistView.h:53
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