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 #include <QPoint>
44 #include <QDrag>
45 #include <QList>
46 #include <QProxyStyle>
47 
48 class PlaylistView :
49  public SearchableTableView,
50  public InfoDialogContainer,
51  private 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 
67 
68  void delete_selected_tracks();
69 
75  void dropEventFromOutside(QDropEvent* event);
76 
77 
78 public slots:
79  void clear();
80  void remove_selected_rows();
81 
82 private:
83  void init_view();
84  void init_context_menu();
85 
86  // d & d
87  int calc_drag_drop_line(QPoint pos);
88  void handle_drop(QDropEvent* event);
89  void handle_inner_drag_drop(int row, bool copy);
90 
91  // overloaded stuff
92  void contextMenuEvent(QContextMenuEvent* e) override;
93 
98  void dragLeaveEvent(QDragLeaveEvent* event) override;
99  void dragEnterEvent(QDragEnterEvent* event) override;
100  void dragMoveEvent(QDragMoveEvent* event) override;
101  void dropEvent(QDropEvent* event) override;
102 
103  void mousePressEvent(QMouseEvent* event) override;
104  void mouseMoveEvent(QMouseEvent* event) override;
105  void mouseDoubleClickEvent(QMouseEvent* event) override;
106 
107  void keyPressEvent(QKeyEvent *event) override;
108 
109  MD::Interpretation metadata_interpretation() const override;
110  MetaDataList info_dialog_data() const override;
111  QMimeData* dragable_mimedata() const override;
112 
113 private slots:
114  void refresh();
115  void async_drop_finished(bool success, int async_drop_index);
116  void rating_changed(Rating rating);
117  void sl_columns_changed();
118 
119  void move_selected_rows_up();
120  void move_selected_rows_down();
121  void play_selected_track();
122 
123 
124 protected:
125  // SayonaraSelectionView interface
126  int index_by_model_index(const QModelIndex& idx) const override;
127  ModelIndexRange model_indexrange_by_index(int idx) const override;
128  bool viewportEvent(QEvent *event) override;
129 
130  void skin_changed() override;
131 };
132 
133 #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: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
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings...
Definition: WidgetTemplate.h:47
The MetaDataList class.
Definition: MetaDataList.h:38
Definition: ListView.h:48
Definition: typedefs.h:28
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:38
std::shared_ptr< Playlist::Base > PlaylistPtr
PlaylistPtr Playlist Pointer (only used internally)
Definition: PlaylistFwd.h:38