author | zecke <zecke> | 2004-06-29 20:04:17 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-06-29 20:04:17 (UTC) |
commit | c4405f8d22769e9881484d3f7640e4ba87ed75ee (patch) (unidiff) | |
tree | af997b01742c9b7762babca007edf1310c455289 | |
parent | 8bd9d5e9416166a1bb9a3f455ebf73a14628c628 (diff) | |
download | opie-c4405f8d22769e9881484d3f7640e4ba87ed75ee.zip opie-c4405f8d22769e9881484d3f7640e4ba87ed75ee.tar.gz opie-c4405f8d22769e9881484d3f7640e4ba87ed75ee.tar.bz2 |
As pointed out by bradc OpiePlayer2 is not able to open desktop files.
Now we check if it is a valid desktop file and then ask for the DocLnk::file()
and then use that for open.
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 6a15134..36f77be 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -138,387 +138,393 @@ PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) | |||
138 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), | 138 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), |
139 | d->tbLoop, SLOT( setOn(bool) ) ); | 139 | d->tbLoop, SLOT( setOn(bool) ) ); |
140 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), | 140 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), |
141 | d->tbShuffle, SLOT( setOn(bool) ) ); | 141 | d->tbShuffle, SLOT( setOn(bool) ) ); |
142 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), | 142 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), |
143 | this, SLOT( playIt(QListViewItem*) ) ); | 143 | this, SLOT( playIt(QListViewItem*) ) ); |
144 | connect ( gammaSlider, SIGNAL( valueChanged(int) ), | 144 | connect ( gammaSlider, SIGNAL( valueChanged(int) ), |
145 | mediaPlayerState, SLOT( setVideoGamma(int) ) ); | 145 | mediaPlayerState, SLOT( setVideoGamma(int) ) ); |
146 | 146 | ||
147 | connect( this, SIGNAL(skinSelected() ), | 147 | connect( this, SIGNAL(skinSelected() ), |
148 | m_mp, SLOT( reloadSkins() ) ); | 148 | m_mp, SLOT( reloadSkins() ) ); |
149 | 149 | ||
150 | // see which skins are installed | 150 | // see which skins are installed |
151 | populateSkinsMenu(); | 151 | populateSkinsMenu(); |
152 | initializeStates(); | 152 | initializeStates(); |
153 | 153 | ||
154 | channel = new QCopChannel( "QPE/Application/opieplayer2", this ); | 154 | channel = new QCopChannel( "QPE/Application/opieplayer2", this ); |
155 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 155 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
156 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); | 156 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); |
157 | 157 | ||
158 | 158 | ||
159 | cfg.setGroup("PlayList"); | 159 | cfg.setGroup("PlayList"); |
160 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 160 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
161 | loadList(DocLnk( currentPlaylist ) ); | 161 | loadList(DocLnk( currentPlaylist ) ); |
162 | 162 | ||
163 | tabWidget->showPage( playListTab ); | 163 | tabWidget->showPage( playListTab ); |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | PlayListWidget::~PlayListWidget() { | 167 | PlayListWidget::~PlayListWidget() { |
168 | delete d; | 168 | delete d; |
169 | delete m_mp; | 169 | delete m_mp; |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | void PlayListWidget::initializeStates() { | 173 | void PlayListWidget::initializeStates() { |
174 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); | 174 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); |
175 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); | 175 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); |
176 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); | 176 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); |
177 | d->playListFrame->show(); | 177 | d->playListFrame->show(); |
178 | } | 178 | } |
179 | 179 | ||
180 | void PlayListWidget::writeDefaultPlaylist() { | 180 | void PlayListWidget::writeDefaultPlaylist() { |
181 | 181 | ||
182 | Config config( "OpiePlayer" ); | 182 | Config config( "OpiePlayer" ); |
183 | config.setGroup( "PlayList" ); | 183 | config.setGroup( "PlayList" ); |
184 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 184 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
185 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 185 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
186 | if( currentString == filename) { | 186 | if( currentString == filename) { |
187 | Om3u *m3uList; | 187 | Om3u *m3uList; |
188 | // odebug << "<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>" << oendl; | 188 | // odebug << "<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>" << oendl; |
189 | if( d->selectedFiles->first() ) { | 189 | if( d->selectedFiles->first() ) { |
190 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 190 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
191 | do { | 191 | do { |
192 | // odebug << d->selectedFiles->current()->file() << oendl; | 192 | // odebug << d->selectedFiles->current()->file() << oendl; |
193 | m3uList->add( d->selectedFiles->current()->file() ); | 193 | m3uList->add( d->selectedFiles->current()->file() ); |
194 | } | 194 | } |
195 | while ( d->selectedFiles->next() ); | 195 | while ( d->selectedFiles->next() ); |
196 | 196 | ||
197 | m3uList->write(); | 197 | m3uList->write(); |
198 | m3uList->close(); | 198 | m3uList->close(); |
199 | delete m3uList; | 199 | delete m3uList; |
200 | 200 | ||
201 | } | 201 | } |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 205 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
206 | d->setDocumentUsed = FALSE; | 206 | d->setDocumentUsed = FALSE; |
207 | if( QFileInfo( lnk.file() ).exists() || | 207 | if( QFileInfo( lnk.file() ).exists() || |
208 | lnk.file().left(4) == "http" ) { | 208 | lnk.file().left(4) == "http" ) { |
209 | d->selectedFiles->addToSelection( lnk ); | 209 | d->selectedFiles->addToSelection( lnk ); |
210 | } | 210 | } |
211 | // writeCurrentM3u(); | 211 | // writeCurrentM3u(); |
212 | } | 212 | } |
213 | 213 | ||
214 | 214 | ||
215 | void PlayListWidget::clearList() { | 215 | void PlayListWidget::clearList() { |
216 | while ( first() ) { | 216 | while ( first() ) { |
217 | d->selectedFiles->removeSelected(); | 217 | d->selectedFiles->removeSelected(); |
218 | } | 218 | } |
219 | Config cfg( "OpiePlayer" ); | 219 | Config cfg( "OpiePlayer" ); |
220 | cfg.setGroup("PlayList"); | 220 | cfg.setGroup("PlayList"); |
221 | cfg.writeEntry("CurrentPlaylist","default"); | 221 | cfg.writeEntry("CurrentPlaylist","default"); |
222 | setCaption("OpiePlayer"); | 222 | setCaption("OpiePlayer"); |
223 | } | 223 | } |
224 | 224 | ||
225 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 225 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
226 | switch (mouse) { | 226 | switch (mouse) { |
227 | case LeftButton: | 227 | case LeftButton: |
228 | break; | 228 | break; |
229 | case RightButton: | 229 | case RightButton: |
230 | { | 230 | { |
231 | QPopupMenu m; | 231 | QPopupMenu m; |
232 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 232 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
233 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 233 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
234 | m.exec( QCursor::pos() ); | 234 | m.exec( QCursor::pos() ); |
235 | } | 235 | } |
236 | break; | 236 | break; |
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | 240 | ||
241 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 241 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
242 | switch (mouse) { | 242 | switch (mouse) { |
243 | case LeftButton: | 243 | case LeftButton: |
244 | break; | 244 | break; |
245 | case RightButton: | 245 | case RightButton: |
246 | { | 246 | { |
247 | QPopupMenu m; | 247 | QPopupMenu m; |
248 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 248 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
249 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 249 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
250 | m.exec( QCursor::pos() ); | 250 | m.exec( QCursor::pos() ); |
251 | } | 251 | } |
252 | break; | 252 | break; |
253 | } | 253 | } |
254 | } | 254 | } |
255 | 255 | ||
256 | 256 | ||
257 | void PlayListWidget::addAllToList() { | 257 | void PlayListWidget::addAllToList() { |
258 | 258 | ||
259 | 259 | ||
260 | audioView->populateView(); | 260 | audioView->populateView(); |
261 | 261 | ||
262 | QListViewItemIterator audioIt( audioView ); | 262 | QListViewItemIterator audioIt( audioView ); |
263 | DocLnk lnk; | 263 | DocLnk lnk; |
264 | QString filename; | 264 | QString filename; |
265 | // iterate through all items of the listview | 265 | // iterate through all items of the listview |
266 | for ( ; audioIt.current(); ++audioIt ) { | 266 | for ( ; audioIt.current(); ++audioIt ) { |
267 | filename = audioIt.current()->text(3); | 267 | filename = audioIt.current()->text(3); |
268 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 268 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
269 | lnk.setFile( filename ); //sets file name | 269 | lnk.setFile( filename ); //sets file name |
270 | d->selectedFiles->addToSelection( lnk); | 270 | d->selectedFiles->addToSelection( lnk); |
271 | } | 271 | } |
272 | 272 | ||
273 | videoView->populateView(); | 273 | videoView->populateView(); |
274 | 274 | ||
275 | QListViewItemIterator videoIt( videoView ); | 275 | QListViewItemIterator videoIt( videoView ); |
276 | for ( ; videoIt.current(); ++videoIt ) { | 276 | for ( ; videoIt.current(); ++videoIt ) { |
277 | filename = videoIt.current()->text(3); | 277 | filename = videoIt.current()->text(3); |
278 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 278 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
279 | lnk.setFile( filename ); //sets file name | 279 | lnk.setFile( filename ); //sets file name |
280 | d->selectedFiles->addToSelection( lnk); | 280 | d->selectedFiles->addToSelection( lnk); |
281 | } | 281 | } |
282 | 282 | ||
283 | tabWidget->setCurrentPage(0); | 283 | tabWidget->setCurrentPage(0); |
284 | 284 | ||
285 | writeCurrentM3u(); | 285 | writeCurrentM3u(); |
286 | d->selectedFiles->first(); | 286 | d->selectedFiles->first(); |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | void PlayListWidget::addAllMusicToList() { | 290 | void PlayListWidget::addAllMusicToList() { |
291 | 291 | ||
292 | audioView->populateView(); | 292 | audioView->populateView(); |
293 | 293 | ||
294 | QListViewItemIterator audioIt( audioView ); | 294 | QListViewItemIterator audioIt( audioView ); |
295 | DocLnk lnk; | 295 | DocLnk lnk; |
296 | QString filename; | 296 | QString filename; |
297 | // iterate through all items of the listview | 297 | // iterate through all items of the listview |
298 | for ( ; audioIt.current(); ++audioIt ) { | 298 | for ( ; audioIt.current(); ++audioIt ) { |
299 | filename = audioIt.current()->text(3); | 299 | filename = audioIt.current()->text(3); |
300 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 300 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
301 | lnk.setFile( filename ); //sets file name | 301 | lnk.setFile( filename ); //sets file name |
302 | d->selectedFiles->addToSelection( lnk); | 302 | d->selectedFiles->addToSelection( lnk); |
303 | } | 303 | } |
304 | 304 | ||
305 | tabWidget->setCurrentPage(0); | 305 | tabWidget->setCurrentPage(0); |
306 | writeCurrentM3u(); | 306 | writeCurrentM3u(); |
307 | d->selectedFiles->first(); | 307 | d->selectedFiles->first(); |
308 | } | 308 | } |
309 | 309 | ||
310 | 310 | ||
311 | void PlayListWidget::addAllVideoToList() { | 311 | void PlayListWidget::addAllVideoToList() { |
312 | 312 | ||
313 | videoView->populateView(); | 313 | videoView->populateView(); |
314 | 314 | ||
315 | QListViewItemIterator videoIt( videoView ); | 315 | QListViewItemIterator videoIt( videoView ); |
316 | DocLnk lnk; | 316 | DocLnk lnk; |
317 | QString filename; | 317 | QString filename; |
318 | for ( ; videoIt.current(); ++videoIt ) { | 318 | for ( ; videoIt.current(); ++videoIt ) { |
319 | filename = videoIt.current()->text(3); | 319 | filename = videoIt.current()->text(3); |
320 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 320 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
321 | lnk.setFile( filename ); //sets file name | 321 | lnk.setFile( filename ); //sets file name |
322 | d->selectedFiles->addToSelection( lnk); | 322 | d->selectedFiles->addToSelection( lnk); |
323 | } | 323 | } |
324 | tabWidget->setCurrentPage(0); | 324 | tabWidget->setCurrentPage(0); |
325 | writeCurrentM3u(); | 325 | writeCurrentM3u(); |
326 | d->selectedFiles->first(); | 326 | d->selectedFiles->first(); |
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | void PlayListWidget::setDocument( const QString& fileref ) { | 330 | void PlayListWidget::setDocument( const QString& _fileref ) { |
331 | // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; | 331 | // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; |
332 | QString fileref = _fileref; | ||
332 | fromSetDocument = TRUE; | 333 | fromSetDocument = TRUE; |
334 | |||
335 | DocLnk lnk(_fileref); | ||
336 | if(lnk.isValid()) | ||
337 | fileref = lnk.file(); | ||
338 | |||
333 | QFileInfo fileInfo(fileref); | 339 | QFileInfo fileInfo(fileref); |
334 | 340 | ||
335 | if ( !fileInfo.exists() ) { | 341 | if ( !fileInfo.exists() ) { |
336 | QMessageBox::warning( this, tr( "Invalid File" ), | 342 | QMessageBox::warning( this, tr( "Invalid File" ), |
337 | tr( "There was a problem in getting the file." ) ); | 343 | tr( "There was a problem in getting the file." ) ); |
338 | return; | 344 | return; |
339 | } | 345 | } |
340 | 346 | ||
341 | clearList(); | 347 | clearList(); |
342 | QString extension = fileInfo.extension(false); | 348 | QString extension = fileInfo.extension(false); |
343 | 349 | ||
344 | if( extension.find( "m3u", 0, false) != -1 | 350 | if( extension.find( "m3u", 0, false) != -1 |
345 | || extension.find( "pls", 0, false) != -1 ) { | 351 | || extension.find( "pls", 0, false) != -1 ) { |
346 | readListFromFile( fileref ); | 352 | readListFromFile( fileref ); |
347 | } else { | 353 | } else { |
348 | clearList(); | 354 | clearList(); |
349 | DocLnk lnk; | 355 | DocLnk lnk; |
350 | lnk.setName( fileInfo.baseName() ); //sets name | 356 | lnk.setName( fileInfo.baseName() ); //sets name |
351 | lnk.setFile( fileref ); //sets file name | 357 | lnk.setFile( fileref ); //sets file name |
352 | addToSelection( lnk ); | 358 | addToSelection( lnk ); |
353 | writeCurrentM3u(); | 359 | writeCurrentM3u(); |
354 | 360 | ||
355 | d->setDocumentUsed = TRUE; | 361 | d->setDocumentUsed = TRUE; |
356 | mediaPlayerState->setPlaying( FALSE ); | 362 | mediaPlayerState->setPlaying( FALSE ); |
357 | mediaPlayerState->setPlaying( TRUE ); | 363 | mediaPlayerState->setPlaying( TRUE ); |
358 | } | 364 | } |
359 | } | 365 | } |
360 | 366 | ||
361 | 367 | ||
362 | void PlayListWidget::useSelectedDocument() { | 368 | void PlayListWidget::useSelectedDocument() { |
363 | d->setDocumentUsed = FALSE; | 369 | d->setDocumentUsed = FALSE; |
364 | } | 370 | } |
365 | 371 | ||
366 | 372 | ||
367 | const DocLnk *PlayListWidget::current() const { // this is fugly | 373 | const DocLnk *PlayListWidget::current() const { // this is fugly |
368 | assert( currentTab() == CurrentPlayList ); | 374 | assert( currentTab() == CurrentPlayList ); |
369 | 375 | ||
370 | const DocLnk *lnk = d->selectedFiles->current(); | 376 | const DocLnk *lnk = d->selectedFiles->current(); |
371 | if ( !lnk ) { | 377 | if ( !lnk ) { |
372 | d->selectedFiles->first(); | 378 | d->selectedFiles->first(); |
373 | lnk = d->selectedFiles->current(); | 379 | lnk = d->selectedFiles->current(); |
374 | } | 380 | } |
375 | assert( lnk ); | 381 | assert( lnk ); |
376 | return lnk; | 382 | return lnk; |
377 | } | 383 | } |
378 | 384 | ||
379 | 385 | ||
380 | bool PlayListWidget::prev() { | 386 | bool PlayListWidget::prev() { |
381 | if ( mediaPlayerState->isShuffled() ) { | 387 | if ( mediaPlayerState->isShuffled() ) { |
382 | const DocLnk *cur = current(); | 388 | const DocLnk *cur = current(); |
383 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 389 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
384 | for ( int i = 0; i < j; i++ ) { | 390 | for ( int i = 0; i < j; i++ ) { |
385 | if ( !d->selectedFiles->next() ) | 391 | if ( !d->selectedFiles->next() ) |
386 | d->selectedFiles->first(); | 392 | d->selectedFiles->first(); |
387 | } | 393 | } |
388 | if ( cur == current() ) | 394 | if ( cur == current() ) |
389 | if ( !d->selectedFiles->next() ) { | 395 | if ( !d->selectedFiles->next() ) { |
390 | d->selectedFiles->first(); | 396 | d->selectedFiles->first(); |
391 | } | 397 | } |
392 | return TRUE; | 398 | return TRUE; |
393 | } else { | 399 | } else { |
394 | if ( !d->selectedFiles->prev() ) { | 400 | if ( !d->selectedFiles->prev() ) { |
395 | if ( mediaPlayerState->isLooping() ) { | 401 | if ( mediaPlayerState->isLooping() ) { |
396 | return d->selectedFiles->last(); | 402 | return d->selectedFiles->last(); |
397 | } else { | 403 | } else { |
398 | return FALSE; | 404 | return FALSE; |
399 | } | 405 | } |
400 | } | 406 | } |
401 | return TRUE; | 407 | return TRUE; |
402 | } | 408 | } |
403 | } | 409 | } |
404 | 410 | ||
405 | 411 | ||
406 | bool PlayListWidget::next() { | 412 | bool PlayListWidget::next() { |
407 | //odebug << "<<<<<<<<<<<<next()" << oendl; | 413 | //odebug << "<<<<<<<<<<<<next()" << oendl; |
408 | if ( mediaPlayerState->isShuffled() ) { | 414 | if ( mediaPlayerState->isShuffled() ) { |
409 | return prev(); | 415 | return prev(); |
410 | } else { | 416 | } else { |
411 | if ( !d->selectedFiles->next() ) { | 417 | if ( !d->selectedFiles->next() ) { |
412 | if ( mediaPlayerState->isLooping() ) { | 418 | if ( mediaPlayerState->isLooping() ) { |
413 | return d->selectedFiles->first(); | 419 | return d->selectedFiles->first(); |
414 | } else { | 420 | } else { |
415 | return FALSE; | 421 | return FALSE; |
416 | } | 422 | } |
417 | } | 423 | } |
418 | return TRUE; | 424 | return TRUE; |
419 | } | 425 | } |
420 | } | 426 | } |
421 | 427 | ||
422 | 428 | ||
423 | bool PlayListWidget::first() { | 429 | bool PlayListWidget::first() { |
424 | return d->selectedFiles->first(); | 430 | return d->selectedFiles->first(); |
425 | } | 431 | } |
426 | 432 | ||
427 | 433 | ||
428 | bool PlayListWidget::last() { | 434 | bool PlayListWidget::last() { |
429 | return d->selectedFiles->last(); | 435 | return d->selectedFiles->last(); |
430 | } | 436 | } |
431 | 437 | ||
432 | 438 | ||
433 | void PlayListWidget::saveList() { | 439 | void PlayListWidget::saveList() { |
434 | writem3u(); | 440 | writem3u(); |
435 | } | 441 | } |
436 | 442 | ||
437 | 443 | ||
438 | void PlayListWidget::loadList( const DocLnk & lnk) { | 444 | void PlayListWidget::loadList( const DocLnk & lnk) { |
439 | QString name = lnk.name(); | 445 | QString name = lnk.name(); |
440 | 446 | ||
441 | if( name.length()>0) { | 447 | if( name.length()>0) { |
442 | setCaption("OpiePlayer: "+name); | 448 | setCaption("OpiePlayer: "+name); |
443 | clearList(); | 449 | clearList(); |
444 | readListFromFile(lnk.file()); | 450 | readListFromFile(lnk.file()); |
445 | tabWidget->setCurrentPage(0); | 451 | tabWidget->setCurrentPage(0); |
446 | } | 452 | } |
447 | } | 453 | } |
448 | 454 | ||
449 | void PlayListWidget::addSelected() { | 455 | void PlayListWidget::addSelected() { |
450 | assert( inFileListMode() ); | 456 | assert( inFileListMode() ); |
451 | 457 | ||
452 | QListViewItemIterator it( currentFileListView ); | 458 | QListViewItemIterator it( currentFileListView ); |
453 | for ( ; it.current(); ++it ) | 459 | for ( ; it.current(); ++it ) |
454 | if ( it.current()->isSelected() ) { | 460 | if ( it.current()->isSelected() ) { |
455 | QString filename = it.current()->text(3); | 461 | QString filename = it.current()->text(3); |
456 | 462 | ||
457 | DocLnk lnk; | 463 | DocLnk lnk; |
458 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 464 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
459 | lnk.setFile( filename ); //sets file name | 465 | lnk.setFile( filename ); //sets file name |
460 | 466 | ||
461 | d->selectedFiles->addToSelection( lnk ); | 467 | d->selectedFiles->addToSelection( lnk ); |
462 | } | 468 | } |
463 | 469 | ||
464 | currentFileListView->clearSelection(); | 470 | currentFileListView->clearSelection(); |
465 | 471 | ||
466 | writeCurrentM3u(); | 472 | writeCurrentM3u(); |
467 | } | 473 | } |
468 | 474 | ||
469 | 475 | ||
470 | void PlayListWidget::removeSelected() { | 476 | void PlayListWidget::removeSelected() { |
471 | d->selectedFiles->removeSelected( ); | 477 | d->selectedFiles->removeSelected( ); |
472 | writeCurrentM3u(); | 478 | writeCurrentM3u(); |
473 | } | 479 | } |
474 | 480 | ||
475 | 481 | ||
476 | void PlayListWidget::playIt( QListViewItem *it) { | 482 | void PlayListWidget::playIt( QListViewItem *it) { |
477 | if(!it) return; | 483 | if(!it) return; |
478 | mediaPlayerState->setPlaying(FALSE); | 484 | mediaPlayerState->setPlaying(FALSE); |
479 | mediaPlayerState->setPlaying(TRUE); | 485 | mediaPlayerState->setPlaying(TRUE); |
480 | d->selectedFiles->unSelect(); | 486 | d->selectedFiles->unSelect(); |
481 | } | 487 | } |
482 | 488 | ||
483 | 489 | ||
484 | void PlayListWidget::addToSelection( QListViewItem *it) { | 490 | void PlayListWidget::addToSelection( QListViewItem *it) { |
485 | d->setDocumentUsed = FALSE; | 491 | d->setDocumentUsed = FALSE; |
486 | 492 | ||
487 | if(it) { | 493 | if(it) { |
488 | if ( currentTab() == CurrentPlayList ) | 494 | if ( currentTab() == CurrentPlayList ) |
489 | return; | 495 | return; |
490 | DocLnk lnk; | 496 | DocLnk lnk; |
491 | QString filename; | 497 | QString filename; |
492 | 498 | ||
493 | filename=it->text(3); | 499 | filename=it->text(3); |
494 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 500 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
495 | lnk.setFile( filename ); //sets file name | 501 | lnk.setFile( filename ); //sets file name |
496 | d->selectedFiles->addToSelection( lnk); | 502 | d->selectedFiles->addToSelection( lnk); |
497 | 503 | ||
498 | writeCurrentM3u(); | 504 | writeCurrentM3u(); |
499 | // tabWidget->setCurrentPage(0); | 505 | // tabWidget->setCurrentPage(0); |
500 | 506 | ||
501 | } | 507 | } |
502 | } | 508 | } |
503 | 509 | ||
504 | 510 | ||
505 | void PlayListWidget::tabChanged(QWidget *) { | 511 | void PlayListWidget::tabChanged(QWidget *) { |
506 | 512 | ||
507 | d->tbPlay->setEnabled( true ); | 513 | d->tbPlay->setEnabled( true ); |
508 | 514 | ||
509 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), | 515 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), |
510 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 516 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
511 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), | 517 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), |
512 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 518 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
513 | 519 | ||
514 | currentFileListView = 0; | 520 | currentFileListView = 0; |
515 | 521 | ||
516 | switch ( currentTab() ) { | 522 | switch ( currentTab() ) { |
517 | case CurrentPlayList: | 523 | case CurrentPlayList: |
518 | { | 524 | { |
519 | if( !tbDeletePlaylist->isHidden() ) { | 525 | if( !tbDeletePlaylist->isHidden() ) { |
520 | tbDeletePlaylist->hide(); | 526 | tbDeletePlaylist->hide(); |
521 | } | 527 | } |
522 | d->tbRemoveFromList->setEnabled(TRUE); | 528 | d->tbRemoveFromList->setEnabled(TRUE); |
523 | d->tbAddToList->setEnabled(FALSE); | 529 | d->tbAddToList->setEnabled(FALSE); |
524 | 530 | ||