-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 21 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.h | 1 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 35 |
3 files changed, 29 insertions, 28 deletions
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index d70df51..d6aff66 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp | |||
@@ -5,120 +5,123 @@ | |||
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
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 <qpainter.h> | 22 | #include <qpainter.h> |
23 | #include <qimage.h> | 23 | #include <qimage.h> |
24 | #include <qheader.h> | 24 | #include <qheader.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qlist.h> | 26 | #include <qlist.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | 28 | ||
29 | #include "playlistselection.h" | 29 | #include "playlistselection.h" |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | class PlayListSelectionItem : public QListViewItem { | 33 | class PlayListSelectionItem : public QListViewItem { |
34 | public: | 34 | public: |
35 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 35 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
36 | setText( 0, f->name() ); | 36 | setText( 0, f->name() ); |
37 | setPixmap( 0, f->pixmap() ); | 37 | setPixmap( 0, f->pixmap() ); |
38 | } | 38 | } |
39 | 39 | ||
40 | ~PlayListSelectionItem() { | 40 | ~PlayListSelectionItem() { |
41 | }; | 41 | }; |
42 | 42 | ||
43 | const DocLnk *file() const { return fl; } | 43 | const DocLnk *file() const { return fl; } |
44 | 44 | ||
45 | private: | 45 | private: |
46 | const DocLnk *fl; | 46 | const DocLnk *fl; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | 49 | ||
50 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 50 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
51 | : QListView( parent, name ) | 51 | : QListView( parent, name ) |
52 | { | 52 | { |
53 | qDebug("starting playlistselector"); | ||
53 | // #ifdef USE_PLAYLIST_BACKGROUND | 54 | // #ifdef USE_PLAYLIST_BACKGROUND |
54 | setStaticBackground( TRUE ); | 55 | // setStaticBackground( TRUE ); |
55 | // setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); | 56 | // setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); |
56 | setBackgroundPixmap( Resource::loadPixmap( "opielogo" ) ); | 57 | |
58 | // setBackgroundPixmap( Resource::loadPixmap( "opielogo" ) ); | ||
57 | // #endif | 59 | // #endif |
58 | // addColumn("Title",236); | 60 | // addColumn("Title",236); |
59 | // setAllColumnsShowFocus( TRUE ); | 61 | // setAllColumnsShowFocus( TRUE ); |
60 | addColumn( tr( "Playlist Selection" ) ); | 62 | addColumn( tr( "Playlist Selection" ) ); |
61 | header()->hide(); | 63 | header()->hide(); |
62 | setSorting( -1, FALSE ); | 64 | setSorting( -1, FALSE ); |
63 | } | 65 | } |
64 | 66 | ||
65 | 67 | ||
66 | PlayListSelection::~PlayListSelection() { | 68 | PlayListSelection::~PlayListSelection() { |
67 | } | 69 | } |
68 | 70 | ||
69 | 71 | ||
70 | // #ifdef USE_PLAYLIST_BACKGROUND | 72 | // #ifdef USE_PLAYLIST_BACKGROUND |
71 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 73 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
72 | p->fillRect( r, QBrush( white ) ); | 74 | // qDebug("drawBackground"); |
73 | // QImage logo = Resource::loadImage( "mpegplayer/background" ); | 75 | // p->fillRect( r, QBrush( white ) ); |
74 | QImage logo = Resource::loadImage( "opielogo" ); | 76 | // QImage logo = Resource::loadImage( "mpegplayer/background" ); |
75 | if ( !logo.isNull() ) | 77 | // // QImage logo = Resource::loadImage( "opielogo" ); |
76 | p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 78 | // if ( !logo.isNull() ) |
79 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | ||
77 | } | 80 | } |
78 | // #endif | 81 | // #endif |
79 | 82 | ||
80 | 83 | ||
81 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 84 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
82 | if ( event->state() == QMouseEvent::LeftButton ) { | 85 | if ( event->state() == QMouseEvent::LeftButton ) { |
83 | QListViewItem *currentItem = selectedItem(); | 86 | QListViewItem *currentItem = selectedItem(); |
84 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 87 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
85 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 88 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
86 | moveSelectedUp(); | 89 | moveSelectedUp(); |
87 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 90 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
88 | moveSelectedDown(); | 91 | moveSelectedDown(); |
89 | } | 92 | } |
90 | } | 93 | } |
91 | 94 | ||
92 | 95 | ||
93 | const DocLnk *PlayListSelection::current() { | 96 | const DocLnk *PlayListSelection::current() { |
94 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 97 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
95 | if ( item ) | 98 | if ( item ) |
96 | return item->file(); | 99 | return item->file(); |
97 | return NULL; | 100 | return NULL; |
98 | } | 101 | } |
99 | 102 | ||
100 | 103 | ||
101 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 104 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
102 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 105 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
103 | QListViewItem *current = selectedItem(); | 106 | QListViewItem *current = selectedItem(); |
104 | if ( current ) | 107 | if ( current ) |
105 | item->moveItem( current ); | 108 | item->moveItem( current ); |
106 | setSelected( item, TRUE ); | 109 | setSelected( item, TRUE ); |
107 | ensureItemVisible( selectedItem() ); | 110 | ensureItemVisible( selectedItem() ); |
108 | } | 111 | } |
109 | 112 | ||
110 | 113 | ||
111 | void PlayListSelection::removeSelected() { | 114 | void PlayListSelection::removeSelected() { |
112 | QListViewItem *item = selectedItem(); | 115 | QListViewItem *item = selectedItem(); |
113 | if ( item ) | 116 | if ( item ) |
114 | delete item; | 117 | delete item; |
115 | setSelected( currentItem(), TRUE ); | 118 | setSelected( currentItem(), TRUE ); |
116 | ensureItemVisible( selectedItem() ); | 119 | ensureItemVisible( selectedItem() ); |
117 | } | 120 | } |
118 | 121 | ||
119 | 122 | ||
120 | void PlayListSelection::moveSelectedUp() { | 123 | void PlayListSelection::moveSelectedUp() { |
121 | QListViewItem *item = selectedItem(); | 124 | QListViewItem *item = selectedItem(); |
122 | if ( item && item->itemAbove() ) | 125 | if ( item && item->itemAbove() ) |
123 | item->itemAbove()->moveItem( item ); | 126 | item->itemAbove()->moveItem( item ); |
124 | ensureItemVisible( selectedItem() ); | 127 | ensureItemVisible( selectedItem() ); |
diff --git a/core/multimedia/opieplayer/playlistselection.h b/core/multimedia/opieplayer/playlistselection.h index 57e10f1..b0d249c 100644 --- a/core/multimedia/opieplayer/playlistselection.h +++ b/core/multimedia/opieplayer/playlistselection.h | |||
@@ -1,61 +1,60 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
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 | #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 | ||
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 | |||
36 | public slots: | 35 | public slots: |
37 | void addToSelection( const DocLnk & ); // Add a media file to the playlist | 36 | void addToSelection( const DocLnk & ); // Add a media file to the playlist |
38 | void removeSelected(); // Remove a media file from the playlist | 37 | void removeSelected(); // Remove a media file from the playlist |
39 | 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 |
40 | 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 |
41 | bool prev(); | 40 | bool prev(); |
42 | bool next(); | 41 | bool next(); |
43 | bool first(); | 42 | bool first(); |
44 | bool last(); | 43 | bool last(); |
45 | 44 | ||
46 | protected: | 45 | protected: |
47 | virtual void contentsMouseMoveEvent(QMouseEvent *); | 46 | virtual void contentsMouseMoveEvent(QMouseEvent *); |
48 | /* #ifdef USE_PLAYLIST_BACKGROUND */ | 47 | /* #ifdef USE_PLAYLIST_BACKGROUND */ |
49 | virtual void drawBackground( QPainter *p, const QRect &r ); | 48 | virtual void drawBackground( QPainter *p, const QRect &r ); |
50 | virtual void paintEmptyArea( QPainter *p, const QRect &r ) { drawBackground( p, r ); }; | 49 | virtual void paintEmptyArea( QPainter *p, const QRect &r ) { drawBackground( p, r ); }; |
51 | /* #endif */ | 50 | /* #endif */ |
52 | 51 | ||
53 | private: | 52 | private: |
54 | QList<DocLnk> selectedList; | 53 | QList<DocLnk> selectedList; |
55 | const DocLnk *lnk; | 54 | const DocLnk *lnk; |
56 | }; | 55 | }; |
57 | 56 | ||
58 | 57 | ||
59 | #endif // PLAY_LIST_SELECTION_H | 58 | #endif // PLAY_LIST_SELECTION_H |
60 | 59 | ||
61 | 60 | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index a6202bc..3171a84 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -373,103 +373,111 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
373 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 373 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
374 | qDebug("add"); | 374 | qDebug("add"); |
375 | d->setDocumentUsed = FALSE; | 375 | d->setDocumentUsed = FALSE; |
376 | if ( mediaPlayerState->playlist() ) | 376 | if ( mediaPlayerState->playlist() ) |
377 | d->selectedFiles->addToSelection( lnk ); | 377 | d->selectedFiles->addToSelection( lnk ); |
378 | else | 378 | else |
379 | mediaPlayerState->setPlaying( TRUE ); | 379 | mediaPlayerState->setPlaying( TRUE ); |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | void PlayListWidget::clearList() { | 383 | void PlayListWidget::clearList() { |
384 | while ( first() ) | 384 | while ( first() ) |
385 | d->selectedFiles->removeSelected(); | 385 | d->selectedFiles->removeSelected(); |
386 | } | 386 | } |
387 | 387 | ||
388 | 388 | ||
389 | void PlayListWidget::addAllToList() { | 389 | void PlayListWidget::addAllToList() { |
390 | DocLnkSet files; | 390 | DocLnkSet files; |
391 | Global::findDocuments(&files, "video/*;audio/*"); | 391 | Global::findDocuments(&files, "video/*;audio/*"); |
392 | QListIterator<DocLnk> dit( files.children() ); | 392 | QListIterator<DocLnk> dit( files.children() ); |
393 | for ( ; dit.current(); ++dit ) | 393 | for ( ; dit.current(); ++dit ) |
394 | d->selectedFiles->addToSelection( **dit ); | 394 | d->selectedFiles->addToSelection( **dit ); |
395 | } | 395 | } |
396 | 396 | ||
397 | 397 | ||
398 | void PlayListWidget::addAllMusicToList() { | 398 | void PlayListWidget::addAllMusicToList() { |
399 | DocLnkSet files; | 399 | DocLnkSet files; |
400 | Global::findDocuments(&files, "audio/*"); | 400 | Global::findDocuments(&files, "audio/*"); |
401 | QListIterator<DocLnk> dit( files.children() ); | 401 | QListIterator<DocLnk> dit( files.children() ); |
402 | for ( ; dit.current(); ++dit ) | 402 | for ( ; dit.current(); ++dit ) |
403 | d->selectedFiles->addToSelection( **dit ); | 403 | d->selectedFiles->addToSelection( **dit ); |
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | void PlayListWidget::addAllVideoToList() { | 407 | void PlayListWidget::addAllVideoToList() { |
408 | DocLnkSet files; | 408 | DocLnkSet files; |
409 | Global::findDocuments(&files, "video/*"); | 409 | Global::findDocuments(&files, "video/*"); |
410 | QListIterator<DocLnk> dit( files.children() ); | 410 | QListIterator<DocLnk> dit( files.children() ); |
411 | for ( ; dit.current(); ++dit ) | 411 | for ( ; dit.current(); ++dit ) |
412 | d->selectedFiles->addToSelection( **dit ); | 412 | d->selectedFiles->addToSelection( **dit ); |
413 | } | 413 | } |
414 | 414 | ||
415 | 415 | ||
416 | void PlayListWidget::setDocument(const QString& fileref) { | 416 | void PlayListWidget::setDocument(const QString& fileref) { |
417 | if ( fileref.isNull() ) { | 417 | if ( fileref.isNull() ) { |
418 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 418 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
419 | return; | 419 | return; |
420 | } | 420 | } |
421 | if(fileref.find("playlist",0,TRUE) == -1) { | ||
421 | addToSelection( DocLnk( fileref ) ); | 422 | addToSelection( DocLnk( fileref ) ); |
422 | d->setDocumentUsed = TRUE; | 423 | d->setDocumentUsed = TRUE; |
423 | qApp->processEvents(); | 424 | qApp->processEvents(); |
424 | mediaPlayerState->setPlaying( FALSE ); | 425 | mediaPlayerState->setPlaying( FALSE ); |
425 | qApp->processEvents(); | 426 | qApp->processEvents(); |
426 | mediaPlayerState->setPlaying( TRUE ); | 427 | mediaPlayerState->setPlaying( TRUE ); |
427 | d->selectedFiles->removeSelected( ); | 428 | d->selectedFiles->removeSelected( ); |
429 | } else { | ||
430 | loadList(DocLnk(fileref)); | ||
431 | d->selectedFiles->first(); | ||
432 | // mediaPlayerState->setPlaying( TRUE ); | ||
433 | // mediaPlayerState->setPlaying( FALSE ); | ||
434 | |||
435 | } | ||
428 | } | 436 | } |
429 | 437 | ||
430 | 438 | ||
431 | void PlayListWidget::setActiveWindow() { | 439 | void PlayListWidget::setActiveWindow() { |
432 | // When we get raised we need to ensure that it switches views | 440 | // When we get raised we need to ensure that it switches views |
433 | char origView = mediaPlayerState->view(); | 441 | char origView = mediaPlayerState->view(); |
434 | mediaPlayerState->setView( 'l' ); // invalidate | 442 | mediaPlayerState->setView( 'l' ); // invalidate |
435 | mediaPlayerState->setView( origView ); // now switch back | 443 | mediaPlayerState->setView( origView ); // now switch back |
436 | } | 444 | } |
437 | 445 | ||
438 | 446 | ||
439 | void PlayListWidget::useSelectedDocument() { | 447 | void PlayListWidget::useSelectedDocument() { |
440 | d->setDocumentUsed = FALSE; | 448 | d->setDocumentUsed = FALSE; |
441 | } | 449 | } |
442 | 450 | ||
443 | 451 | ||
444 | const DocLnk *PlayListWidget::current() { | 452 | const DocLnk *PlayListWidget::current() { |
445 | 453 | ||
446 | // qDebug("in Playlist widget ::current"); | 454 | // qDebug("in Playlist widget ::current"); |
447 | if ( mediaPlayerState->playlist() ) { | 455 | if ( mediaPlayerState->playlist() ) { |
448 | return d->selectedFiles->current(); | 456 | return d->selectedFiles->current(); |
449 | } | 457 | } |
450 | else if ( d->setDocumentUsed && d->current ) { | 458 | else if ( d->setDocumentUsed && d->current ) { |
451 | return d->current; | 459 | return d->current; |
452 | } else { | 460 | } else { |
453 | return d->files->selected(); | 461 | return d->files->selected(); |
454 | } | 462 | } |
455 | } | 463 | } |
456 | 464 | ||
457 | 465 | ||
458 | bool PlayListWidget::prev() { | 466 | bool PlayListWidget::prev() { |
459 | if ( mediaPlayerState->playlist() ) { | 467 | if ( mediaPlayerState->playlist() ) { |
460 | if ( mediaPlayerState->shuffled() ) { | 468 | if ( mediaPlayerState->shuffled() ) { |
461 | const DocLnk *cur = current(); | 469 | const DocLnk *cur = current(); |
462 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 470 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
463 | for ( int i = 0; i < j; i++ ) { | 471 | for ( int i = 0; i < j; i++ ) { |
464 | if ( !d->selectedFiles->next() ) | 472 | if ( !d->selectedFiles->next() ) |
465 | d->selectedFiles->first(); | 473 | d->selectedFiles->first(); |
466 | } | 474 | } |
467 | if ( cur == current() ) | 475 | if ( cur == current() ) |
468 | if ( !d->selectedFiles->next() ) | 476 | if ( !d->selectedFiles->next() ) |
469 | d->selectedFiles->first(); | 477 | d->selectedFiles->first(); |
470 | return TRUE; | 478 | return TRUE; |
471 | } else { | 479 | } else { |
472 | if ( !d->selectedFiles->prev() ) { | 480 | if ( !d->selectedFiles->prev() ) { |
473 | if ( mediaPlayerState->looping() ) { | 481 | if ( mediaPlayerState->looping() ) { |
474 | return d->selectedFiles->last(); | 482 | return d->selectedFiles->last(); |
475 | } else { | 483 | } else { |
@@ -484,120 +492,111 @@ bool PlayListWidget::prev() { | |||
484 | } | 492 | } |
485 | 493 | ||
486 | 494 | ||
487 | bool PlayListWidget::next() { | 495 | bool PlayListWidget::next() { |
488 | if ( mediaPlayerState->playlist() ) { | 496 | if ( mediaPlayerState->playlist() ) { |
489 | if ( mediaPlayerState->shuffled() ) { | 497 | if ( mediaPlayerState->shuffled() ) { |
490 | return prev(); | 498 | return prev(); |
491 | } else { | 499 | } else { |
492 | if ( !d->selectedFiles->next() ) { | 500 | if ( !d->selectedFiles->next() ) { |
493 | if ( mediaPlayerState->looping() ) { | 501 | if ( mediaPlayerState->looping() ) { |
494 | return d->selectedFiles->first(); | 502 | return d->selectedFiles->first(); |
495 | } else { | 503 | } else { |
496 | return FALSE; | 504 | return FALSE; |
497 | } | 505 | } |
498 | } | 506 | } |
499 | return TRUE; | 507 | return TRUE; |
500 | } | 508 | } |
501 | } else { | 509 | } else { |
502 | return mediaPlayerState->looping(); | 510 | return mediaPlayerState->looping(); |
503 | } | 511 | } |
504 | } | 512 | } |
505 | 513 | ||
506 | 514 | ||
507 | bool PlayListWidget::first() { | 515 | bool PlayListWidget::first() { |
508 | if ( mediaPlayerState->playlist() ) | 516 | if ( mediaPlayerState->playlist() ) |
509 | return d->selectedFiles->first(); | 517 | return d->selectedFiles->first(); |
510 | else | 518 | else |
511 | return mediaPlayerState->looping(); | 519 | return mediaPlayerState->looping(); |
512 | } | 520 | } |
513 | 521 | ||
514 | 522 | ||
515 | bool PlayListWidget::last() { | 523 | bool PlayListWidget::last() { |
516 | if ( mediaPlayerState->playlist() ) | 524 | if ( mediaPlayerState->playlist() ) |
517 | return d->selectedFiles->last(); | 525 | return d->selectedFiles->last(); |
518 | else | 526 | else |
519 | return mediaPlayerState->looping(); | 527 | return mediaPlayerState->looping(); |
520 | } | 528 | } |
521 | 529 | ||
522 | 530 | ||
523 | void PlayListWidget::saveList() { | 531 | void PlayListWidget::saveList() { |
524 | 532 | ||
525 | QString filename; | 533 | QString filename; |
526 | InputDialog *fileDlg; | 534 | InputDialog *fileDlg; |
527 | fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); | 535 | fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); |
528 | fileDlg->exec(); | 536 | fileDlg->exec(); |
529 | if( fileDlg->result() == 1 ) { | 537 | if( fileDlg->result() == 1 ) { |
530 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 538 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
531 | qDebug("saving playlist "+filename+".playlist"); | 539 | qDebug("saving playlist "+filename+".playlist"); |
532 | |||
533 | // DocLnk *lnk; | ||
534 | // lnk.setName( filename); //sets file name | ||
535 | // // lnk.setComment(title); | ||
536 | // lnk.setFile( filename+".playlist"); //sets File property | ||
537 | // lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D | ||
538 | // lnk.setIcon("MPEGPlayer"); | ||
539 | // if(!lnk.writeLink()) | ||
540 | // qDebug("Writing doclink did not work"); | ||
541 | |||
542 | Config cfg( filename +".playlist"); | 540 | Config cfg( filename +".playlist"); |
543 | writeConfig( cfg ); | 541 | writeConfig( cfg ); |
542 | DocLnk lnk; | ||
543 | lnk.setName( filename); //sets file name | ||
544 | // lnk.setComment( ""); | ||
545 | lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property | ||
546 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | ||
547 | lnk.setIcon("mpegplayer/playlist2"); | ||
548 | if(!lnk.writeLink()) | ||
549 | qDebug("Writing doclink did not work"); | ||
544 | } | 550 | } |
545 | DocLnk lnk; | ||
546 | lnk.setName( filename); //sets file name | ||
547 | // lnk.setComment(title); | ||
548 | lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property | ||
549 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | ||
550 | lnk.setIcon("MPEGPlayer"); | ||
551 | if(!lnk.writeLink()) | ||
552 | qDebug("Writing doclink did not work"); | ||
553 | 551 | ||
554 | if(fileDlg) | 552 | if(fileDlg) |
555 | delete fileDlg; | 553 | delete fileDlg; |
554 | |||
556 | } | 555 | } |
557 | 556 | ||
558 | 557 | ||
559 | void PlayListWidget::loadList( const DocLnk & lnk) { | 558 | void PlayListWidget::loadList( const DocLnk & lnk) { |
560 | qDebug("load list "+ lnk.name()+".playlist"); | 559 | qDebug("load list "+ lnk.name()+".playlist"); |
561 | clearList(); | 560 | clearList(); |
562 | Config cfg( lnk.name()+".playlist"); | 561 | Config cfg( lnk.name()+".playlist"); |
563 | readConfig(cfg); | 562 | readConfig(cfg); |
564 | tabWidget->setCurrentPage(0); | 563 | tabWidget->setCurrentPage(0); |
565 | setCaption("OpiePlayer: "+lnk.name()); | 564 | setCaption("OpiePlayer: "+lnk.name()); |
566 | } | 565 | } |
567 | 566 | ||
568 | 567 | ||
569 | void PlayListWidget::setPlaylist( bool shown ) { | 568 | void PlayListWidget::setPlaylist( bool shown ) { |
570 | if ( shown ) | 569 | if ( shown ) |
571 | d->playListFrame->show(); | 570 | d->playListFrame->show(); |
572 | else | 571 | else |
573 | d->playListFrame->hide(); | 572 | d->playListFrame->hide(); |
574 | } | 573 | } |
575 | 574 | ||
576 | 575 | ||
577 | void PlayListWidget::setView( char view ) { | 576 | void PlayListWidget::setView( char view ) { |
578 | if ( view == 'l' ) | 577 | if ( view == 'l' ) |
579 | showMaximized(); | 578 | showMaximized(); |
580 | else | 579 | else |
581 | hide(); | 580 | hide(); |
582 | } | 581 | } |
583 | 582 | ||
584 | void PlayListWidget::addSelected() { | 583 | void PlayListWidget::addSelected() { |
585 | 584 | ||
586 | switch (tabWidget->currentPageIndex()) { | 585 | switch (tabWidget->currentPageIndex()) { |
587 | case 0: //playlist | 586 | case 0: //playlist |
588 | break; | 587 | break; |
589 | case 1: { //audio | 588 | case 1: { //audio |
590 | addToSelection( audioView->selectedItem() ); | 589 | addToSelection( audioView->selectedItem() ); |
591 | } | 590 | } |
592 | break; | 591 | break; |
593 | case 2: { // video | 592 | case 2: { // video |
594 | addToSelection( videoView->selectedItem() ); | 593 | addToSelection( videoView->selectedItem() ); |
595 | } | 594 | } |
596 | break; | 595 | break; |
597 | }; | 596 | }; |
598 | } | 597 | } |
599 | 598 | ||
600 | void PlayListWidget::removeSelected() { | 599 | void PlayListWidget::removeSelected() { |
601 | d->selectedFiles->removeSelected( ); | 600 | d->selectedFiles->removeSelected( ); |
602 | } | 601 | } |
603 | 602 | ||