Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 168 |
1 files changed, 124 insertions, 44 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 19724cb..6acdd1d 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -51,83 +51,110 @@ | |||
51 | //only needed for the random play | 51 | //only needed for the random play |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | 53 | ||
54 | #include "audiowidget.h" | 54 | #include "audiowidget.h" |
55 | #include "videowidget.h" | 55 | #include "videowidget.h" |
56 | 56 | ||
57 | extern MediaPlayerState *mediaPlayerState; | 57 | extern MediaPlayerState *mediaPlayerState; |
58 | 58 | ||
59 | 59 | ||
60 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 60 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
61 | : PlayListWidgetGui( parent, name, fl ) { | 61 | : PlayListWidgetGui( parent, name, fl ) { |
62 | 62 | ||
63 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", | 63 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
64 | "opieplayer2/add_to_playlist", | ||
64 | this , SLOT(addSelected() ) ); | 65 | this , SLOT(addSelected() ) ); |
65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", | 66 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
67 | "opieplayer2/remove_from_playlist", | ||
66 | this , SLOT(removeSelected() ) ); | 68 | this , SLOT(removeSelected() ) ); |
67 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 69 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
68 | this , SLOT( btnPlay( bool) ), TRUE ); | 70 | this , SLOT( btnPlay( bool) ), TRUE ); |
69 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 71 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
70 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 72 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
71 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 73 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
72 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 74 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
73 | 75 | ||
74 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 76 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
75 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 77 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
76 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 78 | this, SLOT( addAllMusicToList() ) ); |
77 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 79 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
80 | this, SLOT( addAllVideoToList() ) ); | ||
81 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | ||
82 | this, SLOT( addAllToList() ) ); | ||
78 | pmPlayList->insertSeparator(-1); | 83 | pmPlayList->insertSeparator(-1); |
79 | (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 84 | (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
80 | (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | 85 | this, SLOT( saveList() ) ); |
86 | (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), | ||
87 | this, SLOT(writem3u() ) ); | ||
81 | pmPlayList->insertSeparator(-1); | 88 | pmPlayList->insertSeparator(-1); |
82 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 89 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
90 | this,SLOT( openFile() ) ); | ||
83 | pmPlayList->insertSeparator(-1); | 91 | pmPlayList->insertSeparator(-1); |
84 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 92 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
85 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 93 | this,SLOT( scanForAudio() ) ); |
94 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | ||
95 | this,SLOT( scanForVideo() ) ); | ||
86 | 96 | ||
87 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); | 97 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
98 | mediaPlayerState, SLOT( toggleFullscreen() ) ); | ||
88 | 99 | ||
89 | Config cfg( "OpiePlayer" ); | 100 | Config cfg( "OpiePlayer" ); |
90 | bool b= cfg.readBoolEntry("FullScreen", 0); | 101 | bool b= cfg.readBoolEntry("FullScreen", 0); |
91 | mediaPlayerState->setFullscreen( b ); | 102 | mediaPlayerState->setFullscreen( b ); |
92 | pmView->setItemChecked( -16, b ); | 103 | pmView->setItemChecked( -16, b ); |
93 | 104 | ||
94 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp() ) ); | 105 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
95 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected() ) ); | 106 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
96 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown() ) ); | 107 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
108 | d->selectedFiles, SLOT(removeSelected() ) ); | ||
109 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | ||
110 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | ||
97 | QVBox *stretch2 = new QVBox( vbox1 ); | 111 | QVBox *stretch2 = new QVBox( vbox1 ); |
98 | 112 | ||
99 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) ); | 113 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
100 | connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) ); | 114 | SLOT( deletePlaylist() ) ); |
101 | connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) ); | 115 | connect( pmView, SIGNAL( activated( int ) ), |
116 | this, SLOT( pmViewActivated( int ) ) ); | ||
117 | connect( skinsMenu, SIGNAL( activated( int ) ) , | ||
118 | this, SLOT( skinsMenuActivated( int ) ) ); | ||
102 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 119 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
103 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 120 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
104 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 121 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
105 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 122 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
106 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 123 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
107 | this,SLOT( playIt( QListViewItem *) ) ); | 124 | this,SLOT( playIt( QListViewItem *) ) ); |
108 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 125 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
126 | this, SLOT( addToSelection( QListViewItem *) ) ); | ||
109 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 127 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
110 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 128 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
111 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 129 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
112 | this,SLOT( playIt( QListViewItem *) ) ); | 130 | this,SLOT( playIt( QListViewItem *) ) ); |
113 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 131 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
114 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 132 | this, SLOT( addToSelection( QListViewItem *) ) ); |
115 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) ); | 133 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
116 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 134 | this, SLOT( loadList( const DocLnk & ) ) ); |
117 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 135 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
118 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 136 | this, SLOT( tabChanged( QWidget* ) ) ); |
119 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 137 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
120 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 138 | d->tbPlay, SLOT( setOn( bool ) ) ); |
121 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 139 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
140 | d->tbLoop, SLOT( setOn( bool ) ) ); | ||
141 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | ||
142 | d->tbShuffle, SLOT( setOn( bool ) ) ); | ||
143 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), | ||
144 | this, SLOT( setPlaylist( bool ) ) ); | ||
145 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | ||
146 | this, SLOT( playIt( QListViewItem *) ) ); | ||
147 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | ||
148 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | ||
122 | 149 | ||
123 | readConfig( cfg ); | 150 | readConfig( cfg ); |
124 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); | 151 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); |
125 | loadList(DocLnk( currentPlaylist ) ); | 152 | loadList(DocLnk( currentPlaylist ) ); |
126 | setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); | 153 | setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); |
127 | 154 | ||
128 | // see which skins are installed | 155 | // see which skins are installed |
129 | videoScan=FALSE; | 156 | videoScan=FALSE; |
130 | audioScan=FALSE; | 157 | audioScan=FALSE; |
131 | populateSkinsMenu(); | 158 | populateSkinsMenu(); |
132 | initializeStates(); | 159 | initializeStates(); |
133 | } | 160 | } |
@@ -152,25 +179,26 @@ void PlayListWidget::initializeStates() { | |||
152 | 179 | ||
153 | 180 | ||
154 | void PlayListWidget::readConfig( Config& cfg ) { | 181 | void PlayListWidget::readConfig( Config& cfg ) { |
155 | cfg.setGroup( "PlayList" ); | 182 | cfg.setGroup( "PlayList" ); |
156 | QString currentString = cfg.readEntry( "current", "" ); | 183 | QString currentString = cfg.readEntry( "current", "" ); |
157 | int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); | 184 | int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); |
158 | for ( int i = 0; i < noOfFiles; i++ ) { | 185 | for ( int i = 0; i < noOfFiles; i++ ) { |
159 | QString entryName; | 186 | QString entryName; |
160 | entryName.sprintf( "File%i", i + 1 ); | 187 | entryName.sprintf( "File%i", i + 1 ); |
161 | QString linkFile = cfg.readEntry( entryName ); | 188 | QString linkFile = cfg.readEntry( entryName ); |
162 | if( QFileInfo( linkFile ).exists() ) { | 189 | if( QFileInfo( linkFile ).exists() ) { |
163 | DocLnk lnk( linkFile ); | 190 | DocLnk lnk( linkFile ); |
164 | if ( QFileInfo( lnk.file() ).exists() || linkFile.find( "http" , 0, TRUE) != -1) { | 191 | if ( QFileInfo( lnk.file() ).exists() || |
192 | linkFile.find( "http" , 0, TRUE) != -1) { | ||
165 | d->selectedFiles->addToSelection( lnk ); | 193 | d->selectedFiles->addToSelection( lnk ); |
166 | } | 194 | } |
167 | } | 195 | } |
168 | } | 196 | } |
169 | d->selectedFiles->setSelectedItem( currentString ); | 197 | d->selectedFiles->setSelectedItem( currentString ); |
170 | } | 198 | } |
171 | 199 | ||
172 | 200 | ||
173 | void PlayListWidget::writeConfig( Config& cfg ) const { | 201 | void PlayListWidget::writeConfig( Config& cfg ) const { |
174 | d->selectedFiles->writeCurrent( cfg ); | 202 | d->selectedFiles->writeCurrent( cfg ); |
175 | cfg.setGroup( "PlayList" ); | 203 | cfg.setGroup( "PlayList" ); |
176 | int noOfFiles = 0; | 204 | int noOfFiles = 0; |
@@ -198,25 +226,26 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
198 | } | 226 | } |
199 | noOfFiles++; | 227 | noOfFiles++; |
200 | } | 228 | } |
201 | } | 229 | } |
202 | while ( d->selectedFiles->next() ); | 230 | while ( d->selectedFiles->next() ); |
203 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 231 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
204 | } | 232 | } |
205 | 233 | ||
206 | 234 | ||
207 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 235 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
208 | d->setDocumentUsed = FALSE; | 236 | d->setDocumentUsed = FALSE; |
209 | if ( mediaPlayerState->playlist() ) { | 237 | if ( mediaPlayerState->playlist() ) { |
210 | if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" ) | 238 | if( QFileInfo( lnk.file() ).exists() || |
239 | lnk.file().left(4) == "http" ) | ||
211 | d->selectedFiles->addToSelection( lnk ); | 240 | d->selectedFiles->addToSelection( lnk ); |
212 | } | 241 | } |
213 | else | 242 | else |
214 | mediaPlayerState->setPlaying( TRUE ); | 243 | mediaPlayerState->setPlaying( TRUE ); |
215 | } | 244 | } |
216 | 245 | ||
217 | 246 | ||
218 | void PlayListWidget::clearList() { | 247 | void PlayListWidget::clearList() { |
219 | while ( first() ) { | 248 | while ( first() ) { |
220 | d->selectedFiles->removeSelected(); | 249 | d->selectedFiles->removeSelected(); |
221 | } | 250 | } |
222 | } | 251 | } |
@@ -281,25 +310,26 @@ void PlayListWidget::addAllVideoToList() { | |||
281 | for ( ; dit.current(); ++dit ) { | 310 | for ( ; dit.current(); ++dit ) { |
282 | if( QFileInfo( dit.current()->file() ).exists() ) { | 311 | if( QFileInfo( dit.current()->file() ).exists() ) { |
283 | d->selectedFiles->addToSelection( **dit ); | 312 | d->selectedFiles->addToSelection( **dit ); |
284 | } | 313 | } |
285 | } | 314 | } |
286 | } | 315 | } |
287 | 316 | ||
288 | 317 | ||
289 | void PlayListWidget::setDocument( const QString& fileref ) { | 318 | void PlayListWidget::setDocument( const QString& fileref ) { |
290 | //qDebug( fileref ); | 319 | //qDebug( fileref ); |
291 | fromSetDocument = TRUE; | 320 | fromSetDocument = TRUE; |
292 | if ( fileref.isNull() ) { | 321 | if ( fileref.isNull() ) { |
293 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 322 | QMessageBox::critical( 0, tr( "Invalid File" ), |
323 | tr( "There was a problem in getting the file." ) ); | ||
294 | return; | 324 | return; |
295 | } | 325 | } |
296 | 326 | ||
297 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 327 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
298 | readm3u( fileref ); | 328 | readm3u( fileref ); |
299 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 329 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
300 | readPls( fileref ); | 330 | readPls( fileref ); |
301 | } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist | 331 | } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist |
302 | clearList(); | 332 | clearList(); |
303 | loadList( DocLnk( fileref ) ); | 333 | loadList( DocLnk( fileref ) ); |
304 | d->selectedFiles->first(); | 334 | d->selectedFiles->first(); |
305 | } else { | 335 | } else { |
@@ -412,25 +442,26 @@ void PlayListWidget::saveList() { | |||
412 | InputDialog *fileDlg = 0l; | 442 | InputDialog *fileDlg = 0l; |
413 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 443 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
414 | fileDlg->exec(); | 444 | fileDlg->exec(); |
415 | if( fileDlg->result() == 1 ) { | 445 | if( fileDlg->result() == 1 ) { |
416 | if ( d->current ) | 446 | if ( d->current ) |
417 | delete d->current; | 447 | delete d->current; |
418 | filename = fileDlg->text();//+".playlist"; | 448 | filename = fileDlg->text();//+".playlist"; |
419 | // qDebug("saving playlist "+filename+".playlist"); | 449 | // qDebug("saving playlist "+filename+".playlist"); |
420 | Config cfg( filename +".playlist"); | 450 | Config cfg( filename +".playlist"); |
421 | writeConfig( cfg ); | 451 | writeConfig( cfg ); |
422 | 452 | ||
423 | DocLnk lnk; | 453 | DocLnk lnk; |
424 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 454 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); |
455 | //sets File property | ||
425 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 456 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
426 | lnk.setIcon("opieplayer2/playlist2"); | 457 | lnk.setIcon("opieplayer2/playlist2"); |
427 | lnk.setName( filename); //sets file name | 458 | lnk.setName( filename); //sets file name |
428 | // qDebug(filename); | 459 | // qDebug(filename); |
429 | if(!lnk.writeLink()) { | 460 | if(!lnk.writeLink()) { |
430 | qDebug("Writing doclink did not work"); | 461 | qDebug("Writing doclink did not work"); |
431 | } | 462 | } |
432 | } | 463 | } |
433 | Config config( "OpiePlayer" ); | 464 | Config config( "OpiePlayer" ); |
434 | config.writeEntry("CurrentPlaylist",filename); | 465 | config.writeEntry("CurrentPlaylist",filename); |
435 | setCaption(tr("OpiePlayer: ")+filename); | 466 | setCaption(tr("OpiePlayer: ")+filename); |
436 | d->selectedFiles->first(); | 467 | d->selectedFiles->first(); |
@@ -698,25 +729,26 @@ void PlayListWidget::populateAudioView() { | |||
698 | 729 | ||
699 | QString storage; | 730 | QString storage; |
700 | for ( ; dit.current(); ++dit ) { | 731 | for ( ; dit.current(); ++dit ) { |
701 | for( ; it.current(); ++it ){ | 732 | for( ; it.current(); ++it ){ |
702 | const QString name = (*it)->name(); | 733 | const QString name = (*it)->name(); |
703 | const QString path = (*it)->path(); | 734 | const QString path = (*it)->path(); |
704 | if(dit.current()->file().find(path) != -1 ) { | 735 | if(dit.current()->file().find(path) != -1 ) { |
705 | storage = name; | 736 | storage = name; |
706 | } | 737 | } |
707 | } | 738 | } |
708 | 739 | ||
709 | QListViewItem * newItem; | 740 | QListViewItem * newItem; |
710 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 741 | if ( QFile( dit.current()->file()).exists() || |
742 | dit.current()->file().left(4) == "http" ) { | ||
711 | long size; | 743 | long size; |
712 | if( dit.current()->file().left(4) == "http" ) | 744 | if( dit.current()->file().left(4) == "http" ) |
713 | size=0; | 745 | size=0; |
714 | else | 746 | else |
715 | size = QFile( dit.current()->file() ).size(); | 747 | size = QFile( dit.current()->file() ).size(); |
716 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 748 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
717 | QString::number(size ), storage, dit.current()->file()); | 749 | QString::number(size ), storage, dit.current()->file()); |
718 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 750 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
719 | } | 751 | } |
720 | } | 752 | } |
721 | } | 753 | } |
722 | 754 | ||
@@ -738,58 +770,105 @@ void PlayListWidget::populateVideoView() { | |||
738 | for( ; it.current(); ++it ) { | 770 | for( ; it.current(); ++it ) { |
739 | const QString name = (*it)->name(); | 771 | const QString name = (*it)->name(); |
740 | const QString path = (*it)->path(); | 772 | const QString path = (*it)->path(); |
741 | if( Vdit.current()->file().find(path) != -1 ) { | 773 | if( Vdit.current()->file().find(path) != -1 ) { |
742 | storage=name; | 774 | storage=name; |
743 | pathName=path; | 775 | pathName=path; |
744 | } | 776 | } |
745 | } | 777 | } |
746 | 778 | ||
747 | QListViewItem * newItem; | 779 | QListViewItem * newItem; |
748 | if ( QFile( Vdit.current()->file() ).exists() ) { | 780 | if ( QFile( Vdit.current()->file() ).exists() ) { |
749 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 781 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
750 | QString::number( QFile( Vdit.current()->file() ).size() ), storage, Vdit.current()->file()); | 782 | QString::number( QFile( Vdit.current()->file() ).size() ), |
783 | storage, Vdit.current()->file()); | ||
751 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 784 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
752 | } | 785 | } |
753 | } | 786 | } |
754 | } | 787 | } |
755 | 788 | ||
756 | 789 | ||
757 | void PlayListWidget::openFile() { | 790 | void PlayListWidget::openFile() { |
758 | QString filename, name; | 791 | QString filename, name; |
759 | InputDialog *fileDlg; | 792 | InputDialog *fileDlg; |
760 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 793 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
761 | fileDlg->exec(); | 794 | fileDlg->exec(); |
762 | if( fileDlg->result() == 1 ) { | 795 | if( fileDlg->result() == 1 ) { |
763 | filename = fileDlg->text(); | 796 | filename = fileDlg->text(); |
764 | 797 | ||
765 | qDebug( "Selected filename is " + filename ); | 798 | qDebug( "Selected filename is " + filename ); |
766 | if( filename.right( 3 ) == "m3u" ) { | 799 | |
767 | readm3u( filename ); | 800 | if(filename.left(4) == "http") { |
768 | } else if( filename.right(3) == "pls" ) { | ||
769 | readPls( filename ); | ||
770 | } else { | ||
771 | // this doesnt need fixing | ||
772 | DocLnk lnk; | 801 | DocLnk lnk; |
773 | lnk.setName( filename ); //sets file name | 802 | QString m3uFile, m3uFilePath; |
774 | lnk.setFile( filename ); //sets File property | 803 | if(filename.find(":",8,TRUE) != -1) { |
775 | //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); | 804 | //found a port |
776 | lnk.setType( MimeType( QFile::encodeName(filename) ).id() ); | 805 | m3uFile=filename.left(filename.find(":",8,TRUE)); |
806 | |||
807 | m3uFile=m3uFile.right(m3uFile.length()-7); | ||
808 | qDebug(m3uFile); | ||
809 | m3uFilePath= QDir::homeDirPath()+"/"+m3uFile+".m3u"; | ||
810 | |||
811 | QFile f(m3uFilePath ); | ||
812 | f.open( IO_WriteOnly ); | ||
813 | f.writeBlock( filename, filename.length() ); | ||
814 | f.close(); | ||
815 | |||
816 | lnk.setName( m3uFile ); //sets file name | ||
817 | lnk.setFile( m3uFilePath ); //sets File property | ||
818 | //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); | ||
819 | lnk.setType( MimeType( QFile::encodeName(m3uFilePath) ).id() ); | ||
820 | |||
821 | } else if(filename.left(4) == "http"){ | ||
822 | |||
823 | m3uFile=m3uFile.right(m3uFile.length()-7); | ||
824 | qDebug(m3uFile); | ||
825 | |||
826 | m3uFilePath= QDir::homeDirPath()+"/"+m3uFile+".m3u"; | ||
827 | |||
828 | QFile f(m3uFilePath ); | ||
829 | f.open( IO_WriteOnly ); | ||
830 | f.writeBlock( filename, filename.length() ); | ||
831 | f.close(); | ||
832 | |||
833 | lnk.setName( m3uFile ); //sets file name | ||
834 | lnk.setFile( m3uFilePath ); //sets File property | ||
835 | //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); | ||
836 | lnk.setType( MimeType( QFile::encodeName(m3uFilePath) ).id() ); | ||
837 | |||
838 | } else{ | ||
839 | |||
840 | QFile f( filename ); | ||
841 | f.open( IO_WriteOnly ); | ||
842 | f.writeBlock( filename, filename.length() ); | ||
843 | f.close(); | ||
844 | |||
845 | lnk.setName( filename ); //sets file name | ||
846 | lnk.setFile( filename ); //sets File property | ||
847 | //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); | ||
848 | lnk.setType( MimeType( QFile::encodeName(filename) ).id() ); | ||
849 | } | ||
777 | lnk.setExec( "opieplayer" ); | 850 | lnk.setExec( "opieplayer" ); |
778 | lnk.setIcon( "opieplayer2/MPEGPlayer" ); | 851 | lnk.setIcon( "opieplayer2/MPEGPlayer" ); |
779 | 852 | ||
780 | if( !lnk.writeLink() ) { | 853 | if( !lnk.writeLink() ) { |
781 | qDebug( "Writing doclink did not work" ); | 854 | qDebug( "Writing doclink did not work" ); |
782 | } | 855 | } |
783 | d->selectedFiles->addToSelection( lnk ); | 856 | d->selectedFiles->addToSelection( lnk ); |
857 | |||
858 | } | ||
859 | else if( filename.right( 3 ) == "m3u" ) { | ||
860 | readm3u( filename ); | ||
861 | } else if( filename.right(3) == "pls" ) { | ||
862 | readPls( filename ); | ||
784 | } | 863 | } |
785 | } | 864 | } |
786 | if( fileDlg ) { | 865 | if( fileDlg ) { |
787 | delete fileDlg; | 866 | delete fileDlg; |
788 | } | 867 | } |
789 | } | 868 | } |
790 | 869 | ||
791 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 870 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
792 | switch ( e->key() ) { | 871 | switch ( e->key() ) { |
793 | ////////////////////////////// Zaurus keys | 872 | ////////////////////////////// Zaurus keys |
794 | case Key_F9: //activity | 873 | case Key_F9: //activity |
795 | // if(audioUI->isHidden()) | 874 | // if(audioUI->isHidden()) |
@@ -849,25 +928,26 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | |||
849 | void PlayListWidget::readm3u( const QString &filename ) { | 928 | void PlayListWidget::readm3u( const QString &filename ) { |
850 | qDebug( "m3u filename is " + filename ); | 929 | qDebug( "m3u filename is " + filename ); |
851 | QFile f( filename ); | 930 | QFile f( filename ); |
852 | 931 | ||
853 | if( f.open( IO_ReadOnly ) ) { | 932 | if( f.open( IO_ReadOnly ) ) { |
854 | QTextStream t(&f); | 933 | QTextStream t(&f); |
855 | QString s;//, first, second; | 934 | QString s;//, first, second; |
856 | int i=0; | 935 | int i=0; |
857 | while ( !t.atEnd() ) { | 936 | while ( !t.atEnd() ) { |
858 | s=t.readLine(); | 937 | s=t.readLine(); |
859 | 938 | ||
860 | if( s.find( "#", 0, TRUE) == -1 ) { | 939 | if( s.find( "#", 0, TRUE) == -1 ) { |
861 | if( s.find( " ", 0, TRUE) == -1 ) { // not sure if this is neede since cf uses vfat | 940 | if( s.find( " ", 0, TRUE) == -1 ) { |
941 | // not sure if this is neede since cf uses vfat | ||
862 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 942 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
863 | s = s.right( s.length() -2 ); | 943 | s = s.right( s.length() -2 ); |
864 | DocLnk lnk( s ); | 944 | DocLnk lnk( s ); |
865 | QFileInfo f( s ); | 945 | QFileInfo f( s ); |
866 | QString name = f.baseName(); | 946 | QString name = f.baseName(); |
867 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 947 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
868 | lnk.setName( name ); | 948 | lnk.setName( name ); |
869 | s=s.replace( QRegExp( "\\" ), "/" ); | 949 | s=s.replace( QRegExp( "\\" ), "/" ); |
870 | lnk.setFile( s ); | 950 | lnk.setFile( s ); |
871 | lnk.writeLink(); | 951 | lnk.writeLink(); |
872 | qDebug( "add " + name); | 952 | qDebug( "add " + name); |
873 | d->selectedFiles->addToSelection( lnk ); | 953 | d->selectedFiles->addToSelection( lnk ); |