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