Sayonara Player
PlaylistView.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 
44 namespace Playlist
45 {
50  class View :
51  public SearchableTableView,
52  public InfoDialogContainer,
53  private Gui::Dragable
54  {
55  Q_OBJECT
56  PIMPL(View)
57 
58  signals:
59  void sig_double_clicked(int row);
60  void sig_delete_tracks(const IndexSet& rows);
61  void sig_bookmark_pressed(int track_idx, Seconds timestamp);
62 
63  public:
64  explicit View(PlaylistPtr pl, QWidget* parent=nullptr);
65  ~View() override;
66 
67  void goto_row(int row);
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 current_track_changed(int track_index, int playlist_index);
116  void async_drop_finished(bool success, int async_drop_index);
117  void rating_changed(Rating rating);
118  void sl_columns_changed();
119  void sl_show_rating_changed();
120  void find_track_triggered();
121  void bookmark_triggered(Seconds timestamp);
122 
123  void move_selected_rows_up();
124  void move_selected_rows_down();
125  void play_selected_track();
126  void goto_to_current_track();
127  void playlist_busy_changed(bool b);
128  void current_scanned_file_changed(const QString& current_file);
129 
130  protected:
131  // SayonaraSelectionView interface
132  int index_by_model_index(const QModelIndex& idx) const override;
133  ModelIndexRange model_indexrange_by_index(int idx) const override;
134 
135  void skin_changed() override;
136  bool viewportEvent(QEvent *event) override;
137  };
138 }
139 
140 #endif /* PlaylistView_H_ */
QPair
Definition: typedefs.h:32
MetaDataList
The MetaDataList class.
Definition: MetaDataList.h:37
Util::Set
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:35
Playlist::View
The PlaylistView class.
Definition: PlaylistView.h:50
Gui::WidgetTemplate
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition: WidgetTemplate.h:84
Playlist::View::dropEventFromOutside
void dropEventFromOutside(QDropEvent *event)
called from GUI_Playlist when data has not been dropped directly into the view widget....
InfoDialogContainer
An interface used to abstract the usage of the info dialog. An implementing class has to return the i...
Definition: InfoDialogContainer.h:61
Gui::Dragable
The Dragable class.
Definition: Dragable.h:38