author | llornkcor <llornkcor> | 2002-11-12 02:48:15 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-12 02:48:15 (UTC) |
commit | ee4ec981207254f6541e080a62b91bae8c9f1726 (patch) (unidiff) | |
tree | 587a0f7e079193770f3c0bde6f381bb7acc55b33 /core/multimedia/opieplayer | |
parent | c829e55b85c20034f0ae07336fd3f5b9a03d9a48 (diff) | |
download | opie-ee4ec981207254f6541e080a62b91bae8c9f1726.zip opie-ee4ec981207254f6541e080a62b91bae8c9f1726.tar.gz opie-ee4ec981207254f6541e080a62b91bae8c9f1726.tar.bz2 |
sync with op2
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 7 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 129 |
2 files changed, 57 insertions, 79 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index ef7c8dc..9a55608 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp | |||
@@ -75,24 +75,25 @@ static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | |||
75 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 75 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
76 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) | 76 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) |
77 | { | 77 | { |
78 | setCaption( tr("OpiePlayer") ); | 78 | setCaption( tr("OpiePlayer") ); |
79 | qDebug("<<<<<audioWidget"); | 79 | qDebug("<<<<<audioWidget"); |
80 | 80 | ||
81 | Config cfg("OpiePlayer"); | 81 | Config cfg("OpiePlayer"); |
82 | cfg.setGroup("Options"); | 82 | cfg.setGroup("Options"); |
83 | skin = cfg.readEntry("Skin","default"); | 83 | skin = cfg.readEntry("Skin","default"); |
84 | //skin = "scaleTest"; | 84 | //skin = "scaleTest"; |
85 | // color of background, frame, degree of transparency | 85 | // color of background, frame, degree of transparency |
86 | 86 | ||
87 | // QString skinPath = "opieplayer/skins/" + skin; | ||
87 | QString skinPath = "opieplayer2/skins/" + skin; | 88 | QString skinPath = "opieplayer2/skins/" + skin; |
88 | qDebug("skin path "+skinPath); | 89 | qDebug("skin path "+skinPath); |
89 | 90 | ||
90 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 91 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
91 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 92 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
92 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 93 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
93 | 94 | ||
94 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 95 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
95 | imgButtonMask->fill( 0 ); | 96 | imgButtonMask->fill( 0 ); |
96 | 97 | ||
97 | for ( int i = 0; i < 10; i++ ) { | 98 | for ( int i = 0; i < 10; i++ ) { |
98 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; | 99 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; |
@@ -111,27 +112,27 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | |||
111 | 112 | ||
112 | } | 113 | } |
113 | 114 | ||
114 | for ( int i = 0; i < 11; i++ ) { | 115 | for ( int i = 0; i < 11; i++ ) { |
115 | buttonPixUp[i] = NULL; | 116 | buttonPixUp[i] = NULL; |
116 | buttonPixDown[i] = NULL; | 117 | buttonPixDown[i] = NULL; |
117 | } | 118 | } |
118 | 119 | ||
119 | setBackgroundPixmap( *pixBg ); | 120 | setBackgroundPixmap( *pixBg ); |
120 | 121 | ||
121 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 122 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
122 | 123 | ||
123 | changeTextColor( &songInfo ); | 124 | // changeTextColor( &songInfo ); |
124 | songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 125 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
125 | songInfo.setFrameStyle( QFrame::NoFrame); | 126 | // songInfo.setFrameStyle( QFrame::NoFrame); |
126 | // songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 127 | // songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
127 | //NoFrame | 128 | //NoFrame |
128 | // songInfo.setForegroundColor(Qt::white); | 129 | // songInfo.setForegroundColor(Qt::white); |
129 | 130 | ||
130 | slider.setFixedHeight( 20 ); | 131 | slider.setFixedHeight( 20 ); |
131 | slider.setMinValue( 0 ); | 132 | slider.setMinValue( 0 ); |
132 | slider.setMaxValue( 1 ); | 133 | slider.setMaxValue( 1 ); |
133 | slider.setFocusPolicy( QWidget::NoFocus ); | 134 | slider.setFocusPolicy( QWidget::NoFocus ); |
134 | slider.setBackgroundPixmap( *pixBg ); | 135 | slider.setBackgroundPixmap( *pixBg ); |
135 | 136 | ||
136 | time.setFocusPolicy( QWidget::NoFocus ); | 137 | time.setFocusPolicy( QWidget::NoFocus ); |
137 | time.setAlignment( Qt::AlignCenter ); | 138 | time.setAlignment( Qt::AlignCenter ); |
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index a937d7c..c28548c 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -235,47 +235,50 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
235 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 235 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
236 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 236 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
237 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 237 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
238 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 238 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
239 | 239 | ||
240 | QWidget *aTab; | 240 | QWidget *aTab; |
241 | aTab = new QWidget( tabWidget, "aTab" ); | 241 | aTab = new QWidget( tabWidget, "aTab" ); |
242 | audioView = new QListView( aTab, "Audioview" ); | 242 | audioView = new QListView( aTab, "Audioview" ); |
243 | audioView->setMinimumSize(233,260); | 243 | audioView->setMinimumSize(233,260); |
244 | audioView->addColumn( tr("Title"),140); | 244 | audioView->addColumn( tr("Title"),140); |
245 | audioView->addColumn(tr("Size"), -1); | 245 | audioView->addColumn(tr("Size"), -1); |
246 | audioView->addColumn(tr("Media"),-1); | 246 | audioView->addColumn(tr("Media"),-1); |
247 | audioView->addColumn( tr( "Path" ), 0 ); | ||
248 | |||
247 | audioView->setColumnAlignment(1, Qt::AlignRight); | 249 | audioView->setColumnAlignment(1, Qt::AlignRight); |
248 | audioView->setColumnAlignment(2, Qt::AlignRight); | 250 | audioView->setColumnAlignment(2, Qt::AlignRight); |
249 | audioView->setAllColumnsShowFocus(TRUE); | 251 | audioView->setAllColumnsShowFocus(TRUE); |
250 | 252 | ||
251 | audioView->setMultiSelection( TRUE ); | 253 | audioView->setMultiSelection( TRUE ); |
252 | audioView->setSelectionMode( QListView::Extended); | 254 | audioView->setSelectionMode( QListView::Extended); |
253 | 255 | ||
254 | tabWidget->insertTab(aTab,tr("Audio")); | 256 | tabWidget->insertTab(aTab,tr("Audio")); |
255 | 257 | ||
256 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 258 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
257 | 259 | ||
258 | // audioView | 260 | // audioView |
259 | // populateAudioView(); | 261 | // populateAudioView(); |
260 | // videowidget | 262 | // videowidget |
261 | 263 | ||
262 | QWidget *vTab; | 264 | QWidget *vTab; |
263 | vTab = new QWidget( tabWidget, "vTab" ); | 265 | vTab = new QWidget( tabWidget, "vTab" ); |
264 | videoView = new QListView( vTab, "Videoview" ); | 266 | videoView = new QListView( vTab, "Videoview" ); |
265 | videoView->setMinimumSize(233,260); | 267 | videoView->setMinimumSize(233,260); |
266 | 268 | ||
267 | videoView->addColumn(tr("Title"),140); | 269 | videoView->addColumn(tr("Title"),140); |
268 | videoView->addColumn(tr("Size"),-1); | 270 | videoView->addColumn(tr("Size"),-1); |
269 | videoView->addColumn(tr("Media"),-1); | 271 | videoView->addColumn(tr("Media"),-1); |
272 | videoView->addColumn(tr( "Path" ), 0 ); | ||
270 | videoView->setColumnAlignment(1, Qt::AlignRight); | 273 | videoView->setColumnAlignment(1, Qt::AlignRight); |
271 | videoView->setColumnAlignment(2, Qt::AlignRight); | 274 | videoView->setColumnAlignment(2, Qt::AlignRight); |
272 | videoView->setAllColumnsShowFocus(TRUE); | 275 | videoView->setAllColumnsShowFocus(TRUE); |
273 | videoView->setMultiSelection( TRUE ); | 276 | videoView->setMultiSelection( TRUE ); |
274 | videoView->setSelectionMode( QListView::Extended); | 277 | videoView->setSelectionMode( QListView::Extended); |
275 | 278 | ||
276 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 279 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
277 | 280 | ||
278 | tabWidget->insertTab( vTab,tr("Video")); | 281 | tabWidget->insertTab( vTab,tr("Video")); |
279 | 282 | ||
280 | QWidget *LTab; | 283 | QWidget *LTab; |
281 | LTab = new QWidget( tabWidget, "LTab" ); | 284 | LTab = new QWidget( tabWidget, "LTab" ); |
@@ -310,27 +313,27 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
310 | 313 | ||
311 | // connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 314 | // connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
312 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 315 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
313 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 316 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
314 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 317 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
315 | 318 | ||
316 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 319 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
317 | 320 | ||
318 | setCentralWidget( vbox5 ); | 321 | setCentralWidget( vbox5 ); |
319 | 322 | ||
320 | Config cfg( "OpiePlayer" ); | 323 | Config cfg( "OpiePlayer" ); |
321 | readConfig( cfg ); | 324 | readConfig( cfg ); |
322 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 325 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
323 | loadList(DocLnk( currentPlaylist)); | 326 | loadList(DocLnk( currentPlaylist)); |
324 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 327 | setCaption(tr("OpiePlayer: ")+ QFileInfo(currentPlaylist).baseName()); |
325 | 328 | ||
326 | initializeStates(); | 329 | initializeStates(); |
327 | } | 330 | } |
328 | 331 | ||
329 | 332 | ||
330 | PlayListWidget::~PlayListWidget() { | 333 | PlayListWidget::~PlayListWidget() { |
331 | Config cfg( "OpiePlayer" ); | 334 | Config cfg( "OpiePlayer" ); |
332 | writeConfig( cfg ); | 335 | writeConfig( cfg ); |
333 | 336 | ||
334 | if ( d->current ) | 337 | if ( d->current ) |
335 | delete d->current; | 338 | delete d->current; |
336 | delete d; | 339 | delete d; |
@@ -414,40 +417,52 @@ void PlayListWidget::clearList() { | |||
414 | while ( first() ) | 417 | while ( first() ) |
415 | d->selectedFiles->removeSelected(); | 418 | d->selectedFiles->removeSelected(); |
416 | } | 419 | } |
417 | 420 | ||
418 | 421 | ||
419 | void PlayListWidget::addAllToList() { | 422 | void PlayListWidget::addAllToList() { |
420 | DocLnkSet filesAll; | 423 | DocLnkSet filesAll; |
421 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 424 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
422 | QListIterator<DocLnk> Adit( filesAll.children() ); | 425 | QListIterator<DocLnk> Adit( filesAll.children() ); |
423 | for ( ; Adit.current(); ++Adit ) | 426 | for ( ; Adit.current(); ++Adit ) |
424 | if(QFileInfo(Adit.current()->file()).exists()) | 427 | if(QFileInfo(Adit.current()->file()).exists()) |
425 | d->selectedFiles->addToSelection( **Adit ); | 428 | d->selectedFiles->addToSelection( **Adit ); |
429 | tabWidget->setCurrentPage(0); | ||
430 | |||
431 | writeCurrentM3u(); | ||
432 | d->selectedFiles->first(); | ||
426 | } | 433 | } |
427 | 434 | ||
428 | 435 | ||
429 | void PlayListWidget::addAllMusicToList() { | 436 | void PlayListWidget::addAllMusicToList() { |
430 | QListIterator<DocLnk> dit( files.children() ); | 437 | QListIterator<DocLnk> dit( files.children() ); |
431 | for ( ; dit.current(); ++dit ) | 438 | for ( ; dit.current(); ++dit ) |
432 | if(QFileInfo(dit.current()->file()).exists()) | 439 | if(QFileInfo(dit.current()->file()).exists()) |
433 | d->selectedFiles->addToSelection( **dit ); | 440 | d->selectedFiles->addToSelection( **dit ); |
441 | tabWidget->setCurrentPage(0); | ||
442 | |||
443 | writeCurrentM3u(); | ||
444 | d->selectedFiles->first(); | ||
434 | } | 445 | } |
435 | 446 | ||
436 | 447 | ||
437 | void PlayListWidget::addAllVideoToList() { | 448 | void PlayListWidget::addAllVideoToList() { |
438 | QListIterator<DocLnk> dit( vFiles.children() ); | 449 | QListIterator<DocLnk> dit( vFiles.children() ); |
439 | for ( ; dit.current(); ++dit ) | 450 | for ( ; dit.current(); ++dit ) |
440 | if(QFileInfo( dit.current()->file()).exists()) | 451 | if(QFileInfo( dit.current()->file()).exists()) |
441 | d->selectedFiles->addToSelection( **dit ); | 452 | d->selectedFiles->addToSelection( **dit ); |
453 | tabWidget->setCurrentPage(0); | ||
454 | |||
455 | writeCurrentM3u(); | ||
456 | d->selectedFiles->first(); | ||
442 | } | 457 | } |
443 | 458 | ||
444 | 459 | ||
445 | void PlayListWidget::setDocument(const QString& fileref) { | 460 | void PlayListWidget::setDocument(const QString& fileref) { |
446 | qDebug(fileref); | 461 | qDebug(fileref); |
447 | fromSetDocument = TRUE; | 462 | fromSetDocument = TRUE; |
448 | if ( fileref.isNull() ) { | 463 | if ( fileref.isNull() ) { |
449 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 464 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
450 | return; | 465 | return; |
451 | } | 466 | } |
452 | // qDebug("setDocument "+fileref); | 467 | // qDebug("setDocument "+fileref); |
453 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 468 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
@@ -636,127 +651,87 @@ void PlayListWidget::setPlaylist( bool shown ) { | |||
636 | else | 651 | else |
637 | d->playListFrame->hide(); | 652 | d->playListFrame->hide(); |
638 | } | 653 | } |
639 | 654 | ||
640 | void PlayListWidget::setView( char view ) { | 655 | void PlayListWidget::setView( char view ) { |
641 | if ( view == 'l' ) | 656 | if ( view == 'l' ) |
642 | showMaximized(); | 657 | showMaximized(); |
643 | else | 658 | else |
644 | hide(); | 659 | hide(); |
645 | } | 660 | } |
646 | 661 | ||
647 | void PlayListWidget::addSelected() { | 662 | void PlayListWidget::addSelected() { |
648 | 663 | qDebug("addSelected"); | |
649 | Config cfg( "OpiePlayer" ); | 664 | DocLnk lnk; |
650 | cfg.setGroup("PlayList"); | 665 | QString filename; |
651 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | ||
652 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | ||
653 | |||
654 | switch (tabWidget->currentPageIndex()) { | 666 | switch (tabWidget->currentPageIndex()) { |
667 | |||
655 | case 0: //playlist | 668 | case 0: //playlist |
669 | return; | ||
656 | break; | 670 | break; |
657 | case 1: { //audio | 671 | case 1: { //audio |
658 | // QString entryName; | 672 | filename=audioView->currentItem()->text(3); |
659 | // entryName.sprintf( "File%i", i + 1 ); | 673 | // d->selectedFiles->next(); |
660 | // QString linkFile = cfg.readEntry( entryName ); | ||
661 | QListViewItemIterator it( audioView ); | ||
662 | // iterate through all items of the listview | ||
663 | for ( ; it.current(); ++it ) { | ||
664 | if ( it.current()->isSelected() ) { | ||
665 | QListIterator<DocLnk> dit( files.children() ); | ||
666 | for ( ; dit.current(); ++dit ) { | ||
667 | if( dit.current()->name() == it.current()->text(0) ) { | ||
668 | d->selectedFiles->addToSelection( **dit ); | ||
669 | } | ||
670 | } | ||
671 | audioView->setSelected( it.current(),FALSE); | ||
672 | } | ||
673 | } | ||
674 | tabWidget->setCurrentPage(0); | ||
675 | } | 674 | } |
676 | break; | 675 | break; |
676 | |||
677 | case 2: { // video | 677 | case 2: { // video |
678 | QListViewItemIterator it( videoView ); | 678 | filename=videoView->currentItem()->text(3); |
679 | // iterate through all items of the listview | 679 | // tabWidget->setCurrentPage(0); |
680 | for ( ; it.current(); ++it ) { | ||
681 | if ( it.current()->isSelected() ) { | ||
682 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
683 | for ( ; dit.current(); ++dit ) { | ||
684 | if( dit.current()->name() == it.current()->text(0) ) { | ||
685 | d->selectedFiles->addToSelection( **dit ); | ||
686 | } | ||
687 | } | ||
688 | 680 | ||
689 | videoView->setSelected( it.current(),FALSE); | ||
690 | } | ||
691 | } | ||
692 | // for ( int i = 0; i < noOfFiles; i++ ) { | ||
693 | // QString entryName; | ||
694 | // entryName.sprintf( "File%i", i + 1 ); | ||
695 | // QString linkFile = cfg.readEntry( entryName ); | ||
696 | // if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | ||
697 | // int result= QMessageBox::warning(this,tr("OpiePlayer"), | ||
698 | // tr("This is all ready in your playlist.\nContinue?"), | ||
699 | // tr("Yes"),tr("No"),0,0,1); | ||
700 | // if (result !=0) | ||
701 | // return; | ||
702 | // } | ||
703 | // } | ||
704 | // addToSelection( videoView->selectedItem() ); | ||
705 | tabWidget->setCurrentPage(0); | ||
706 | } | 681 | } |
707 | break; | 682 | break; |
708 | }; | 683 | }; |
684 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | ||
685 | lnk.setFile( filename ); //sets file name | ||
686 | d->selectedFiles->addToSelection( lnk); | ||
687 | tabWidget->setCurrentPage(0); | ||
688 | writeCurrentM3u(); | ||
689 | |||
709 | } | 690 | } |
710 | 691 | ||
711 | void PlayListWidget::removeSelected() { | 692 | void PlayListWidget::removeSelected() { |
712 | d->selectedFiles->removeSelected( ); | 693 | d->selectedFiles->removeSelected( ); |
713 | } | 694 | } |
714 | 695 | ||
715 | void PlayListWidget::playIt( QListViewItem *) { | 696 | void PlayListWidget::playIt( QListViewItem *) { |
716 | // d->setDocumentUsed = FALSE; | 697 | // d->setDocumentUsed = FALSE; |
717 | // mediaPlayerState->curPosition =0; | 698 | // mediaPlayerState->curPosition =0; |
718 | qDebug("playIt"); | 699 | qDebug("playIt"); |
719 | mediaPlayerState->setPlaying(FALSE); | 700 | mediaPlayerState->setPlaying(FALSE); |
720 | mediaPlayerState->setPlaying(TRUE); | 701 | mediaPlayerState->setPlaying(TRUE); |
721 | d->selectedFiles->unSelect(); | 702 | d->selectedFiles->unSelect(); |
722 | } | 703 | } |
723 | 704 | ||
724 | void PlayListWidget::addToSelection( QListViewItem *it) { | 705 | void PlayListWidget::addToSelection( QListViewItem *it) { |
725 | d->setDocumentUsed = FALSE; | 706 | d->setDocumentUsed = FALSE; |
726 | 707 | ||
727 | if(it) { | 708 | if(it) { |
728 | switch (tabWidget->currentPageIndex()) { | 709 | switch (tabWidget->currentPageIndex()) { |
729 | case 1: { | 710 | case 0: //playlist |
730 | QListIterator<DocLnk> dit( files.children() ); | 711 | return; |
731 | for ( ; dit.current(); ++dit ) { | ||
732 | if( dit.current()->name() == it->text(0)) { | ||
733 | d->selectedFiles->addToSelection( **dit ); | ||
734 | } | ||
735 | } | ||
736 | } | ||
737 | break; | ||
738 | case 2: { | ||
739 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
740 | for ( ; dit.current(); ++dit ) { | ||
741 | if( dit.current()->name() == it->text(0)) { | ||
742 | d->selectedFiles->addToSelection( **dit ); | ||
743 | } | ||
744 | } | ||
745 | } | ||
746 | break; | ||
747 | case 0: | ||
748 | break; | 712 | break; |
749 | }; | 713 | }; |
714 | // case 1: { | ||
715 | DocLnk lnk; | ||
716 | QString filename; | ||
717 | |||
718 | filename=it->text(3); | ||
719 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | ||
720 | lnk.setFile( filename ); //sets file name | ||
721 | d->selectedFiles->addToSelection( lnk); | ||
722 | |||
723 | writeCurrentM3u(); | ||
750 | tabWidget->setCurrentPage(0); | 724 | tabWidget->setCurrentPage(0); |
725 | |||
751 | } | 726 | } |
752 | } | 727 | } |
753 | 728 | ||
754 | void PlayListWidget::tabChanged(QWidget *) { | 729 | void PlayListWidget::tabChanged(QWidget *) { |
755 | 730 | ||
756 | switch ( tabWidget->currentPageIndex()) { | 731 | switch ( tabWidget->currentPageIndex()) { |
757 | case 0: | 732 | case 0: |
758 | { | 733 | { |
759 | if( !tbDeletePlaylist->isHidden()) | 734 | if( !tbDeletePlaylist->isHidden()) |
760 | tbDeletePlaylist->hide(); | 735 | tbDeletePlaylist->hide(); |
761 | d->tbRemoveFromList->setEnabled(TRUE); | 736 | d->tbRemoveFromList->setEnabled(TRUE); |
762 | d->tbAddToList->setEnabled(FALSE); | 737 | d->tbAddToList->setEnabled(FALSE); |
@@ -980,25 +955,25 @@ void PlayListWidget::populateAudioView() { | |||
980 | if(dit.current()->file().find(path) != -1 ) storage=name; | 955 | if(dit.current()->file().find(path) != -1 ) storage=name; |
981 | } | 956 | } |
982 | 957 | ||
983 | QListViewItem * newItem; | 958 | QListViewItem * newItem; |
984 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 959 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
985 | long size; | 960 | long size; |
986 | if( dit.current()->file().left(4) == "http" ) | 961 | if( dit.current()->file().left(4) == "http" ) |
987 | size=0; | 962 | size=0; |
988 | else | 963 | else |
989 | size = QFile( dit.current()->file() ).size(); | 964 | size = QFile( dit.current()->file() ).size(); |
990 | // qDebug(dit.current()->name()); | 965 | // qDebug(dit.current()->name()); |
991 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 966 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
992 | QString::number(size ), storage); | 967 | QString::number(size ), storage, dit.current()->file()); |
993 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 968 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
994 | } | 969 | } |
995 | } | 970 | } |
996 | 971 | ||
997 | } | 972 | } |
998 | 973 | ||
999 | void PlayListWidget::populateVideoView() { | 974 | void PlayListWidget::populateVideoView() { |
1000 | videoView->clear(); | 975 | videoView->clear(); |
1001 | StorageInfo storageInfo; | 976 | StorageInfo storageInfo; |
1002 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 977 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1003 | 978 | ||
1004 | if(!videoScan ) scanForVideo(); | 979 | if(!videoScan ) scanForVideo(); |
@@ -1008,25 +983,26 @@ void PlayListWidget::populateVideoView() { | |||
1008 | videoView->clear(); | 983 | videoView->clear(); |
1009 | QString storage; | 984 | QString storage; |
1010 | for ( ; Vdit.current(); ++Vdit ) { | 985 | for ( ; Vdit.current(); ++Vdit ) { |
1011 | for( ; it.current(); ++it ){ | 986 | for( ; it.current(); ++it ){ |
1012 | const QString name = (*it)->name(); | 987 | const QString name = (*it)->name(); |
1013 | const QString path = (*it)->path(); | 988 | const QString path = (*it)->path(); |
1014 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 989 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1015 | } | 990 | } |
1016 | 991 | ||
1017 | QListViewItem * newItem; | 992 | QListViewItem * newItem; |
1018 | if ( QFile( Vdit.current()->file()).exists() ) { | 993 | if ( QFile( Vdit.current()->file()).exists() ) { |
1019 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 994 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1020 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 995 | QString::number( QFile( Vdit.current()->file() ).size() ), |
996 | storage, Vdit.current()->file()); | ||
1021 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 997 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1022 | } | 998 | } |
1023 | } | 999 | } |
1024 | } | 1000 | } |
1025 | 1001 | ||
1026 | void PlayListWidget::openFile() { | 1002 | void PlayListWidget::openFile() { |
1027 | qDebug("<<<<<<<<<OPEN File"); | 1003 | qDebug("<<<<<<<<<OPEN File"); |
1028 | QString filename, name; | 1004 | QString filename, name; |
1029 | InputDialog *fileDlg; | 1005 | InputDialog *fileDlg; |
1030 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1006 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1031 | fileDlg->exec(); | 1007 | fileDlg->exec(); |
1032 | if( fileDlg->result() == 1 ) { | 1008 | if( fileDlg->result() == 1 ) { |
@@ -1053,25 +1029,27 @@ void PlayListWidget::openFile() { | |||
1053 | lnk.setName( filename ); //sets name | 1029 | lnk.setName( filename ); //sets name |
1054 | lnk.setFile( filename ); //sets file name | 1030 | lnk.setFile( filename ); //sets file name |
1055 | lnk.setIcon("opieplayer2/musicfile"); | 1031 | lnk.setIcon("opieplayer2/musicfile"); |
1056 | d->selectedFiles->addToSelection( lnk ); | 1032 | d->selectedFiles->addToSelection( lnk ); |
1057 | writeCurrentM3u(); | 1033 | writeCurrentM3u(); |
1058 | } | 1034 | } |
1059 | else if( filename.right( 3) == "m3u" ) { | 1035 | else if( filename.right( 3) == "m3u" ) { |
1060 | readm3u( filename ); | 1036 | readm3u( filename ); |
1061 | 1037 | ||
1062 | } else if( filename.right(3) == "pls" ) { | 1038 | } else if( filename.right(3) == "pls" ) { |
1063 | readPls( filename ); | 1039 | readPls( filename ); |
1064 | } else { | 1040 | } else { |
1065 | d->selectedFiles->addToSelection( DocLnk(filename) ); | 1041 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
1042 | lnk.setFile( filename ); //sets file name | ||
1043 | d->selectedFiles->addToSelection( lnk); | ||
1066 | writeCurrentM3u(); | 1044 | writeCurrentM3u(); |
1067 | } | 1045 | } |
1068 | } | 1046 | } |
1069 | 1047 | ||
1070 | if( fileDlg ) { | 1048 | if( fileDlg ) { |
1071 | delete fileDlg; | 1049 | delete fileDlg; |
1072 | } | 1050 | } |
1073 | } | 1051 | } |
1074 | 1052 | ||
1075 | 1053 | ||
1076 | /* | 1054 | /* |
1077 | reads m3u and shows files/urls to playlist widget */ | 1055 | reads m3u and shows files/urls to playlist widget */ |
@@ -1168,29 +1146,28 @@ void PlayListWidget::readPls( const QString &filename ) { | |||
1168 | 1146 | ||
1169 | m3uList->close(); | 1147 | m3uList->close(); |
1170 | if(m3uList) delete m3uList; | 1148 | if(m3uList) delete m3uList; |
1171 | } | 1149 | } |
1172 | 1150 | ||
1173 | /* | 1151 | /* |
1174 | writes current playlist to current m3u file */ | 1152 | writes current playlist to current m3u file */ |
1175 | void PlayListWidget::writeCurrentM3u() { | 1153 | void PlayListWidget::writeCurrentM3u() { |
1176 | qDebug("writing to current m3u"); | 1154 | qDebug("writing to current m3u"); |
1177 | Config cfg( "OpiePlayer" ); | 1155 | Config cfg( "OpiePlayer" ); |
1178 | cfg.setGroup("PlayList"); | 1156 | cfg.setGroup("PlayList"); |
1179 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 1157 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
1180 | |||
1181 | if( d->selectedFiles->first()) { | ||
1182 | Om3u *m3uList; | 1158 | Om3u *m3uList; |
1183 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 1159 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
1184 | 1160 | ||
1161 | if( d->selectedFiles->first()) { | ||
1185 | do { | 1162 | do { |
1186 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | 1163 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); |
1187 | m3uList->add( d->selectedFiles->current()->file() ); | 1164 | m3uList->add( d->selectedFiles->current()->file() ); |
1188 | } | 1165 | } |
1189 | while ( d->selectedFiles->next() ); | 1166 | while ( d->selectedFiles->next() ); |
1190 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 1167 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
1191 | m3uList->write(); | 1168 | m3uList->write(); |
1192 | m3uList->close(); | 1169 | m3uList->close(); |
1193 | 1170 | ||
1194 | if(m3uList) delete m3uList; | 1171 | if(m3uList) delete m3uList; |
1195 | } | 1172 | } |
1196 | } | 1173 | } |