-rw-r--r-- | noncore/multimedia/opieplayer2/playlistfileview.cpp | 13 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistfileview.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 56 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 1 |
4 files changed, 59 insertions, 12 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.cpp b/noncore/multimedia/opieplayer2/playlistfileview.cpp index 3ef4d03..3094876 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.cpp +++ b/noncore/multimedia/opieplayer2/playlistfileview.cpp | |||
@@ -68,28 +68,39 @@ void PlayListFileView::populateView() | |||
68 | m_viewPopulated = true; | 68 | m_viewPopulated = true; |
69 | 69 | ||
70 | QString storage; | 70 | QString storage; |
71 | QListIterator<DocLnk> dit( m_files.children() ); | 71 | QListIterator<DocLnk> dit( m_files.children() ); |
72 | for ( ; dit.current(); ++dit ) { | 72 | for ( ; dit.current(); ++dit ) { |
73 | 73 | ||
74 | QListViewItem *newItem; | 74 | QListViewItem *newItem; |
75 | 75 | ||
76 | if ( QFile::exists( dit.current()->file() ) || | 76 | if ( QFile::exists( dit.current()->file() ) || |
77 | dit.current()->file().left( 4 ) == "http" ) { | 77 | dit.current()->file().left( 4 ) == "http" ) { |
78 | 78 | ||
79 | unsigned long size = QFile( dit.current()->file() ).size(); | 79 | unsigned long size = QFile( dit.current()->file() ).size(); |
80 | QString sizestr; | ||
81 | fileSize(size, sizestr); | ||
80 | 82 | ||
81 | newItem = new QListViewItem( this, dit.current()->name(), | 83 | newItem = new QListViewItem( this, dit.current()->name(), |
82 | QString::number( size ), "" /*storage*/, | 84 | sizestr, "" /*storage*/, |
83 | dit.current()->file() ); | 85 | dit.current()->file() ); |
84 | newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) ); | 86 | newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) ); |
85 | } | 87 | } |
86 | } | 88 | } |
87 | } | 89 | } |
88 | 90 | ||
89 | void PlayListFileView::checkSelection() | 91 | void PlayListFileView::checkSelection() |
90 | { | 92 | { |
91 | emit itemsSelected( hasSelection() ); | 93 | emit itemsSelected( hasSelection() ); |
92 | } | 94 | } |
93 | 95 | ||
96 | void PlayListFileView::fileSize(unsigned long size, QString &str) { | ||
97 | if( size > 1048576 ) | ||
98 | str.sprintf( "%.0fM", size / 1048576.0 ); | ||
99 | else if( size > 1024 ) | ||
100 | str.sprintf( "%.0fK", size / 1024.0 ); | ||
101 | else | ||
102 | str.sprintf( "%d", size ); | ||
103 | } | ||
104 | |||
94 | /* vim: et sw=4 ts=4 | 105 | /* vim: et sw=4 ts=4 |
95 | */ | 106 | */ |
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.h b/noncore/multimedia/opieplayer2/playlistfileview.h index 5b15526..d92f258 100644 --- a/noncore/multimedia/opieplayer2/playlistfileview.h +++ b/noncore/multimedia/opieplayer2/playlistfileview.h | |||
@@ -16,22 +16,23 @@ public: | |||
16 | 16 | ||
17 | public slots: | 17 | public slots: |
18 | void scanFiles(); | 18 | void scanFiles(); |
19 | void populateView(); | 19 | void populateView(); |
20 | 20 | ||
21 | signals: | 21 | signals: |
22 | void itemsSelected( bool selected ); | 22 | void itemsSelected( bool selected ); |
23 | 23 | ||
24 | private slots: | 24 | private slots: |
25 | void checkSelection(); | 25 | void checkSelection(); |
26 | 26 | ||
27 | private: | 27 | private: |
28 | void fileSize(unsigned long size, QString &str); | ||
28 | QString m_mimeTypePattern; | 29 | QString m_mimeTypePattern; |
29 | QString m_itemPixmapName; | 30 | QString m_itemPixmapName; |
30 | DocLnkSet m_files; | 31 | DocLnkSet m_files; |
31 | bool m_scannedFiles; | 32 | bool m_scannedFiles; |
32 | bool m_viewPopulated; | 33 | bool m_viewPopulated; |
33 | }; | 34 | }; |
34 | 35 | ||
35 | #endif // PLAYLISTFILEVIEW_H | 36 | #endif // PLAYLISTFILEVIEW_H |
36 | /* vim: et sw=4 ts=4 | 37 | /* vim: et sw=4 ts=4 |
37 | */ | 38 | */ |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 5f4159c..83eb83b 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -171,24 +171,56 @@ PlayListWidget::~PlayListWidget() { | |||
171 | delete d; | 171 | delete d; |
172 | delete m_mp; | 172 | delete m_mp; |
173 | } | 173 | } |
174 | 174 | ||
175 | 175 | ||
176 | void PlayListWidget::initializeStates() { | 176 | void PlayListWidget::initializeStates() { |
177 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); | 177 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); |
178 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); | 178 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); |
179 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); | 179 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); |
180 | d->playListFrame->show(); | 180 | d->playListFrame->show(); |
181 | } | 181 | } |
182 | 182 | ||
183 | void PlayListWidget::setButtons(void) { | ||
184 | bool hasitem; | ||
185 | |||
186 | switch ( currentTab() ) { | ||
187 | case CurrentPlayList: | ||
188 | { | ||
189 | hasitem = !d->selectedFiles->isEmpty(); | ||
190 | d->tbPlay->setEnabled( hasitem ); | ||
191 | d->tbRemoveFromList->setEnabled( hasitem ); | ||
192 | } | ||
193 | break; | ||
194 | case AudioFiles: | ||
195 | { | ||
196 | d->tbPlay->setEnabled( audioView->hasSelection() ); | ||
197 | d->tbRemoveFromList->setEnabled( false ); | ||
198 | } | ||
199 | break; | ||
200 | case VideoFiles: | ||
201 | { | ||
202 | d->tbPlay->setEnabled( videoView->hasSelection() ); | ||
203 | d->tbRemoveFromList->setEnabled( false ); | ||
204 | } | ||
205 | break; | ||
206 | case PlayLists: | ||
207 | { | ||
208 | d->tbPlay->setEnabled( false ); | ||
209 | d->tbRemoveFromList->setEnabled( false ); | ||
210 | } | ||
211 | break; | ||
212 | }; | ||
213 | } | ||
214 | |||
183 | void PlayListWidget::writeDefaultPlaylist() { | 215 | void PlayListWidget::writeDefaultPlaylist() { |
184 | 216 | ||
185 | Config config( "OpiePlayer" ); | 217 | Config config( "OpiePlayer" ); |
186 | config.setGroup( "PlayList" ); | 218 | config.setGroup( "PlayList" ); |
187 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 219 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
188 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 220 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
189 | if( currentString == filename) { | 221 | if( currentString == filename) { |
190 | Om3u *m3uList; | 222 | Om3u *m3uList; |
191 | if( d->selectedFiles->first() ) { | 223 | if( d->selectedFiles->first() ) { |
192 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 224 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
193 | do { | 225 | do { |
194 | m3uList->add( d->selectedFiles->current()->file() ); | 226 | m3uList->add( d->selectedFiles->current()->file() ); |
@@ -211,24 +243,25 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) { | |||
211 | } | 243 | } |
212 | } | 244 | } |
213 | 245 | ||
214 | 246 | ||
215 | void PlayListWidget::clearList() { | 247 | void PlayListWidget::clearList() { |
216 | while ( first() ) { | 248 | while ( first() ) { |
217 | d->selectedFiles->removeSelected(); | 249 | d->selectedFiles->removeSelected(); |
218 | } | 250 | } |
219 | Config cfg( "OpiePlayer" ); | 251 | Config cfg( "OpiePlayer" ); |
220 | cfg.setGroup("PlayList"); | 252 | cfg.setGroup("PlayList"); |
221 | cfg.writeEntry("CurrentPlaylist","default"); | 253 | cfg.writeEntry("CurrentPlaylist","default"); |
222 | setCaption("OpiePlayer"); | 254 | setCaption("OpiePlayer"); |
255 | setButtons(); | ||
223 | } | 256 | } |
224 | 257 | ||
225 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 258 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
226 | switch (mouse) { | 259 | switch (mouse) { |
227 | case LeftButton: | 260 | case LeftButton: |
228 | break; | 261 | break; |
229 | case RightButton: | 262 | case RightButton: |
230 | { | 263 | { |
231 | QPopupMenu m; | 264 | QPopupMenu m; |
232 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 265 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
233 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 266 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
234 | m.exec( QCursor::pos() ); | 267 | m.exec( QCursor::pos() ); |
@@ -275,64 +308,70 @@ void PlayListWidget::addAllToList() { | |||
275 | QListViewItemIterator videoIt( videoView ); | 308 | QListViewItemIterator videoIt( videoView ); |
276 | for ( ; videoIt.current(); ++videoIt ) { | 309 | for ( ; videoIt.current(); ++videoIt ) { |
277 | filename = videoIt.current()->text(3); | 310 | filename = videoIt.current()->text(3); |
278 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 311 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
279 | lnk.setFile( filename ); //sets file name | 312 | lnk.setFile( filename ); //sets file name |
280 | d->selectedFiles->addToSelection( lnk); | 313 | d->selectedFiles->addToSelection( lnk); |
281 | } | 314 | } |
282 | 315 | ||
283 | tabWidget->setCurrentPage(0); | 316 | tabWidget->setCurrentPage(0); |
284 | 317 | ||
285 | writeCurrentM3u(); | 318 | writeCurrentM3u(); |
286 | d->selectedFiles->first(); | 319 | d->selectedFiles->first(); |
320 | |||
321 | setButtons(); | ||
287 | } | 322 | } |
288 | 323 | ||
289 | 324 | ||
290 | void PlayListWidget::addAllMusicToList() { | 325 | void PlayListWidget::addAllMusicToList() { |
291 | 326 | ||
292 | audioView->populateView(); | 327 | audioView->populateView(); |
293 | 328 | ||
294 | QListViewItemIterator audioIt( audioView ); | 329 | QListViewItemIterator audioIt( audioView ); |
295 | DocLnk lnk; | 330 | DocLnk lnk; |
296 | QString filename; | 331 | QString filename; |
297 | // iterate through all items of the listview | 332 | // iterate through all items of the listview |
298 | for ( ; audioIt.current(); ++audioIt ) { | 333 | for ( ; audioIt.current(); ++audioIt ) { |
299 | filename = audioIt.current()->text(3); | 334 | filename = audioIt.current()->text(3); |
300 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 335 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
301 | lnk.setFile( filename ); //sets file name | 336 | lnk.setFile( filename ); //sets file name |
302 | d->selectedFiles->addToSelection( lnk); | 337 | d->selectedFiles->addToSelection( lnk); |
303 | } | 338 | } |
304 | 339 | ||
305 | tabWidget->setCurrentPage(0); | 340 | tabWidget->setCurrentPage(0); |
306 | writeCurrentM3u(); | 341 | writeCurrentM3u(); |
307 | d->selectedFiles->first(); | 342 | d->selectedFiles->first(); |
343 | |||
344 | setButtons(); | ||
308 | } | 345 | } |
309 | 346 | ||
310 | 347 | ||
311 | void PlayListWidget::addAllVideoToList() { | 348 | void PlayListWidget::addAllVideoToList() { |
312 | 349 | ||
313 | videoView->populateView(); | 350 | videoView->populateView(); |
314 | 351 | ||
315 | QListViewItemIterator videoIt( videoView ); | 352 | QListViewItemIterator videoIt( videoView ); |
316 | DocLnk lnk; | 353 | DocLnk lnk; |
317 | QString filename; | 354 | QString filename; |
318 | for ( ; videoIt.current(); ++videoIt ) { | 355 | for ( ; videoIt.current(); ++videoIt ) { |
319 | filename = videoIt.current()->text(3); | 356 | filename = videoIt.current()->text(3); |
320 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 357 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
321 | lnk.setFile( filename ); //sets file name | 358 | lnk.setFile( filename ); //sets file name |
322 | d->selectedFiles->addToSelection( lnk); | 359 | d->selectedFiles->addToSelection( lnk); |
323 | } | 360 | } |
324 | tabWidget->setCurrentPage(0); | 361 | tabWidget->setCurrentPage(0); |
325 | writeCurrentM3u(); | 362 | writeCurrentM3u(); |
326 | d->selectedFiles->first(); | 363 | d->selectedFiles->first(); |
364 | |||
365 | setButtons(); | ||
327 | } | 366 | } |
328 | 367 | ||
329 | 368 | ||
330 | void PlayListWidget::setDocument( const QString& _fileref ) { | 369 | void PlayListWidget::setDocument( const QString& _fileref ) { |
331 | // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; | 370 | // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; |
332 | QString fileref = _fileref; | 371 | QString fileref = _fileref; |
333 | fromSetDocument = TRUE; | 372 | fromSetDocument = TRUE; |
334 | 373 | ||
335 | DocLnk lnk(_fileref); | 374 | DocLnk lnk(_fileref); |
336 | if(lnk.isValid()) | 375 | if(lnk.isValid()) |
337 | fileref = lnk.file(); | 376 | fileref = lnk.file(); |
338 | 377 | ||
@@ -467,24 +506,25 @@ void PlayListWidget::addSelected() { | |||
467 | d->selectedFiles->addToSelection( lnk ); | 506 | d->selectedFiles->addToSelection( lnk ); |
468 | } | 507 | } |
469 | 508 | ||
470 | currentFileListView->clearSelection(); | 509 | currentFileListView->clearSelection(); |
471 | 510 | ||
472 | writeCurrentM3u(); | 511 | writeCurrentM3u(); |
473 | } | 512 | } |
474 | 513 | ||
475 | 514 | ||
476 | void PlayListWidget::removeSelected() { | 515 | void PlayListWidget::removeSelected() { |
477 | d->selectedFiles->removeSelected( ); | 516 | d->selectedFiles->removeSelected( ); |
478 | writeCurrentM3u(); | 517 | writeCurrentM3u(); |
518 | setButtons(); | ||
479 | } | 519 | } |
480 | 520 | ||
481 | 521 | ||
482 | void PlayListWidget::playIt( QListViewItem *it) { | 522 | void PlayListWidget::playIt( QListViewItem *it) { |
483 | if(!it) return; | 523 | if(!it) return; |
484 | mediaPlayerState->setPlaying(FALSE); | 524 | mediaPlayerState->setPlaying(FALSE); |
485 | mediaPlayerState->setPlaying(TRUE); | 525 | mediaPlayerState->setPlaying(TRUE); |
486 | d->selectedFiles->unSelect(); | 526 | d->selectedFiles->unSelect(); |
487 | } | 527 | } |
488 | 528 | ||
489 | 529 | ||
490 | void PlayListWidget::addToSelection( QListViewItem *it) { | 530 | void PlayListWidget::addToSelection( QListViewItem *it) { |
@@ -501,92 +541,83 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
501 | lnk.setFile( filename ); //sets file name | 541 | lnk.setFile( filename ); //sets file name |
502 | d->selectedFiles->addToSelection( lnk); | 542 | d->selectedFiles->addToSelection( lnk); |
503 | 543 | ||
504 | writeCurrentM3u(); | 544 | writeCurrentM3u(); |
505 | // tabWidget->setCurrentPage(0); | 545 | // tabWidget->setCurrentPage(0); |
506 | 546 | ||
507 | } | 547 | } |
508 | } | 548 | } |
509 | 549 | ||
510 | 550 | ||
511 | void PlayListWidget::tabChanged(QWidget *) { | 551 | void PlayListWidget::tabChanged(QWidget *) { |
512 | 552 | ||
513 | d->tbPlay->setEnabled( true ); | ||
514 | |||
515 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), | 553 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), |
516 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 554 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
517 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), | 555 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), |
518 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 556 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
519 | 557 | ||
520 | currentFileListView = 0; | 558 | currentFileListView = 0; |
521 | 559 | ||
522 | switch ( currentTab() ) { | 560 | switch ( currentTab() ) { |
523 | case CurrentPlayList: | 561 | case CurrentPlayList: |
524 | { | 562 | { |
525 | if( !tbDeletePlaylist->isHidden() ) { | 563 | if( !tbDeletePlaylist->isHidden() ) { |
526 | tbDeletePlaylist->hide(); | 564 | tbDeletePlaylist->hide(); |
527 | } | 565 | } |
528 | d->tbRemoveFromList->setEnabled(TRUE); | ||
529 | d->tbAddToList->setEnabled(FALSE); | 566 | d->tbAddToList->setEnabled(FALSE); |
530 | 567 | ||
531 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | ||
532 | } | 568 | } |
533 | break; | 569 | break; |
534 | case AudioFiles: | 570 | case AudioFiles: |
535 | { | 571 | { |
536 | audioView->populateView(); | 572 | audioView->populateView(); |
537 | 573 | ||
538 | if( !tbDeletePlaylist->isHidden() ) { | 574 | if( !tbDeletePlaylist->isHidden() ) { |
539 | tbDeletePlaylist->hide(); | 575 | tbDeletePlaylist->hide(); |
540 | } | 576 | } |
541 | d->tbRemoveFromList->setEnabled(FALSE); | ||
542 | d->tbAddToList->setEnabled(TRUE); | 577 | d->tbAddToList->setEnabled(TRUE); |
543 | 578 | ||
544 | connect( audioView, SIGNAL( itemsSelected(bool) ), | 579 | connect( audioView, SIGNAL( itemsSelected(bool) ), |
545 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 580 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
546 | 581 | ||
547 | d->tbPlay->setEnabled( audioView->hasSelection() ); | ||
548 | |||
549 | currentFileListView = audioView; | 582 | currentFileListView = audioView; |
550 | } | 583 | } |
551 | break; | 584 | break; |
552 | case VideoFiles: | 585 | case VideoFiles: |
553 | { | 586 | { |
554 | videoView->populateView(); | 587 | videoView->populateView(); |
555 | if( !tbDeletePlaylist->isHidden() ) { | 588 | if( !tbDeletePlaylist->isHidden() ) { |
556 | tbDeletePlaylist->hide(); | 589 | tbDeletePlaylist->hide(); |
557 | } | 590 | } |
558 | d->tbRemoveFromList->setEnabled(FALSE); | ||
559 | d->tbAddToList->setEnabled(TRUE); | 591 | d->tbAddToList->setEnabled(TRUE); |
560 | 592 | ||
561 | connect( videoView, SIGNAL( itemsSelected(bool) ), | 593 | connect( videoView, SIGNAL( itemsSelected(bool) ), |
562 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 594 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
563 | 595 | ||
564 | d->tbPlay->setEnabled( videoView->hasSelection() ); | ||
565 | |||
566 | currentFileListView = videoView; | 596 | currentFileListView = videoView; |
567 | } | 597 | } |
568 | break; | 598 | break; |
569 | case PlayLists: | 599 | case PlayLists: |
570 | { | 600 | { |
571 | if( tbDeletePlaylist->isHidden() ) { | 601 | if( tbDeletePlaylist->isHidden() ) { |
572 | tbDeletePlaylist->show(); | 602 | tbDeletePlaylist->show(); |
573 | } | 603 | } |
574 | playLists->reread(); | 604 | playLists->reread(); |
575 | d->tbAddToList->setEnabled(FALSE); | 605 | d->tbAddToList->setEnabled(FALSE); |
576 | 606 | ||
577 | d->tbPlay->setEnabled( false ); | ||
578 | } | 607 | } |
579 | break; | 608 | break; |
580 | }; | 609 | }; |
610 | |||
611 | setButtons(); | ||
581 | } | 612 | } |
582 | 613 | ||
583 | 614 | ||
584 | void PlayListWidget::btnPlay(bool b) { | 615 | void PlayListWidget::btnPlay(bool b) { |
585 | // mediaPlayerState->setPlaying(false); | 616 | // mediaPlayerState->setPlaying(false); |
586 | mediaPlayerState->setPlaying(b); | 617 | mediaPlayerState->setPlaying(b); |
587 | insanityBool=FALSE; | 618 | insanityBool=FALSE; |
588 | } | 619 | } |
589 | 620 | ||
590 | void PlayListWidget::deletePlaylist() { | 621 | void PlayListWidget::deletePlaylist() { |
591 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 622 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
592 | (tr("You really want to delete\nthis playlist?")), | 623 | (tr("You really want to delete\nthis playlist?")), |
@@ -701,24 +732,26 @@ void PlayListWidget::openFile() { | |||
701 | return; | 732 | return; |
702 | 733 | ||
703 | if(str.left(2) == "//") str=str.right(str.length()-1); | 734 | if(str.left(2) == "//") str=str.right(str.length()-1); |
704 | 735 | ||
705 | 736 | ||
706 | if( str.right( 3) == "m3u" || str.right(3) == "pls" ) { | 737 | if( str.right( 3) == "m3u" || str.right(3) == "pls" ) { |
707 | readListFromFile( str ); | 738 | readListFromFile( str ); |
708 | } else { | 739 | } else { |
709 | QFileInfo info( str ); | 740 | QFileInfo info( str ); |
710 | DocLnk lnk = addFileToPlaylist( str, info.baseName() ); | 741 | DocLnk lnk = addFileToPlaylist( str, info.baseName() ); |
711 | d->selectedFiles->setSelectedItem( lnk.name() ); | 742 | d->selectedFiles->setSelectedItem( lnk.name() ); |
712 | } | 743 | } |
744 | |||
745 | setButtons(); | ||
713 | } | 746 | } |
714 | 747 | ||
715 | void PlayListWidget::openDirectory() { | 748 | void PlayListWidget::openDirectory() { |
716 | QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector, | 749 | QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector, |
717 | QString::null, 0, | 750 | QString::null, 0, |
718 | tr( "Add Files from Directory")); | 751 | tr( "Add Files from Directory")); |
719 | 752 | ||
720 | if(str.isEmpty() ) | 753 | if(str.isEmpty() ) |
721 | return; | 754 | return; |
722 | 755 | ||
723 | if(str.left(2) == "//") str=str.right(str.length()-1); | 756 | if(str.left(2) == "//") str=str.right(str.length()-1); |
724 | QDir dir( str ); | 757 | QDir dir( str ); |
@@ -770,24 +803,25 @@ void PlayListWidget::readListFromFile( const QString &filename ) { | |||
770 | config.setGroup( "PlayList" ); | 803 | config.setGroup( "PlayList" ); |
771 | 804 | ||
772 | config.writeEntry("CurrentPlaylist",filename); | 805 | config.writeEntry("CurrentPlaylist",filename); |
773 | config.write(); | 806 | config.write(); |
774 | currentPlayList=filename; | 807 | currentPlayList=filename; |
775 | 808 | ||
776 | m3uList->close(); | 809 | m3uList->close(); |
777 | delete m3uList; | 810 | delete m3uList; |
778 | 811 | ||
779 | d->selectedFiles->setSelectedItem( s); | 812 | d->selectedFiles->setSelectedItem( s); |
780 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 813 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
781 | 814 | ||
815 | setButtons(); | ||
782 | } | 816 | } |
783 | 817 | ||
784 | // writes current playlist to current m3u file */ | 818 | // writes current playlist to current m3u file */ |
785 | void PlayListWidget::writeCurrentM3u() { | 819 | void PlayListWidget::writeCurrentM3u() { |
786 | odebug << "writing to current m3u" << oendl; | 820 | odebug << "writing to current m3u" << oendl; |
787 | Config cfg( "OpiePlayer" ); | 821 | Config cfg( "OpiePlayer" ); |
788 | cfg.setGroup("PlayList"); | 822 | cfg.setGroup("PlayList"); |
789 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 823 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
790 | 824 | ||
791 | Om3u *m3uList; | 825 | Om3u *m3uList; |
792 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 826 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
793 | if( d->selectedFiles->first()) { | 827 | if( d->selectedFiles->first()) { |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index 1f5ba92..7db0029 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -123,23 +123,24 @@ private slots: | |||
123 | void playIt( QListViewItem *); | 123 | void playIt( QListViewItem *); |
124 | void btnPlay(bool); | 124 | void btnPlay(bool); |
125 | void deletePlaylist(); | 125 | void deletePlaylist(); |
126 | void addSelected(); | 126 | void addSelected(); |
127 | void removeSelected(); | 127 | void removeSelected(); |
128 | void tabChanged(QWidget*); | 128 | void tabChanged(QWidget*); |
129 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 129 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
130 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 130 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
131 | void playSelected(); | 131 | void playSelected(); |
132 | 132 | ||
133 | private: | 133 | private: |
134 | DocLnk addFileToPlaylist(const QString& directory, const QString& name); | 134 | DocLnk addFileToPlaylist(const QString& directory, const QString& name); |
135 | void setButtons(void); | ||
135 | bool fromSetDocument; | 136 | bool fromSetDocument; |
136 | bool insanityBool; | 137 | bool insanityBool; |
137 | QString setDocFileRef, currentPlayList; | 138 | QString setDocFileRef, currentPlayList; |
138 | int selected; | 139 | int selected; |
139 | QListView *currentFileListView; | 140 | QListView *currentFileListView; |
140 | 141 | ||
141 | MediaPlayer *m_mp; | 142 | MediaPlayer *m_mp; |
142 | }; | 143 | }; |
143 | 144 | ||
144 | #endif // PLAY_LIST_WIDGET_H | 145 | #endif // PLAY_LIST_WIDGET_H |
145 | 146 | ||