summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-14 02:56:04 (UTC)
committer llornkcor <llornkcor>2002-11-14 02:56:04 (UTC)
commit4a60497bd689bd01ca301378f382bff6863b592e (patch) (unidiff)
tree3b9926eb8f6f89b204eaca2a443b6bb9b5e9f883
parent3bfb64a41ca7948b593982fc1c266d5ec829b9ab (diff)
downloadopie-4a60497bd689bd01ca301378f382bff6863b592e.zip
opie-4a60497bd689bd01ca301378f382bff6863b592e.tar.gz
opie-4a60497bd689bd01ca301378f382bff6863b592e.tar.bz2
no longer scans and populates audio_video lists everytime tab is changed. rescan from File menu does it except for the first tab change
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp18
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h2
2 files changed, 13 insertions, 7 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index c2b5c77..6bedb57 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,350 +1,352 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpetoolbar.h> 34#include <qpe/qpetoolbar.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/storage.h> 36#include <qpe/storage.h>
37#include <qpe/mimetype.h> 37#include <qpe/mimetype.h>
38#include <qpe/global.h> 38#include <qpe/global.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40 40
41#include <qdatetime.h> 41#include <qdatetime.h>
42#include <qdir.h> 42#include <qdir.h>
43#include <qmessagebox.h> 43#include <qmessagebox.h>
44#include <qregexp.h> 44#include <qregexp.h>
45#include <qtextstream.h> 45#include <qtextstream.h>
46 46
47#include "playlistselection.h" 47#include "playlistselection.h"
48#include "playlistwidget.h" 48#include "playlistwidget.h"
49#include "mediaplayerstate.h" 49#include "mediaplayerstate.h"
50#include "inputDialog.h" 50#include "inputDialog.h"
51#include "om3u.h" 51#include "om3u.h"
52 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;
160 videoPopulated=false;
159 populateSkinsMenu(); 161 populateSkinsMenu();
160 initializeStates(); 162 initializeStates();
161 163
162 cfg.setGroup("PlayList"); 164 cfg.setGroup("PlayList");
163 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 165 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
164 loadList(DocLnk( currentPlaylist ) ); 166 loadList(DocLnk( currentPlaylist ) );
165} 167}
166 168
167 169
168PlayListWidget::~PlayListWidget() { 170PlayListWidget::~PlayListWidget() {
169 if ( d->current ) { 171 if ( d->current ) {
170 delete d->current; 172 delete d->current;
171 } 173 }
172 delete d; 174 delete d;
173} 175}
174 176
175 177
176void PlayListWidget::initializeStates() { 178void PlayListWidget::initializeStates() {
177 d->tbPlay->setOn( mediaPlayerState->playing() ); 179 d->tbPlay->setOn( mediaPlayerState->playing() );
178 d->tbLoop->setOn( mediaPlayerState->looping() ); 180 d->tbLoop->setOn( mediaPlayerState->looping() );
179 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 181 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
180 setPlaylist( true ); 182 setPlaylist( true );
181} 183}
182 184
183void PlayListWidget::writeDefaultPlaylist() { 185void PlayListWidget::writeDefaultPlaylist() {
184 186
185 Config config( "OpiePlayer" ); 187 Config config( "OpiePlayer" );
186 config.setGroup( "PlayList" ); 188 config.setGroup( "PlayList" );
187 QString filename=QPEApplication::documentDir() + "/default.m3u"; 189 QString filename=QPEApplication::documentDir() + "/default.m3u";
188 QString currentString = config.readEntry( "CurrentPlaylist", filename); 190 QString currentString = config.readEntry( "CurrentPlaylist", filename);
189 if( currentString == filename) { 191 if( currentString == filename) {
190 Om3u *m3uList; 192 Om3u *m3uList;
191 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); 193 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
192 if( d->selectedFiles->first() ) { 194 if( d->selectedFiles->first() ) {
193 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 195 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
194 do { 196 do {
195 // qDebug(d->selectedFiles->current()->file()); 197 // qDebug(d->selectedFiles->current()->file());
196 m3uList->add( d->selectedFiles->current()->file() ); 198 m3uList->add( d->selectedFiles->current()->file() );
197 } 199 }
198 while ( d->selectedFiles->next() ); 200 while ( d->selectedFiles->next() );
199 201
200 m3uList->write(); 202 m3uList->write();
201 m3uList->close(); 203 m3uList->close();
202 if(m3uList) delete m3uList; 204 if(m3uList) delete m3uList;
203 205
204 } 206 }
205 } 207 }
206} 208}
207 209
208void PlayListWidget::addToSelection( const DocLnk& lnk ) { 210void PlayListWidget::addToSelection( const DocLnk& lnk ) {
209 d->setDocumentUsed = FALSE; 211 d->setDocumentUsed = FALSE;
210 if ( mediaPlayerState->playlist() ) { 212 if ( mediaPlayerState->playlist() ) {
211 if( QFileInfo( lnk.file() ).exists() || 213 if( QFileInfo( lnk.file() ).exists() ||
212 lnk.file().left(4) == "http" ) { 214 lnk.file().left(4) == "http" ) {
213 d->selectedFiles->addToSelection( lnk ); 215 d->selectedFiles->addToSelection( lnk );
214 } 216 }
215// writeCurrentM3u(); 217// writeCurrentM3u();
216 } 218 }
217 else 219 else
218 mediaPlayerState->setPlaying( TRUE ); 220 mediaPlayerState->setPlaying( TRUE );
219} 221}
220 222
221 223
222void PlayListWidget::clearList() { 224void PlayListWidget::clearList() {
223 while ( first() ) { 225 while ( first() ) {
224 d->selectedFiles->removeSelected(); 226 d->selectedFiles->removeSelected();
225 } 227 }
226} 228}
227 229
228void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 230void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
229 switch (mouse) { 231 switch (mouse) {
230 case 1: 232 case 1:
231 break; 233 break;
232 case 2: 234 case 2:
233 { 235 {
234 QPopupMenu m; 236 QPopupMenu m;
235 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 237 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
236 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 238 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
237 m.exec( QCursor::pos() ); 239 m.exec( QCursor::pos() );
238 } 240 }
239 break; 241 break;
240 } 242 }
241} 243}
242 244
243 245
244void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 246void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
245 switch (mouse) { 247 switch (mouse) {
246 case 1: 248 case 1:
247 break; 249 break;
248 case 2: 250 case 2:
249 { 251 {
250 QPopupMenu m; 252 QPopupMenu m;
251 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 253 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
252 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 254 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
253 m.exec( QCursor::pos() ); 255 m.exec( QCursor::pos() );
254 } 256 }
255 break; 257 break;
256 } 258 }
257} 259}
258 260
259 261
260void PlayListWidget::addAllToList() { 262void PlayListWidget::addAllToList() {
261 263
262// QTime t; 264// QTime t;
263// t.start(); 265// t.start();
264 266
265 if(!audioScan) { 267 if(!audioScan) {
266 if(audioView->childCount() < 1) 268 if(audioView->childCount() < 1)
267 populateAudioView(); 269 populateAudioView();
268 } 270 }
269 271
270 QListViewItemIterator audioIt( audioView ); 272 QListViewItemIterator audioIt( audioView );
271 DocLnk lnk; 273 DocLnk lnk;
272 QString filename; 274 QString filename;
273 // iterate through all items of the listview 275 // iterate through all items of the listview
274 for ( ; audioIt.current(); ++audioIt ) { 276 for ( ; audioIt.current(); ++audioIt ) {
275 filename = audioIt.current()->text(3); 277 filename = audioIt.current()->text(3);
276 lnk.setName( QFileInfo(filename).baseName() ); //sets name 278 lnk.setName( QFileInfo(filename).baseName() ); //sets name
277 lnk.setFile( filename ); //sets file name 279 lnk.setFile( filename ); //sets file name
278 d->selectedFiles->addToSelection( lnk); 280 d->selectedFiles->addToSelection( lnk);
279 } 281 }
280 282
281 if(!videoScan) { 283 if(!videoScan) {
282 if(videoView->childCount() < 1) 284 if(videoView->childCount() < 1)
283 populateVideoView(); 285 populateVideoView();
284 } 286 }
285 287
286 QListViewItemIterator videoIt( videoView ); 288 QListViewItemIterator videoIt( videoView );
287 for ( ; videoIt.current(); ++videoIt ) { 289 for ( ; videoIt.current(); ++videoIt ) {
288 filename = videoIt.current()->text(3); 290 filename = videoIt.current()->text(3);
289 lnk.setName( QFileInfo(filename).baseName() ); //sets name 291 lnk.setName( QFileInfo(filename).baseName() ); //sets name
290 lnk.setFile( filename ); //sets file name 292 lnk.setFile( filename ); //sets file name
291 d->selectedFiles->addToSelection( lnk); 293 d->selectedFiles->addToSelection( lnk);
292 } 294 }
293 295
294 // d->selectedFiles->addToSelection( ); 296 // d->selectedFiles->addToSelection( );
295 // if ( it.current()->isSelected() ) 297 // if ( it.current()->isSelected() )
296 // lst->append( audioIt.current() ); 298 // lst->append( audioIt.current() );
297 // } 299 // }
298 300
299 /* 301 /*
300 if(!audioScan) 302 if(!audioScan)
301 scanForAudio(); 303 scanForAudio();
302 if(!videoScan) 304 if(!videoScan)
303 scanForVideo(); 305 scanForVideo();
304 306
305 DocLnkSet filesAll; 307 DocLnkSet filesAll;
306 Global::findDocuments(&filesAll, "video/*;"+audioMimes); 308 Global::findDocuments(&filesAll, "video/*;"+audioMimes);
307 QListIterator<DocLnk> Adit( filesAll.children() ); 309 QListIterator<DocLnk> Adit( filesAll.children() );
308 for ( ; Adit.current(); ++Adit ) { 310 for ( ; Adit.current(); ++Adit ) {
309 if( QFileInfo( Adit.current()->file() ).exists() ) { 311 if( QFileInfo( Adit.current()->file() ).exists() ) {
310 d->selectedFiles->addToSelection( **Adit ); 312 d->selectedFiles->addToSelection( **Adit );
311 } 313 }
312 } 314 }
313*/ 315*/
314 // qDebug("elapsed time %d", t.elapsed() ); 316 // qDebug("elapsed time %d", t.elapsed() );
315 317
316 tabWidget->setCurrentPage(0); 318 tabWidget->setCurrentPage(0);
317 319
318 writeCurrentM3u(); 320 writeCurrentM3u();
319 d->selectedFiles->first(); 321 d->selectedFiles->first();
320} 322}
321 323
322 324
323void PlayListWidget::addAllMusicToList() { 325void PlayListWidget::addAllMusicToList() {
324 326
325 if(!audioScan) { 327 if(!audioScan) {
326 if(audioView->childCount() < 1) 328 if(audioView->childCount() < 1)
327 populateAudioView(); 329 populateAudioView();
328 } 330 }
329 331
330 QListViewItemIterator audioIt( audioView ); 332 QListViewItemIterator audioIt( audioView );
331 DocLnk lnk; 333 DocLnk lnk;
332 QString filename; 334 QString filename;
333 // iterate through all items of the listview 335 // iterate through all items of the listview
334 for ( ; audioIt.current(); ++audioIt ) { 336 for ( ; audioIt.current(); ++audioIt ) {
335 filename = audioIt.current()->text(3); 337 filename = audioIt.current()->text(3);
336 lnk.setName( QFileInfo(filename).baseName() ); //sets name 338 lnk.setName( QFileInfo(filename).baseName() ); //sets name
337 lnk.setFile( filename ); //sets file name 339 lnk.setFile( filename ); //sets file name
338 d->selectedFiles->addToSelection( lnk); 340 d->selectedFiles->addToSelection( lnk);
339 } 341 }
340 342
341 /* if(!audioScan) 343 /* if(!audioScan)
342 scanForAudio(); 344 scanForAudio();
343 QListIterator<DocLnk> dit( files.children() ); 345 QListIterator<DocLnk> dit( files.children() );
344 for ( ; dit.current(); ++dit ) { 346 for ( ; dit.current(); ++dit ) {
345 if( QFileInfo(dit.current()->file() ).exists() ) { 347 if( QFileInfo(dit.current()->file() ).exists() ) {
346 d->selectedFiles->addToSelection( **dit ); 348 d->selectedFiles->addToSelection( **dit );
347 } 349 }
348 } 350 }
349 */ 351 */
350 tabWidget->setCurrentPage(0); 352 tabWidget->setCurrentPage(0);
@@ -429,534 +431,538 @@ const DocLnk *PlayListWidget::current() { // this is fugly
429 if ( mediaPlayerState->playlist() ) { 431 if ( mediaPlayerState->playlist() ) {
430 return d->selectedFiles->current(); 432 return d->selectedFiles->current();
431 } else if ( d->setDocumentUsed && d->current ) { 433 } else if ( d->setDocumentUsed && d->current ) {
432 return d->current; 434 return d->current;
433 } else { 435 } else {
434 return &(d->files->selectedDocument()); 436 return &(d->files->selectedDocument());
435 } 437 }
436 } 438 }
437 break; 439 break;
438 }; 440 };
439 return 0; 441 return 0;
440} 442}
441 443
442 444
443bool PlayListWidget::prev() { 445bool PlayListWidget::prev() {
444 if ( mediaPlayerState->playlist() ) { 446 if ( mediaPlayerState->playlist() ) {
445 if ( mediaPlayerState->shuffled() ) { 447 if ( mediaPlayerState->shuffled() ) {
446 const DocLnk *cur = current(); 448 const DocLnk *cur = current();
447 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 449 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
448 for ( int i = 0; i < j; i++ ) { 450 for ( int i = 0; i < j; i++ ) {
449 if ( !d->selectedFiles->next() ) 451 if ( !d->selectedFiles->next() )
450 d->selectedFiles->first(); 452 d->selectedFiles->first();
451 } 453 }
452 if ( cur == current() ) 454 if ( cur == current() )
453 if ( !d->selectedFiles->next() ) { 455 if ( !d->selectedFiles->next() ) {
454 d->selectedFiles->first(); 456 d->selectedFiles->first();
455 } 457 }
456 return TRUE; 458 return TRUE;
457 } else { 459 } else {
458 if ( !d->selectedFiles->prev() ) { 460 if ( !d->selectedFiles->prev() ) {
459 if ( mediaPlayerState->looping() ) { 461 if ( mediaPlayerState->looping() ) {
460 return d->selectedFiles->last(); 462 return d->selectedFiles->last();
461 } else { 463 } else {
462 return FALSE; 464 return FALSE;
463 } 465 }
464 } 466 }
465 return TRUE; 467 return TRUE;
466 } 468 }
467 } else { 469 } else {
468 return mediaPlayerState->looping(); 470 return mediaPlayerState->looping();
469 } 471 }
470} 472}
471 473
472 474
473bool PlayListWidget::next() { 475bool PlayListWidget::next() {
474//qDebug("<<<<<<<<<<<<next()"); 476//qDebug("<<<<<<<<<<<<next()");
475 if ( mediaPlayerState->playlist() ) { 477 if ( mediaPlayerState->playlist() ) {
476 if ( mediaPlayerState->shuffled() ) { 478 if ( mediaPlayerState->shuffled() ) {
477 return prev(); 479 return prev();
478 } else { 480 } else {
479 if ( !d->selectedFiles->next() ) { 481 if ( !d->selectedFiles->next() ) {
480 if ( mediaPlayerState->looping() ) { 482 if ( mediaPlayerState->looping() ) {
481 return d->selectedFiles->first(); 483 return d->selectedFiles->first();
482 } else { 484 } else {
483 return FALSE; 485 return FALSE;
484 } 486 }
485 } 487 }
486 return TRUE; 488 return TRUE;
487 } 489 }
488 } else { 490 } else {
489 return mediaPlayerState->looping(); 491 return mediaPlayerState->looping();
490 } 492 }
491} 493}
492 494
493 495
494bool PlayListWidget::first() { 496bool PlayListWidget::first() {
495 if ( mediaPlayerState->playlist() ) 497 if ( mediaPlayerState->playlist() )
496 return d->selectedFiles->first(); 498 return d->selectedFiles->first();
497 else 499 else
498 return mediaPlayerState->looping(); 500 return mediaPlayerState->looping();
499} 501}
500 502
501 503
502bool PlayListWidget::last() { 504bool PlayListWidget::last() {
503 if ( mediaPlayerState->playlist() ) 505 if ( mediaPlayerState->playlist() )
504 return d->selectedFiles->last(); 506 return d->selectedFiles->last();
505 else 507 else
506 return mediaPlayerState->looping(); 508 return mediaPlayerState->looping();
507} 509}
508 510
509 511
510 void PlayListWidget::saveList() { 512 void PlayListWidget::saveList() {
511 writem3u(); 513 writem3u();
512 } 514 }
513 515
514 516
515void PlayListWidget::loadList( const DocLnk & lnk) { 517void PlayListWidget::loadList( const DocLnk & lnk) {
516 QString name = lnk.name(); 518 QString name = lnk.name();
517 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 519 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
518 520
519 if( name.length()>0) { 521 if( name.length()>0) {
520 setCaption("OpiePlayer: "+name); 522 setCaption("OpiePlayer: "+name);
521// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 523// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
522 clearList(); 524 clearList();
523 readm3u(lnk.file()); 525 readm3u(lnk.file());
524 tabWidget->setCurrentPage(0); 526 tabWidget->setCurrentPage(0);
525 } 527 }
526} 528}
527 529
528 530
529void PlayListWidget::setPlaylist( bool shown ) { 531void PlayListWidget::setPlaylist( bool shown ) {
530 if ( shown ) { 532 if ( shown ) {
531 d->playListFrame->show(); 533 d->playListFrame->show();
532 } else { 534 } else {
533 d->playListFrame->hide(); 535 d->playListFrame->hide();
534 } 536 }
535} 537}
536 538
537 539
538void PlayListWidget::addSelected() { 540void PlayListWidget::addSelected() {
539 qDebug("addSelected"); 541 qDebug("addSelected");
540 DocLnk lnk; 542 DocLnk lnk;
541 QString filename; 543 QString filename;
542 switch (whichList()) { 544 switch (whichList()) {
543 545
544 case 0: //playlist 546 case 0: //playlist
545 return; 547 return;
546 break; 548 break;
547 case 1: { //audio 549 case 1: { //audio
548 filename=audioView->currentItem()->text(3); 550 filename=audioView->currentItem()->text(3);
549 // d->selectedFiles->next(); 551 // d->selectedFiles->next();
550 } 552 }
551 break; 553 break;
552 554
553 case 2: { // video 555 case 2: { // video
554 filename=videoView->currentItem()->text(3); 556 filename=videoView->currentItem()->text(3);
555 // tabWidget->setCurrentPage(0); 557 // tabWidget->setCurrentPage(0);
556 558
557 } 559 }
558 break; 560 break;
559 }; 561 };
560 lnk.setName( QFileInfo(filename).baseName() ); //sets name 562 lnk.setName( QFileInfo(filename).baseName() ); //sets name
561 lnk.setFile( filename ); //sets file name 563 lnk.setFile( filename ); //sets file name
562 d->selectedFiles->addToSelection( lnk); 564 d->selectedFiles->addToSelection( lnk);
563 tabWidget->setCurrentPage(0); 565 tabWidget->setCurrentPage(0);
564 writeCurrentM3u(); 566 writeCurrentM3u();
565} 567}
566 568
567 569
568void PlayListWidget::removeSelected() { 570void PlayListWidget::removeSelected() {
569 d->selectedFiles->removeSelected( ); 571 d->selectedFiles->removeSelected( );
570 writeCurrentM3u(); 572 writeCurrentM3u();
571} 573}
572 574
573 575
574void PlayListWidget::playIt( QListViewItem *it) { 576void PlayListWidget::playIt( QListViewItem *it) {
575 if(!it) return; 577 if(!it) return;
576 mediaPlayerState->setPlaying(FALSE); 578 mediaPlayerState->setPlaying(FALSE);
577 mediaPlayerState->setPlaying(TRUE); 579 mediaPlayerState->setPlaying(TRUE);
578 d->selectedFiles->unSelect(); 580 d->selectedFiles->unSelect();
579} 581}
580 582
581 583
582void PlayListWidget::addToSelection( QListViewItem *it) { 584void PlayListWidget::addToSelection( QListViewItem *it) {
583 d->setDocumentUsed = FALSE; 585 d->setDocumentUsed = FALSE;
584 586
585 if(it) { 587 if(it) {
586 switch ( whichList()) { 588 switch ( whichList()) {
587 case 0: //playlist 589 case 0: //playlist
588 return; 590 return;
589 break; 591 break;
590 }; 592 };
591 // case 1: { 593 // case 1: {
592 DocLnk lnk; 594 DocLnk lnk;
593 QString filename; 595 QString filename;
594 596
595 filename=it->text(3); 597 filename=it->text(3);
596 lnk.setName( QFileInfo(filename).baseName() ); //sets name 598 lnk.setName( QFileInfo(filename).baseName() ); //sets name
597 lnk.setFile( filename ); //sets file name 599 lnk.setFile( filename ); //sets file name
598 d->selectedFiles->addToSelection( lnk); 600 d->selectedFiles->addToSelection( lnk);
599 601
600 writeCurrentM3u(); 602 writeCurrentM3u();
601 tabWidget->setCurrentPage(0); 603 tabWidget->setCurrentPage(0);
602 604
603 } 605 }
604} 606}
605 607
606 608
607void PlayListWidget::tabChanged(QWidget *) { 609void PlayListWidget::tabChanged(QWidget *) {
608 610
609 switch ( whichList()) { 611 switch ( whichList()) {
610 case 0: 612 case 0:
611 { 613 {
612 if( !tbDeletePlaylist->isHidden() ) { 614 if( !tbDeletePlaylist->isHidden() ) {
613 tbDeletePlaylist->hide(); 615 tbDeletePlaylist->hide();
614 } 616 }
615 d->tbRemoveFromList->setEnabled(TRUE); 617 d->tbRemoveFromList->setEnabled(TRUE);
616 d->tbAddToList->setEnabled(FALSE); 618 d->tbAddToList->setEnabled(FALSE);
617 } 619 }
618 break; 620 break;
619 case 1: 621 case 1:
620 { 622 {
621 audioView->clear(); 623 // audioView->clear();
622 populateAudioView(); 624 if(!audioPopulated) populateAudioView();
623 625
624 if( !tbDeletePlaylist->isHidden() ) { 626 if( !tbDeletePlaylist->isHidden() ) {
625 tbDeletePlaylist->hide(); 627 tbDeletePlaylist->hide();
626 } 628 }
627 d->tbRemoveFromList->setEnabled(FALSE); 629 d->tbRemoveFromList->setEnabled(FALSE);
628 d->tbAddToList->setEnabled(TRUE); 630 d->tbAddToList->setEnabled(TRUE);
629 } 631 }
630 break; 632 break;
631 case 2: 633 case 2:
632 { 634 {
633 videoView->clear(); 635 // videoView->clear();
634 populateVideoView(); 636 if(!videoPopulated) populateVideoView();
635 if( !tbDeletePlaylist->isHidden() ) { 637 if( !tbDeletePlaylist->isHidden() ) {
636 tbDeletePlaylist->hide(); 638 tbDeletePlaylist->hide();
637 } 639 }
638 d->tbRemoveFromList->setEnabled(FALSE); 640 d->tbRemoveFromList->setEnabled(FALSE);
639 d->tbAddToList->setEnabled(TRUE); 641 d->tbAddToList->setEnabled(TRUE);
640 } 642 }
641 break; 643 break;
642 case 3: 644 case 3:
643 { 645 {
644 if( tbDeletePlaylist->isHidden() ) { 646 if( tbDeletePlaylist->isHidden() ) {
645 tbDeletePlaylist->show(); 647 tbDeletePlaylist->show();
646 } 648 }
647 playLists->reread(); 649 playLists->reread();
648 } 650 }
649 break; 651 break;
650 }; 652 };
651} 653}
652 654
653 655
654void PlayListWidget::btnPlay(bool b) { 656void PlayListWidget::btnPlay(bool b) {
655// mediaPlayerState->setPlaying(false); 657// mediaPlayerState->setPlaying(false);
656 mediaPlayerState->setPlaying(b); 658 mediaPlayerState->setPlaying(b);
657 insanityBool=FALSE; 659 insanityBool=FALSE;
658} 660}
659 661
660void PlayListWidget::deletePlaylist() { 662void PlayListWidget::deletePlaylist() {
661 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 663 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
662 (tr("You really want to delete\nthis playlist?")), 664 (tr("You really want to delete\nthis playlist?")),
663 (tr("Yes")), (tr("No")), 0 )){ 665 (tr("Yes")), (tr("No")), 0 )){
664 case 0: // Yes clicked, 666 case 0: // Yes clicked,
665 QFile().remove(playLists->selectedDocument().file()); 667 QFile().remove(playLists->selectedDocument().file());
666 QFile().remove(playLists->selectedDocument().linkFile()); 668 QFile().remove(playLists->selectedDocument().linkFile());
667 playLists->reread(); 669 playLists->reread();
668 break; 670 break;
669 case 1: // Cancel 671 case 1: // Cancel
670 break; 672 break;
671 }; 673 };
672} 674}
673 675
674 676
675void PlayListWidget::playSelected() { 677void PlayListWidget::playSelected() {
676 btnPlay( TRUE); 678 btnPlay( TRUE);
677} 679}
678 680
679 681
680void PlayListWidget::scanForAudio() { 682void PlayListWidget::scanForAudio() {
681// qDebug("scan for audio"); 683// qDebug("scan for audio");
682 files.detachChildren(); 684 files.detachChildren();
683 QListIterator<DocLnk> sdit( files.children() ); 685 QListIterator<DocLnk> sdit( files.children() );
684 for ( ; sdit.current(); ++sdit ) { 686 for ( ; sdit.current(); ++sdit ) {
685 delete sdit.current(); 687 delete sdit.current();
686 } 688 }
687// Global::findDocuments( &files, "audio/*"); 689// Global::findDocuments( &files, "audio/*");
688 Global::findDocuments( &files, audioMimes); 690 Global::findDocuments( &files, audioMimes);
689 audioScan = TRUE; 691 audioScan = true;
692 populateAudioView();
690} 693}
691 694
692void PlayListWidget::scanForVideo() { 695void PlayListWidget::scanForVideo() {
693// qDebug("scan for video"); 696// qDebug("scan for video");
694 vFiles.detachChildren(); 697 vFiles.detachChildren();
695 QListIterator<DocLnk> sdit( vFiles.children() ); 698 QListIterator<DocLnk> sdit( vFiles.children() );
696 for ( ; sdit.current(); ++sdit ) { 699 for ( ; sdit.current(); ++sdit ) {
697 delete sdit.current(); 700 delete sdit.current();
698 } 701 }
699 Global::findDocuments(&vFiles, "video/*"); 702 Global::findDocuments(&vFiles, "video/*");
700 videoScan = TRUE; 703 videoScan = true;
704 populateVideoView();
701} 705}
702 706
703void PlayListWidget::populateAudioView() { 707void PlayListWidget::populateAudioView() {
704 audioView->clear(); 708 audioView->clear();
705 StorageInfo storageInfo; 709 StorageInfo storageInfo;
706 const QList<FileSystem> &fs = storageInfo.fileSystems(); 710 const QList<FileSystem> &fs = storageInfo.fileSystems();
707 if(!audioScan) { 711 if(!audioScan) {
708 scanForAudio(); 712 scanForAudio();
709 } 713 }
710 714
711 QListIterator<DocLnk> dit( files.children() ); 715 QListIterator<DocLnk> dit( files.children() );
712 QListIterator<FileSystem> it ( fs ); 716 QListIterator<FileSystem> it ( fs );
713 717
714 QString storage; 718 QString storage;
715 for ( ; dit.current(); ++dit ) { 719 for ( ; dit.current(); ++dit ) {
716 for( ; it.current(); ++it ){ 720 for( ; it.current(); ++it ){
717 const QString name = (*it)->name(); 721 const QString name = (*it)->name();
718 const QString path = (*it)->path(); 722 const QString path = (*it)->path();
719 if(dit.current()->file().find(path) != -1 ) { 723 if(dit.current()->file().find(path) != -1 ) {
720 storage = name; 724 storage = name;
721 } 725 }
722 } 726 }
723 727
724 QListViewItem * newItem; 728 QListViewItem * newItem;
725 if ( QFile( dit.current()->file()).exists() || 729 if ( QFile( dit.current()->file()).exists() ||
726 dit.current()->file().left(4) == "http" ) { 730 dit.current()->file().left(4) == "http" ) {
727 long size; 731 long size;
728 if( dit.current()->file().left(4) == "http" ) 732 if( dit.current()->file().left(4) == "http" )
729 size=0; 733 size=0;
730 else 734 else
731 size = QFile( dit.current()->file() ).size(); 735 size = QFile( dit.current()->file() ).size();
732 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 736 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
733 QString::number(size ), storage, dit.current()->file()); 737 QString::number(size ), storage, dit.current()->file());
734 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 738 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
735 } 739 }
736 } 740 }
741 audioPopulated=true;
737} 742}
738 743
739 744
740void PlayListWidget::populateVideoView() { 745void PlayListWidget::populateVideoView() {
741 videoView->clear(); 746 videoView->clear();
742 StorageInfo storageInfo; 747 StorageInfo storageInfo;
743 const QList<FileSystem> &fs = storageInfo.fileSystems(); 748 const QList<FileSystem> &fs = storageInfo.fileSystems();
744 749
745 if(!videoScan ) { 750 if(!videoScan ) {
746 scanForVideo(); 751 scanForVideo();
747 } 752 }
748 753
749 QListIterator<DocLnk> Vdit( vFiles.children() ); 754 QListIterator<DocLnk> Vdit( vFiles.children() );
750 QListIterator<FileSystem> it ( fs ); 755 QListIterator<FileSystem> it ( fs );
751 videoView->clear(); 756 videoView->clear();
752 QString storage, pathName; 757 QString storage, pathName;
753 for ( ; Vdit.current(); ++Vdit ) { 758 for ( ; Vdit.current(); ++Vdit ) {
754 for( ; it.current(); ++it ) { 759 for( ; it.current(); ++it ) {
755 const QString name = (*it)->name(); 760 const QString name = (*it)->name();
756 const QString path = (*it)->path(); 761 const QString path = (*it)->path();
757 if( Vdit.current()->file().find(path) != -1 ) { 762 if( Vdit.current()->file().find(path) != -1 ) {
758 storage=name; 763 storage=name;
759 pathName=path; 764 pathName=path;
760 } 765 }
761 } 766 }
762 767
763 QListViewItem * newItem; 768 QListViewItem * newItem;
764 if ( QFile( Vdit.current()->file() ).exists() ) { 769 if ( QFile( Vdit.current()->file() ).exists() ) {
765 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 770 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
766 QString::number( QFile( Vdit.current()->file() ).size() ), 771 QString::number( QFile( Vdit.current()->file() ).size() ),
767 storage, Vdit.current()->file()); 772 storage, Vdit.current()->file());
768 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 773 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
769 } 774 }
770 } 775 }
776 videoPopulated=true;
771} 777}
772 778
773 779
774void PlayListWidget::openFile() { 780void PlayListWidget::openFile() {
775 // http://66.28.164.33:2080 781 // http://66.28.164.33:2080
776 // http://somafm.com/star0242.m3u 782 // http://somafm.com/star0242.m3u
777 QString filename, name; 783 QString filename, name;
778 InputDialog *fileDlg; 784 InputDialog *fileDlg;
779 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 785 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
780 fileDlg->exec(); 786 fileDlg->exec();
781 if( fileDlg->result() == 1 ) { 787 if( fileDlg->result() == 1 ) {
782 filename = fileDlg->text(); 788 filename = fileDlg->text();
783 qDebug( "Selected filename is " + filename ); 789 qDebug( "Selected filename is " + filename );
784 Om3u *m3uList; 790 Om3u *m3uList;
785 DocLnk lnk; 791 DocLnk lnk;
786 Config cfg( "OpiePlayer" ); 792 Config cfg( "OpiePlayer" );
787 cfg.setGroup("PlayList"); 793 cfg.setGroup("PlayList");
788 794
789 if(filename.left(4) == "http") { 795 if(filename.left(4) == "http") {
790 QString m3uFile, m3uFilePath; 796 QString m3uFile, m3uFilePath;
791 if(filename.find(":",8,TRUE) != -1) { //found a port 797 if(filename.find(":",8,TRUE) != -1) { //found a port
792 m3uFile = filename.left( filename.find( ":",8,TRUE)); 798 m3uFile = filename.left( filename.find( ":",8,TRUE));
793 m3uFile = m3uFile.right( 7); 799 m3uFile = m3uFile.right( 7);
794 } else if(filename.left(4) == "http"){ 800 } else if(filename.left(4) == "http"){
795 m3uFile=filename; 801 m3uFile=filename;
796 m3uFile = m3uFile.right( m3uFile.length() - 7); 802 m3uFile = m3uFile.right( m3uFile.length() - 7);
797 } else{ 803 } else{
798 m3uFile=filename; 804 m3uFile=filename;
799 } 805 }
800 806
801// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 807// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
802 lnk.setName( filename ); //sets name 808 lnk.setName( filename ); //sets name
803 lnk.setFile( filename ); //sets file name 809 lnk.setFile( filename ); //sets file name
804 810
805// lnk.setIcon("opieplayer2/musicfile"); 811// lnk.setIcon("opieplayer2/musicfile");
806 812
807 d->selectedFiles->addToSelection( lnk ); 813 d->selectedFiles->addToSelection( lnk );
808 writeCurrentM3u(); 814 writeCurrentM3u();
809 d->selectedFiles->setSelectedItem( lnk.name()); 815 d->selectedFiles->setSelectedItem( lnk.name());
810 } 816 }
811 else if( filename.right( 3) == "m3u" ) { 817 else if( filename.right( 3) == "m3u" ) {
812 readm3u( filename ); 818 readm3u( filename );
813 819
814 } else if( filename.right(3) == "pls" ) { 820 } else if( filename.right(3) == "pls" ) {
815 readPls( filename ); 821 readPls( filename );
816 } else { 822 } else {
817 lnk.setName( QFileInfo(filename).baseName() ); //sets name 823 lnk.setName( QFileInfo(filename).baseName() ); //sets name
818 lnk.setFile( filename ); //sets file name 824 lnk.setFile( filename ); //sets file name
819 d->selectedFiles->addToSelection( lnk); 825 d->selectedFiles->addToSelection( lnk);
820 writeCurrentM3u(); 826 writeCurrentM3u();
821 d->selectedFiles->setSelectedItem( lnk.name()); 827 d->selectedFiles->setSelectedItem( lnk.name());
822 } 828 }
823 } 829 }
824 830
825 if( fileDlg ) { 831 if( fileDlg ) {
826 delete fileDlg; 832 delete fileDlg;
827 } 833 }
828} 834}
829 835
830/* 836/*
831reads m3u and shows files/urls to playlist widget */ 837reads m3u and shows files/urls to playlist widget */
832void PlayListWidget::readm3u( const QString &filename ) { 838void PlayListWidget::readm3u( const QString &filename ) {
833 qDebug( "read m3u filename " + filename ); 839 qDebug( "read m3u filename " + filename );
834 840
835 Om3u *m3uList; 841 Om3u *m3uList;
836 QString s, name; 842 QString s, name;
837 m3uList = new Om3u( filename, IO_ReadOnly ); 843 m3uList = new Om3u( filename, IO_ReadOnly );
838 m3uList->readM3u(); 844 m3uList->readM3u();
839 DocLnk lnk; 845 DocLnk lnk;
840 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 846 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
841 s = *it; 847 s = *it;
842// qDebug("reading "+ s); 848// qDebug("reading "+ s);
843 if(s.left(4)=="http") { 849 if(s.left(4)=="http") {
844 lnk.setName( s ); //sets file name 850 lnk.setName( s ); //sets file name
845 lnk.setIcon("opieplayer2/musicfile"); 851 lnk.setIcon("opieplayer2/musicfile");
846 lnk.setFile( s ); //sets file name 852 lnk.setFile( s ); //sets file name
847 853
848 } else { 854 } else {
849 // if( QFileInfo( s ).exists() ) { 855 // if( QFileInfo( s ).exists() ) {
850 lnk.setName( QFileInfo(s).baseName()); 856 lnk.setName( QFileInfo(s).baseName());
851 // if(s.right(4) == '.') {//if regular file 857 // if(s.right(4) == '.') {//if regular file
852 if(s.left(1) != "/") { 858 if(s.left(1) != "/") {
853 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 859 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
854 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 860 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
855// lnk.setIcon(MimeType(s).pixmap() ); 861// lnk.setIcon(MimeType(s).pixmap() );
856// lnk.setIcon("SoundPlayer"); 862// lnk.setIcon("SoundPlayer");
857 } else { 863 } else {
858 // qDebug("set link2 "+s); 864 // qDebug("set link2 "+s);
859 lnk.setFile( s); 865 lnk.setFile( s);
860// lnk.setIcon(MimeType(s).pixmap() ); 866// lnk.setIcon(MimeType(s).pixmap() );
861// lnk.setIcon("SoundPlayer"); 867// lnk.setIcon("SoundPlayer");
862 } 868 }
863 } 869 }
864 d->selectedFiles->addToSelection( lnk ); 870 d->selectedFiles->addToSelection( lnk );
865 } 871 }
866 Config config( "OpiePlayer" ); 872 Config config( "OpiePlayer" );
867 config.setGroup( "PlayList" ); 873 config.setGroup( "PlayList" );
868 874
869 config.writeEntry("CurrentPlaylist",filename); 875 config.writeEntry("CurrentPlaylist",filename);
870 config.write(); 876 config.write();
871 currentPlayList=filename; 877 currentPlayList=filename;
872 878
873// m3uList->write(); 879// m3uList->write();
874 m3uList->close(); 880 m3uList->close();
875 if(m3uList) delete m3uList; 881 if(m3uList) delete m3uList;
876 882
877 d->selectedFiles->setSelectedItem( s); 883 d->selectedFiles->setSelectedItem( s);
878 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 884 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
879 885
880} 886}
881 887
882/* 888/*
883reads pls and adds files/urls to playlist */ 889reads pls and adds files/urls to playlist */
884void PlayListWidget::readPls( const QString &filename ) { 890void PlayListWidget::readPls( const QString &filename ) {
885 891
886 qDebug( "pls filename is " + filename ); 892 qDebug( "pls filename is " + filename );
887 Om3u *m3uList; 893 Om3u *m3uList;
888 QString s, name; 894 QString s, name;
889 m3uList = new Om3u( filename, IO_ReadOnly ); 895 m3uList = new Om3u( filename, IO_ReadOnly );
890 m3uList->readPls(); 896 m3uList->readPls();
891 897
892 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 898 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
893 s = *it; 899 s = *it;
894 // s.replace( QRegExp( "%20" )," " ); 900 // s.replace( QRegExp( "%20" )," " );
895 DocLnk lnk( s ); 901 DocLnk lnk( s );
896 QFileInfo f( s ); 902 QFileInfo f( s );
897 QString name = f.baseName(); 903 QString name = f.baseName();
898 904
899 if( name.left( 4 ) == "http" ) { 905 if( name.left( 4 ) == "http" ) {
900 name = s.right( s.length() - 7); 906 name = s.right( s.length() - 7);
901 } else { 907 } else {
902 name = s; 908 name = s;
903 } 909 }
904 910
905 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 911 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
906 912
907 lnk.setName( name ); 913 lnk.setName( name );
908 if( s.at( s.length() - 4) == '.') {// if this is probably a file 914 if( s.at( s.length() - 4) == '.') {// if this is probably a file
909 lnk.setFile( s ); 915 lnk.setFile( s );
910 } else { //if its a url 916 } else { //if its a url
911// if( name.right( 1 ).find( '/' ) == -1) { 917// if( name.right( 1 ).find( '/' ) == -1) {
912// s += "/"; 918// s += "/";
913// } 919// }
914 lnk.setFile( s ); 920 lnk.setFile( s );
915 } 921 }
916 lnk.setType( "audio/x-mpegurl" ); 922 lnk.setType( "audio/x-mpegurl" );
917 923
918 lnk.writeLink(); 924 lnk.writeLink();
919 d->selectedFiles->addToSelection( lnk ); 925 d->selectedFiles->addToSelection( lnk );
920 } 926 }
921 927
922 m3uList->close(); 928 m3uList->close();
923 if(m3uList) delete m3uList; 929 if(m3uList) delete m3uList;
924} 930}
925 931
926/* 932/*
927 writes current playlist to current m3u file */ 933 writes current playlist to current m3u file */
928void PlayListWidget::writeCurrentM3u() { 934void PlayListWidget::writeCurrentM3u() {
929 qDebug("writing to current m3u"); 935 qDebug("writing to current m3u");
930 Config cfg( "OpiePlayer" ); 936 Config cfg( "OpiePlayer" );
931 cfg.setGroup("PlayList"); 937 cfg.setGroup("PlayList");
932 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 938 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
933 939
934 Om3u *m3uList; 940 Om3u *m3uList;
935 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 941 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
936 if( d->selectedFiles->first()) { 942 if( d->selectedFiles->first()) {
937 943
938 do { 944 do {
939 qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); 945 qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
940 m3uList->add( d->selectedFiles->current()->file() ); 946 m3uList->add( d->selectedFiles->current()->file() );
941 } 947 }
942 while ( d->selectedFiles->next() ); 948 while ( d->selectedFiles->next() );
943 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 949 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
944 m3uList->write(); 950 m3uList->write();
945 m3uList->close(); 951 m3uList->close();
946 952
947 if(m3uList) delete m3uList; 953 if(m3uList) delete m3uList;
948 } 954 }
949 955
950} 956}
951 957
952 /* 958 /*
953 writes current playlist to m3u file */ 959 writes current playlist to m3u file */
954void PlayListWidget::writem3u() { 960void PlayListWidget::writem3u() {
955 InputDialog *fileDlg; 961 InputDialog *fileDlg;
956 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 962 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
957 fileDlg->exec(); 963 fileDlg->exec();
958 QString name, filename, list; 964 QString name, filename, list;
959 Om3u *m3uList; 965 Om3u *m3uList;
960 966
961 if( fileDlg->result() == 1 ) { 967 if( fileDlg->result() == 1 ) {
962 name = fileDlg->text(); 968 name = fileDlg->text();
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 53be7a7..b2c389e 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -1,121 +1,121 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef PLAY_LIST_WIDGET_H 34#ifndef PLAY_LIST_WIDGET_H
35#define PLAY_LIST_WIDGET_H 35#define PLAY_LIST_WIDGET_H
36 36
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qpe/applnk.h> 38#include <qpe/applnk.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qpe/fileselector.h> 40#include <qpe/fileselector.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qpopupmenu.h> 42#include <qpopupmenu.h>
43 43
44#include "playlistwidgetgui.h" 44#include "playlistwidgetgui.h"
45 45
46 46
47//class PlayListWidgetPrivate; 47//class PlayListWidgetPrivate;
48class Config; 48class Config;
49class QListViewItem; 49class QListViewItem;
50class QListView; 50class QListView;
51class QPoint; 51class QPoint;
52class QAction; 52class QAction;
53class QLabel; 53class QLabel;
54 54
55class PlayListWidget : public PlayListWidgetGui { 55class PlayListWidget : public PlayListWidgetGui {
56 Q_OBJECT 56 Q_OBJECT
57public: 57public:
58 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 58 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
59 ~PlayListWidget(); 59 ~PlayListWidget();
60 DocLnkSet files; 60 DocLnkSet files;
61 DocLnkSet vFiles; 61 DocLnkSet vFiles;
62 bool fromSetDocument; 62 bool fromSetDocument;
63 bool insanityBool; 63 bool insanityBool;
64 QString setDocFileRef, currentPlayList; 64 QString setDocFileRef, currentPlayList;
65 // retrieve the current playlist entry (media file link) 65 // retrieve the current playlist entry (media file link)
66 const DocLnk *current(); 66 const DocLnk *current();
67 void useSelectedDocument(); 67 void useSelectedDocument();
68 int selected; 68 int selected;
69 int whichList(); 69 int whichList();
70 70
71public slots: 71public slots:
72 bool first(); 72 bool first();
73 bool last(); 73 bool last();
74 bool next(); 74 bool next();
75 bool prev(); 75 bool prev();
76 void writeDefaultPlaylist( ); 76 void writeDefaultPlaylist( );
77 QString currentFileListPathName(); 77 QString currentFileListPathName();
78protected: 78protected:
79 void keyReleaseEvent( QKeyEvent *e); 79 void keyReleaseEvent( QKeyEvent *e);
80 80
81private: 81private:
82 int defaultSkinIndex; 82 int defaultSkinIndex;
83 bool audioScan, videoScan; 83 bool audioScan, videoScan, audioPopulated, videoPopulated;
84 void readm3u(const QString &); 84 void readm3u(const QString &);
85 void readPls(const QString &); 85 void readPls(const QString &);
86 void initializeStates(); 86 void initializeStates();
87 void populateAudioView(); 87 void populateAudioView();
88 void populateVideoView(); 88 void populateVideoView();
89 89
90private slots: 90private slots:
91 void populateSkinsMenu(); 91 void populateSkinsMenu();
92 void skinsMenuActivated(int); 92 void skinsMenuActivated(int);
93 void pmViewActivated(int); 93 void pmViewActivated(int);
94 void writem3u(); 94 void writem3u();
95 void writeCurrentM3u(); 95 void writeCurrentM3u();
96 void scanForAudio(); 96 void scanForAudio();
97 void scanForVideo(); 97 void scanForVideo();
98 void openFile(); 98 void openFile();
99 void setDocument( const QString& fileref ); 99 void setDocument( const QString& fileref );
100 void addToSelection( const DocLnk& ); // Add a media file to the playlist 100 void addToSelection( const DocLnk& ); // Add a media file to the playlist
101 void addToSelection( QListViewItem* ); // Add a media file to the playlist 101 void addToSelection( QListViewItem* ); // Add a media file to the playlist
102 void setPlaylist( bool ); // Show/Hide the playlist 102 void setPlaylist( bool ); // Show/Hide the playlist
103 void clearList(); 103 void clearList();
104 void addAllToList(); 104 void addAllToList();
105 void addAllMusicToList(); 105 void addAllMusicToList();
106 void addAllVideoToList(); 106 void addAllVideoToList();
107 void saveList(); // Save the playlist 107 void saveList(); // Save the playlist
108 void loadList( const DocLnk &); // Load a playlist 108 void loadList( const DocLnk &); // Load a playlist
109 void playIt( QListViewItem *); 109 void playIt( QListViewItem *);
110 void btnPlay(bool); 110 void btnPlay(bool);
111 void deletePlaylist(); 111 void deletePlaylist();
112 void addSelected(); 112 void addSelected();
113 void removeSelected(); 113 void removeSelected();
114 void tabChanged(QWidget*); 114 void tabChanged(QWidget*);
115 void viewPressed( int, QListViewItem *, const QPoint&, int); 115 void viewPressed( int, QListViewItem *, const QPoint&, int);
116 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 116 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
117 void playSelected(); 117 void playSelected();
118}; 118};
119 119
120#endif // PLAY_LIST_WIDGET_H 120#endif // PLAY_LIST_WIDGET_H
121 121