summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-12-12 19:24:08 (UTC)
committer llornkcor <llornkcor>2002-12-12 19:24:08 (UTC)
commitfa60d33a4c40ed6fc0bfb87a5366b276d65b98d8 (patch) (unidiff)
tree96ea1742473b7526089f5f785a2ccff6373f13a4
parent4789fc5908e0f6e5f828e1069b3fa5c7dad1412c (diff)
downloadopie-fa60d33a4c40ed6fc0bfb87a5366b276d65b98d8.zip
opie-fa60d33a4c40ed6fc0bfb87a5366b276d65b98d8.tar.gz
opie-fa60d33a4c40ed6fc0bfb87a5366b276d65b98d8.tar.bz2
moved readM3u and readPls to one function. fixed pls. more to come
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp195
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h5
3 files changed, 101 insertions, 102 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index 235d973..841d950 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -1,165 +1,166 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 4 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU General Public 10:`=1 )Y*s>-.--   : the terms of the GNU General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; General Public License for more 20..}^=.=       =       ; General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = General Public License along with 24  -_. . .   )=.  = General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include "playlistwidget.h" 32#include "playlistwidget.h"
33#include "om3u.h" 33#include "om3u.h"
34 34
35#include <qpe/applnk.h> 35#include <qpe/applnk.h>
36#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37#include <qpe/storage.h> 37#include <qpe/storage.h>
38#include <qpe/mimetype.h> 38#include <qpe/mimetype.h>
39#include <qpe/global.h> 39#include <qpe/global.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41 41
42#include <qdir.h> 42#include <qdir.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qstring.h> 44#include <qstring.h>
45#include <qtextstream.h> 45#include <qtextstream.h>
46#include <qstringlist.h> 46#include <qstringlist.h>
47#include <qcstring.h> 47#include <qcstring.h>
48 48
49//extern PlayListWidget *playList; 49//extern PlayListWidget *playList;
50 50
51Om3u::Om3u( const QString &filePath, int mode) 51Om3u::Om3u( const QString &filePath, int mode)
52 : QStringList (){ 52 : QStringList (){
53qDebug("<<<<<<<new m3u "+filePath); 53qDebug("<<<<<<<new m3u "+filePath);
54 f.setName(filePath); 54 f.setName(filePath);
55 f.open(mode); 55 f.open(mode);
56} 56}
57 57
58Om3u::~Om3u(){} 58Om3u::~Om3u(){}
59 59
60void Om3u::readM3u() { 60void Om3u::readM3u() {
61// qDebug("<<<<<<reading m3u "+f.name()); 61// qDebug("<<<<<<reading m3u "+f.name());
62 QTextStream t(&f); 62 QTextStream t(&f);
63 QString s; 63 QString s;
64 while ( !t.atEnd() ) { 64 while ( !t.atEnd() ) {
65 s=t.readLine(); 65 s=t.readLine();
66// qDebug(s); 66// qDebug(s);
67 if( s.find( "#", 0, TRUE) == -1 ) { 67 if( s.find( "#", 0, TRUE) == -1 ) {
68 if( s.left(2) == "E:" || s.left(2) == "P:" ) { 68 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
69 s = s.right( s.length() -2 ); 69 s = s.right( s.length() -2 );
70 QFileInfo f( s ); 70 QFileInfo f( s );
71 QString name = f.baseName(); 71 QString name = f.baseName();
72 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); 72 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
73 s=s.replace( QRegExp( "\\" ), "/" ); 73 s=s.replace( QRegExp( "\\" ), "/" );
74 append(s); 74 append(s);
75// qDebug(s); 75// qDebug(s);
76 } else { // is url 76 } else { // is url
77 s.replace( QRegExp( "%20" )," " ); 77 s.replace( QRegExp( "%20" )," " );
78 QString name; 78 QString name;
79// if( name.left( 4 ) == "http" ) { 79// if( name.left( 4 ) == "http" ) {
80// name = s.right( s.length() - 7 ); 80// name = s.right( s.length() - 7 );
81// } else { 81// } else {
82 name = s; 82 name = s;
83// } 83// }
84 append(name); 84 append(name);
85// qDebug(name); 85// qDebug(name);
86 } 86 }
87 } 87 }
88 } 88 }
89} 89}
90 90
91void Om3u::readPls() { //it's a pls file 91void Om3u::readPls() { //it's a pls file
92 QTextStream t( &f ); 92 QTextStream t( &f );
93 QString s; 93 QString s;
94 while ( !t.atEnd() ) { 94 while ( !t.atEnd() ) {
95 s = t.readLine(); 95 s = t.readLine();
96 if( s.left(4) == "File" ) { 96 if( s.left(4) == "File" ) {
97 s = s.right( s.length() - 6 ); 97 s = s.right( s.length() - s.find("=",0,true)-1 );
98 s = s.stripWhiteSpace();
98 s.replace( QRegExp( "%20" )," "); 99 s.replace( QRegExp( "%20" )," ");
99// qDebug( "adding " + s + " to playlist" ); 100// qDebug( "adding " + s + " to playlist" );
100 // numberofentries=2 101 // numberofentries=2
101 // File1=http 102 // File1=http
102 // Title 103 // Title
103 // Length 104 // Length
104 // Version 105 // Version
105 // File2=http 106 // File2=http
106 s = s.replace( QRegExp( "\\" ), "/" ); 107 s = s.replace( QRegExp( "\\" ), "/" );
107 QFileInfo f( s ); 108 QFileInfo f( s );
108 QString name = f.baseName(); 109 QString name = f.baseName();
109 if( name.left( 4 ) == "http" ) { 110 if( name.left( 4 ) == "http" ) {
110 name = s.right( s.length() - 7); 111 name = s.right( s.length() - 7);
111 } else { 112 } else {
112 name = s; 113 name = s;
113 } 114 }
114 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 115 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
115 if( s.at( s.length() - 4) == '.') // if this is probably a file 116 if( s.at( s.length() - 4) == '.') // if this is probably a file
116 append(s); 117 append(s);
117 else { //if its a url 118 else { //if its a url
118// if( name.right( 1 ).find( '/' ) == -1) { 119// if( name.right( 1 ).find( '/' ) == -1) {
119// s += "/"; 120// s += "/";
120// } 121// }
121 append(s); 122 append(s);
122 } 123 }
123 } 124 }
124 } 125 }
125} 126}
126 127
127void Om3u::write() { //writes list to m3u file 128void Om3u::write() { //writes list to m3u file
128 QString list; 129 QString list;
129 if(count()>0) { 130 if(count()>0) {
130 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 131 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
131// qDebug(*it); 132// qDebug(*it);
132 list += *it+"\n"; 133 list += *it+"\n";
133 } 134 }
134 f.writeBlock( list, list.length() ); 135 f.writeBlock( list, list.length() );
135 } 136 }
136// f.close(); 137// f.close();
137} 138}
138 139
139void Om3u::add(const QString &filePath) { //adds to m3u file 140void Om3u::add(const QString &filePath) { //adds to m3u file
140 append(filePath); 141 append(filePath);
141} 142}
142 143
143void Om3u::remove(const QString &filePath) { //removes from m3u list 144void Om3u::remove(const QString &filePath) { //removes from m3u list
144 QString list, currentFile; 145 QString list, currentFile;
145 if(count()>0) { 146 if(count()>0) {
146 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { 147 for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
147 currentFile=*it; 148 currentFile=*it;
148 // qDebug(*it); 149 // qDebug(*it);
149 150
150 if( filePath != currentFile) 151 if( filePath != currentFile)
151 list += currentFile+"\n"; 152 list += currentFile+"\n";
152 } 153 }
153 f.writeBlock( list, list.length() ); 154 f.writeBlock( list, list.length() );
154 } 155 }
155} 156}
156 157
157void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file 158void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file
158 f.close(); 159 f.close();
159 f.remove(); 160 f.remove();
160 161
161} 162}
162 163
163void Om3u::close() { //closes m3u file 164void Om3u::close() { //closes m3u file
164 f.close(); 165 f.close();
165} 166}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index a65495e..6e2457f 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1015 +1,1012 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpetoolbar.h> 34#include <qpe/qpetoolbar.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/storage.h> 36#include <qpe/storage.h>
37#include <qpe/mimetype.h> 37#include <qpe/mimetype.h>
38#include <qpe/global.h> 38#include <qpe/global.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40 40
41#include <qdatetime.h> 41#include <qdatetime.h>
42#include <qdir.h> 42#include <qdir.h>
43#include <qmessagebox.h> 43#include <qmessagebox.h>
44#include <qregexp.h> 44#include <qregexp.h>
45#include <qtextstream.h> 45#include <qtextstream.h>
46 46
47#include "playlistselection.h" 47#include "playlistselection.h"
48#include "playlistwidget.h" 48#include "playlistwidget.h"
49#include "mediaplayerstate.h" 49#include "mediaplayerstate.h"
50#include "inputDialog.h" 50#include "inputDialog.h"
51#include "om3u.h" 51#include "om3u.h"
52#include "playlistfileview.h" 52#include "playlistfileview.h"
53 53
54//only needed for the random play 54//only needed for the random play
55#include <stdlib.h> 55#include <stdlib.h>
56#include <assert.h> 56#include <assert.h>
57 57
58PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 58PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
59 : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) 59 : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 )
60{ 60{
61 61
62 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 62 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
63 "opieplayer2/add_to_playlist", 63 "opieplayer2/add_to_playlist",
64 this , SLOT(addSelected() ) ); 64 this , SLOT(addSelected() ) );
65 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 65 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
66 "opieplayer2/remove_from_playlist", 66 "opieplayer2/remove_from_playlist",
67 this , SLOT(removeSelected() ) ); 67 this , SLOT(removeSelected() ) );
68 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 68 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
69 this , SLOT( btnPlay( bool) ), TRUE ); 69 this , SLOT( btnPlay( bool) ), TRUE );
70 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 70 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
71 &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); 71 &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
72 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 72 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
73 &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 73 &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
74 74
75 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 75 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
76 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 76 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
77 this, SLOT( addAllMusicToList() ) ); 77 this, SLOT( addAllMusicToList() ) );
78 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 78 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
79 this, SLOT( addAllVideoToList() ) ); 79 this, SLOT( addAllVideoToList() ) );
80 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 80 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
81 this, SLOT( addAllToList() ) ); 81 this, SLOT( addAllToList() ) );
82 pmPlayList->insertSeparator(-1); 82 pmPlayList->insertSeparator(-1);
83// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), 83// (void)new MenuItem( pmPlayList, tr( "Save PlayList" ),
84// this, SLOT( saveList() ) ); 84// this, SLOT( saveList() ) );
85 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 85 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
86 this, SLOT(writem3u() ) ); 86 this, SLOT(writem3u() ) );
87 pmPlayList->insertSeparator(-1); 87 pmPlayList->insertSeparator(-1);
88 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), 88 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ),
89 this,SLOT( openFile() ) ); 89 this,SLOT( openFile() ) );
90 pmPlayList->insertSeparator(-1); 90 pmPlayList->insertSeparator(-1);
91 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 91 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
92 audioView, SLOT( scanFiles() ) ); 92 audioView, SLOT( scanFiles() ) );
93 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 93 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
94 videoView, SLOT( scanFiles() ) ); 94 videoView, SLOT( scanFiles() ) );
95 95
96 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 96 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
97 &mediaPlayerState, SLOT( toggleFullscreen() ) ); 97 &mediaPlayerState, SLOT( toggleFullscreen() ) );
98 98
99 Config cfg( "OpiePlayer" ); 99 Config cfg( "OpiePlayer" );
100 bool b= cfg.readBoolEntry("FullScreen", 0); 100 bool b= cfg.readBoolEntry("FullScreen", 0);
101 mediaPlayerState.setFullscreen( b ); 101 mediaPlayerState.setFullscreen( b );
102 pmView->setItemChecked( -16, b ); 102 pmView->setItemChecked( -16, b );
103 103
104 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 104 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
105 d->selectedFiles, SLOT(moveSelectedUp() ) ); 105 d->selectedFiles, SLOT(moveSelectedUp() ) );
106 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 106 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
107 d->selectedFiles, SLOT(removeSelected() ) ); 107 d->selectedFiles, SLOT(removeSelected() ) );
108 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 108 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
109 d->selectedFiles, SLOT(moveSelectedDown() ) ); 109 d->selectedFiles, SLOT(moveSelectedDown() ) );
110 QVBox *stretch2 = new QVBox( vbox1 ); 110 // QVBox *stretch2 = new QVBox( vbox1 );
111 111
112 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 112 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
113 SLOT( deletePlaylist() ) ); 113 SLOT( deletePlaylist() ) );
114 connect( pmView, SIGNAL( activated( int ) ), 114 connect( pmView, SIGNAL( activated( int ) ),
115 this, SLOT( pmViewActivated( int ) ) ); 115 this, SLOT( pmViewActivated( int ) ) );
116 connect( skinsMenu, SIGNAL( activated( int ) ) , 116 connect( skinsMenu, SIGNAL( activated( int ) ) ,
117 this, SLOT( skinsMenuActivated( int ) ) ); 117 this, SLOT( skinsMenuActivated( int ) ) );
118 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 118 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
119 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 119 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
120 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), 120 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
121 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 121 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
122 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), 122 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
123 this,SLOT( playIt( QListViewItem *) ) ); 123 this,SLOT( playIt( QListViewItem *) ) );
124 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), 124 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ),
125 this, SLOT( addToSelection( QListViewItem *) ) ); 125 this, SLOT( addToSelection( QListViewItem *) ) );
126 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 126 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
127 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 127 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
128 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 128 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
129 this,SLOT( playIt( QListViewItem *) ) ); 129 this,SLOT( playIt( QListViewItem *) ) );
130 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), 130 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ),
131 this, SLOT( addToSelection( QListViewItem *) ) ); 131 this, SLOT( addToSelection( QListViewItem *) ) );
132 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), 132 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ),
133 this, SLOT( loadList( const DocLnk & ) ) ); 133 this, SLOT( loadList( const DocLnk & ) ) );
134 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 134 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
135 this, SLOT( tabChanged( QWidget* ) ) ); 135 this, SLOT( tabChanged( QWidget* ) ) );
136 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 136 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
137 d->tbPlay, SLOT( setOn( bool ) ) ); 137 d->tbPlay, SLOT( setOn( bool ) ) );
138 connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), 138 connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ),
139 d->tbLoop, SLOT( setOn( bool ) ) ); 139 d->tbLoop, SLOT( setOn( bool ) ) );
140 connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), 140 connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ),
141 d->tbShuffle, SLOT( setOn( bool ) ) ); 141 d->tbShuffle, SLOT( setOn( bool ) ) );
142 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), 142 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
143 this, SLOT( playIt( QListViewItem *) ) ); 143 this, SLOT( playIt( QListViewItem *) ) );
144 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), 144 connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
145 &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 145 &mediaPlayerState, SLOT( setVideoGamma( int ) ) );
146 146
147 // see which skins are installed 147 // see which skins are installed
148 populateSkinsMenu(); 148 populateSkinsMenu();
149 initializeStates(); 149 initializeStates();
150 150
151 cfg.setGroup("PlayList"); 151 cfg.setGroup("PlayList");
152 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 152 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
153 loadList(DocLnk( currentPlaylist ) ); 153 loadList(DocLnk( currentPlaylist ) );
154 154
155 tabWidget->showPage( playListTab ); 155 tabWidget->showPage( playListTab );
156} 156}
157 157
158 158
159PlayListWidget::~PlayListWidget() { 159PlayListWidget::~PlayListWidget() {
160 delete d; 160 delete d;
161} 161}
162 162
163 163
164void PlayListWidget::initializeStates() { 164void PlayListWidget::initializeStates() {
165 d->tbPlay->setOn( mediaPlayerState.isPlaying() ); 165 d->tbPlay->setOn( mediaPlayerState.isPlaying() );
166 d->tbLoop->setOn( mediaPlayerState.isLooping() ); 166 d->tbLoop->setOn( mediaPlayerState.isLooping() );
167 d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); 167 d->tbShuffle->setOn( mediaPlayerState.isShuffled() );
168 d->playListFrame->show(); 168 d->playListFrame->show();
169} 169}
170 170
171void PlayListWidget::writeDefaultPlaylist() { 171void PlayListWidget::writeDefaultPlaylist() {
172 172
173 Config config( "OpiePlayer" ); 173 Config config( "OpiePlayer" );
174 config.setGroup( "PlayList" ); 174 config.setGroup( "PlayList" );
175 QString filename=QPEApplication::documentDir() + "/default.m3u"; 175 QString filename=QPEApplication::documentDir() + "/default.m3u";
176 QString currentString = config.readEntry( "CurrentPlaylist", filename); 176 QString currentString = config.readEntry( "CurrentPlaylist", filename);
177 if( currentString == filename) { 177 if( currentString == filename) {
178 Om3u *m3uList; 178 Om3u *m3uList;
179 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); 179 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
180 if( d->selectedFiles->first() ) { 180 if( d->selectedFiles->first() ) {
181 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 181 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
182 do { 182 do {
183 // qDebug(d->selectedFiles->current()->file()); 183 // qDebug(d->selectedFiles->current()->file());
184 m3uList->add( d->selectedFiles->current()->file() ); 184 m3uList->add( d->selectedFiles->current()->file() );
185 } 185 }
186 while ( d->selectedFiles->next() ); 186 while ( d->selectedFiles->next() );
187 187
188 m3uList->write(); 188 m3uList->write();
189 m3uList->close(); 189 m3uList->close();
190 delete m3uList; 190 delete m3uList;
191 191
192 } 192 }
193 } 193 }
194} 194}
195 195
196void PlayListWidget::addToSelection( const DocLnk& lnk ) { 196void PlayListWidget::addToSelection( const DocLnk& lnk ) {
197 d->setDocumentUsed = FALSE; 197 d->setDocumentUsed = FALSE;
198 if( QFileInfo( lnk.file() ).exists() || 198 if( QFileInfo( lnk.file() ).exists() ||
199 lnk.file().left(4) == "http" ) { 199 lnk.file().left(4) == "http" ) {
200 d->selectedFiles->addToSelection( lnk ); 200 d->selectedFiles->addToSelection( lnk );
201 } 201 }
202// writeCurrentM3u(); 202// writeCurrentM3u();
203} 203}
204 204
205 205
206void PlayListWidget::clearList() { 206void PlayListWidget::clearList() {
207 while ( first() ) { 207 while ( first() ) {
208 d->selectedFiles->removeSelected(); 208 d->selectedFiles->removeSelected();
209 } 209 }
210 Config cfg( "OpiePlayer" ); 210 Config cfg( "OpiePlayer" );
211 cfg.setGroup("PlayList"); 211 cfg.setGroup("PlayList");
212 cfg.writeEntry("CurrentPlaylist","default"); 212 cfg.writeEntry("CurrentPlaylist","default");
213 setCaption("OpiePlayer"); 213 setCaption("OpiePlayer");
214} 214}
215 215
216void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 216void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
217 switch (mouse) { 217 switch (mouse) {
218 case LeftButton: 218 case LeftButton:
219 break; 219 break;
220 case RightButton: 220 case RightButton:
221 { 221 {
222 QPopupMenu m; 222 QPopupMenu m;
223 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 223 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
224 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 224 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
225 m.exec( QCursor::pos() ); 225 m.exec( QCursor::pos() );
226 } 226 }
227 break; 227 break;
228 } 228 }
229} 229}
230 230
231 231
232void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 232void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
233 switch (mouse) { 233 switch (mouse) {
234 case LeftButton: 234 case LeftButton:
235 break; 235 break;
236 case RightButton: 236 case RightButton:
237 { 237 {
238 QPopupMenu m; 238 QPopupMenu m;
239 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 239 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
240 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 240 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
241 m.exec( QCursor::pos() ); 241 m.exec( QCursor::pos() );
242 } 242 }
243 break; 243 break;
244 } 244 }
245} 245}
246 246
247 247
248void PlayListWidget::addAllToList() { 248void PlayListWidget::addAllToList() {
249 249
250// QTime t; 250// QTime t;
251// t.start(); 251// t.start();
252 252
253 audioView->populateView(); 253 audioView->populateView();
254 254
255 QListViewItemIterator audioIt( audioView ); 255 QListViewItemIterator audioIt( audioView );
256 DocLnk lnk; 256 DocLnk lnk;
257 QString filename; 257 QString filename;
258 // iterate through all items of the listview 258 // iterate through all items of the listview
259 for ( ; audioIt.current(); ++audioIt ) { 259 for ( ; audioIt.current(); ++audioIt ) {
260 filename = audioIt.current()->text(3); 260 filename = audioIt.current()->text(3);
261 lnk.setName( QFileInfo(filename).baseName() ); //sets name 261 lnk.setName( QFileInfo(filename).baseName() ); //sets name
262 lnk.setFile( filename ); //sets file name 262 lnk.setFile( filename ); //sets file name
263 d->selectedFiles->addToSelection( lnk); 263 d->selectedFiles->addToSelection( lnk);
264 } 264 }
265 265
266 videoView->populateView(); 266 videoView->populateView();
267 267
268 QListViewItemIterator videoIt( videoView ); 268 QListViewItemIterator videoIt( videoView );
269 for ( ; videoIt.current(); ++videoIt ) { 269 for ( ; videoIt.current(); ++videoIt ) {
270 filename = videoIt.current()->text(3); 270 filename = videoIt.current()->text(3);
271 lnk.setName( QFileInfo(filename).baseName() ); //sets name 271 lnk.setName( QFileInfo(filename).baseName() ); //sets name
272 lnk.setFile( filename ); //sets file name 272 lnk.setFile( filename ); //sets file name
273 d->selectedFiles->addToSelection( lnk); 273 d->selectedFiles->addToSelection( lnk);
274 } 274 }
275 275
276 // d->selectedFiles->addToSelection( ); 276 // d->selectedFiles->addToSelection( );
277 // if ( it.current()->isSelected() ) 277 // if ( it.current()->isSelected() )
278 // lst->append( audioIt.current() ); 278 // lst->append( audioIt.current() );
279 // } 279 // }
280 280
281 281
282// if(!audioScan) 282// if(!audioScan)
283// scanForAudio(); 283// scanForAudio();
284// if(!videoScan) 284// if(!videoScan)
285// scanForVideo(); 285// scanForVideo();
286 286
287// DocLnkSet filesAll; 287// DocLnkSet filesAll;
288// Global::findDocuments(&filesAll, "video/*;"+audioMimes); 288// Global::findDocuments(&filesAll, "video/*;"+audioMimes);
289// QListIterator<DocLnk> Adit( filesAll.children() ); 289// QListIterator<DocLnk> Adit( filesAll.children() );
290// for ( ; Adit.current(); ++Adit ) { 290// for ( ; Adit.current(); ++Adit ) {
291// if( QFileInfo( Adit.current()->file() ).exists() ) { 291// if( QFileInfo( Adit.current()->file() ).exists() ) {
292// d->selectedFiles->addToSelection( **Adit ); 292// d->selectedFiles->addToSelection( **Adit );
293// } 293// }
294// } 294// }
295 295
296 // qDebug("elapsed time %d", t.elapsed() ); 296 // qDebug("elapsed time %d", t.elapsed() );
297 297
298 tabWidget->setCurrentPage(0); 298 tabWidget->setCurrentPage(0);
299 299
300 writeCurrentM3u(); 300 writeCurrentM3u();
301 d->selectedFiles->first(); 301 d->selectedFiles->first();
302} 302}
303 303
304 304
305void PlayListWidget::addAllMusicToList() { 305void PlayListWidget::addAllMusicToList() {
306 306
307 audioView->populateView(); 307 audioView->populateView();
308 308
309 QListViewItemIterator audioIt( audioView ); 309 QListViewItemIterator audioIt( audioView );
310 DocLnk lnk; 310 DocLnk lnk;
311 QString filename; 311 QString filename;
312 // iterate through all items of the listview 312 // iterate through all items of the listview
313 for ( ; audioIt.current(); ++audioIt ) { 313 for ( ; audioIt.current(); ++audioIt ) {
314 filename = audioIt.current()->text(3); 314 filename = audioIt.current()->text(3);
315 lnk.setName( QFileInfo(filename).baseName() ); //sets name 315 lnk.setName( QFileInfo(filename).baseName() ); //sets name
316 lnk.setFile( filename ); //sets file name 316 lnk.setFile( filename ); //sets file name
317 d->selectedFiles->addToSelection( lnk); 317 d->selectedFiles->addToSelection( lnk);
318 } 318 }
319 319
320 /* if(!audioScan) 320 /* if(!audioScan)
321 scanForAudio(); 321 scanForAudio();
322 QListIterator<DocLnk> dit( files.children() ); 322 QListIterator<DocLnk> dit( files.children() );
323 for ( ; dit.current(); ++dit ) { 323 for ( ; dit.current(); ++dit ) {
324 if( QFileInfo(dit.current()->file() ).exists() ) { 324 if( QFileInfo(dit.current()->file() ).exists() ) {
325 d->selectedFiles->addToSelection( **dit ); 325 d->selectedFiles->addToSelection( **dit );
326 } 326 }
327 } 327 }
328 */ 328 */
329 tabWidget->setCurrentPage(0); 329 tabWidget->setCurrentPage(0);
330 writeCurrentM3u(); 330 writeCurrentM3u();
331 d->selectedFiles->first(); 331 d->selectedFiles->first();
332} 332}
333 333
334 334
335void PlayListWidget::addAllVideoToList() { 335void PlayListWidget::addAllVideoToList() {
336 336
337 videoView->populateView(); 337 videoView->populateView();
338 338
339 QListViewItemIterator videoIt( videoView ); 339 QListViewItemIterator videoIt( videoView );
340 DocLnk lnk; 340 DocLnk lnk;
341 QString filename; 341 QString filename;
342 for ( ; videoIt.current(); ++videoIt ) { 342 for ( ; videoIt.current(); ++videoIt ) {
343 filename = videoIt.current()->text(3); 343 filename = videoIt.current()->text(3);
344 lnk.setName( QFileInfo(filename).baseName() ); //sets name 344 lnk.setName( QFileInfo(filename).baseName() ); //sets name
345 lnk.setFile( filename ); //sets file name 345 lnk.setFile( filename ); //sets file name
346 d->selectedFiles->addToSelection( lnk); 346 d->selectedFiles->addToSelection( lnk);
347 } 347 }
348 348
349 349
350 /* if(!videoScan) 350 /* if(!videoScan)
351 scanForVideo(); 351 scanForVideo();
352 QListIterator<DocLnk> dit( vFiles.children() ); 352 QListIterator<DocLnk> dit( vFiles.children() );
353 for ( ; dit.current(); ++dit ) { 353 for ( ; dit.current(); ++dit ) {
354 if( QFileInfo( dit.current()->file() ).exists() ) { 354 if( QFileInfo( dit.current()->file() ).exists() ) {
355 d->selectedFiles->addToSelection( **dit ); 355 d->selectedFiles->addToSelection( **dit );
356 } 356 }
357 } 357 }
358*/ 358*/
359 tabWidget->setCurrentPage(0); 359 tabWidget->setCurrentPage(0);
360 writeCurrentM3u(); 360 writeCurrentM3u();
361 d->selectedFiles->first(); 361 d->selectedFiles->first();
362} 362}
363 363
364 364
365void PlayListWidget::setDocument( const QString& fileref ) { 365void PlayListWidget::setDocument( const QString& fileref ) {
366 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); 366 // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
367 fromSetDocument = TRUE; 367 fromSetDocument = TRUE;
368 if ( fileref.isNull() ) { 368 QFileInfo fileInfo(fileref);
369
370 if ( !fileInfo.exists() ) {
369 QMessageBox::warning( this, tr( "Invalid File" ), 371 QMessageBox::warning( this, tr( "Invalid File" ),
370 tr( "There was a problem in getting the file." ) ); 372 tr( "There was a problem in getting the file." ) );
371 return; 373 return;
372 } 374 }
373 375
374 clearList(); 376 clearList();
375 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 377 QString extension = fileInfo.extension(false);
376 readm3u( fileref ); 378
377 } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { 379 if( extension.find( "m3u", 0, false) != -1
378 readm3u( DocLnk( fileref).file() ); 380 || extension.find( "pls", 0, false) != -1 ) {
379 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 381 readListFromFile( fileref );
380 readPls( fileref );
381 } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
382 readPls( DocLnk( fileref).file() );
383 } else { 382 } else {
384 clearList(); 383 clearList();
385 addToSelection( DocLnk( fileref ) ); 384 DocLnk lnk;
385 lnk.setName( fileInfo.baseName() ); //sets name
386 lnk.setFile( fileref ); //sets file name
387 addToSelection( lnk );
386 writeCurrentM3u(); 388 writeCurrentM3u();
387 389
388 d->setDocumentUsed = TRUE; 390 d->setDocumentUsed = TRUE;
389 mediaPlayerState.setPlaying( FALSE ); 391 mediaPlayerState.setPlaying( FALSE );
390 mediaPlayerState.setPlaying( TRUE ); 392 mediaPlayerState.setPlaying( TRUE );
391 } 393 }
392} 394}
393 395
394 396
395void PlayListWidget::useSelectedDocument() { 397void PlayListWidget::useSelectedDocument() {
396 d->setDocumentUsed = FALSE; 398 d->setDocumentUsed = FALSE;
397} 399}
398 400
399 401
400const DocLnk *PlayListWidget::current() const { // this is fugly 402const DocLnk *PlayListWidget::current() const { // this is fugly
401 assert( currentTab() == CurrentPlayList ); 403 assert( currentTab() == CurrentPlayList );
402 404
403 const DocLnk *lnk = d->selectedFiles->current(); 405 const DocLnk *lnk = d->selectedFiles->current();
404 if ( !lnk ) { 406 if ( !lnk ) {
405 d->selectedFiles->first(); 407 d->selectedFiles->first();
406 lnk = d->selectedFiles->current(); 408 lnk = d->selectedFiles->current();
407 } 409 }
408 assert( lnk ); 410 assert( lnk );
409 return lnk; 411 return lnk;
410} 412}
411 413
412 414
413bool PlayListWidget::prev() { 415bool PlayListWidget::prev() {
414 if ( mediaPlayerState.isShuffled() ) { 416 if ( mediaPlayerState.isShuffled() ) {
415 const DocLnk *cur = current(); 417 const DocLnk *cur = current();
416 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 418 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
417 for ( int i = 0; i < j; i++ ) { 419 for ( int i = 0; i < j; i++ ) {
418 if ( !d->selectedFiles->next() ) 420 if ( !d->selectedFiles->next() )
419 d->selectedFiles->first(); 421 d->selectedFiles->first();
420 } 422 }
421 if ( cur == current() ) 423 if ( cur == current() )
422 if ( !d->selectedFiles->next() ) { 424 if ( !d->selectedFiles->next() ) {
423 d->selectedFiles->first(); 425 d->selectedFiles->first();
424 } 426 }
425 return TRUE; 427 return TRUE;
426 } else { 428 } else {
427 if ( !d->selectedFiles->prev() ) { 429 if ( !d->selectedFiles->prev() ) {
428 if ( mediaPlayerState.isLooping() ) { 430 if ( mediaPlayerState.isLooping() ) {
429 return d->selectedFiles->last(); 431 return d->selectedFiles->last();
430 } else { 432 } else {
431 return FALSE; 433 return FALSE;
432 } 434 }
433 } 435 }
434 return TRUE; 436 return TRUE;
435 } 437 }
436} 438}
437 439
438 440
439bool PlayListWidget::next() { 441bool PlayListWidget::next() {
440//qDebug("<<<<<<<<<<<<next()"); 442//qDebug("<<<<<<<<<<<<next()");
441 if ( mediaPlayerState.isShuffled() ) { 443 if ( mediaPlayerState.isShuffled() ) {
442 return prev(); 444 return prev();
443 } else { 445 } else {
444 if ( !d->selectedFiles->next() ) { 446 if ( !d->selectedFiles->next() ) {
445 if ( mediaPlayerState.isLooping() ) { 447 if ( mediaPlayerState.isLooping() ) {
446 return d->selectedFiles->first(); 448 return d->selectedFiles->first();
447 } else { 449 } else {
448 return FALSE; 450 return FALSE;
449 } 451 }
450 } 452 }
451 return TRUE; 453 return TRUE;
452 } 454 }
453} 455}
454 456
455 457
456bool PlayListWidget::first() { 458bool PlayListWidget::first() {
457 return d->selectedFiles->first(); 459 return d->selectedFiles->first();
458} 460}
459 461
460 462
461bool PlayListWidget::last() { 463bool PlayListWidget::last() {
462 return d->selectedFiles->last(); 464 return d->selectedFiles->last();
463} 465}
464 466
465 467
466 void PlayListWidget::saveList() { 468 void PlayListWidget::saveList() {
467 writem3u(); 469 writem3u();
468 } 470 }
469 471
470 472
471void PlayListWidget::loadList( const DocLnk & lnk) { 473void PlayListWidget::loadList( const DocLnk & lnk) {
472 QString name = lnk.name(); 474 QString name = lnk.name();
473 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 475 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
474 476
475 if( name.length()>0) { 477 if( name.length()>0) {
476 setCaption("OpiePlayer: "+name); 478 setCaption("OpiePlayer: "+name);
477// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 479// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
478 clearList(); 480 clearList();
479 readm3u(lnk.file()); 481// readm3u(lnk.file());
482 readListFromFile(lnk.file());
480 tabWidget->setCurrentPage(0); 483 tabWidget->setCurrentPage(0);
481 } 484 }
482} 485}
483 486
484void PlayListWidget::addSelected() { 487void PlayListWidget::addSelected() {
485 assert( inFileListMode() ); 488 assert( inFileListMode() );
486 489
487 QListViewItemIterator it( currentFileListView ); 490 QListViewItemIterator it( currentFileListView );
488 for ( ; it.current(); ++it ) 491 for ( ; it.current(); ++it )
489 if ( it.current()->isSelected() ) { 492 if ( it.current()->isSelected() ) {
490 QString filename = it.current()->text(3); 493 QString filename = it.current()->text(3);
491 494
492 DocLnk lnk; 495 DocLnk lnk;
493 lnk.setName( QFileInfo( filename ).baseName() ); //sets name 496 lnk.setName( QFileInfo( filename ).baseName() ); //sets name
494 lnk.setFile( filename ); //sets file name 497 lnk.setFile( filename ); //sets file name
495 498
496 d->selectedFiles->addToSelection( lnk ); 499 d->selectedFiles->addToSelection( lnk );
497 } 500 }
498 501
499 currentFileListView->clearSelection(); 502 currentFileListView->clearSelection();
500 503
501// tabWidget->setCurrentPage( 0 ); 504// tabWidget->setCurrentPage( 0 );
502 writeCurrentM3u(); 505 writeCurrentM3u();
503} 506}
504 507
505 508
506void PlayListWidget::removeSelected() { 509void PlayListWidget::removeSelected() {
507 d->selectedFiles->removeSelected( ); 510 d->selectedFiles->removeSelected( );
508 writeCurrentM3u(); 511 writeCurrentM3u();
509} 512}
510 513
511 514
512void PlayListWidget::playIt( QListViewItem *it) { 515void PlayListWidget::playIt( QListViewItem *it) {
513 if(!it) return; 516 if(!it) return;
514 mediaPlayerState.setPlaying(FALSE); 517 mediaPlayerState.setPlaying(FALSE);
515 mediaPlayerState.setPlaying(TRUE); 518 mediaPlayerState.setPlaying(TRUE);
516 d->selectedFiles->unSelect(); 519 d->selectedFiles->unSelect();
517} 520}
518 521
519 522
520void PlayListWidget::addToSelection( QListViewItem *it) { 523void PlayListWidget::addToSelection( QListViewItem *it) {
521 d->setDocumentUsed = FALSE; 524 d->setDocumentUsed = FALSE;
522 525
523 if(it) { 526 if(it) {
524 if ( currentTab() == CurrentPlayList ) 527 if ( currentTab() == CurrentPlayList )
525 return; 528 return;
526 // case 1: { 529 // case 1: {
527 DocLnk lnk; 530 DocLnk lnk;
528 QString filename; 531 QString filename;
529 532
530 filename=it->text(3); 533 filename=it->text(3);
531 lnk.setName( QFileInfo(filename).baseName() ); //sets name 534 lnk.setName( QFileInfo(filename).baseName() ); //sets name
532 lnk.setFile( filename ); //sets file name 535 lnk.setFile( filename ); //sets file name
533 d->selectedFiles->addToSelection( lnk); 536 d->selectedFiles->addToSelection( lnk);
534 537
535 writeCurrentM3u(); 538 writeCurrentM3u();
536// tabWidget->setCurrentPage(0); 539// tabWidget->setCurrentPage(0);
537 540
538 } 541 }
539} 542}
540 543
541 544
542void PlayListWidget::tabChanged(QWidget *) { 545void PlayListWidget::tabChanged(QWidget *) {
543 546
544 d->tbPlay->setEnabled( true ); 547 d->tbPlay->setEnabled( true );
545 548
546 disconnect( audioView, SIGNAL( itemsSelected( bool ) ), 549 disconnect( audioView, SIGNAL( itemsSelected( bool ) ),
547 d->tbPlay, SLOT( setEnabled( bool ) ) ); 550 d->tbPlay, SLOT( setEnabled( bool ) ) );
548 disconnect( videoView, SIGNAL( itemsSelected( bool ) ), 551 disconnect( videoView, SIGNAL( itemsSelected( bool ) ),
549 d->tbPlay, SLOT( setEnabled( bool ) ) ); 552 d->tbPlay, SLOT( setEnabled( bool ) ) );
550 553
551 currentFileListView = 0; 554 currentFileListView = 0;
552 555
553 switch ( currentTab() ) { 556 switch ( currentTab() ) {
554 case CurrentPlayList: 557 case CurrentPlayList:
555 { 558 {
556 if( !tbDeletePlaylist->isHidden() ) { 559 if( !tbDeletePlaylist->isHidden() ) {
557 tbDeletePlaylist->hide(); 560 tbDeletePlaylist->hide();
558 } 561 }
559 d->tbRemoveFromList->setEnabled(TRUE); 562 d->tbRemoveFromList->setEnabled(TRUE);
560 d->tbAddToList->setEnabled(FALSE); 563 d->tbAddToList->setEnabled(FALSE);
561 564
562 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); 565 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() );
563 } 566 }
564 break; 567 break;
565 case AudioFiles: 568 case AudioFiles:
566 { 569 {
567 audioView->populateView(); 570 audioView->populateView();
568 571
569 if( !tbDeletePlaylist->isHidden() ) { 572 if( !tbDeletePlaylist->isHidden() ) {
570 tbDeletePlaylist->hide(); 573 tbDeletePlaylist->hide();
571 } 574 }
572 d->tbRemoveFromList->setEnabled(FALSE); 575 d->tbRemoveFromList->setEnabled(FALSE);
573 d->tbAddToList->setEnabled(TRUE); 576 d->tbAddToList->setEnabled(TRUE);
574 577
575 connect( audioView, SIGNAL( itemsSelected( bool ) ), 578 connect( audioView, SIGNAL( itemsSelected( bool ) ),
576 d->tbPlay, SLOT( setEnabled( bool ) ) ); 579 d->tbPlay, SLOT( setEnabled( bool ) ) );
577 580
578 d->tbPlay->setEnabled( audioView->hasSelection() ); 581 d->tbPlay->setEnabled( audioView->hasSelection() );
579 582
580 currentFileListView = audioView; 583 currentFileListView = audioView;
581 } 584 }
582 break; 585 break;
583 case VideoFiles: 586 case VideoFiles:
584 { 587 {
585 videoView->populateView(); 588 videoView->populateView();
586 if( !tbDeletePlaylist->isHidden() ) { 589 if( !tbDeletePlaylist->isHidden() ) {
587 tbDeletePlaylist->hide(); 590 tbDeletePlaylist->hide();
588 } 591 }
589 d->tbRemoveFromList->setEnabled(FALSE); 592 d->tbRemoveFromList->setEnabled(FALSE);
590 d->tbAddToList->setEnabled(TRUE); 593 d->tbAddToList->setEnabled(TRUE);
591 594
592 connect( videoView, SIGNAL( itemsSelected( bool ) ), 595 connect( videoView, SIGNAL( itemsSelected( bool ) ),
593 d->tbPlay, SLOT( setEnabled( bool ) ) ); 596 d->tbPlay, SLOT( setEnabled( bool ) ) );
594 597
595 d->tbPlay->setEnabled( videoView->hasSelection() ); 598 d->tbPlay->setEnabled( videoView->hasSelection() );
596 599
597 currentFileListView = videoView; 600 currentFileListView = videoView;
598 } 601 }
599 break; 602 break;
600 case PlayLists: 603 case PlayLists:
601 { 604 {
602 if( tbDeletePlaylist->isHidden() ) { 605 if( tbDeletePlaylist->isHidden() ) {
603 tbDeletePlaylist->show(); 606 tbDeletePlaylist->show();
604 } 607 }
605 playLists->reread(); 608 playLists->reread();
606 d->tbAddToList->setEnabled(FALSE); 609 d->tbAddToList->setEnabled(FALSE);
607 610
608 d->tbPlay->setEnabled( false ); 611 d->tbPlay->setEnabled( false );
609 } 612 }
610 break; 613 break;
611 }; 614 };
612} 615}
613 616
614 617
615void PlayListWidget::btnPlay(bool b) { 618void PlayListWidget::btnPlay(bool b) {
616// mediaPlayerState->setPlaying(false); 619// mediaPlayerState->setPlaying(false);
617 mediaPlayerState.setPlaying(b); 620 mediaPlayerState.setPlaying(b);
618 insanityBool=FALSE; 621 insanityBool=FALSE;
619} 622}
620 623
621void PlayListWidget::deletePlaylist() { 624void PlayListWidget::deletePlaylist() {
622 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 625 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
623 (tr("You really want to delete\nthis playlist?")), 626 (tr("You really want to delete\nthis playlist?")),
624 (tr("Yes")), (tr("No")), 0 )){ 627 (tr("Yes")), (tr("No")), 0 )){
625 case 0: // Yes clicked, 628 case 0: // Yes clicked,
626 QFile().remove(playLists->selectedDocument().file()); 629 QFile().remove(playLists->selectedDocument().file());
627 QFile().remove(playLists->selectedDocument().linkFile()); 630 QFile().remove(playLists->selectedDocument().linkFile());
628 playLists->reread(); 631 playLists->reread();
629 break; 632 break;
630 case 1: // Cancel 633 case 1: // Cancel
631 break; 634 break;
632 }; 635 };
633} 636}
634 637
635 638
636void PlayListWidget::playSelected() { 639void PlayListWidget::playSelected() {
637 btnPlay( TRUE); 640 btnPlay( TRUE);
638} 641}
639 642
640bool PlayListWidget::inFileListMode() const 643bool PlayListWidget::inFileListMode() const
641{ 644{
642 TabType tab = currentTab(); 645 TabType tab = currentTab();
643 return tab == AudioFiles || tab == VideoFiles; 646 return tab == AudioFiles || tab == VideoFiles;
644} 647}
645 648
646void PlayListWidget::openFile() { 649void PlayListWidget::openFile() {
647 // http://66.28.164.33:2080 650 // http://66.28.164.33:2080
648 // http://somafm.com/star0242.m3u 651 // http://somafm.com/star0242.m3u
649 QString filename, name; 652 QString filename, name;
650 InputDialog *fileDlg; 653 InputDialog *fileDlg;
651 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 654 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
652 fileDlg->exec(); 655 fileDlg->exec();
653 if( fileDlg->result() == 1 ) { 656 if( fileDlg->result() == 1 ) {
654 filename = fileDlg->text(); 657 filename = fileDlg->text();
655 qDebug( "Selected filename is " + filename ); 658 qDebug( "Selected filename is " + filename );
656 // Om3u *m3uList; 659 // Om3u *m3uList;
657 DocLnk lnk; 660 DocLnk lnk;
658 Config cfg( "OpiePlayer" ); 661 Config cfg( "OpiePlayer" );
659 cfg.setGroup("PlayList"); 662 cfg.setGroup("PlayList");
660 663
661 if(filename.left(4) == "http") { 664 if(filename.left(4) == "http") {
662 QString m3uFile, m3uFilePath; 665 QString m3uFile, m3uFilePath;
663 if(filename.find(":",8,TRUE) != -1) { //found a port 666 if(filename.find(":",8,TRUE) != -1) { //found a port
664 m3uFile = filename.left( filename.find( ":",8,TRUE)); 667 m3uFile = filename.left( filename.find( ":",8,TRUE));
665 m3uFile = m3uFile.right( 7); 668 m3uFile = m3uFile.right( 7);
666 } else if(filename.left(4) == "http"){ 669 } else if(filename.left(4) == "http"){
667 m3uFile=filename; 670 m3uFile=filename;
668 m3uFile = m3uFile.right( m3uFile.length() - 7); 671 m3uFile = m3uFile.right( m3uFile.length() - 7);
669 } else{ 672 } else{
670 m3uFile=filename; 673 m3uFile=filename;
671 } 674 }
672 675
673// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 676// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
674 lnk.setName( filename ); //sets name 677 lnk.setName( filename ); //sets name
675 lnk.setFile( filename ); //sets file name 678 lnk.setFile( filename ); //sets file name
676 679
677// lnk.setIcon("opieplayer2/musicfile"); 680// lnk.setIcon("opieplayer2/musicfile");
678 681
679 d->selectedFiles->addToSelection( lnk ); 682 d->selectedFiles->addToSelection( lnk );
680 writeCurrentM3u(); 683 writeCurrentM3u();
681 d->selectedFiles->setSelectedItem( lnk.name()); 684 d->selectedFiles->setSelectedItem( lnk.name());
682 } 685 }
683 else if( filename.right( 3) == "m3u" ) { 686 else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) {
684 readm3u( filename ); 687 readListFromFile( filename );
685 688// readPls( filename );
686 } else if( filename.right(3) == "pls" ) {
687 readPls( filename );
688 } else { 689 } else {
689 lnk.setName( QFileInfo(filename).baseName() ); //sets name 690 lnk.setName( QFileInfo(filename).baseName() ); //sets name
690 lnk.setFile( filename ); //sets file name 691 lnk.setFile( filename ); //sets file name
691 d->selectedFiles->addToSelection( lnk); 692 d->selectedFiles->addToSelection( lnk);
692 writeCurrentM3u(); 693 writeCurrentM3u();
693 d->selectedFiles->setSelectedItem( lnk.name()); 694 d->selectedFiles->setSelectedItem( lnk.name());
694 } 695 }
695 } 696 }
696 697
698
697 delete fileDlg; 699 delete fileDlg;
698} 700}
699 701
700/* 702void PlayListWidget::readListFromFile( const QString &filename ) {
701reads m3u and shows files/urls to playlist widget */ 703 qDebug( "read list filename " + filename );
702void PlayListWidget::readm3u( const QString &filename ) { 704 QFileInfo fi(filename);
703 qDebug( "read m3u filename " + filename );
704
705 Om3u *m3uList; 705 Om3u *m3uList;
706 QString s, name; 706 QString s, name;
707 m3uList = new Om3u( filename, IO_ReadOnly ); 707 m3uList = new Om3u( filename, IO_ReadOnly );
708 m3uList->readM3u(); 708 if(fi.extension(false).find("m3u",0,false) != -1 )
709 m3uList->readM3u();
710 else if(fi.extension(false).find("pls",0,false) != -1 )
711 m3uList->readPls();
712
709 DocLnk lnk; 713 DocLnk lnk;
710 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 714 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
711 s = *it; 715 s = *it;
712// qDebug("reading "+ s); 716 // qDebug(s);
713 if(s.left(4)=="http") { 717 if(s.left(4)=="http") {
714 lnk.setName( s ); //sets file name 718 lnk.setName( s ); //sets file name
715 lnk.setIcon("opieplayer2/musicfile"); 719 lnk.setIcon("opieplayer2/musicfile");
716 lnk.setFile( s ); //sets file name 720 lnk.setFile( s ); //sets file name
717 721
718 } else { 722 } else { //is file
719 // if( QFileInfo( s ).exists() ) {
720 lnk.setName( QFileInfo(s).baseName()); 723 lnk.setName( QFileInfo(s).baseName());
721 // if(s.right(4) == '.') {//if regular file
722 if(s.left(1) != "/") { 724 if(s.left(1) != "/") {
723 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 725
724 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 726 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
725// lnk.setIcon(MimeType(s).pixmap() );
726// lnk.setIcon("SoundPlayer");
727 } else { 727 } else {
728 // qDebug("set link2 "+s);
729 lnk.setFile( s); 728 lnk.setFile( s);
730// lnk.setIcon(MimeType(s).pixmap() );
731// lnk.setIcon("SoundPlayer");
732 } 729 }
733 } 730 }
734 d->selectedFiles->addToSelection( lnk ); 731 d->selectedFiles->addToSelection( lnk );
735 } 732 }
736 Config config( "OpiePlayer" ); 733 Config config( "OpiePlayer" );
737 config.setGroup( "PlayList" ); 734 config.setGroup( "PlayList" );
738 735
739 config.writeEntry("CurrentPlaylist",filename); 736 config.writeEntry("CurrentPlaylist",filename);
740 config.write(); 737 config.write();
741 currentPlayList=filename; 738 currentPlayList=filename;
742 739
743// m3uList->write(); 740// m3uList->write();
744 m3uList->close(); 741 m3uList->close();
745 delete m3uList; 742 delete m3uList;
746 743
747 d->selectedFiles->setSelectedItem( s); 744 d->selectedFiles->setSelectedItem( s);
748 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 745 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
749 746
750} 747}
751 748
752/* 749// /*
753reads pls and adds files/urls to playlist */ 750// reads pls and adds files/urls to playlist */
754void PlayListWidget::readPls( const QString &filename ) { 751// void PlayListWidget::readPls( const QString &filename ) {
755 752
756 qDebug( "pls filename is " + filename ); 753// qDebug( "pls filename is " + filename );
757 Om3u *m3uList; 754// Om3u *m3uList;
758 QString s, name; 755// QString s, name;
759 m3uList = new Om3u( filename, IO_ReadOnly ); 756// m3uList = new Om3u( filename, IO_ReadOnly );
760 m3uList->readPls(); 757// m3uList->readPls();
761 758
762 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 759// for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
763 s = *it; 760// s = *it;
764 // s.replace( QRegExp( "%20" )," " ); 761// // s.replace( QRegExp( "%20" )," " );
765 DocLnk lnk( s ); 762// DocLnk lnk( s );
766 QFileInfo f( s ); 763// QFileInfo f( s );
767 QString name = f.baseName(); 764// QString name = f.baseName();
768 765
769 if( name.left( 4 ) == "http" ) { 766// if( name.left( 4 ) == "http" ) {
770 name = s.right( s.length() - 7); 767// name = s.right( s.length() - 7);
771 } else { 768// } else {
772 name = s; 769// name = s;
773 } 770// }
774 771
775 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 772// name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
776 773
777 lnk.setName( name ); 774// lnk.setName( name );
778 if( s.at( s.length() - 4) == '.') {// if this is probably a file 775// if( s.at( s.length() - 4) == '.') {// if this is probably a file
779 lnk.setFile( s ); 776// lnk.setFile( s );
780 } else { //if its a url 777// } else { //if its a url
781// if( name.right( 1 ).find( '/' ) == -1) { 778// // if( name.right( 1 ).find( '/' ) == -1) {
782// s += "/"; 779// // s += "/";
783// } 780// // }
784 lnk.setFile( s ); 781// lnk.setFile( s );
785 } 782// }
786 lnk.setType( "audio/x-mpegurl" ); 783// lnk.setType( "audio/x-mpegurl" );
787 784
788 lnk.writeLink(); 785// lnk.writeLink();
789 d->selectedFiles->addToSelection( lnk ); 786// d->selectedFiles->addToSelection( lnk );
790 } 787// }
791 788
792 m3uList->close(); 789// m3uList->close();
793 delete m3uList; 790// delete m3uList;
794} 791// }
795 792
796/* 793// /*
797 writes current playlist to current m3u file */ 794// writes current playlist to current m3u file */
798void PlayListWidget::writeCurrentM3u() { 795 void PlayListWidget::writeCurrentM3u() {
799 qDebug("writing to current m3u"); 796 qDebug("writing to current m3u");
800 Config cfg( "OpiePlayer" ); 797 Config cfg( "OpiePlayer" );
801 cfg.setGroup("PlayList"); 798 cfg.setGroup("PlayList");
802 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 799 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
803 800
804 Om3u *m3uList; 801 Om3u *m3uList;
805 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 802 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
806 if( d->selectedFiles->first()) { 803 if( d->selectedFiles->first()) {
807 804
808 do { 805 do {
809 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 806 // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
810 m3uList->add( d->selectedFiles->current()->file() ); 807 m3uList->add( d->selectedFiles->current()->file() );
811 } 808 }
812 while ( d->selectedFiles->next() ); 809 while ( d->selectedFiles->next() );
813 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 810 // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
814 m3uList->write(); 811 m3uList->write();
815 m3uList->close(); 812 m3uList->close();
816 } 813 }
817 delete m3uList; 814 delete m3uList;
818 815
819} 816 }
820 817
821 /* 818 /*
822 writes current playlist to m3u file */ 819 writes current playlist to m3u file */
823void PlayListWidget::writem3u() { 820void PlayListWidget::writem3u() {
824 InputDialog *fileDlg; 821 InputDialog *fileDlg;
825 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 822 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
826 fileDlg->exec(); 823 fileDlg->exec();
827 QString name, filename, list; 824 QString name, filename, list;
828 Om3u *m3uList; 825 Om3u *m3uList;
829 826
830 if( fileDlg->result() == 1 ) { 827 if( fileDlg->result() == 1 ) {
831 name = fileDlg->text(); 828 name = fileDlg->text();
832// qDebug( filename ); 829// qDebug( filename );
833 830
834 if( name.left( 1) != "/" ) { 831 if( name.left( 1) != "/" ) {
835 filename = QPEApplication::documentDir() + "/" + name; 832 filename = QPEApplication::documentDir() + "/" + name;
836 } 833 }
837 834
838 if( name.right( 3 ) != "m3u" ) { 835 if( name.right( 3 ) != "m3u" ) {
839 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 836 filename = QPEApplication::documentDir() + "/" +name+".m3u";
840 } 837 }
841 838
842 if( d->selectedFiles->first()) { 839 if( d->selectedFiles->first()) {
843 m3uList = new Om3u(filename, IO_ReadWrite); 840 m3uList = new Om3u(filename, IO_ReadWrite);
844 841
845 do { 842 do {
846 m3uList->add( d->selectedFiles->current()->file()); 843 m3uList->add( d->selectedFiles->current()->file());
847 } 844 }
848 while ( d->selectedFiles->next() ); 845 while ( d->selectedFiles->next() );
849 // qDebug( list ); 846 // qDebug( list );
850 m3uList->write(); 847 m3uList->write();
851 m3uList->close(); 848 m3uList->close();
852 delete m3uList; 849 delete m3uList;
853 850
854 delete fileDlg; 851 delete fileDlg;
855 852
856 DocLnk lnk; 853 DocLnk lnk;
857 lnk.setFile( filename); 854 lnk.setFile( filename);
858 lnk.setIcon("opieplayer2/playlist2"); 855 lnk.setIcon("opieplayer2/playlist2");
859 lnk.setName( name); //sets file name 856 lnk.setName( name); //sets file name
860 857
861 // qDebug(filename); 858 // qDebug(filename);
862 Config config( "OpiePlayer" ); 859 Config config( "OpiePlayer" );
863 config.setGroup( "PlayList" ); 860 config.setGroup( "PlayList" );
864 861
865 config.writeEntry("CurrentPlaylist",filename); 862 config.writeEntry("CurrentPlaylist",filename);
866 currentPlayList=filename; 863 currentPlayList=filename;
867 864
868 if(!lnk.writeLink()) { 865 if(!lnk.writeLink()) {
869 qDebug("Writing doclink did not work"); 866 qDebug("Writing doclink did not work");
870 } 867 }
871 868
872 setCaption(tr("OpiePlayer: ") + name); 869 setCaption(tr("OpiePlayer: ") + name);
873 } 870 }
874 } 871 }
875} 872}
876 873
877void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 874void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
878 switch ( e->key() ) { 875 switch ( e->key() ) {
879 ////////////////////////////// Zaurus keys 876 ////////////////////////////// Zaurus keys
880 case Key_F9: //activity 877 case Key_F9: //activity
881 // if(audioUI->isHidden()) 878 // if(audioUI->isHidden())
882 // audioUI->showMaximized(); 879 // audioUI->showMaximized();
883 break; 880 break;
884 case Key_F10: //contacts 881 case Key_F10: //contacts
885 // if( videoUI->isHidden()) 882 // if( videoUI->isHidden())
886 // videoUI->showMaximized(); 883 // videoUI->showMaximized();
887 break; 884 break;
888 case Key_F11: //menu 885 case Key_F11: //menu
889 break; 886 break;
890 case Key_F12: //home 887 case Key_F12: //home
891 // doBlank(); 888 // doBlank();
892 break; 889 break;
893 case Key_F13: //mail 890 case Key_F13: //mail
894 // doUnblank(); 891 // doUnblank();
895 break; 892 break;
896 case Key_Q: //add to playlist 893 case Key_Q: //add to playlist
897 addSelected(); 894 addSelected();
898 break; 895 break;
899 case Key_R: //remove from playlist 896 case Key_R: //remove from playlist
900 removeSelected(); 897 removeSelected();
901 break; 898 break;
902 // case Key_P: //play 899 // case Key_P: //play
903 // qDebug("Play"); 900 // qDebug("Play");
904 // playSelected(); 901 // playSelected();
905 // break; 902 // break;
906 case Key_Space: 903 case Key_Space:
907 // playSelected(); puh 904 // playSelected(); puh
908 break; 905 break;
909 case Key_1: 906 case Key_1:
910 tabWidget->setCurrentPage( 0 ); 907 tabWidget->setCurrentPage( 0 );
911 break; 908 break;
912 case Key_2: 909 case Key_2:
913 tabWidget->setCurrentPage( 1 ); 910 tabWidget->setCurrentPage( 1 );
914 break; 911 break;
915 case Key_3: 912 case Key_3:
916 tabWidget->setCurrentPage( 2 ); 913 tabWidget->setCurrentPage( 2 );
917 break; 914 break;
918 case Key_4: 915 case Key_4:
919 tabWidget->setCurrentPage( 3 ); 916 tabWidget->setCurrentPage( 3 );
920 break; 917 break;
921 case Key_Down: 918 case Key_Down:
922 if ( !d->selectedFiles->next() ) 919 if ( !d->selectedFiles->next() )
923 d->selectedFiles->first(); 920 d->selectedFiles->first();
924 break; 921 break;
925 case Key_Up: 922 case Key_Up:
926 if ( !d->selectedFiles->prev() ) 923 if ( !d->selectedFiles->prev() )
927 // d->selectedFiles->last(); 924 // d->selectedFiles->last();
928 break; 925 break;
929 } 926 }
930} 927}
931 928
932void PlayListWidget::pmViewActivated(int index) { 929void PlayListWidget::pmViewActivated(int index) {
933// qDebug("%d", index); 930// qDebug("%d", index);
934 switch(index) { 931 switch(index) {
935 case -16: 932 case -16:
936 { 933 {
937 mediaPlayerState.toggleFullscreen(); 934 mediaPlayerState.toggleFullscreen();
938 bool b=mediaPlayerState.isFullscreen(); 935 bool b=mediaPlayerState.isFullscreen();
939 pmView->setItemChecked( index, b); 936 pmView->setItemChecked( index, b);
940 Config cfg( "OpiePlayer" ); 937 Config cfg( "OpiePlayer" );
941 cfg.writeEntry( "FullScreen", b ); 938 cfg.writeEntry( "FullScreen", b );
942 } 939 }
943 break; 940 break;
944 }; 941 };
945} 942}
946 943
947void PlayListWidget::populateSkinsMenu() { 944void PlayListWidget::populateSkinsMenu() {
948 int item = 0; 945 int item = 0;
949 defaultSkinIndex = 0; 946 defaultSkinIndex = 0;
950 QString skinName; 947 QString skinName;
951 Config cfg( "OpiePlayer" ); 948 Config cfg( "OpiePlayer" );
952 cfg.setGroup("Options" ); 949 cfg.setGroup("Options" );
953 QString skin = cfg.readEntry( "Skin", "default" ); 950 QString skin = cfg.readEntry( "Skin", "default" );
954 951
955 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 952 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
956 skinsDir.setFilter( QDir::Dirs ); 953 skinsDir.setFilter( QDir::Dirs );
957 skinsDir.setSorting(QDir::Name ); 954 skinsDir.setSorting(QDir::Name );
958 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 955 const QFileInfoList *skinslist = skinsDir.entryInfoList();
959 QFileInfoListIterator it( *skinslist ); 956 QFileInfoListIterator it( *skinslist );
960 QFileInfo *fi; 957 QFileInfo *fi;
961 while ( ( fi = it.current() ) ) { 958 while ( ( fi = it.current() ) ) {
962 skinName = fi->fileName(); 959 skinName = fi->fileName();
963// qDebug( fi->fileName() ); 960// qDebug( fi->fileName() );
964 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 961 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
965 item = skinsMenu->insertItem( fi->fileName() ) ; 962 item = skinsMenu->insertItem( fi->fileName() ) ;
966 } 963 }
967 if( skinName == "default" ) { 964 if( skinName == "default" ) {
968 defaultSkinIndex = item; 965 defaultSkinIndex = item;
969 } 966 }
970 if( skinName == skin ) { 967 if( skinName == skin ) {
971 skinsMenu->setItemChecked( item, TRUE ); 968 skinsMenu->setItemChecked( item, TRUE );
972 } 969 }
973 ++it; 970 ++it;
974 } 971 }
975} 972}
976 973
977void PlayListWidget::skinsMenuActivated( int item ) { 974void PlayListWidget::skinsMenuActivated( int item ) {
978 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 975 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
979 skinsMenu->setItemChecked( i, FALSE ); 976 skinsMenu->setItemChecked( i, FALSE );
980 } 977 }
981 skinsMenu->setItemChecked( item, TRUE ); 978 skinsMenu->setItemChecked( item, TRUE );
982 979
983 { 980 {
984 Config cfg( "OpiePlayer" ); 981 Config cfg( "OpiePlayer" );
985 cfg.setGroup("Options"); 982 cfg.setGroup("Options");
986 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 983 cfg.writeEntry("Skin", skinsMenu->text( item ) );
987 } 984 }
988 985
989 emit skinSelected(); 986 emit skinSelected();
990} 987}
991 988
992PlayListWidget::TabType PlayListWidget::currentTab() const 989PlayListWidget::TabType PlayListWidget::currentTab() const
993{ 990{
994 static const TabType indexToTabType[ TabTypeCount ] = 991 static const TabType indexToTabType[ TabTypeCount ] =
995 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 992 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
996 993
997 int index = tabWidget->currentPageIndex(); 994 int index = tabWidget->currentPageIndex();
998 assert( index < TabTypeCount && index >= 0 ); 995 assert( index < TabTypeCount && index >= 0 );
999 996
1000 return indexToTabType[ index ]; 997 return indexToTabType[ index ];
1001} 998}
1002 999
1003PlayListWidget::Entry PlayListWidget::currentEntry() const 1000PlayListWidget::Entry PlayListWidget::currentEntry() const
1004{ 1001{
1005 if ( currentTab() == CurrentPlayList ) { 1002 if ( currentTab() == CurrentPlayList ) {
1006 const DocLnk *lnk = current(); 1003 const DocLnk *lnk = current();
1007 return Entry( lnk->name(), lnk->file() ); 1004 return Entry( lnk->name(), lnk->file() );
1008 } 1005 }
1009 1006
1010 return Entry( currentFileListPathName() ); 1007 return Entry( currentFileListPathName() );
1011} 1008}
1012 1009
1013QString PlayListWidget::currentFileListPathName() const { 1010QString PlayListWidget::currentFileListPathName() const {
1014 return currentFileListView->currentItem()->text( 3 ); 1011 return currentFileListView->currentItem()->text( 3 );
1015} 1012}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index e8bf211..cb65d5c 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -1,138 +1,139 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef PLAY_LIST_WIDGET_H 34#ifndef PLAY_LIST_WIDGET_H
35#define PLAY_LIST_WIDGET_H 35#define PLAY_LIST_WIDGET_H
36 36
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qpe/applnk.h> 38#include <qpe/applnk.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qpe/fileselector.h> 40#include <qpe/fileselector.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qpopupmenu.h> 42#include <qpopupmenu.h>
43 43
44#include "playlistwidgetgui.h" 44#include "playlistwidgetgui.h"
45 45
46 46
47//class PlayListWidgetPrivate; 47//class PlayListWidgetPrivate;
48class Config; 48class Config;
49class QListViewItem; 49class QListViewItem;
50class QListView; 50class QListView;
51class QPoint; 51class QPoint;
52class QAction; 52class QAction;
53class QLabel; 53class QLabel;
54 54
55class PlayListWidget : public PlayListWidgetGui { 55class PlayListWidget : public PlayListWidgetGui {
56 Q_OBJECT 56 Q_OBJECT
57public: 57public:
58 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 58 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
59 enum { TabTypeCount = 4 }; 59 enum { TabTypeCount = 4 };
60 60
61 struct Entry 61 struct Entry
62 { 62 {
63 Entry( const QString &_name, const QString &_fileName ) 63 Entry( const QString &_name, const QString &_fileName )
64 : name( _name ), file( _fileName ) {} 64 : name( _name ), file( _fileName ) {}
65 Entry( const QString &_fileName ) 65 Entry( const QString &_fileName )
66 : name( _fileName ), file( _fileName ) {} 66 : name( _fileName ), file( _fileName ) {}
67 67
68 QString name; 68 QString name;
69 QString file; 69 QString file;
70 }; 70 };
71 71
72 PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 72 PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
73 ~PlayListWidget(); 73 ~PlayListWidget();
74 74
75 // retrieve the current playlist entry (media file link) 75 // retrieve the current playlist entry (media file link)
76 const DocLnk *current() const; 76 const DocLnk *current() const;
77 void useSelectedDocument(); 77 void useSelectedDocument();
78 TabType currentTab() const; 78 TabType currentTab() const;
79 79
80 Entry currentEntry() const; 80 Entry currentEntry() const;
81 81
82public slots: 82public slots:
83 bool first(); 83 bool first();
84 bool last(); 84 bool last();
85 bool next(); 85 bool next();
86 bool prev(); 86 bool prev();
87 void writeDefaultPlaylist( ); 87 void writeDefaultPlaylist( );
88 QString currentFileListPathName() const; 88 QString currentFileListPathName() const;
89protected: 89protected:
90 void keyReleaseEvent( QKeyEvent *e); 90 void keyReleaseEvent( QKeyEvent *e);
91 91
92signals: 92signals:
93 void skinSelected(); 93 void skinSelected();
94 94
95private: 95private:
96 int defaultSkinIndex; 96 int defaultSkinIndex;
97 void readm3u(const QString &); 97/* void readm3u(const QString &); */
98 void readPls(const QString &); 98/* void readPls(const QString &); */
99 void readListFromFile(const QString &);
99 void initializeStates(); 100 void initializeStates();
100 101
101 bool inFileListMode() const; 102 bool inFileListMode() const;
102 103
103private slots: 104private slots:
104 void populateSkinsMenu(); 105 void populateSkinsMenu();
105 void skinsMenuActivated(int); 106 void skinsMenuActivated(int);
106 void pmViewActivated(int); 107 void pmViewActivated(int);
107 void writem3u(); 108 void writem3u();
108 void writeCurrentM3u(); 109 void writeCurrentM3u();
109 void openFile(); 110 void openFile();
110 void setDocument( const QString& fileref ); 111 void setDocument( const QString& fileref );
111 void addToSelection( const DocLnk& ); // Add a media file to the playlist 112 void addToSelection( const DocLnk& ); // Add a media file to the playlist
112 void addToSelection( QListViewItem* ); // Add a media file to the playlist 113 void addToSelection( QListViewItem* ); // Add a media file to the playlist
113 void clearList(); 114 void clearList();
114 void addAllToList(); 115 void addAllToList();
115 void addAllMusicToList(); 116 void addAllMusicToList();
116 void addAllVideoToList(); 117 void addAllVideoToList();
117 void saveList(); // Save the playlist 118 void saveList(); // Save the playlist
118 void loadList( const DocLnk &); // Load a playlist 119 void loadList( const DocLnk &); // Load a playlist
119 void playIt( QListViewItem *); 120 void playIt( QListViewItem *);
120 void btnPlay(bool); 121 void btnPlay(bool);
121 void deletePlaylist(); 122 void deletePlaylist();
122 void addSelected(); 123 void addSelected();
123 void removeSelected(); 124 void removeSelected();
124 void tabChanged(QWidget*); 125 void tabChanged(QWidget*);
125 void viewPressed( int, QListViewItem *, const QPoint&, int); 126 void viewPressed( int, QListViewItem *, const QPoint&, int);
126 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 127 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
127 void playSelected(); 128 void playSelected();
128 129
129private: 130private:
130 bool fromSetDocument; 131 bool fromSetDocument;
131 bool insanityBool; 132 bool insanityBool;
132 QString setDocFileRef, currentPlayList; 133 QString setDocFileRef, currentPlayList;
133 int selected; 134 int selected;
134 QListView *currentFileListView; 135 QListView *currentFileListView;
135}; 136};
136 137
137#endif // PLAY_LIST_WIDGET_H 138#endif // PLAY_LIST_WIDGET_H
138 139