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

Last change on this file since 93 was 93, checked in by Silvan Scherrer, 16 years ago

smplayer: 0.6.9

File size: 5.6 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2010 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
79 bool isModified() { return modified; };
80
81public slots:
82 void addItem(QString filename, QString name, double duration);
83
84 // Start playing, from item 0 if shuffle is off, or from
85 // a random item otherwise
86 void startPlay();
87
88 void playItem(int n);
89
90 virtual void playNext();
91 virtual void playPrev();
92
93 virtual void removeSelected();
94 virtual void removeAll();
95
96 virtual void addCurrentFile();
97 virtual void addFiles();
98 virtual void addDirectory();
99
100 virtual void addFile(QString file, AutoGetInfo auto_get_info = UserDefined);
101 virtual void addFiles(QStringList files, AutoGetInfo auto_get_info = UserDefined);
102
103 // Adds a directory, no recursive
104 virtual void addOneDirectory(QString dir);
105
106 // Adds a directory, maybe with recursion (depends on user config)
107 virtual void addDirectory(QString dir);
108
109 void editPreferences();
110
111 virtual bool maybeSave();
112 virtual void load();
113 virtual bool save();
114
115 virtual void load_m3u(QString file);
116 virtual bool save_m3u(QString file);
117
118 virtual void load_pls(QString file);
119 virtual bool save_pls(QString file);
120
121 virtual void getMediaInfo();
122
123 void setModified(bool);
124
125/*
126public:
127 MyAction * playPrevAct() { return prevAct; };
128 MyAction * playNextAct() { return nextAct; };
129*/
130
131signals:
132 void playlistEnded();
133 void visibilityChanged(bool visible);
134 void modifiedChanged(bool);
135
136protected:
137 void updateView();
138 void setCurrentItem(int current);
139 void clearPlayedTag();
140 int chooseRandomItem();
141 void swapItems(int item1, int item2 );
142 QString lastDir();
143
144protected slots:
145 virtual void playCurrent();
146 virtual void itemDoubleClicked(int row);
147 virtual void showPopup(const QPoint & pos);
148 virtual void upItem();
149 virtual void downItem();
150 virtual void editCurrentItem();
151 virtual void editItem(int item);
152
153 virtual void saveSettings();
154 virtual void loadSettings();
155
156 virtual void maybeSaveSettings();
157
158protected:
159 void createTable();
160 void createActions();
161 void createToolbar();
162
163protected:
164 void retranslateStrings();
165 virtual void changeEvent ( QEvent * event ) ;
166 virtual void dragEnterEvent( QDragEnterEvent * ) ;
167 virtual void dropEvent ( QDropEvent * );
168 virtual void hideEvent ( QHideEvent * );
169 virtual void showEvent ( QShowEvent * );
170 virtual void closeEvent( QCloseEvent * e );
171
172protected:
173 typedef QList <PlaylistItem> PlaylistItemList;
174 PlaylistItemList pl;
175 int current_item;
176
177 QString playlist_path;
178 QString latest_dir;
179
180 Core * core;
181 QMenu * add_menu;
182 QMenu * remove_menu;
183 QMenu * popup;
184
185 MyTableWidget * listView;
186
187 QToolBar * toolbar;
188 QToolButton * add_button;
189 QToolButton * remove_button;
190
191 MyAction * openAct;
192 MyAction * saveAct;
193 MyAction * playAct;
194 MyAction * prevAct;
195 MyAction * nextAct;
196 MyAction * repeatAct;
197 MyAction * shuffleAct;
198 MyAction * preferencesAct;
199
200 MyAction * moveUpAct;
201 MyAction * moveDownAct;
202 MyAction * editAct;
203
204 MyAction * addCurrentAct;
205 MyAction * addFilesAct;
206 MyAction * addDirectoryAct;
207
208 MyAction * removeSelectedAct;
209 MyAction * removeAllAct;
210
211private:
212 bool modified;
213 QTimer * save_timer;
214
215 //Preferences
216 bool recursive_add_directory;
217 bool automatically_get_info;
218 bool save_playlist_in_config;
219 bool play_files_from_start;
220 int row_spacing;
221
222 bool automatically_play_next;
223};
224
225
226#endif
227
Note: See TracBrowser for help on using the repository browser.