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 
35 #include "GUI/InfoDialog/InfoDialogContainer.h"
36 
37 #include "Utils/Playlist/PlaylistFwd.h"
38 #include "Utils/MetaData/MetaDataFwd.h"
39 #include "Utils/Pimpl.h"
40 
41 #include <QPoint>
42 #include <QDrag>
43 #include <QList>
44 
45 class PlaylistView :
46  public SearchableListView,
47  public InfoDialogContainer,
48  private Dragable
49 {
50  Q_OBJECT
51  PIMPL(PlaylistView)
52 
53 signals:
54  void sig_double_clicked(int row);
55  void sig_delete_tracks(const IndexSet& rows);
56 
57 public:
58  explicit PlaylistView(PlaylistPtr pl, QWidget* parent=nullptr);
59  virtual ~PlaylistView();
60 
61  void goto_row(int row);
62  void scroll_up();
63  void scroll_down();
64 
65  void remove_cur_selected_rows();
66  void delete_cur_selected_tracks();
67 
73  void dropEventFromOutside(QDropEvent* event);
74 
75 
76 public slots:
77  void clear();
78 
79 private:
80  void init_context_menu();
81 
82  // d & d
83  void clear_drag_drop_lines(int row);
84  int calc_drag_drop_line(QPoint pos);
85  void handle_drop(QDropEvent* event);
86  void handle_inner_drag_drop(int row, bool copy);
87 
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  void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected ) override;
107 
108  MD::Interpretation metadata_interpretation() const override;
109  MetaDataList info_dialog_data() const override;
110  QMimeData* dragable_mimedata() const override;
111 
112 
113 private slots:
114  void async_drop_finished(bool success);
115  void rating_changed(int rating);
116 
117 
118 protected:
119  // SayonaraSelectionView interface
120  int index_by_model_index(const QModelIndex& idx) const override;
121  QModelIndex model_index_by_index(int idx) const override;
122 };
123 
124 #endif /* PlaylistView_H_ */
Definition: SearchableView.h:77
An interface used to abstract the usage of the info dialog. An implementing class has to return the i...
Definition: InfoDialogContainer.h:36
void dropEventFromOutside(QDropEvent *event)
called from GUI_Playlist when data has not been dropped directly into the view widget. Insert on first row then
The MetaDataList class.
Definition: MetaDataList.h:38
Definition: ListView.h:45
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: AbstractPlaylist.h:36
std::shared_ptr< Playlist::Base > PlaylistPtr
PlaylistPtr Playlist Pointer (only used internally)
Definition: PlaylistFwd.h:38