Sayonara Player
ListView.h
1 /* PlaylistView.h */
2 
3 /* Copyright (C) 2011-2019 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/Utils/SearchableWidget/SearchableView.h"
33 #include "Gui/Utils/Widgets/Dragable.h"
34 #include "Gui/Utils/Widgets/WidgetTemplate.h"
35 
36 #include "Gui/InfoDialog/InfoDialogContainer.h"
37 
38 #include "Utils/Playlist/PlaylistFwd.h"
39 #include "Utils/MetaData/MetaDataFwd.h"
40 #include "Utils/Pimpl.h"
41 
42 class QPoint;
43 
48 class PlaylistView :
49  public SearchableTableView,
50  public InfoDialogContainer,
51  private Gui::Dragable
52 {
53  Q_OBJECT
54  PIMPL(PlaylistView)
55 
56 signals:
57  void sig_double_clicked(int row);
58  void sig_delete_tracks(const IndexSet& rows);
59  void sig_bookmark_pressed(int track_idx, Seconds timestamp);
60 
61 public:
62  explicit PlaylistView(PlaylistPtr pl, QWidget* parent=nullptr);
63  virtual ~PlaylistView();
64 
65  void goto_row(int row);
66  void delete_selected_tracks();
67 
73  void dropEventFromOutside(QDropEvent* event);
74 
75 
76 public slots:
77  void clear();
78  void remove_selected_rows();
79 
80 private:
81  void init_view();
82  void init_context_menu();
83 
84  // d & d
85  int calc_drag_drop_line(QPoint pos);
86  void handle_drop(QDropEvent* event);
87  void handle_inner_drag_drop(int row, bool copy);
88 
89  // overloaded stuff
90  void contextMenuEvent(QContextMenuEvent* e) override;
91 
96  void dragLeaveEvent(QDragLeaveEvent* event) override;
97  void dragEnterEvent(QDragEnterEvent* event) override;
98  void dragMoveEvent(QDragMoveEvent* event) override;
99  void dropEvent(QDropEvent* event) override;
100 
101  void mousePressEvent(QMouseEvent* event) override;
102  void mouseMoveEvent(QMouseEvent* event) override;
103  void mouseDoubleClickEvent(QMouseEvent* event) override;
104 
105  void keyPressEvent(QKeyEvent *event) override;
106 
107  MD::Interpretation metadata_interpretation() const override;
108  MetaDataList info_dialog_data() const override;
109  QMimeData* dragable_mimedata() const override;
110 
111 private slots:
112  void refresh();
113  void current_track_changed(int track_index, int playlist_index);
114  void async_drop_finished(bool success, int async_drop_index);
115  void rating_changed(Rating rating);
116  void sl_columns_changed();
117  void find_track_triggered();
118 
119  void move_selected_rows_up();
120  void move_selected_rows_down();
121  void play_selected_track();
122  void goto_to_current_track();
123 
124 
125 protected:
126  // SayonaraSelectionView interface
127  int index_by_model_index(const QModelIndex& idx) const override;
128  ModelIndexRange model_indexrange_by_index(int idx) const override;
129 
130  void skin_changed() override;
131  bool viewportEvent(QEvent *event) override;
132 };
133 
134 #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....
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition: WidgetTemplate.h:84
The MetaDataList class.
Definition: MetaDataList.h:37
The PlaylistView class.
Definition: ListView.h:48
Definition: typedefs.h:32
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:35
The Dragable class.
Definition: Dragable.h:38