Sayonara Player
ListView.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/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 #include "Utils/Settings/SayonaraClass.h"
42 
43 class QPoint;
44 class PlaylistView :
45  public SearchableTableView,
46  public InfoDialogContainer,
47  private Dragable
48 {
49  Q_OBJECT
50  PIMPL(PlaylistView)
51 
52 signals:
53  void sig_double_clicked(int row);
54  void sig_delete_tracks(const IndexSet& rows);
55  void sig_bookmark_pressed(int track_idx, Seconds timestamp);
56 
57 public:
58  explicit PlaylistView(PlaylistPtr pl, QWidget* parent=nullptr);
59  virtual ~PlaylistView();
60 
61  void goto_row(int row);
62  void delete_selected_tracks();
63 
69  void dropEventFromOutside(QDropEvent* event);
70 
71 
72 public slots:
73  void clear();
74  void remove_selected_rows();
75 
76 private:
77  void init_view();
78  void init_context_menu();
79 
80  // d & d
81  int calc_drag_drop_line(QPoint pos);
82  void handle_drop(QDropEvent* event);
83  void handle_inner_drag_drop(int row, bool copy);
84 
85  // overloaded stuff
86  void contextMenuEvent(QContextMenuEvent* e) override;
87 
92  void dragLeaveEvent(QDragLeaveEvent* event) override;
93  void dragEnterEvent(QDragEnterEvent* event) override;
94  void dragMoveEvent(QDragMoveEvent* event) override;
95  void dropEvent(QDropEvent* event) override;
96 
97  void mousePressEvent(QMouseEvent* event) override;
98  void mouseMoveEvent(QMouseEvent* event) override;
99  void mouseDoubleClickEvent(QMouseEvent* event) override;
100 
101  void keyPressEvent(QKeyEvent *event) override;
102 
103  MD::Interpretation metadata_interpretation() const override;
104  MetaDataList info_dialog_data() const override;
105  QMimeData* dragable_mimedata() const override;
106 
107 private slots:
108  void refresh();
109  void async_drop_finished(bool success, int async_drop_index);
110  void rating_changed(Rating rating);
111  void sl_columns_changed();
112 
113  void move_selected_rows_up();
114  void move_selected_rows_down();
115  void play_selected_track();
116  void goto_to_current_track();
117 
118 
119 protected:
120  // SayonaraSelectionView interface
121  int index_by_model_index(const QModelIndex& idx) const override;
122  ModelIndexRange model_indexrange_by_index(int idx) const override;
123 
124  void skin_changed() override;
125  bool viewportEvent(QEvent *event) override;
126 };
127 
128 #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:78
The MetaDataList class.
Definition: MetaDataList.h:37
Definition: ListView.h:44
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