source: smplayer/trunk/src/playlist.h@ 165

Last change on this file since 165 was 165, checked in by Silvan Scherrer, 12 years ago

SMPlayer: update trunk to latest 0.8.7

  • Property svn:eol-style set to LF
File size: 6.2 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2014 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 resumePlay();
95
96 virtual void removeSelected();
97 virtual void removeAll();
98 virtual void remove(int);
99
100 virtual void moveItemUp(int);
101 virtual void moveItemDown(int);
102
103 virtual void addCurrentFile();
104 virtual void addFiles();
105 virtual void addDirectory();
106 virtual void addUrls();
107
108 virtual void addFile(QString file, AutoGetInfo auto_get_info = UserDefined);
109 virtual void addFiles(QStringList files, AutoGetInfo auto_get_info = UserDefined);
110
111 // Adds a directory, no recursive
112 virtual void addOneDirectory(QString dir);
113
114 // Adds a directory, maybe with recursion (depends on user config)
115 virtual void addDirectory(QString dir);
116
117 // EDIT BY NEO -->
118 virtual void sortBy(int section);
119 // <--
120
121 virtual bool maybeSave();
122 virtual void load();
123 virtual bool save();
124
125 virtual void load_m3u(QString file);
126 virtual bool save_m3u(QString file);
127
128 virtual void load_pls(QString file);
129 virtual bool save_pls(QString file);
130
131 virtual void getMediaInfo();
132
133 void setModified(bool);
134
135 // Preferences
136 void setDirectoryRecursion(bool b) { recursive_add_directory = b; };
137 void setAutoGetInfo(bool b) { automatically_get_info = b; };
138 void setSavePlaylistOnExit(bool b) { save_playlist_in_config = b; };
139 void setPlayFilesFromStart(bool b) { play_files_from_start = b; };
140
141public:
142 bool directoryRecursion() { return recursive_add_directory; };
143 bool autoGetInfo() { return automatically_get_info; };
144 bool savePlaylistOnExit() { return save_playlist_in_config; };
145 bool playFilesFromStart() { return play_files_from_start; };
146
147 QList<PlaylistItem> playlist(){return pl;};
148
149/*
150public:
151 MyAction * playPrevAct() { return prevAct; };
152 MyAction * playNextAct() { return nextAct; };
153*/
154
155signals:
156 void playlistEnded();
157 void visibilityChanged(bool visible);
158 void modifiedChanged(bool);
159
160protected:
161 void updateView();
162 void setCurrentItem(int current);
163 void clearPlayedTag();
164 int chooseRandomItem();
165 void swapItems(int item1, int item2 );
166 // EDIT BY NEO -->
167 void sortBy(int section, bool revert, int count);
168 // <--
169 QString lastDir();
170
171protected slots:
172 virtual void playCurrent();
173 virtual void itemDoubleClicked(int row);
174 virtual void showPopup(const QPoint & pos);
175 virtual void upItem();
176 virtual void downItem();
177 virtual void editCurrentItem();
178 virtual void editItem(int item);
179
180 virtual void saveSettings();
181 virtual void loadSettings();
182
183 virtual void maybeSaveSettings();
184
185protected:
186 void createTable();
187 void createActions();
188 void createToolbar();
189
190protected:
191 void retranslateStrings();
192 virtual void changeEvent ( QEvent * event ) ;
193 virtual void dragEnterEvent( QDragEnterEvent * ) ;
194 virtual void dropEvent ( QDropEvent * );
195 virtual void hideEvent ( QHideEvent * );
196 virtual void showEvent ( QShowEvent * );
197 virtual void closeEvent( QCloseEvent * e );
198
199protected:
200 typedef QList <PlaylistItem> PlaylistItemList;
201 PlaylistItemList pl;
202 int current_item;
203
204 QString playlist_path;
205 QString latest_dir;
206
207 Core * core;
208 QMenu * add_menu;
209 QMenu * remove_menu;
210 QMenu * popup;
211
212 MyTableWidget * listView;
213
214 QToolBar * toolbar;
215 QToolButton * add_button;
216 QToolButton * remove_button;
217
218 MyAction * openAct;
219 MyAction * saveAct;
220 MyAction * playAct;
221 MyAction * prevAct;
222 MyAction * nextAct;
223 MyAction * repeatAct;
224 MyAction * shuffleAct;
225
226 MyAction * moveUpAct;
227 MyAction * moveDownAct;
228 MyAction * editAct;
229
230 MyAction * addCurrentAct;
231 MyAction * addFilesAct;
232 MyAction * addDirectoryAct;
233 MyAction * addUrlsAct;
234
235 MyAction * removeSelectedAct;
236 MyAction * removeAllAct;
237
238private:
239 bool modified;
240 QTimer * save_timer;
241
242 //Preferences
243 bool recursive_add_directory;
244 bool automatically_get_info;
245 bool save_playlist_in_config;
246 bool play_files_from_start;
247 int row_spacing;
248
249 bool automatically_play_next;
250};
251
252
253#endif
254
Note: See TracBrowser for help on using the repository browser.