source: smplayer/vendor/current/src/playlist.h@ 140

Last change on this file since 140 was 140, checked in by Silvan Scherrer, 13 years ago

SMPlayer: update vendor to 0.8.5'

File size: 6.2 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2013 Ricardo Villalba <[email protected]>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 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 General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19
20#ifndef _PLAYLIST_H_
21#define _PLAYLIST_H_
22
23#include <QList>
24#include <QStringList>
25#include <QWidget>
26
27class PlaylistItem {
28
29public:
30 PlaylistItem() { _filename=""; _name=""; _duration=0;
31 _played = FALSE; _deleted=FALSE; };
32 PlaylistItem(QString filename, QString name, double duration) {
33 _filename = filename; _name = name; _duration = duration;
34 _played = FALSE; _deleted = FALSE; };
35 ~PlaylistItem() {};
36
37 void setFilename(QString filename) { _filename = filename; };
38 void setName(QString name) { _name = name; };
39 void setDuration(double duration) { _duration = duration; };
40 void setPlayed(bool b) { _played = b; };
41 void setMarkForDeletion(bool b) { _deleted = b; };
42
43 QString filename() { return _filename; };
44 QString name() { return _name; };
45 double duration() { return _duration; };
46 bool played() { return _played; };
47 bool markedForDeletion() { return _deleted; };
48
49private:
50 QString _filename, _name;
51 double _duration;
52 bool _played, _deleted;
53};
54
55class MyTableWidget;
56class QToolBar;
57class MyAction;
58class Core;
59class QMenu;
60class QSettings;
61class QToolButton;
62class QTimer;
63
64class Playlist : public QWidget
65{
66 Q_OBJECT
67
68public:
69 enum AutoGetInfo { NoGetInfo = 0, GetInfo = 1, UserDefined = 2 };
70
71 Playlist( Core *c, QWidget * parent = 0, Qt::WindowFlags f = Qt::Window );
72 ~Playlist();
73
74 void clear();
75 void list();
76 int count();
77 bool isEmpty();
78 QString print(QString seperator);
79
80 bool isModified() { return modified; };
81
82public slots:
83 void addItem(QString filename, QString name, double duration);
84
85 // Start playing, from item 0 if shuffle is off, or from
86 // a random item otherwise
87 void startPlay();
88
89 void playItem(int n);
90
91 virtual void playNext();
92 virtual void playPrev();
93
94 virtual void removeSelected();
95 virtual void removeAll();
96 virtual void remove(int);
97
98 virtual void moveItemUp(int);
99 virtual void moveItemDown(int);
100
101 virtual void addCurrentFile();
102 virtual void addFiles();
103 virtual void addDirectory();
104 virtual void addUrls();
105
106 virtual void addFile(QString file, AutoGetInfo auto_get_info = UserDefined);
107 virtual void addFiles(QStringList files, AutoGetInfo auto_get_info = UserDefined);
108
109 // Adds a directory, no recursive
110 virtual void addOneDirectory(QString dir);
111
112 // Adds a directory, maybe with recursion (depends on user config)
113 virtual void addDirectory(QString dir);
114
115 // EDIT BY NEO -->
116 virtual void sortBy(int section);
117 // <--
118
119 virtual bool maybeSave();
120 virtual void load();
121 virtual bool save();
122
123 virtual void load_m3u(QString file);
124 virtual bool save_m3u(QString file);
125
126 virtual void load_pls(QString file);
127 virtual bool save_pls(QString file);
128
129 virtual void getMediaInfo();
130
131 void setModified(bool);
132
133 // Preferences
134 void setDirectoryRecursion(bool b) { recursive_add_directory = b; };
135 void setAutoGetInfo(bool b) { automatically_get_info = b; };
136 void setSavePlaylistOnExit(bool b) { save_playlist_in_config = b; };
137 void setPlayFilesFromStart(bool b) { play_files_from_start = b; };
138
139public:
140 bool directoryRecursion() { return recursive_add_directory; };
141 bool autoGetInfo() { return automatically_get_info; };
142 bool savePlaylistOnExit() { return save_playlist_in_config; };
143 bool playFilesFromStart() { return play_files_from_start; };
144
145 QList<PlaylistItem> playlist(){return pl;};
146
147/*
148public:
149 MyAction * playPrevAct() { return prevAct; };
150 MyAction * playNextAct() { return nextAct; };
151*/
152
153signals:
154 void playlistEnded();
155 void visibilityChanged(bool visible);
156 void modifiedChanged(bool);
157
158protected:
159 void updateView();
160 void setCurrentItem(int current);
161 void clearPlayedTag();
162 int chooseRandomItem();
163 void swapItems(int item1, int item2 );
164 // EDIT BY NEO -->
165 void sortBy(int section, bool revert, int count);
166 // <--
167 QString lastDir();
168
169protected slots:
170 virtual void playCurrent();
171 virtual void itemDoubleClicked(int row);
172 virtual void showPopup(const QPoint & pos);
173 virtual void upItem();
174 virtual void downItem();
175 virtual void editCurrentItem();
176 virtual void editItem(int item);
177
178 virtual void saveSettings();
179 virtual void loadSettings();
180
181 virtual void maybeSaveSettings();
182
183protected:
184 void createTable();
185 void createActions();
186 void createToolbar();
187
188protected:
189 void retranslateStrings();
190 virtual void changeEvent ( QEvent * event ) ;
191 virtual void dragEnterEvent( QDragEnterEvent * ) ;
192 virtual void dropEvent ( QDropEvent * );
193 virtual void hideEvent ( QHideEvent * );
194 virtual void showEvent ( QShowEvent * );
195 virtual void closeEvent( QCloseEvent * e );
196
197protected:
198 typedef QList <PlaylistItem> PlaylistItemList;
199 PlaylistItemList pl;
200 int current_item;
201
202 QString playlist_path;
203 QString latest_dir;
204
205 Core * core;
206 QMenu * add_menu;
207 QMenu * remove_menu;
208 QMenu * popup;
209
210 MyTableWidget * listView;
211
212 QToolBar * toolbar;
213 QToolButton * add_button;
214 QToolButton * remove_button;
215
216 MyAction * openAct;
217 MyAction * saveAct;
218 MyAction * playAct;
219 MyAction * prevAct;
220 MyAction * nextAct;
221 MyAction * repeatAct;
222 MyAction * shuffleAct;
223
224 MyAction * moveUpAct;
225 MyAction * moveDownAct;
226 MyAction * editAct;
227
228 MyAction * addCurrentAct;
229 MyAction * addFilesAct;
230 MyAction * addDirectoryAct;
231 MyAction * addUrlsAct;
232
233 MyAction * removeSelectedAct;
234 MyAction * removeAllAct;
235
236private:
237 bool modified;
238 QTimer * save_timer;
239
240 //Preferences
241 bool recursive_add_directory;
242 bool automatically_get_info;
243 bool save_playlist_in_config;
244 bool play_files_from_start;
245 int row_spacing;
246
247 bool automatically_play_next;
248};
249
250
251#endif
252
Note: See TracBrowser for help on using the repository browser.