Sayonara Player
PlaylistView.h
1 /* PlaylistView.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (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: Michael Lugmair (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 sigDoubleClicked(int row);
60  void sigDeleteTracks(const IndexSet& rows);
61  void sigBookmarkPressed(int trackIdx, Seconds timestamp);
62 
63  public:
64  explicit View(PlaylistPtr pl, QWidget* parent=nullptr);
65  ~View() override;
66 
67  void gotoRow(int row);
68  void deleteSelectedTracks();
69 
75  void dropEventFromOutside(QDropEvent* event);
76 
77  public slots:
78  void clear();
79  void removeSelectedRows();
80 
81  private slots:
82  void refresh();
83  void currentTrackChanged(int track_index, int playlistIndex);
84  void asyncDropFinished();
85  void ratingChanged(Rating rating);
86  void columnsChanged();
87  void showRatingChanged();
88  void findTrackTriggered();
89  void reverseTriggered();
90  void bookmarkTriggered(Seconds timestamp);
91 
92  void moveSelectedRowsUp();
93  void moveSelectedRowsDown();
94  void playSelectedTrack();
95  void gotoToCurrentTrack();
96  void playlistBusyChanged(bool b);
97  void currentScannedFileChanged(const QString& currentFile);
98 
99  private:
100  void initView();
101  void initContextMenu();
102 
103  // d & d
104  int calcDragDropLine(QPoint pos);
105  void handleDrop(QDropEvent* event);
106  void handleInnerDragDrop(int row, bool copy);
107 
108  protected:
109  MD::Interpretation metadataInterpretation() const override;
110  MetaDataList infoDialogData() const override;
111  QMimeData* dragableMimedata() const override;
112  int mapModelIndexToIndex(const QModelIndex& idx) const override;
113  ModelIndexRange mapIndexToModelIndexes(int idx) const override;
114 
115  void skinChanged() override;
116 
121  void dragLeaveEvent(QDragLeaveEvent* event) override;
122  void dragEnterEvent(QDragEnterEvent* event) override;
123  void dragMoveEvent(QDragMoveEvent* event) override;
124  void dropEvent(QDropEvent* event) override;
125  void mousePressEvent(QMouseEvent* event) override;
126  void mouseDoubleClickEvent(QMouseEvent* event) override;
127  void keyPressEvent(QKeyEvent* event) override;
128  bool viewportEvent(QEvent* event) override;
129  void contextMenuEvent(QContextMenuEvent* e) override;
130  };
131 }
132 
133 #endif /* PlaylistView_H_ */
QPair
Definition: typedefs.h:32
Playlist::View::metadataInterpretation
MD::Interpretation metadataInterpretation() const override
get the interpretation for the metadata. Maybe a list of metadata should be intrepeted as albums whil...
MetaDataList
The MetaDataList class.
Definition: MetaDataList.h:35
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....
Playlist::View::dragLeaveEvent
void dragLeaveEvent(QDragLeaveEvent *event) override
we start the drag action, all lines has to be cleared
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:60
Playlist::View::infoDialogData
MetaDataList infoDialogData() const override
get the metadata that should be used for the info dialog So for lists, the selected tracks are used h...