-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 13 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.h | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libmpeg3/mpeg3io.c | 20 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 18 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.h | 4 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 98 |
6 files changed, 102 insertions, 53 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp index 9f8ba65..8ede537 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp +++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp | |||
@@ -23,39 +23,41 @@ | |||
23 | #include <sys/types.h> | 23 | #include <sys/types.h> |
24 | #include <sys/stat.h> | 24 | #include <sys/stat.h> |
25 | #include <fcntl.h> | 25 | #include <fcntl.h> |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #include <string.h> | 27 | #include <string.h> |
28 | #include <ctype.h> | 28 | #include <ctype.h> |
29 | #include <errno.h> | 29 | #include <errno.h> |
30 | #include <time.h> | 30 | #include <time.h> |
31 | #include <locale.h> | 31 | #include <locale.h> |
32 | #include <math.h> | 32 | #include <math.h> |
33 | #include <assert.h> | 33 | #include <assert.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qpe/config.h> | ||
35 | 36 | ||
36 | //#define HAVE_MMAP | 37 | //#define HAVE_MMAP |
37 | 38 | ||
38 | #if defined(HAVE_MMAP) | 39 | #if defined(HAVE_MMAP) |
39 | # include <sys/mman.h> | 40 | # include <sys/mman.h> |
40 | #endif | 41 | #endif |
41 | #include "libmadplugin.h" | 42 | #include "libmadplugin.h" |
42 | 43 | ||
43 | 44 | ||
44 | extern "C" { | 45 | extern "C" { |
45 | #include "mad.h" | 46 | #include "mad.h" |
46 | } | 47 | } |
47 | 48 | ||
48 | 49 | ||
49 | #define MPEG_BUFFER_SIZE 65536 | 50 | #define MPEG_BUFFER_SIZE 65536 |
51 | //#define MPEG_BUFFER_SIZE 32768 //16384 // 8192 | ||
50 | //#define debugMsg(a) qDebug(a) | 52 | //#define debugMsg(a) qDebug(a) |
51 | #define debugMsg(a) | 53 | #define debugMsg(a) |
52 | 54 | ||
53 | 55 | ||
54 | class Input { | 56 | class Input { |
55 | public: | 57 | public: |
56 | char const *path; | 58 | char const *path; |
57 | int fd; | 59 | int fd; |
58 | #if defined(HAVE_MMAP) | 60 | #if defined(HAVE_MMAP) |
59 | void *fdm; | 61 | void *fdm; |
60 | #endif | 62 | #endif |
61 | unsigned char *data; | 63 | unsigned char *data; |
@@ -156,25 +158,28 @@ bool LibMadPlugin::isFileSupported( const QString& path ) { | |||
156 | if ( strncasecmp(ext, ".mp2", 4) == 0 ) | 158 | if ( strncasecmp(ext, ".mp2", 4) == 0 ) |
157 | return TRUE; | 159 | return TRUE; |
158 | if ( strncasecmp(ext, ".mp3", 4) == 0 ) | 160 | if ( strncasecmp(ext, ".mp3", 4) == 0 ) |
159 | return TRUE; | 161 | return TRUE; |
160 | } | 162 | } |
161 | 163 | ||
162 | return FALSE; | 164 | return FALSE; |
163 | } | 165 | } |
164 | 166 | ||
165 | 167 | ||
166 | bool LibMadPlugin::open( const QString& path ) { | 168 | bool LibMadPlugin::open( const QString& path ) { |
167 | debugMsg( "LibMadPlugin::open" ); | 169 | debugMsg( "LibMadPlugin::open" ); |
168 | 170 | Config cfg("MediaPlayer"); | |
171 | cfg.setGroup("Options"); | ||
172 | bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE); | ||
173 | qDebug("buffer size is %d", bufferSize); | ||
169 | d->bad_last_frame = 0; | 174 | d->bad_last_frame = 0; |
170 | d->flush = TRUE; | 175 | d->flush = TRUE; |
171 | info = QString( "" ); | 176 | info = QString( "" ); |
172 | 177 | ||
173 | //qDebug( "Opening %s", path.latin1() ); | 178 | //qDebug( "Opening %s", path.latin1() ); |
174 | 179 | ||
175 | d->input.path = path.latin1(); | 180 | d->input.path = path.latin1(); |
176 | d->input.fd = ::open( d->input.path, O_RDONLY ); | 181 | d->input.fd = ::open( d->input.path, O_RDONLY ); |
177 | if (d->input.fd == -1) { | 182 | if (d->input.fd == -1) { |
178 | qDebug("error opening %s", d->input.path ); | 183 | qDebug("error opening %s", d->input.path ); |
179 | return FALSE; | 184 | return FALSE; |
180 | } | 185 | } |
@@ -188,25 +193,25 @@ bool LibMadPlugin::open( const QString& path ) { | |||
188 | } | 193 | } |
189 | if (S_ISREG(stat.st_mode) && stat.st_size > 0) { | 194 | if (S_ISREG(stat.st_mode) && stat.st_size > 0) { |
190 | d->input.length = stat.st_size; | 195 | d->input.length = stat.st_size; |
191 | d->input.fdm = map_file(d->input.fd, &d->input.length); | 196 | d->input.fdm = map_file(d->input.fd, &d->input.length); |
192 | if (d->input.fdm == 0) { | 197 | if (d->input.fdm == 0) { |
193 | qDebug("error mmapping file"); return FALSE; | 198 | qDebug("error mmapping file"); return FALSE; |
194 | } | 199 | } |
195 | d->input.data = (unsigned char *)d->input.fdm; | 200 | d->input.data = (unsigned char *)d->input.fdm; |
196 | } | 201 | } |
197 | #endif | 202 | #endif |
198 | 203 | ||
199 | if (d->input.data == 0) { | 204 | if (d->input.data == 0) { |
200 | d->input.data = (unsigned char *)malloc(MPEG_BUFFER_SIZE); | 205 | d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/); |
201 | if (d->input.data == 0) { | 206 | if (d->input.data == 0) { |
202 | qDebug("error allocating input buffer"); | 207 | qDebug("error allocating input buffer"); |
203 | return FALSE; | 208 | return FALSE; |
204 | } | 209 | } |
205 | d->input.length = 0; | 210 | d->input.length = 0; |
206 | } | 211 | } |
207 | 212 | ||
208 | d->input.eof = 0; | 213 | d->input.eof = 0; |
209 | 214 | ||
210 | mad_stream_init(&d->stream); | 215 | mad_stream_init(&d->stream); |
211 | mad_frame_init(&d->frame); | 216 | mad_frame_init(&d->frame); |
212 | mad_synth_init(&d->synth); | 217 | mad_synth_init(&d->synth); |
@@ -360,36 +365,36 @@ bool LibMadPlugin::read() { | |||
360 | 365 | ||
361 | mad_stream_buffer(&d->stream, d->input.data + skip, d->input.length - skip); | 366 | mad_stream_buffer(&d->stream, d->input.data + skip, d->input.length - skip); |
362 | 367 | ||
363 | } else | 368 | } else |
364 | #endif | 369 | #endif |
365 | { | 370 | { |
366 | if (d->stream.next_frame) { | 371 | if (d->stream.next_frame) { |
367 | memmove(d->input.data, d->stream.next_frame, | 372 | memmove(d->input.data, d->stream.next_frame, |
368 | d->input.length = &d->input.data[d->input.length] - d->stream.next_frame); | 373 | d->input.length = &d->input.data[d->input.length] - d->stream.next_frame); |
369 | } | 374 | } |
370 | 375 | ||
371 | do { | 376 | do { |
372 | len = ::read(d->input.fd, d->input.data + d->input.length, MPEG_BUFFER_SIZE - d->input.length); | 377 | len = ::read(d->input.fd, d->input.data + d->input.length, bufferSize /* MPEG_BUFFER_SIZE*/ - d->input.length); |
373 | } | 378 | } |
374 | while (len == -1 && errno == EINTR); | 379 | while (len == -1 && errno == EINTR); |
375 | 380 | ||
376 | if (len == -1) { | 381 | if (len == -1) { |
377 | qDebug("error reading audio"); | 382 | qDebug("error reading audio"); |
378 | return FALSE; | 383 | return FALSE; |
379 | } | 384 | } |
380 | else if (len == 0) { | 385 | else if (len == 0) { |
381 | d->input.eof = 1; | 386 | d->input.eof = 1; |
382 | 387 | ||
383 | assert(MPEG_BUFFER_SIZE - d->input.length >= MAD_BUFFER_GUARD); | 388 | assert(bufferSize /*MPEG_BUFFER_SIZE*/ - d->input.length >= MAD_BUFFER_GUARD); |
384 | 389 | ||
385 | while (len < MAD_BUFFER_GUARD) | 390 | while (len < MAD_BUFFER_GUARD) |
386 | d->input.data[d->input.length + len++] = 0; | 391 | d->input.data[d->input.length + len++] = 0; |
387 | } | 392 | } |
388 | 393 | ||
389 | mad_stream_buffer(&d->stream, d->input.data, d->input.length += len); | 394 | mad_stream_buffer(&d->stream, d->input.data, d->input.length += len); |
390 | } | 395 | } |
391 | 396 | ||
392 | return TRUE; | 397 | return TRUE; |
393 | } | 398 | } |
394 | 399 | ||
395 | 400 | ||
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.h b/core/multimedia/opieplayer/libmad/libmadplugin.h index b240b77..46cd4a1 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.h +++ b/core/multimedia/opieplayer/libmad/libmadplugin.h | |||
@@ -94,17 +94,17 @@ public: | |||
94 | bool supportsVideo() { return FALSE; } | 94 | bool supportsVideo() { return FALSE; } |
95 | bool supportsYUV() { return FALSE; } | 95 | bool supportsYUV() { return FALSE; } |
96 | bool supportsMMX() { return TRUE; } | 96 | bool supportsMMX() { return TRUE; } |
97 | bool supportsSMP() { return FALSE; } | 97 | bool supportsSMP() { return FALSE; } |
98 | bool supportsStereo() { return TRUE; } | 98 | bool supportsStereo() { return TRUE; } |
99 | bool supportsScaling() { return FALSE; } | 99 | bool supportsScaling() { return FALSE; } |
100 | 100 | ||
101 | long getPlayTime() { return -1; } | 101 | long getPlayTime() { return -1; } |
102 | 102 | ||
103 | private: | 103 | private: |
104 | LibMadPluginData *d; | 104 | LibMadPluginData *d; |
105 | QString info; | 105 | QString info; |
106 | 106 | int bufferSize; | |
107 | }; | 107 | }; |
108 | 108 | ||
109 | 109 | ||
110 | #endif | 110 | #endif |
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3io.c b/core/multimedia/opieplayer/libmpeg3/mpeg3io.c index c5807a7..c5cae00 100644 --- a/core/multimedia/opieplayer/libmpeg3/mpeg3io.c +++ b/core/multimedia/opieplayer/libmpeg3/mpeg3io.c | |||
@@ -25,34 +25,34 @@ int mpeg3_delete_fs(mpeg3_fs_t *fs) | |||
25 | return 0; | 25 | return 0; |
26 | } | 26 | } |
27 | 27 | ||
28 | int mpeg3_copy_fs(mpeg3_fs_t *dst, mpeg3_fs_t *src) | 28 | int mpeg3_copy_fs(mpeg3_fs_t *dst, mpeg3_fs_t *src) |
29 | { | 29 | { |
30 | strcpy(dst->path, src->path); | 30 | strcpy(dst->path, src->path); |
31 | dst->current_byte = 0; | 31 | dst->current_byte = 0; |
32 | return 0; | 32 | return 0; |
33 | } | 33 | } |
34 | 34 | ||
35 | long mpeg3io_get_total_bytes(mpeg3_fs_t *fs) | 35 | long mpeg3io_get_total_bytes(mpeg3_fs_t *fs) |
36 | { | 36 | { |
37 | /* | 37 | |
38 | * struct stat st; | 38 | struct stat st; |
39 | * if(stat(fs->path, &st) < 0) return 0; | 39 | if(stat(fs->path, &st) < 0) return 0; |
40 | * return (long)st.st_size; | 40 | return (long)st.st_size; |
41 | */ | 41 | |
42 | 42 | ||
43 | fseek(fs->fd, 0, SEEK_END); | 43 | /* fseek(fs->fd, 0, SEEK_END); */ |
44 | fs->total_bytes = ftell(fs->fd); | 44 | /* fs->total_bytes = ftell(fs->fd); */ |
45 | fseek(fs->fd, 0, SEEK_SET); | 45 | /* fseek(fs->fd, 0, SEEK_SET); */ |
46 | return fs->total_bytes; | 46 | /* return fs->total_bytes; */ |
47 | } | 47 | } |
48 | 48 | ||
49 | int mpeg3io_open_file(mpeg3_fs_t *fs) | 49 | int mpeg3io_open_file(mpeg3_fs_t *fs) |
50 | { | 50 | { |
51 | /* Need to perform authentication before reading a single byte. */ | 51 | /* Need to perform authentication before reading a single byte. */ |
52 | mpeg3_get_keys(fs->css, fs->path); | 52 | mpeg3_get_keys(fs->css, fs->path); |
53 | 53 | ||
54 | if(!(fs->fd = fopen(fs->path, "rb"))) | 54 | if(!(fs->fd = fopen(fs->path, "rb"))) |
55 | { | 55 | { |
56 | perror("mpeg3io_open_file"); | 56 | perror("mpeg3io_open_file"); |
57 | return 1; | 57 | return 1; |
58 | } | 58 | } |
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index 6259b3f..8f3711a 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp | |||
@@ -10,24 +10,26 @@ | |||
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/applnk.h> | 20 | #include <qpe/applnk.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/config.h> | ||
23 | |||
22 | #include <qpainter.h> | 24 | #include <qpainter.h> |
23 | #include <qimage.h> | 25 | #include <qimage.h> |
24 | #include <qheader.h> | 26 | #include <qheader.h> |
25 | #include <qlistview.h> | 27 | #include <qlistview.h> |
26 | #include <qlist.h> | 28 | #include <qlist.h> |
27 | #include <qpixmap.h> | 29 | #include <qpixmap.h> |
28 | 30 | ||
29 | #include "playlistselection.h" | 31 | #include "playlistselection.h" |
30 | 32 | ||
31 | #include <stdlib.h> | 33 | #include <stdlib.h> |
32 | 34 | ||
33 | class PlayListSelectionItem : public QListViewItem { | 35 | class PlayListSelectionItem : public QListViewItem { |
@@ -41,25 +43,25 @@ public: | |||
41 | }; | 43 | }; |
42 | 44 | ||
43 | const DocLnk *file() const { return fl; } | 45 | const DocLnk *file() const { return fl; } |
44 | 46 | ||
45 | private: | 47 | private: |
46 | const DocLnk *fl; | 48 | const DocLnk *fl; |
47 | }; | 49 | }; |
48 | 50 | ||
49 | 51 | ||
50 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 52 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
51 | : QListView( parent, name ) | 53 | : QListView( parent, name ) |
52 | { | 54 | { |
53 | qDebug("starting playlistselector"); | 55 | // qDebug("starting playlistselector"); |
54 | // #ifdef USE_PLAYLIST_BACKGROUND | 56 | // #ifdef USE_PLAYLIST_BACKGROUND |
55 | // setStaticBackground( TRUE ); | 57 | // setStaticBackground( TRUE ); |
56 | // setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); | 58 | // setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); |
57 | 59 | ||
58 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); | 60 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); |
59 | // #endif | 61 | // #endif |
60 | // addColumn("Title",236); | 62 | // addColumn("Title",236); |
61 | // setAllColumnsShowFocus( TRUE ); | 63 | // setAllColumnsShowFocus( TRUE ); |
62 | addColumn( tr( "Playlist Selection" ) ); | 64 | addColumn( tr( "Playlist Selection" ) ); |
63 | header()->hide(); | 65 | header()->hide(); |
64 | setSorting( -1, FALSE ); | 66 | setSorting( -1, FALSE ); |
65 | } | 67 | } |
@@ -176,12 +178,26 @@ bool PlayListSelection::last() { | |||
176 | setSelected( prevItem, TRUE ); | 178 | setSelected( prevItem, TRUE ); |
177 | else | 179 | else |
178 | return FALSE; | 180 | return FALSE; |
179 | ensureItemVisible( selectedItem() ); | 181 | ensureItemVisible( selectedItem() ); |
180 | return TRUE; | 182 | return TRUE; |
181 | } | 183 | } |
182 | 184 | ||
183 | void PlayListSelection::unSelect() | 185 | void PlayListSelection::unSelect() |
184 | { | 186 | { |
185 | QListViewItem *item = selectedItem(); | 187 | QListViewItem *item = selectedItem(); |
186 | setSelected( currentItem(), FALSE); | 188 | setSelected( currentItem(), FALSE); |
187 | } \ No newline at end of file | 189 | } \ No newline at end of file |
190 | |||
191 | void PlayListSelection::writeCurrent( Config& cfg ) { | ||
192 | cfg.setGroup("PlayList"); | ||
193 | QListViewItem *item = selectedItem(); | ||
194 | if ( item ) | ||
195 | cfg.writeEntry("current", item->text(0) ); | ||
196 | qDebug(item->text(0)); | ||
197 | |||
198 | } | ||
199 | |||
200 | void PlayListSelection::setSelectedItem(const QString &strk ) { | ||
201 | // setSelected( item, TRUE ); | ||
202 | // ensureItemVisible( selectedItem() ); | ||
203 | } | ||
diff --git a/core/multimedia/opieplayer/playlistselection.h b/core/multimedia/opieplayer/playlistselection.h index ba37271..d10bc82 100644 --- a/core/multimedia/opieplayer/playlistselection.h +++ b/core/multimedia/opieplayer/playlistselection.h | |||
@@ -14,39 +14,41 @@ | |||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef PLAY_LIST_SELECTION_H | 20 | #ifndef PLAY_LIST_SELECTION_H |
21 | #define PLAY_LIST_SELECTION_H | 21 | #define PLAY_LIST_SELECTION_H |
22 | 22 | ||
23 | #include <qlist.h> | 23 | #include <qlist.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | 26 | #include <qpe/config.h> | |
27 | 27 | ||
28 | class PlayListSelection : public QListView { | 28 | class PlayListSelection : public QListView { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | PlayListSelection( QWidget *parent, const char *name=0 ); | 31 | PlayListSelection( QWidget *parent, const char *name=0 ); |
32 | ~PlayListSelection(); | 32 | ~PlayListSelection(); |
33 | 33 | ||
34 | const DocLnk *current(); // retrieve the current playlist entry (media file link) | 34 | const DocLnk *current(); // retrieve the current playlist entry (media file link) |
35 | public slots: | 35 | public slots: |
36 | void addToSelection( const DocLnk & ); // Add a media file to the playlist | 36 | void addToSelection( const DocLnk & ); // Add a media file to the playlist |
37 | void removeSelected(); // Remove a media file from the playlist | 37 | void removeSelected(); // Remove a media file from the playlist |
38 | void moveSelectedUp(); // Move the media file up the playlist so it is played earlier | 38 | void moveSelectedUp(); // Move the media file up the playlist so it is played earlier |
39 | void moveSelectedDown(); // Move the media file down the playlist so it is played later | 39 | void moveSelectedDown(); // Move the media file down the playlist so it is played later |
40 | void unSelect(); | 40 | void unSelect(); |
41 | void writeCurrent( Config &); | ||
42 | void setSelectedItem( const QString & ); | ||
41 | bool prev(); | 43 | bool prev(); |
42 | bool next(); | 44 | bool next(); |
43 | bool first(); | 45 | bool first(); |
44 | bool last(); | 46 | bool last(); |
45 | 47 | ||
46 | protected: | 48 | protected: |
47 | virtual void contentsMouseMoveEvent(QMouseEvent *); | 49 | virtual void contentsMouseMoveEvent(QMouseEvent *); |
48 | /* #ifdef USE_PLAYLIST_BACKGROUND */ | 50 | /* #ifdef USE_PLAYLIST_BACKGROUND */ |
49 | virtual void drawBackground( QPainter *p, const QRect &r ); | 51 | virtual void drawBackground( QPainter *p, const QRect &r ); |
50 | virtual void paintEmptyArea( QPainter *p, const QRect &r ) { drawBackground( p, r ); }; | 52 | virtual void paintEmptyArea( QPainter *p, const QRect &r ) { drawBackground( p, r ); }; |
51 | /* #endif */ | 53 | /* #endif */ |
52 | 54 | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 3b8f6d7..63df715 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -16,24 +16,25 @@ | |||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | 21 | #define QTOPIA_INTERNAL_FSLP |
22 | 22 | ||
23 | #include <qpe/qpemenubar.h> | 23 | #include <qpe/qpemenubar.h> |
24 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
25 | #include <qpe/fileselector.h> | 25 | #include <qpe/fileselector.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/lnkproperties.h> | 27 | #include <qpe/lnkproperties.h> |
28 | #include <qpe/storage.h> | ||
28 | 29 | ||
29 | #include <qpe/applnk.h> | 30 | #include <qpe/applnk.h> |
30 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
31 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
32 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
33 | #include <qaction.h> | 34 | #include <qaction.h> |
34 | #include <qimage.h> | 35 | #include <qimage.h> |
35 | #include <qfile.h> | 36 | #include <qfile.h> |
36 | #include <qdir.h> | 37 | #include <qdir.h> |
37 | #include <qlayout.h> | 38 | #include <qlayout.h> |
38 | #include <qlabel.h> | 39 | #include <qlabel.h> |
39 | #include <qlist.h> | 40 | #include <qlist.h> |
@@ -207,46 +208,52 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
207 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 208 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
208 | 209 | ||
209 | QWidget *aTab; | 210 | QWidget *aTab; |
210 | aTab = new QWidget( tabWidget, "aTab" ); | 211 | aTab = new QWidget( tabWidget, "aTab" ); |
211 | audioView = new QListView( aTab, "Audioview" ); | 212 | audioView = new QListView( aTab, "Audioview" ); |
212 | audioView->setMinimumSize(233,260); | 213 | audioView->setMinimumSize(233,260); |
213 | audioView->addColumn( tr("Title"),140); | 214 | audioView->addColumn( tr("Title"),140); |
214 | audioView->addColumn(tr("Size"), -1); | 215 | audioView->addColumn(tr("Size"), -1); |
215 | audioView->addColumn(tr("Media"),-1); | 216 | audioView->addColumn(tr("Media"),-1); |
216 | audioView->setColumnAlignment(1, Qt::AlignRight); | 217 | audioView->setColumnAlignment(1, Qt::AlignRight); |
217 | audioView->setColumnAlignment(2, Qt::AlignRight); | 218 | audioView->setColumnAlignment(2, Qt::AlignRight); |
218 | audioView->setAllColumnsShowFocus(TRUE); | 219 | audioView->setAllColumnsShowFocus(TRUE); |
220 | // audioView->setMultiSelection( TRUE ); | ||
221 | // audioView->setSelectionMode( QListView::Extended); | ||
222 | |||
219 | tabWidget->insertTab(aTab,tr("Audio")); | 223 | tabWidget->insertTab(aTab,tr("Audio")); |
220 | 224 | ||
221 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 225 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
222 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 226 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
223 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 227 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
224 | 228 | ||
225 | 229 | ||
226 | // audioView | 230 | // audioView |
227 | populateAudioView(); | 231 | populateAudioView(); |
228 | // videowidget | 232 | // videowidget |
229 | 233 | ||
230 | QWidget *vTab; | 234 | QWidget *vTab; |
231 | vTab = new QWidget( tabWidget, "vTab" ); | 235 | vTab = new QWidget( tabWidget, "vTab" ); |
232 | videoView = new QListView( vTab, "Videoview" ); | 236 | videoView = new QListView( vTab, "Videoview" ); |
233 | videoView->setMinimumSize(233,260); | 237 | videoView->setMinimumSize(233,260); |
234 | 238 | ||
235 | videoView->addColumn(tr("Title"),140); | 239 | videoView->addColumn(tr("Title"),140); |
236 | videoView->addColumn(tr("Size"),-1); | 240 | videoView->addColumn(tr("Size"),-1); |
237 | videoView->addColumn(tr("Media"),-1); | 241 | videoView->addColumn(tr("Media"),-1); |
238 | videoView->setColumnAlignment(1, Qt::AlignRight); | 242 | videoView->setColumnAlignment(1, Qt::AlignRight); |
239 | videoView->setColumnAlignment(2, Qt::AlignRight); | 243 | videoView->setColumnAlignment(2, Qt::AlignRight); |
240 | videoView->setAllColumnsShowFocus(TRUE); | 244 | videoView->setAllColumnsShowFocus(TRUE); |
245 | // videoView->setMultiSelection( TRUE ); | ||
246 | // videoView->setSelectionMode( QListView::Extended); | ||
247 | |||
241 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 248 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
242 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 249 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
243 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 250 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
244 | 251 | ||
245 | tabWidget->insertTab( vTab,tr("Video")); | 252 | tabWidget->insertTab( vTab,tr("Video")); |
246 | 253 | ||
247 | 254 | ||
248 | //playlists list | 255 | //playlists list |
249 | QWidget *LTab; | 256 | QWidget *LTab; |
250 | LTab = new QWidget( tabWidget, "LTab" ); | 257 | LTab = new QWidget( tabWidget, "LTab" ); |
251 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 258 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
252 | playLists->setMinimumSize(233,260);; | 259 | playLists->setMinimumSize(233,260);; |
@@ -309,113 +316,111 @@ void PlayListWidget::initializeStates() { | |||
309 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 316 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
310 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 317 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
311 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 318 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
312 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 319 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
313 | // setPlaylist( mediaPlayerState->playlist() ); | 320 | // setPlaylist( mediaPlayerState->playlist() ); |
314 | setPlaylist( true); | 321 | setPlaylist( true); |
315 | d->selectedFiles->first(); | 322 | d->selectedFiles->first(); |
316 | } | 323 | } |
317 | 324 | ||
318 | 325 | ||
319 | void PlayListWidget::readConfig( Config& cfg ) { | 326 | void PlayListWidget::readConfig( Config& cfg ) { |
320 | cfg.setGroup("PlayList"); | 327 | cfg.setGroup("PlayList"); |
321 | 328 | QString currentString = cfg.readEntry("current", "" ); | |
322 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 329 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
323 | |||
324 | for ( int i = 0; i < noOfFiles; i++ ) { | 330 | for ( int i = 0; i < noOfFiles; i++ ) { |
325 | QString entryName; | 331 | QString entryName; |
326 | entryName.sprintf( "File%i", i + 1 ); | 332 | entryName.sprintf( "File%i", i + 1 ); |
327 | QString linkFile = cfg.readEntry( entryName ); | 333 | QString linkFile = cfg.readEntry( entryName ); |
328 | DocLnk lnk( linkFile ); | 334 | DocLnk lnk( linkFile ); |
329 | if ( lnk.isValid() ) | 335 | if ( lnk.isValid() ) { |
330 | d->selectedFiles->addToSelection( lnk ); | 336 | d->selectedFiles->addToSelection( lnk ); |
331 | } | 337 | } |
332 | } | 338 | } |
339 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); | ||
340 | } | ||
333 | 341 | ||
334 | 342 | ||
335 | void PlayListWidget::writeConfig( Config& cfg ) const { | 343 | void PlayListWidget::writeConfig( Config& cfg ) const { |
336 | cfg.setGroup("PlayList"); | ||
337 | 344 | ||
345 | d->selectedFiles->writeCurrent( cfg); | ||
346 | cfg.setGroup("PlayList"); | ||
338 | int noOfFiles = 0; | 347 | int noOfFiles = 0; |
339 | |||
340 | d->selectedFiles->first(); | 348 | d->selectedFiles->first(); |
341 | do { | 349 | do { |
342 | const DocLnk *lnk = d->selectedFiles->current(); | 350 | const DocLnk *lnk = d->selectedFiles->current(); |
343 | if ( lnk ) { | 351 | if ( lnk ) { |
344 | QString entryName; | 352 | QString entryName; |
345 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 353 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
354 | qDebug(entryName); | ||
346 | cfg.writeEntry( entryName, lnk->linkFile() ); | 355 | cfg.writeEntry( entryName, lnk->linkFile() ); |
347 | // if this link does exist, add it so we have the file | 356 | // if this link does exist, add it so we have the file |
348 | // next time... | 357 | // next time... |
349 | if ( !QFile::exists( lnk->linkFile() ) ) { | 358 | if ( !QFile::exists( lnk->linkFile() ) ) { |
350 | // the way writing lnks doesn't really check for out | 359 | // the way writing lnks doesn't really check for out |
351 | // of disk space, but check it anyway. | 360 | // of disk space, but check it anyway. |
352 | if ( !lnk->writeLink() ) { | 361 | if ( !lnk->writeLink() ) { |
353 | QMessageBox::critical( 0, tr("Out of space"), | 362 | QMessageBox::critical( 0, tr("Out of space"), |
354 | tr( "There was a problem saving " | 363 | tr( "There was a problem saving " |
355 | "the playlist.\n" | 364 | "the playlist.\n" |
356 | "Your playlist " | 365 | "Your playlist " |
357 | "may be missing some entries\n" | 366 | "may be missing some entries\n" |
358 | "the next time you start it." ) | 367 | "the next time you start it." ) |
359 | ); | 368 | ); |
360 | } | 369 | } |
361 | } | 370 | } |
362 | noOfFiles++; | 371 | noOfFiles++; |
363 | } | 372 | } |
364 | } while ( d->selectedFiles->next() ); | 373 | } |
365 | 374 | while ( d->selectedFiles->next() ); | |
366 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 375 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
367 | |||
368 | |||
369 | } | 376 | } |
370 | 377 | ||
371 | 378 | ||
372 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 379 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
373 | // qDebug("add"); | 380 | // qDebug("add"); |
374 | d->setDocumentUsed = FALSE; | 381 | d->setDocumentUsed = FALSE; |
375 | if ( mediaPlayerState->playlist() ) | 382 | if ( mediaPlayerState->playlist() ) |
376 | d->selectedFiles->addToSelection( lnk ); | 383 | d->selectedFiles->addToSelection( lnk ); |
377 | else | 384 | else |
378 | mediaPlayerState->setPlaying( TRUE ); | 385 | mediaPlayerState->setPlaying( TRUE ); |
379 | } | 386 | } |
380 | 387 | ||
381 | 388 | ||
382 | void PlayListWidget::clearList() { | 389 | void PlayListWidget::clearList() { |
383 | while ( first() ) | 390 | while ( first() ) |
384 | d->selectedFiles->removeSelected(); | 391 | d->selectedFiles->removeSelected(); |
385 | } | 392 | } |
386 | 393 | ||
387 | 394 | ||
388 | void PlayListWidget::addAllToList() { | 395 | void PlayListWidget::addAllToList() { |
389 | DocLnkSet files; | 396 | DocLnkSet filesAll; |
390 | Global::findDocuments(&files, "video/*;audio/*"); | 397 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
391 | QListIterator<DocLnk> dit( files.children() ); | 398 | QListIterator<DocLnk> Adit( filesAll.children() ); |
392 | for ( ; dit.current(); ++dit ) | 399 | for ( ; Adit.current(); ++Adit ) |
393 | d->selectedFiles->addToSelection( **dit ); | 400 | d->selectedFiles->addToSelection( **Adit ); |
394 | } | 401 | } |
395 | 402 | ||
396 | 403 | ||
397 | void PlayListWidget::addAllMusicToList() { | 404 | void PlayListWidget::addAllMusicToList() { |
398 | DocLnkSet files; | 405 | // DocLnkSet files; |
399 | Global::findDocuments(&files, "audio/*"); | 406 | // Global::findDocuments(&files, "audio/*"); |
400 | QListIterator<DocLnk> dit( files.children() ); | 407 | QListIterator<DocLnk> dit( files.children() ); |
401 | for ( ; dit.current(); ++dit ) | 408 | for ( ; dit.current(); ++dit ) |
402 | d->selectedFiles->addToSelection( **dit ); | 409 | d->selectedFiles->addToSelection( **dit ); |
403 | } | 410 | } |
404 | 411 | ||
405 | 412 | ||
406 | void PlayListWidget::addAllVideoToList() { | 413 | void PlayListWidget::addAllVideoToList() { |
407 | DocLnkSet files; | 414 | QListIterator<DocLnk> dit( vFiles.children() ); |
408 | Global::findDocuments(&files, "video/*"); | ||
409 | QListIterator<DocLnk> dit( files.children() ); | ||
410 | for ( ; dit.current(); ++dit ) | 415 | for ( ; dit.current(); ++dit ) |
411 | d->selectedFiles->addToSelection( **dit ); | 416 | d->selectedFiles->addToSelection( **dit ); |
412 | } | 417 | } |
413 | 418 | ||
414 | 419 | ||
415 | void PlayListWidget::setDocument(const QString& fileref) { | 420 | void PlayListWidget::setDocument(const QString& fileref) { |
416 | fromSetDocument = TRUE; | 421 | fromSetDocument = TRUE; |
417 | if ( fileref.isNull() ) { | 422 | if ( fileref.isNull() ) { |
418 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 423 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
419 | return; | 424 | return; |
420 | } | 425 | } |
421 | // qDebug("setDocument "+fileref); | 426 | // qDebug("setDocument "+fileref); |
@@ -579,62 +584,69 @@ void PlayListWidget::saveList() { | |||
579 | 584 | ||
580 | QString filename; | 585 | QString filename; |
581 | InputDialog *fileDlg; | 586 | InputDialog *fileDlg; |
582 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 587 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
583 | fileDlg->exec(); | 588 | fileDlg->exec(); |
584 | if( fileDlg->result() == 1 ) { | 589 | if( fileDlg->result() == 1 ) { |
585 | if ( d->current ) | 590 | if ( d->current ) |
586 | delete d->current; | 591 | delete d->current; |
587 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 592 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
588 | // qDebug("saving playlist "+filename+".playlist"); | 593 | // qDebug("saving playlist "+filename+".playlist"); |
589 | Config cfg( filename +".playlist"); | 594 | Config cfg( filename +".playlist"); |
590 | writeConfig( cfg ); | 595 | writeConfig( cfg ); |
591 | if( playLists->selected()->name() == filename) { | ||
592 | // qDebug("same name so delete lnk"); | ||
593 | QFile().remove(playLists->selected()->file()); | ||
594 | QFile().remove(playLists->selected()->linkFile()); | ||
595 | playLists->reread(); | ||
596 | } | ||
597 | 596 | ||
597 | // qDebug("same name so delete lnk??"); | ||
598 | // if( playLists->selected()->name() == filename) { | ||
599 | |||
600 | // qDebug("same name so delete lnk"); | ||
601 | // QFile().remove(playLists->selected()->file()); | ||
602 | // QFile().remove(playLists->selected()->linkFile()); | ||
603 | // playLists->reread(); | ||
604 | // } | ||
605 | // qDebug("new doclnk"); | ||
598 | DocLnk lnk; | 606 | DocLnk lnk; |
599 | // lnk.setComment( ""); | 607 | // lnk.setComment( ""); |
600 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 608 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
601 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 609 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
602 | lnk.setIcon("mpegplayer/playlist2"); | 610 | lnk.setIcon("mpegplayer/playlist2"); |
603 | lnk.setName( filename); //sets file name | 611 | lnk.setName( filename); //sets file name |
612 | qDebug(filename); | ||
604 | if(!lnk.writeLink()) | 613 | if(!lnk.writeLink()) |
605 | qDebug("Writing doclink did not work"); | 614 | qDebug("Writing doclink did not work"); |
606 | } | 615 | } |
607 | Config config( "MediaPlayer" ); | 616 | Config config( "MediaPlayer" ); |
608 | config.writeEntry("CurrentPlaylist",filename); | 617 | config.writeEntry("CurrentPlaylist",filename); |
609 | setCaption(tr("OpiePlayer: ")+filename); | 618 | setCaption(tr("OpiePlayer: ")+filename); |
610 | d->selectedFiles->first(); | 619 | d->selectedFiles->first(); |
611 | if(fileDlg) | 620 | if(fileDlg) |
612 | delete fileDlg; | 621 | delete fileDlg; |
613 | } | 622 | } |
614 | 623 | ||
615 | void PlayListWidget::loadList( const DocLnk & lnk) { | 624 | void PlayListWidget::loadList( const DocLnk & lnk) { |
616 | QString name= lnk.name(); | 625 | QString name= lnk.name(); |
617 | // qDebug("currentList is "+name); | 626 | // qDebug("currentList is "+name); |
618 | if( name.length()>1) { | 627 | if( name.length()>1) { |
619 | setCaption("OpiePlayer: "+name); | 628 | setCaption("OpiePlayer: "+name); |
620 | // qDebug("load list "+ name+".playlist"); | 629 | // qDebug("load list "+ name+".playlist"); |
621 | clearList(); | 630 | clearList(); |
622 | Config cfg( name+".playlist"); | 631 | Config cfg( name+".playlist"); |
623 | readConfig(cfg); | 632 | readConfig(cfg); |
633 | |||
624 | tabWidget->setCurrentPage(0); | 634 | tabWidget->setCurrentPage(0); |
635 | |||
625 | Config config( "MediaPlayer" ); | 636 | Config config( "MediaPlayer" ); |
626 | config.writeEntry("CurrentPlaylist", name); | 637 | config.writeEntry("CurrentPlaylist", name); |
627 | d->selectedFiles->first(); | 638 | // d->selectedFiles->first(); |
628 | } | 639 | } |
640 | |||
629 | } | 641 | } |
630 | 642 | ||
631 | void PlayListWidget::setPlaylist( bool shown ) { | 643 | void PlayListWidget::setPlaylist( bool shown ) { |
632 | if ( shown ) | 644 | if ( shown ) |
633 | d->playListFrame->show(); | 645 | d->playListFrame->show(); |
634 | else | 646 | else |
635 | d->playListFrame->hide(); | 647 | d->playListFrame->hide(); |
636 | } | 648 | } |
637 | 649 | ||
638 | void PlayListWidget::setView( char view ) { | 650 | void PlayListWidget::setView( char view ) { |
639 | if ( view == 'l' ) | 651 | if ( view == 'l' ) |
640 | showMaximized(); | 652 | showMaximized(); |
@@ -774,36 +786,38 @@ void PlayListWidget::btnPlay(bool b) { | |||
774 | case 0: | 786 | case 0: |
775 | { | 787 | { |
776 | mediaPlayerState->setPlaying(b); | 788 | mediaPlayerState->setPlaying(b); |
777 | } | 789 | } |
778 | break; | 790 | break; |
779 | case 1: | 791 | case 1: |
780 | { | 792 | { |
781 | addToSelection( audioView->selectedItem() ); | 793 | addToSelection( audioView->selectedItem() ); |
782 | mediaPlayerState->setPlaying(b); | 794 | mediaPlayerState->setPlaying(b); |
783 | // qApp->processEvents(); | 795 | // qApp->processEvents(); |
784 | d->selectedFiles->removeSelected( ); | 796 | d->selectedFiles->removeSelected( ); |
785 | tabWidget->setCurrentPage(1); | 797 | tabWidget->setCurrentPage(1); |
786 | d->selectedFiles->unSelect(); | 798 | audioView->clearSelection(); |
799 | // d->selectedFiles->unSelect(); | ||
787 | // mediaPlayerState->setPlaying(FALSE); | 800 | // mediaPlayerState->setPlaying(FALSE); |
788 | } | 801 | } |
789 | break; | 802 | break; |
790 | case 2: | 803 | case 2: |
791 | { | 804 | { |
792 | addToSelection( videoView->selectedItem() ); | 805 | addToSelection( videoView->selectedItem() ); |
793 | mediaPlayerState->setPlaying(b); | 806 | mediaPlayerState->setPlaying(b); |
794 | qApp->processEvents(); | 807 | qApp->processEvents(); |
795 | d->selectedFiles->removeSelected( ); | 808 | d->selectedFiles->removeSelected( ); |
796 | tabWidget->setCurrentPage(2); | 809 | tabWidget->setCurrentPage(2); |
797 | d->selectedFiles->unSelect(); | 810 | videoView->clearSelection(); |
811 | // d->selectedFiles->unSelect(); | ||
798 | // mediaPlayerState->setPlaying(FALSE); | 812 | // mediaPlayerState->setPlaying(FALSE); |
799 | } | 813 | } |
800 | break; | 814 | break; |
801 | }; | 815 | }; |
802 | } | 816 | } |
803 | 817 | ||
804 | void PlayListWidget::deletePlaylist() { | 818 | void PlayListWidget::deletePlaylist() { |
805 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 819 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
806 | (tr("You really want to delete\nthis playlist?")), | 820 | (tr("You really want to delete\nthis playlist?")), |
807 | (tr("Yes")), (tr("No")), 0 )){ | 821 | (tr("Yes")), (tr("No")), 0 )){ |
808 | case 0: // Yes clicked, | 822 | case 0: // Yes clicked, |
809 | QFile().remove(playLists->selected()->file()); | 823 | QFile().remove(playLists->selected()->file()); |
@@ -896,46 +910,58 @@ void PlayListWidget::listDelete() { | |||
896 | // prop.showMaximized(); | 910 | // prop.showMaximized(); |
897 | // prop.exec(); | 911 | // prop.exec(); |
898 | // } | 912 | // } |
899 | // } | 913 | // } |
900 | } | 914 | } |
901 | break; | 915 | break; |
902 | }; | 916 | }; |
903 | } | 917 | } |
904 | 918 | ||
905 | void PlayListWidget::populateAudioView() { | 919 | void PlayListWidget::populateAudioView() { |
906 | // if(files) | 920 | // if(files) |
907 | // files.~DocLnkSet(); | 921 | // files.~DocLnkSet(); |
922 | StorageInfo storageInfo; | ||
923 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | ||
924 | |||
908 | Global::findDocuments(&files, "audio/*"); | 925 | Global::findDocuments(&files, "audio/*"); |
909 | QListIterator<DocLnk> dit( files.children() ); | 926 | QListIterator<DocLnk> dit( files.children() ); |
927 | QListIterator<FileSystem> it ( fs ); | ||
910 | audioView->clear(); | 928 | audioView->clear(); |
911 | QString storage; | 929 | QString storage; |
912 | for ( ; dit.current(); ++dit ) { | 930 | for ( ; dit.current(); ++dit ) { |
931 | for( ; it.current(); ++it ){ | ||
932 | const QString name = (*it)->name(); | ||
933 | const QString path = (*it)->path(); | ||
934 | if(dit.current()->file().find(path) != -1 ) storage=name; | ||
935 | } | ||
936 | |||
913 | QListViewItem * newItem; | 937 | QListViewItem * newItem; |
914 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage=tr("CF"); | ||
915 | else if(dit.current()->file().find("/mnt/hda") != -1 ) storage=tr("CF"); | ||
916 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage=tr("SD"); | ||
917 | else storage=tr("RAM"); | ||
918 | if ( QFile( dit.current()->file()).exists() ) { | 938 | if ( QFile( dit.current()->file()).exists() ) { |
919 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 939 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
920 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | 940 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); |
921 | } | 941 | } |
922 | } | 942 | } |
923 | } | 943 | } |
924 | 944 | ||
925 | void PlayListWidget::populateVideoView() { | 945 | void PlayListWidget::populateVideoView() { |
946 | StorageInfo storageInfo; | ||
947 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | ||
948 | |||
926 | Global::findDocuments(&vFiles, "video/*"); | 949 | Global::findDocuments(&vFiles, "video/*"); |
927 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 950 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
951 | QListIterator<FileSystem> it ( fs ); | ||
928 | videoView->clear(); | 952 | videoView->clear(); |
929 | QString storage; | 953 | QString storage; |
930 | for ( ; Vdit.current(); ++Vdit ) { | 954 | for ( ; Vdit.current(); ++Vdit ) { |
931 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage=tr("CF"); | 955 | for( ; it.current(); ++it ){ |
932 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage=tr("CF"); | 956 | const QString name = (*it)->name(); |
933 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage=tr("SD"); | 957 | const QString path = (*it)->path(); |
934 | else storage=tr("RAM"); | 958 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
959 | } | ||
960 | |||
935 | QListViewItem * newItem; | 961 | QListViewItem * newItem; |
936 | if ( QFile( Vdit.current()->file()).exists() ) { | 962 | if ( QFile( Vdit.current()->file()).exists() ) { |
937 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 963 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
938 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | 964 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); |
939 | } | 965 | } |
940 | } | 966 | } |
941 | } | 967 | } |