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 class PlaylistView :
44  public SearchableTableView,
45  public InfoDialogContainer,
46  private Dragable
47 {
48  Q_OBJECT
49  PIMPL(PlaylistView)
50 
51 signals:
52  void sig_double_clicked(int row);
53  void sig_delete_tracks(const IndexSet& rows);
54  void sig_bookmark_pressed(int track_idx, Seconds timestamp);
55 
56 public:
57  explicit PlaylistView(PlaylistPtr pl, QWidget* parent=nullptr);
58  virtual ~PlaylistView();
59 
60  void goto_row(int row);
61  void delete_selected_tracks();
62 
68  void dropEventFromOutside(QDropEvent* event);
69 
70 
71 public slots:
72  void clear();
73  void remove_selected_rows();
74 
75 private:
76  void init_view();
77  void init_context_menu();
78 
79  // d & d
80  int calc_drag_drop_line(QPoint pos);
81  void handle_drop(QDropEvent* event);
82  void handle_inner_drag_drop(int row, bool copy);
83 
84  // overloaded stuff
85  void contextMenuEvent(QContextMenuEvent* e) override;
86 
91  void dragLeaveEvent(QDragLeaveEvent* event) override;
92  void dragEnterEvent(QDragEnterEvent* event) override;
93  void dragMoveEvent(QDragMoveEvent* event) override;
94  void dropEvent(QDropEvent* event) override;
95 
96  void mousePressEvent(QMouseEvent* event) override;
97  void mouseMoveEvent(QMouseEvent* event) override;
98  void mouseDoubleClickEvent(QMouseEvent* event) override;
99 
100  void keyPressEvent(QKeyEvent *event) override;
101 
102  MD::Interpretation metadata_interpretation() const override;
103  MetaDataList info_dialog_data() const override;
104  QMimeData* dragable_mimedata() const override;
105 
106 private slots:
107  void refresh();
108  void async_drop_finished(bool success, int async_drop_index);
109  void rating_changed(Rating rating);
110  void sl_columns_changed();
111 
112  void move_selected_rows_up();
113  void move_selected_rows_down();
114  void play_selected_track();
115  void goto_to_current_track();
116 
117 
118 protected:
119  // SayonaraSelectionView interface
120  int index_by_model_index(const QModelIndex& idx) const override;
121  ModelIndexRange model_indexrange_by_index(int idx) const override;
122 
123  void skin_changed() override;
124  bool viewportEvent(QEvent *event) override;
125 };
126 
127 #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
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings...
Definition: WidgetTemplate.h:76
The MetaDataList class.
Definition: MetaDataList.h:37
Definition: ListView.h:43
Definition: typedefs.h:31
The Dragable class.
Definition: Dragable.h:37
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:35
std::shared_ptr< Playlist::Base > PlaylistPtr
PlaylistPtr Playlist Pointer (only used internally)
Definition: PlaylistFwd.h:38