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

Last change on this file since 186 was 186, checked in by Silvan Scherrer, 9 years ago

SMPlayer: update vendor to 17.1.0

File size: 9.2 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2017 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#ifndef PLAYLIST_H
20#define PLAYLIST_H
21
22#include <QList>
23#include <QStringList>
24#include <QWidget>
25#include <QModelIndex>
26#include <QStandardItem>
27#include <QProcess>
28#include "mediadata.h"
29
30#define PLAYLIST_DOWNLOAD
31//#define PLAYLIST_DOUBLE_TOOLBAR
32//#define PLAYLIST_DELETE_FROM_DISK
33
34class PLItem : public QStandardItem {
35public:
36 enum PLItem_Roles { Role_Played = Qt::UserRole + 2, Role_Current = Qt::UserRole + 3, Role_Params = Qt::UserRole + 4,
37 Role_Video_URL = Qt::UserRole + 5 };
38
39 PLItem();
40 PLItem(const QString filename, const QString name, double duration);
41 ~PLItem();
42
43 void setFilename(const QString filename);
44 void setName(const QString name);
45 void setDuration(double duration);
46 void setExtraParams(const QStringList & pars);
47 void setVideoURL(const QString & url);
48 void setPlayed(bool played);
49 void setPosition(int position);
50 void setCurrent(bool b);
51
52 QString filename();
53 QString name();
54 double duration();
55 QStringList extraParams();
56 QString videoURL();
57 bool played();
58 int position();
59 bool isCurrent();
60
61 QList<QStandardItem *> items();
62
63protected:
64 QStandardItem * col_num;
65 QStandardItem * col_duration;
66 QStandardItem * col_filename;
67};
68
69
70class QTableView;
71class QStandardItemModel;
72class QStandardItem;
73class QSortFilterProxyModel;
74class QToolBar;
75class MyAction;
76class MyLineEdit;
77class LoadPage;
78class QMenu;
79class QSettings;
80class QToolButton;
81class QTimer;
82class QMovie;
83class URLHistory;
84
85class Playlist : public QWidget
86{
87 Q_OBJECT
88
89public:
90 enum AutoGetInfo { NoGetInfo = 0, GetInfo = 1, UserDefined = 2 };
91 enum M3UFormat { M3U = 0, M3U8 = 1, DetectFormat = 2 };
92
93 Playlist(QWidget * parent = 0, Qt::WindowFlags f = Qt::Window );
94 ~Playlist();
95
96 void setConfigPath(const QString & config_path);
97
98 void clear();
99 void list();
100
101 int count();
102 bool isEmpty();
103
104 bool isModified() { return modified; };
105
106 PLItem * itemData(int row);
107 PLItem * itemFromProxy(int row);
108 bool existsItem(int row);
109
110 /*
111 void changeItem(int row, const QString & filename, const QString name, double duration, bool played = false, int pos = -1);
112 */
113
114public slots:
115 void addItem(QString filename, QString name, double duration, QStringList params = QStringList(), QString video_url = QString::null);
116
117 // Start playing, from item 0 if shuffle is off, or from
118 // a random item otherwise
119 void startPlay();
120
121 void playItem(int n);
122
123 void playNext();
124 void playPrev();
125
126 void playNextAuto(); // Called from GUI when a file finished
127
128 void resumePlay();
129
130 void removeSelected();
131 void removeAll();
132
133 void addCurrentFile();
134 void addFiles();
135 void addDirectory();
136 void addUrls();
137
138 void addFile(QString file, AutoGetInfo auto_get_info = UserDefined);
139 void addFiles(QStringList files, AutoGetInfo auto_get_info = UserDefined);
140
141 // Adds a directory, no recursive
142 void addOneDirectory(QString dir);
143
144 // Adds a directory, maybe with recursion (depends on user config)
145 void addDirectory(QString dir);
146
147#ifdef PLAYLIST_DELETE_FROM_DISK
148 void deleteSelectedFileFromDisk();
149#endif
150
151 bool maybeSave();
152 void load();
153
154 bool saveCurrentPlaylist();
155 bool save(const QString & filename = QString::null);
156
157#ifdef PLAYLIST_DOWNLOAD
158 void openUrl();
159 void openUrl(const QString & url);
160#endif
161
162 void load_m3u(QString file, M3UFormat format = DetectFormat);
163 bool save_m3u(QString file);
164
165 void load_pls(QString file);
166 bool save_pls(QString file);
167
168 void loadXSPF(const QString & filename);
169 bool saveXSPF(const QString & filename);
170
171 void setModified(bool);
172
173 void setFilter(const QString & filter);
174
175 // Slots to connect from basegui
176 void getMediaInfo(const MediaData &);
177 void playerFailed(QProcess::ProcessError);
178 void playerFinishedWithError(int);
179
180public:
181 // Preferences
182 void setDirectoryRecursion(bool b) { recursive_add_directory = b; };
183 void setAutoGetInfo(bool b) { automatically_get_info = b; };
184 void setSavePlaylistOnExit(bool b) { save_playlist_in_config = b; };
185 void setPlayFilesFromStart(bool b) { play_files_from_start = b; };
186 void setIgnorePlayerErrors(bool b) { ignore_player_errors = b; };
187 void setStartPlayOnLoad(bool b) { start_play_on_load = b; };
188 void setAutomaticallyPlayNext(bool b) { automatically_play_next = b; };
189 void setAutoSort(bool b);
190 void setSortCaseSensitive(bool b);
191 void setFilterCaseSensitive(bool b);
192
193 bool directoryRecursion() { return recursive_add_directory; };
194 bool autoGetInfo() { return automatically_get_info; };
195 bool savePlaylistOnExit() { return save_playlist_in_config; };
196 bool playFilesFromStart() { return play_files_from_start; };
197 bool ignorePlayerErrors() { return ignore_player_errors; };
198 bool startPlayOnLoad() { return start_play_on_load; };
199 bool automaticallyPlayNext() { return automatically_play_next; };
200 bool autoSort();
201 bool sortCaseSensitive();
202 bool filterCaseSensitive();
203
204#ifdef PLAYLIST_DOWNLOAD
205 void setMaxItemsUrlHistory(int max_items);
206 int maxItemsUrlHistory();
207#endif
208
209/*
210public:
211 MyAction * playPrevAct() { return prevAct; };
212 MyAction * playNextAct() { return nextAct; };
213*/
214
215signals:
216 void requestToPlayFile(const QString & filename, int seek = -1);
217 void requestToPlayStream(const QString & filename, QStringList params = QStringList());
218
219 void requestToAddCurrentFile();
220 void playlistEnded();
221 void visibilityChanged(bool visible);
222 void modifiedChanged(bool);
223 void windowTitleChanged(const QString & title);
224
225protected:
226 void setCurrentItem(int current);
227 int findCurrentItem();
228 void clearPlayedTag();
229 int chooseRandomItem();
230 QString lastDir();
231
232 void setPlaylistFilename(const QString &);
233 QString playlistFilename() { return playlist_filename; };
234
235 void updateWindowTitle();
236
237protected slots:
238 void playCurrent();
239 void itemActivated(const QModelIndex & index );
240 void showPopup(const QPoint & pos);
241 void upItem();
242 void downItem();
243 void editCurrentItem();
244 void editItem(int row);
245
246 void copyURL();
247 void openFolder();
248
249#ifdef CHROMECAST_SUPPORT
250 void playOnChromecast();
251#else
252 void openURLInWeb();
253#endif
254
255 void saveSettings();
256 void loadSettings();
257
258 void maybeSaveSettings();
259
260 void filterEditChanged(const QString &);
261
262#ifdef PLAYLIST_DOWNLOAD
263 void playlistDownloaded(QByteArray);
264 void errorOcurred(int error_number, QString error_str);
265 void showLoadingAnimation(bool b);
266#endif
267
268 void setPositionColumnVisible(bool b);
269 void setNameColumnVisible(bool b);
270 void setDurationColumnVisible(bool b);
271 void setFilenameColumnVisible(bool b);
272
273protected:
274 void createTable();
275 void createActions();
276 void createToolbar();
277
278protected:
279 void retranslateStrings();
280 virtual void changeEvent ( QEvent * event ) ;
281 virtual void dragEnterEvent( QDragEnterEvent * ) ;
282 virtual void dropEvent ( QDropEvent * );
283 virtual void hideEvent ( QHideEvent * );
284 virtual void showEvent ( QShowEvent * );
285 virtual void closeEvent( QCloseEvent * e );
286
287protected:
288 QString playlist_path;
289 QString playlist_filename;
290 QString latest_dir;
291
292 QMenu * file_menu;
293 QMenu * add_menu;
294 QMenu * remove_menu;
295 QMenu * popup;
296
297 QTableView * listView;
298 QStandardItemModel * table;
299 QSortFilterProxyModel * proxy;
300
301 QToolBar * toolbar;
302#ifdef PLAYLIST_DOUBLE_TOOLBAR
303 QToolBar * toolbar2;
304#endif
305
306 QToolButton * file_button;
307 QToolButton * add_button;
308 QToolButton * remove_button;
309
310 MyLineEdit * filter_edit;
311
312 MyAction * openAct;
313#ifdef PLAYLIST_DOWNLOAD
314 MyAction * openUrlAct;
315#endif
316 MyAction * saveAct;
317 MyAction * saveAsAct;
318 MyAction * playAct;
319 MyAction * prevAct;
320 MyAction * nextAct;
321 MyAction * repeatAct;
322 MyAction * shuffleAct;
323 MyAction * showSearchAct;
324
325 MyAction * moveUpAct;
326 MyAction * moveDownAct;
327 MyAction * editAct;
328
329 MyAction * addCurrentAct;
330 MyAction * addFilesAct;
331 MyAction * addDirectoryAct;
332 MyAction * addUrlsAct;
333
334 MyAction * removeSelectedAct;
335 MyAction * removeAllAct;
336
337#ifdef PLAYLIST_DELETE_FROM_DISK
338 MyAction * deleteSelectedFileFromDiskAct;
339#endif
340
341 MyAction * copyURLAct;
342 MyAction * openFolderAct;
343
344#ifdef CHROMECAST_SUPPORT
345 MyAction * playOnChromecastAct;
346#else
347 MyAction * openURLInWebAct;
348#endif
349
350 MyAction * showPositionColumnAct;
351 MyAction * showNameColumnAct;
352 MyAction * showDurationColumnAct;
353 MyAction * showFilenameColumnAct;
354
355 QSettings * set;
356
357#ifdef PLAYLIST_DOWNLOAD
358 LoadPage * downloader;
359 URLHistory * history_urls;
360 QMovie * animation;
361 QAction * loading_label_action;
362#endif
363
364private:
365 bool modified;
366 QTimer * save_timer;
367
368 //Preferences
369 bool recursive_add_directory;
370 bool automatically_get_info;
371 bool save_playlist_in_config;
372 bool play_files_from_start;
373 int row_spacing;
374
375 bool start_play_on_load;
376 bool automatically_play_next;
377 bool ignore_player_errors;
378 bool change_name;
379 bool save_dirs;
380};
381
382#endif
Note: See TracBrowser for help on using the repository browser.