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