Debian Codegraph @

src/playlist.h

raw symbols SCIP
1 /*
2 Copyright (C) 2005-2014 Mario Stephan <[email protected]>
3
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef PLAYLIST_H
19 #define PLAYLIST_H
20
21 #include "track.h"
22
23 #include <QTreeWidget>
24
25 class Playlist : public QTreeWidget {
26 Q_OBJECT
27 public:
28 Playlist(QWidget* parent = nullptr);
29 ~Playlist();
30 //virtual void keyPressEvent ( QKeyEvent* e );
31 //virtual bool isExecuteArea( const QPoint& point );
32
33 enum Mode { Tracklist = 0,
34 Playlist_Single = 1,
35 Playlist_Multi = 2
36 };
37
38 /** Add a songs to the plalist*/
39 void addTrack(QUrl file, PlaylistItem* after);
40 void appendSong(Track* track);
41 void addTrack(Track* track, PlaylistItem* after);
42 void appendSong(QString songFileName);
43 void appendList(QList<QUrl>, PlaylistItem* after);
44 void appendTracks(const QList<Track*> tracks, PlaylistItem* after);
45
46 void saveXML(const QString&) const;
47 void loadXML(const QString&);
48
49 //----------------
50 PlaylistItem* firstTrack() const { return firstChild(); }
51 PlaylistItem* nextTrack() const { return nextPlaylistItem; }
52 PlaylistItem* currentTrack() const { return currentPlaylistItem; }
53 PlaylistItem* dragTrack() const { return (PlaylistItem*)this->currentItem(); }
54 PlaylistItem* newTrack() const { return newPlaylistItem; }
55 QList<Track*> allTracks();
56 bool isCurrentList() const { return m_isCurrentList; }
57 void setIsCurrentList(bool b)
58 {
59 m_isCurrentList = b;
60 handleChanges();
61 }
62
63 bool isEmpty() const { return this->topLevelItemCount() == 0; }
64 bool isFirst() const { return this->topLevelItemCount() == 1; }
65
66 void setPlaylistMode(Mode);
67 void setAutoClearOn(bool b) { autoClearOn = b; }
68
69 QString defaultPlaylistPath();
70 static void showTrackInfo(Track* bundle);
71 PlaylistItem* lastChild() const { return (PlaylistItem*)topLevelItem(topLevelItemCount() - 1); }
72 int countTrack() const { return topLevelItemCount(); }
73
74 //ToDo: what is for private only? Sort!
75
76 protected:
77 void keyPressEvent(QKeyEvent* event);
78 void mousePressEvent(QMouseEvent* event);
79 void mouseMoveEvent(QMouseEvent* event);
80 void mouseReleaseEvent(QMouseEvent* event);
81 void mouseDoubleClickEvent(QMouseEvent* event);
82 void dragEnterEvent(QDragEnterEvent* event);
83 void dropEvent(QDropEvent* event);
84 void dragMoveEvent(QDragMoveEvent* event);
85 void dragLeaveEvent(QDragLeaveEvent* event);
86 void paintEvent(QPaintEvent* event); //For better DropTarget
87
88 QMimeData* mimeData;
89 QDrag* drag;
90 QRect dropSite;
91 Qt::DropAction dropAction;
92 bool showDropHighlighter;
93
94 public Q_SLOTS:
95 void appendList(QList<QUrl>);
96 void appendTracks(const QList<Track*> tracks);
97 void changeTracks(const QList<Track*> tracks);
98 void addCurrentTrack(Track*);
99 void addNextTrack(Track*);
100 void removeSelectedItems();
101 void setPlaying(bool plays) { m_isPlaying = plays; }
102 bool isPlaying() { return m_isPlaying; }
103 void setAlternateMax(int max)
104 {
105 m_alternateMax = max;
106 fillNoColumn();
107 }
108 void skipForward();
109 void skipRewind();
110 void onRatingChanged(float);
111
112 Q_SIGNALS:
113 void currentTrackChanged(Track*);
114 void trackDoubleClicked(Track*);
115 void trackPropertyChanged(Track*);
116 void trackSelected(Track*);
117 void wantSearch(QString);
118 void wantLoad(Track*, QString);
119 void countChanged(int);
120 void countChanged(QList<Track*>);
121
122 private:
123 void setCurrentPlaylistItem(PlaylistItem*);
124 void setNextPlaylistItem(PlaylistItem*);
125 void removePlaylistItem(PlaylistItem*);
126 void checkCurrentItem();
127
128 void updateNextPlaylistItem();
129 void updateCurrentPlaylistItem();
130 void updatePlaylistItems();
131
132 int m_recursionCount;
133 int mDropVisualizerWidth;
134 int m_alternateMax;
135 void fillNoColumn();
136 void performDrag();
137 QTimer* timer;
138 QTimer* timerDragLock;
139 bool ignoreNextRelease;
140 bool m_dragLocked;
141
142 QPoint startPos;
143
144 bool m_isPlaying;
145 bool m_isCurrentList;
146 bool m_isInternDrop;
147 bool isChangeSignalEnabled;
148
149 bool autoClearOn;
150
151 PlaylistItem* nextPlaylistItem; //the item to be played after the current track
152 PlaylistItem* previousPlaylistItem;
153 PlaylistItem* newPlaylistItem; //the latest item
154 PlaylistItem* currentPlaylistItem; //the item that is playing
155 PlaylistItem* m_marker; //the item that has the drag/drop marker under it
156
157 QColor m_CurrentTrackColor;
158 QColor m_NextTrackColor;
159
160 Mode m_PlaylistMode;
161
162 inline PlaylistItem* firstChild() const { return (PlaylistItem*)topLevelItem(0); }
163 inline PlaylistItem* lastItem() const { return lastChild(); }
164
165 private Q_SLOTS:
166
167 void showContextMenu(PlaylistItem*, int);
168 void slotItemClicked(QTreeWidgetItem*, int);
169 void slotItemDoubleClicked(QTreeWidgetItem* sender, int column);
170 void emitClicked();
171 void timeoutDragLock();
172 void handleChanges();
173 void slotItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
174 void dummySlot();
175 };
176
177 #endif