Sayonara Player
PlaylistView.h
1 /* PlaylistView.h */
2 
3 /* Copyright (C) 2011-2017 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 "GUI/Helper/SearchableWidget/SearchableView.h"
33 #include "GUI/Helper/Dragable/Dragable.h"
34 #include "GUI/InfoDialog/InfoDialogContainer.h"
35 #include "Helper/Playlist/PlaylistFwd.h"
36 #include "Helper/MetaData/MetaDataFwd.h"
37 
38 #include <QPoint>
39 #include <QDrag>
40 #include <QList>
41 
42 class SayonaraLoadingBar;
43 class LibraryContextMenu;
44 class PlaylistItemModel;
46 class BookmarksMenu;
47 
48 class PlaylistView :
49  public SearchableListView,
50  public InfoDialogContainer,
51  private Dragable
52 {
53  Q_OBJECT
54 
55 signals:
56  void sig_double_clicked(int row);
57  void sig_left_tab_clicked();
58  void sig_right_tab_clicked();
59  void sig_time_changed();
60  void sig_delete_tracks(const SP::Set<int>& rows);
61 
62 public:
63  explicit PlaylistView(PlaylistPtr pl, QWidget* parent=nullptr);
64  virtual ~PlaylistView();
65 
66  void fill(PlaylistPtr pl);
67 
68  void goto_row(int row);
69  void scroll_up();
70  void scroll_down();
71 
72  int get_num_rows() const;
73  void remove_cur_selected_rows();
74  void delete_cur_selected_tracks();
75 
81  void dropEventFromOutside(QDropEvent* event);
82 
83 
84 public slots:
85  void clear();
86 
87 
88 private:
89  LibraryContextMenu* _rc_menu=nullptr;
90 
91  PlaylistItemModel* _model=nullptr;
92  PlaylistItemDelegate* _delegate=nullptr;
93  SayonaraLoadingBar* _progress=nullptr;
94  BookmarksMenu* _bookmarks_menu=nullptr;
95  QAction* _bookmarks_action=nullptr;
96 
97  int _async_drop_index;
98 
99 
100 private:
101 
102  void init_rc_menu();
103  void set_delegate_max_width(int n_items);
104 
105  // d & d
106  void clear_drag_drop_lines(int row);
107  int calc_drag_drop_line(QPoint pos);
108  void handle_drop(QDropEvent* event);
109  void handle_inner_drag_drop(int row, bool copy);
110 
111 
112  // overloaded stuff
113  void contextMenuEvent(QContextMenuEvent* e) override;
114 
119  void dragLeaveEvent(QDragLeaveEvent* event) override;
120  void dragEnterEvent(QDragEnterEvent* event) override;
121  void dragMoveEvent(QDragMoveEvent* event) override;
122  void dropEvent(QDropEvent* event) override;
123 
124  void mousePressEvent(QMouseEvent* event) override;
125  void mouseMoveEvent(QMouseEvent* event) override;
126  void mouseDoubleClickEvent(QMouseEvent* event) override;
127 
128  void keyPressEvent(QKeyEvent *event) override;
129  void resizeEvent(QResizeEvent *e) override;
130  void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected ) override;
131 
132  MD::Interpretation get_metadata_interpretation() const override;
133  MetaDataList get_data_for_info_dialog() const override;
134  QMimeData* get_mimedata() const override;
135 
136 
137 private slots:
138  void handle_async_drop(bool success);
139  void rating_changed(int rating);
140 
141  // SayonaraSelectionView interface
142 public:
143  int get_index_by_model_index(const QModelIndex& idx) const override;
144  QModelIndex get_model_index_by_index(int idx) const override;
145 };
146 
147 #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:35
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:29
Definition: MetaDataList.h:39
Definition: BookmarksMenu.h:28
Definition: PlaylistView.h:48
The Dragable class.
Definition: Dragable.h:37
std::shared_ptr< AbstractPlaylist > PlaylistPtr
PlaylistPtr Playlist Pointer (only used internally)
Definition: PlaylistFwd.h:27
The SayonaraLoadingBar class.
Definition: SayonaraLoadingBar.h:33
Definition: SearchableView.h:77
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: AbstractPlaylist.h:37
Definition: PlaylistItemModel.h:47
Context menu used for Library and playlist windows.
Definition: LibraryContextMenu.h:35