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

Last change on this file since 121 was 121, checked in by Silvan Scherrer, 14 years ago

SMPlayer 0.7.1: vendor update

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