author | llornkcor <llornkcor> | 2002-11-14 04:03:36 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-14 04:03:36 (UTC) |
commit | 736339b62f325652b71615b8c3fbc0b064fcf837 (patch) (unidiff) | |
tree | cd739278da93b0092bcb6d947a8c43390df2aaa6 | |
parent | abf6aa1c155e3d5df3092f4261edb7143656de7e (diff) | |
download | opie-736339b62f325652b71615b8c3fbc0b064fcf837.zip opie-736339b62f325652b71615b8c3fbc0b064fcf837.tar.gz opie-736339b62f325652b71615b8c3fbc0b064fcf837.tar.bz2 |
takeout qDebugs
-rw-r--r-- | noncore/multimedia/opieplayer2/om3u.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 6 |
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 | ||
51 | Om3u::Om3u( const QString &filePath, int mode) | 51 | Om3u::Om3u( const QString &filePath, int mode) |
52 | : QStringList (){ | 52 | : QStringList (){ |
53 | qDebug("<<<<<<<new m3u "+filePath); | 53 | qDebug("<<<<<<<new m3u "+filePath); |
54 | f.setName(filePath); | 54 | f.setName(filePath); |
55 | f.open(mode); | 55 | f.open(mode); |
56 | } | 56 | } |
57 | 57 | ||
58 | Om3u::~Om3u(){} | 58 | Om3u::~Om3u(){} |
59 | 59 | ||
60 | void Om3u::readM3u() { | 60 | void 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 | ||
91 | void Om3u::readPls() { //it's a pls file | 91 | void 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 | ||
127 | void Om3u::write() { //writes list to m3u file | 127 | void 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 | ||
139 | void Om3u::add(const QString &filePath) { //adds to m3u file | 139 | void Om3u::add(const QString &filePath) { //adds to m3u file |
140 | append(filePath); | 140 | append(filePath); |
141 | } | 141 | } |
142 | 142 | ||
143 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 143 | void 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 | ||
157 | void Om3u::deleteFile(const QString &filePath) {//deletes m3u file | 157 | void 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 | ||
163 | void Om3u::close() { //closes m3u file | 163 | void 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 | |||
@@ -296,193 +296,193 @@ void PlayListWidget::addAllToList() { | |||
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 | ||
325 | void PlayListWidget::addAllMusicToList() { | 325 | void 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 | ||
358 | void PlayListWidget::addAllVideoToList() { | 358 | void 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 | ||
391 | void PlayListWidget::setDocument( const QString& fileref ) { | 391 | void 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 | ||
421 | void PlayListWidget::useSelectedDocument() { | 421 | void PlayListWidget::useSelectedDocument() { |
422 | d->setDocumentUsed = FALSE; | 422 | d->setDocumentUsed = FALSE; |
423 | } | 423 | } |
424 | 424 | ||
425 | 425 | ||
426 | const DocLnk *PlayListWidget::current() { // this is fugly | 426 | const 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 | ||
445 | bool PlayListWidget::prev() { | 445 | bool 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 | ||
475 | bool PlayListWidget::next() { | 475 | bool 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; |
@@ -866,197 +866,197 @@ void PlayListWidget::readm3u( const QString &filename ) { | |||
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 | /* |
906 | reads pls and adds files/urls to playlist */ | 906 | reads pls and adds files/urls to playlist */ |
907 | void PlayListWidget::readPls( const QString &filename ) { | 907 | void 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 */ |
951 | void PlayListWidget::writeCurrentM3u() { | 951 | void 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 */ |
977 | void PlayListWidget::writem3u() { | 977 | void 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 | ||
1031 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 1031 | void 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; |