Miam-Player  0.8.0
A nice music player
playlist.h
Go to the documentation of this file.
1 #ifndef PLAYLIST_H
2 #define PLAYLIST_H
3 
4 #include <QMediaPlaylist>
5 #include <QMenu>
6 #include <QTableView>
7 
8 #include "playlistmodel.h"
9 #include "model/trackdao.h"
10 
11 #include <mediaplayer.h>
13 
21 class MIAMTABPLAYLISTS_LIBRARY Playlist : public QTableView
22 {
23  Q_OBJECT
24 
25 private:
26  MediaPlayer *_mediaPlayer;
27 
29  QMenu *_trackProperties;
30 
32  PlaylistModel *_playlistModel;
33 
34  QPoint _dragStartPosition;
35 
37  QModelIndexList _previouslySelectedRows;
38 
40  bool _isDragging;
41 
42  uint _hash;
43 
44  uint _id;
45 
46  Q_ENUMS(Columns)
47 
48 public:
49  enum Columns{COL_TRACK_NUMBER = 0,
50  COL_TITLE = 1,
51  COL_ALBUM = 2,
52  COL_LENGTH = 3,
53  COL_ARTIST = 4,
54  COL_RATINGS = 5,
55  COL_YEAR = 6,
56  COL_ICON = 7,
57  COL_TRACK_DAO = 8};
58 
59  explicit Playlist(MediaPlayer *mediaPlayer, QWidget *parent = nullptr);
60 
61  inline MediaPlayer *mediaPlayer() const { return _mediaPlayer; }
62 
63  inline MediaPlaylist *mediaPlaylist() const { return _playlistModel->mediaPlaylist(); }
64 
65  uint generateNewHash() const;
66 
67  inline uint id() const { return _id; }
68  bool isModified() const;
69 
70  void insertMedias(int rowIndex, const QList<QMediaContent> &medias);
71 
73  void insertMedias(int rowIndex, const QList<TrackDAO> &tracks);
74 
75  virtual QSize minimumSizeHint() const override;
76 
77  inline void forceDrop(QDropEvent *e) { this->dropEvent(e); }
78 
79  inline uint hash() const { return _hash; }
80  inline void setHash(uint hash) { _hash = hash; }
81  inline void setId(uint id) { _id = id; }
82 
83 protected:
84 
86  virtual void contextMenuEvent(QContextMenuEvent *event) override;
87 
88  virtual void dragEnterEvent(QDragEnterEvent *event) override;
89  virtual void dragLeaveEvent(QDragLeaveEvent *event) override;
90  virtual void dragMoveEvent(QDragMoveEvent *event) override;
91  virtual void startDrag(Qt::DropActions) override;
92 
94  virtual void dropEvent(QDropEvent *event) override;
95 
97  virtual void keyPressEvent(QKeyEvent *event) override;
98 
99  virtual void mouseMoveEvent(QMouseEvent *event) override;
100 
102  virtual void mousePressEvent(QMouseEvent *event) override;
103 
105  virtual void paintEvent(QPaintEvent *e) override;
106 
107  virtual int sizeHintForColumn(int column) const override;
108 
109  virtual void showEvent(QShowEvent *event) override;
110 
111  virtual void wheelEvent(QWheelEvent *event) override;
112 
113 private:
114  void autoResize();
115 
116 public slots:
118  void moveTracksDown();
119 
121  void moveTracksUp();
122 
124  void removeSelectedTracks();
125 
126 signals:
127  void aboutToSendToTagEditor(const QList<QUrl> &tracks);
128 
129  void contentHasChanged();
130 
131  void selectionHasChanged(bool isEmpty);
132 };
133 
134 #endif // PLAYLIST_H
void setId(uint id)
Definition: playlist.h:81
uint hash() const
Definition: playlist.h:79
void forceDrop(QDropEvent *e)
Definition: playlist.h:77
The Playlist class is used to display tracks in the MainWindow class.
Definition: playlist.h:21
The MediaPlaylist class has been created to have a custom Random mode.
Definition: mediaplaylist.h:16
Columns
Definition: playlist.h:49
MediaPlaylist * mediaPlaylist() const
Definition: playlist.h:63
void setHash(uint hash)
Definition: playlist.h:80
MediaPlaylist * mediaPlaylist() const
Definition: playlistmodel.h:46
uint id() const
Definition: playlist.h:67
MediaPlayer * mediaPlayer() const
Definition: playlist.h:61
The MediaPlayer class is a central class which controls local and remote sources. ...
Definition: mediaplayer.h:22
#define MIAMTABPLAYLISTS_LIBRARY
Definition: miamtabplaylists_global.hpp:8
The PlaylistModel class is the underlying class for Playlist class.
Definition: playlistmodel.h:20