Changeset 188 for smplayer/trunk/src/playlist.cpp
- Timestamp:
- Jan 24, 2017, 12:41:54 PM (8 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
- Property svn:mergeinfo changed
/smplayer/vendor/current merged: 186
- Property svn:mergeinfo changed
-
smplayer/trunk/src/playlist.cpp
r181 r188 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 6Ricardo Villalba <rvm@users.sourceforge.net>2 Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 45 45 #include <QMimeData> 46 46 #include <QDomDocument> 47 #include <QDesktopServices> 47 48 #include <QDebug> 48 49 … … 61 62 #include "extensions.h" 62 63 #include "guiconfig.h" 64 65 #ifdef CHROMECAST_SUPPORT 66 #include "chromecast.h" 67 #endif 63 68 64 69 #ifdef PLAYLIST_DOWNLOAD … … 224 229 } 225 230 231 void PLItem::setExtraParams(const QStringList & pars) { 232 setData(pars, Role_Params); 233 } 234 235 QStringList PLItem::extraParams() { 236 return data(Role_Params).toStringList(); 237 } 238 239 void PLItem::setVideoURL(const QString & url) { 240 setData(url, Role_Video_URL); 241 } 242 243 QString PLItem::videoURL() { 244 return data(Role_Video_URL).toString(); 245 } 226 246 227 247 /* ----------------------------------------------------------- */ … … 237 257 , play_files_from_start(true) 238 258 , row_spacing(-1) // Default height 259 , start_play_on_load(true) 239 260 , automatically_play_next(true) 240 261 , ignore_player_errors(false) … … 245 266 latest_dir = ""; 246 267 268 filter_edit = new MyLineEdit(this); 269 connect(filter_edit, SIGNAL(textChanged(const QString &)), this, SLOT(filterEditChanged(const QString &))); 270 247 271 createTable(); 248 272 createActions(); … … 250 274 251 275 QVBoxLayout *layout = new QVBoxLayout; 276 #ifdef PLAYLIST_DOUBLE_TOOLBAR 277 layout->addWidget(toolbar); 278 layout->addWidget(listView); 279 layout->addWidget(toolbar2); 280 #else 252 281 layout->addWidget(listView); 253 282 layout->addWidget(toolbar); 254 #ifdef PLAYLIST_DOUBLE_TOOLBAR 255 layout->addWidget(toolbar2);283 layout->addWidget(filter_edit); 284 filter_edit->hide(); 256 285 #endif 257 286 setLayout(layout); … … 291 320 292 321 history_urls = new URLHistory; 293 history_urls->addUrl("http://smplayer.info/ onlinetv.php");322 history_urls->addUrl("http://smplayer.info/sample.m3u8"); 294 323 #endif 295 324 } … … 320 349 } 321 350 351 void Playlist::updateWindowTitle() { 352 QString title; 353 354 title = playlist_filename; 355 if (title.isEmpty()) title = tr("Untitled playlist"); 356 if (modified) title += " (*)"; 357 358 qDebug() << "Playlist::updateWindowTitle:" << title; 359 360 setWindowTitle(title); 361 emit windowTitleChanged(title); 362 } 363 364 void Playlist::setPlaylistFilename(const QString & f) { 365 playlist_filename = f; 366 updateWindowTitle(); 367 } 322 368 323 369 void Playlist::setModified(bool mod) { … … 326 372 modified = mod; 327 373 emit modifiedChanged(modified); 374 updateWindowTitle(); 328 375 } 329 376 … … 358 405 listView->setShowGrid(false); 359 406 listView->setSortingEnabled(true); 407 listView->setWordWrap(false); 360 408 #if !USE_ITEM_DELEGATE 361 409 listView->setAlternatingRowColors(true); … … 376 424 #endif 377 425 listView->horizontalHeader()->setStretchLastSection(true); 426 listView->horizontalHeader()->setSortIndicator(0, Qt::AscendingOrder); 378 427 379 428 /* … … 393 442 connect(listView, SIGNAL(activated(const QModelIndex &)), 394 443 this, SLOT(itemActivated(const QModelIndex &)) ); 444 445 setFilenameColumnVisible(false); 395 446 } 396 447 … … 405 456 406 457 saveAct = new MyAction(this, "pl_save", false); 407 connect( saveAct, SIGNAL(triggered()), this, SLOT(save()) ); 458 connect( saveAct, SIGNAL(triggered()), this, SLOT(saveCurrentPlaylist()) ); 459 460 saveAsAct = new MyAction(this, "pl_save_as", false); 461 connect( saveAsAct, SIGNAL(triggered()), this, SLOT(save()) ); 408 462 409 463 playAct = new MyAction(this, "pl_play", false); … … 452 506 connect( editAct, SIGNAL(triggered()), this, SLOT(editCurrentItem()) ); 453 507 508 #ifdef PLAYLIST_DELETE_FROM_DISK 454 509 deleteSelectedFileFromDiskAct = new MyAction(this, "pl_delete_from_disk"); 455 510 connect( deleteSelectedFileFromDiskAct, SIGNAL(triggered()), this, SLOT(deleteSelectedFileFromDisk())); 511 #endif 512 513 copyURLAct = new MyAction(this, "pl_copy_url"); 514 connect( copyURLAct, SIGNAL(triggered()), this, SLOT(copyURL())); 515 516 openFolderAct = new MyAction(this, "pl_open_folder"); 517 connect( openFolderAct, SIGNAL(triggered()), this, SLOT(openFolder())); 518 519 #ifdef CHROMECAST_SUPPORT 520 playOnChromecastAct = new MyAction(this, "pl_chromecast"); 521 connect( playOnChromecastAct, SIGNAL(triggered()), this, SLOT(playOnChromecast())); 522 #else 523 openURLInWebAct = new MyAction(this, "pl_url_in_web"); 524 connect( openURLInWebAct, SIGNAL(triggered()), this, SLOT(openURLInWeb())); 525 #endif 526 527 showSearchAct = new MyAction(this, "pl_show_search", false); 528 showSearchAct->setCheckable(true); 529 connect(showSearchAct, SIGNAL(toggled(bool)), filter_edit, SLOT(setVisible(bool))); 530 531 showPositionColumnAct = new MyAction(this, "pl_show_position_column"); 532 showPositionColumnAct->setCheckable(true); 533 connect(showPositionColumnAct, SIGNAL(toggled(bool)), this, SLOT(setPositionColumnVisible(bool))); 534 535 showNameColumnAct = new MyAction(this, "pl_show_name_column"); 536 showNameColumnAct->setCheckable(true); 537 connect(showNameColumnAct, SIGNAL(toggled(bool)), this, SLOT(setNameColumnVisible(bool))); 538 539 showDurationColumnAct = new MyAction(this, "pl_show_duration_column"); 540 showDurationColumnAct->setCheckable(true); 541 connect(showDurationColumnAct, SIGNAL(toggled(bool)), this, SLOT(setDurationColumnVisible(bool))); 542 543 showFilenameColumnAct = new MyAction(this, "pl_show_filename_column"); 544 showFilenameColumnAct->setCheckable(true); 545 connect(showFilenameColumnAct, SIGNAL(toggled(bool)), this, SLOT(setFilenameColumnVisible(bool))); 456 546 } 457 547 … … 466 556 #endif 467 557 558 /* 468 559 toolbar->addAction(openAct); 469 560 #ifdef PLAYLIST_DOWNLOAD … … 472 563 toolbar->addAction(saveAct);; 473 564 toolbar->addSeparator(); 565 */ 566 567 file_menu = new QMenu(this); 568 file_menu->addAction(openAct); 569 file_menu->addAction(saveAct); 570 file_menu->addAction(saveAsAct); 571 #ifdef PLAYLIST_DOWNLOAD 572 file_menu->addAction(openUrlAct); 573 #endif 574 575 file_button = new QToolButton(this); 576 file_button->setMenu(file_menu); 577 file_button->setPopupMode(QToolButton::InstantPopup); 474 578 475 579 add_menu = new QMenu( this ); … … 491 595 remove_button->setPopupMode(QToolButton::InstantPopup); 492 596 493 filter_edit = new MyLineEdit(this);494 connect(filter_edit, SIGNAL(textChanged(const QString &)), this, SLOT(filterEditChanged(const QString &)));495 597 496 598 #ifdef PLAYLIST_DOWNLOAD … … 501 603 #endif 502 604 605 toolbar->addWidget(file_button); 606 toolbar->addSeparator(); 503 607 toolbar->addWidget(add_button); 504 608 toolbar->addWidget(remove_button); … … 526 630 toolbar->addAction(moveDownAct); 527 631 toolbar->addSeparator(); 528 toolbar->addWidget(filter_edit); 632 toolbar->addAction(showSearchAct); 633 // toolbar->addWidget(filter_edit); 529 634 #ifdef PLAYLIST_DOWNLOAD 530 635 loading_label_action = toolbar->addWidget(loading_label); … … 541 646 popup->addAction(removeSelectedAct); 542 647 popup->addAction(editAct); 648 #ifdef PLAYLIST_DELETE_FROM_DISK 543 649 popup->addAction(deleteSelectedFileFromDiskAct); 650 #endif 651 popup->addAction(copyURLAct); 652 popup->addAction(openFolderAct); 653 #ifdef CHROMECAST_SUPPORT 654 popup->addAction(playOnChromecastAct); 655 #else 656 popup->addAction(openURLInWebAct); 657 #endif 658 popup->addSeparator(); 659 popup->addAction(showPositionColumnAct); 660 popup->addAction(showNameColumnAct); 661 popup->addAction(showDurationColumnAct); 662 popup->addAction(showFilenameColumnAct); 544 663 545 664 connect( listView, SIGNAL(customContextMenuRequested(const QPoint &)), … … 550 669 table->setHorizontalHeaderLabels(QStringList() << " " << tr("Name") << tr("Length") << tr("Filename / URL") ); 551 670 552 openAct->change( Images::icon("open"), tr("&Load ") );671 openAct->change( Images::icon("open"), tr("&Load...") ); 553 672 #ifdef PLAYLIST_DOWNLOAD 554 openUrlAct->change( Images::icon("url"), tr(" &Open URL") );673 openUrlAct->change( Images::icon("url"), tr("Load playlist from &URL...") ); 555 674 openUrlAct->setToolTip(tr("Download playlist from URL")); 556 675 #endif 557 676 saveAct->change( Images::icon("save"), tr("&Save") ); 677 saveAsAct->change( Images::icon("save"), tr("Save &as...") ); 558 678 559 679 playAct->change( tr("&Play") ); … … 579 699 580 700 // Remove actions 581 removeSelectedAct->change( tr("Remove &selected") );701 removeSelectedAct->change( Images::icon("delete"), tr("Remove &selected") ); 582 702 removeAllAct->change( tr("Remove &all") ); 583 703 704 #ifdef PLAYLIST_DELETE_FROM_DISK 584 705 deleteSelectedFileFromDiskAct->change( tr("&Delete file from disk") ); 706 #endif 707 708 copyURLAct->change( Images::icon("copy"), tr("&Copy file path to clipboard") ); 709 openFolderAct->change( Images::icon("openfolder"), tr("&Open source folder") ); 710 711 #ifdef CHROMECAST_SUPPORT 712 playOnChromecastAct->change( Images::icon("chromecast"), tr("Play on Chromec&ast") ); 713 #else 714 openURLInWebAct->change( tr("Open stream in &a web browser") ); 715 #endif 716 717 showSearchAct->change(Images::icon("find"), tr("Search")); 718 719 showPositionColumnAct->change(tr("Show position column")); 720 showNameColumnAct->change(tr("Show name column")); 721 showDurationColumnAct->change(tr("Show length column")); 722 showFilenameColumnAct->change(tr("Show filename column")); 585 723 586 724 // Edit … … 588 726 589 727 // Tool buttons 728 file_button->setIcon(Images::icon("open")); // FIXME: change icon 729 file_button->setToolTip(tr("Load/Save")); 590 730 add_button->setIcon( Images::icon("plus") ); 591 731 add_button->setToolTip( tr("Add...") ); … … 600 740 // Icon 601 741 setWindowIcon( Images::icon("logo", 64) ); 602 setWindowTitle( tr( "SMPlayer - Playlist" ) );742 //setWindowTitle( tr( "SMPlayer - Playlist" ) ); 603 743 } 604 744 … … 619 759 qDebug() << "Playlist::filterEditChanged:" << text; 620 760 setFilter(text); 761 762 if (text.isEmpty()) { 763 qApp->processEvents(); 764 listView->scrollTo(listView->currentIndex(), QAbstractItemView::PositionAtCenter); 765 } 621 766 } 622 767 … … 675 820 676 821 bool Playlist::isEmpty() { 677 return (table->rowCount() >0);822 return (table->rowCount() == 0); 678 823 } 679 824 … … 713 858 */ 714 859 715 void Playlist::addItem(QString filename, QString name, double duration ) {860 void Playlist::addItem(QString filename, QString name, double duration, QStringList params, QString video_url) { 716 861 //qDebug() << "Playlist::addItem:" << filename; 717 862 … … 733 878 734 879 PLItem * i = new PLItem(filename, name, duration); 880 i->setExtraParams(params); 881 i->setVideoURL(video_url); 735 882 i->setPosition(count()+1); 736 883 table->appendRow(i->items()); … … 802 949 QString name=""; 803 950 double duration=0; 951 QStringList extra_params; 804 952 805 953 QTextStream stream( &f ); … … 833 981 if (fields.count() >= 1) duration = fields[0].toDouble(); 834 982 if (fields.count() >= 2) name = fields[1]; 983 } 984 else 985 if (line.startsWith("#EXTVLCOPT:")) { 986 QString par = line.mid(11); 987 qDebug() << "Playlist::load_m3u: EXTVLCOPT:" << par; 988 extra_params << par; 835 989 } 836 990 else … … 849 1003 } 850 1004 } 851 addItem( filename, name, duration ); 1005 name.replace(",", ","); 1006 //qDebug() << "Playlist::load_m3u: extra_params:" << extra_params; 1007 addItem( filename, name, duration, extra_params ); 852 1008 name=""; 853 1009 duration = 0; 1010 extra_params.clear(); 854 1011 } 855 1012 } … … 857 1014 //list(); 858 1015 1016 setPlaylistFilename(file); 859 1017 setModified( false ); 860 1018 861 startPlay();1019 if (start_play_on_load) startPlay(); 862 1020 } 863 1021 } … … 906 1064 //list(); 907 1065 1066 setPlaylistFilename(file); 908 1067 setModified( false ); 909 1068 910 if (set.status() == QSettings::NoError ) startPlay();1069 if (set.status() == QSettings::NoError && start_play_on_load) startPlay(); 911 1070 } 912 1071 … … 948 1107 949 1108 //list(); 1109 setPlaylistFilename(filename); 950 1110 setModified( false ); 951 startPlay();1111 if (start_play_on_load) startPlay(); 952 1112 } 953 1113 } … … 977 1137 978 1138 QString filename; 1139 QString name; 979 1140 980 1141 stream << "#EXTM3U" << "\n"; … … 987 1148 filename = Helper::changeSlashes(filename); 988 1149 #endif 1150 name = i->name(); 1151 name.replace(",", ","); 989 1152 stream << "#EXTINF:"; 990 1153 stream << i->duration() << ","; 991 stream << i->name() << "\n"; 1154 stream << name << "\n"; 1155 1156 // Save extra params 1157 QStringList params = i->extraParams(); 1158 foreach(QString par, params) { 1159 stream << "#EXTVLCOPT:" << par << "\n"; 1160 } 1161 992 1162 // Try to save the filename as relative instead of absolute 993 1163 if (filename.startsWith( dir_path )) { … … 998 1168 f.close(); 999 1169 1170 setPlaylistFilename(file); 1000 1171 setModified( false ); 1001 1172 return true; … … 1048 1219 1049 1220 bool ok = (set.status() == QSettings::NoError); 1050 if (ok) setModified( false ); 1221 if (ok) { 1222 setPlaylistFilename(file); 1223 setModified( false ); 1224 } 1051 1225 1052 1226 return ok; … … 1112 1286 stream << "</playlist>\n"; 1113 1287 1288 setPlaylistFilename(filename); 1114 1289 setModified(false); 1115 1290 return true; … … 1147 1322 } 1148 1323 1149 bool Playlist::save() { 1150 Extensions e; 1151 QString s = MyFileDialog::getSaveFileName( 1324 bool Playlist::saveCurrentPlaylist() { 1325 qDebug("Playlist::saveCurrentPlaylist"); 1326 return save(playlistFilename()); 1327 } 1328 1329 bool Playlist::save(const QString & filename) { 1330 qDebug() << "Playlist::save:" << filename; 1331 1332 QString s = filename; 1333 1334 if (s.isEmpty()) { 1335 Extensions e; 1336 s = MyFileDialog::getSaveFileName( 1152 1337 this, tr("Choose a filename"), 1153 1338 lastDir(), 1154 1339 tr("Playlists") + e.playlist().forFilter() + ";;" + tr("All files") +" (*)"); 1340 } 1155 1341 1156 1342 if (!s.isEmpty()) { … … 1222 1408 qDebug("Playlist::showPopup: x: %d y: %d", pos.x(), pos.y() ); 1223 1409 1410 QModelIndex index = listView->currentIndex(); 1411 if (!index.isValid()) { 1412 playAct->setEnabled(false); 1413 removeSelectedAct->setEnabled(false); 1414 editAct->setEnabled(false); 1415 #ifdef PLAYLIST_DELETE_FROM_DISK 1416 deleteSelectedFileFromDiskAct->setEnabled(false); 1417 #endif 1418 copyURLAct->setEnabled(false); 1419 openFolderAct->setEnabled(false); 1420 #ifdef CHROMECAST_SUPPORT 1421 playOnChromecastAct->setEnabled(false); 1422 #else 1423 openURLInWebAct->setEnabled(false); 1424 #endif 1425 } else { 1426 playAct->setEnabled(true); 1427 removeSelectedAct->setEnabled(true); 1428 editAct->setEnabled(true); 1429 #ifdef PLAYLIST_DELETE_FROM_DISK 1430 deleteSelectedFileFromDiskAct->setEnabled(true); 1431 #endif 1432 copyURLAct->setEnabled(true); 1433 openFolderAct->setEnabled(true); 1434 #ifdef CHROMECAST_SUPPORT 1435 playOnChromecastAct->setEnabled(true); 1436 #else 1437 openURLInWebAct->setEnabled(true); 1438 #endif 1439 1440 QModelIndex s_index = proxy->mapToSource(index); 1441 int current = s_index.row(); 1442 PLItem * i = itemData(current); 1443 QString filename = i->filename(); 1444 QFileInfo fi(filename); 1445 1446 if (fi.exists()) { 1447 copyURLAct->setText( tr("&Copy file path to clipboard") ); 1448 #ifndef CHROMECAST_SUPPORT 1449 openURLInWebAct->setEnabled(false); 1450 #endif 1451 } else { 1452 copyURLAct->setText( tr("&Copy URL to clipboard") ); 1453 openFolderAct->setEnabled(false); 1454 } 1455 } 1456 1224 1457 if (!popup->isVisible()) { 1225 1458 popup->move( listView->viewport()->mapToGlobal(pos) ); … … 1245 1478 } 1246 1479 1247 QString filename = itemFromProxy(n)->filename(); 1480 PLItem * i = itemFromProxy(n); 1481 QString filename = i->filename(); 1482 QStringList params = i->extraParams(); 1483 1248 1484 if (!filename.isEmpty()) { 1249 1485 setCurrentItem(n); 1250 if (play_files_from_start) { 1251 emit requestToPlayFile(filename, 0); 1486 1487 if (!params.isEmpty()) { 1488 emit requestToPlayStream(filename, params); 1252 1489 } else { 1253 emit requestToPlayFile(filename); 1490 if (play_files_from_start) { 1491 emit requestToPlayFile(filename, 0); 1492 } else { 1493 emit requestToPlayFile(filename); 1494 } 1254 1495 } 1255 1496 } … … 1294 1535 } 1295 1536 1537 void Playlist::playNextAuto() { 1538 qDebug("Playlist::playNextAuto"); 1539 if (automatically_play_next) { 1540 playNext(); 1541 } else { 1542 emit playlistEnded(); 1543 } 1544 } 1296 1545 1297 1546 void Playlist::resumePlay() { … … 1311 1560 double duration = mdat.duration; 1312 1561 QString artist = mdat.clip_artist; 1562 QString video_url = mdat.stream_path; 1313 1563 1314 1564 #if defined(Q_OS_WIN) || defined(Q_OS_OS2) … … 1350 1600 i->setDuration(duration); 1351 1601 } 1602 i->setVideoURL(video_url); 1352 1603 } 1353 1604 } … … 1368 1619 tr("All files") +" (*.*)" ); 1369 1620 1370 if (files.count()!=0) addFiles(files); 1621 if (files.count() != 0) { 1622 addFiles(files); 1623 setModified(true); 1624 } 1371 1625 } 1372 1626 … … 1446 1700 if (!u.isEmpty()) addItem( u, "", 0 ); 1447 1701 } 1702 setModified(true); 1448 1703 } 1449 1704 } … … 1487 1742 } 1488 1743 } 1744 setModified(true); 1489 1745 } 1490 1746 … … 1513 1769 void Playlist::removeAll() { 1514 1770 clear(); 1771 setPlaylistFilename(""); 1515 1772 } 1516 1773 … … 1568 1825 table->insertRow(s_prev.row(), cells); 1569 1826 listView->selectionModel()->setCurrentIndex(listView->model()->index(index.row()-1, 0), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); 1827 1828 setModified(true); 1570 1829 } 1571 1830 } … … 1598 1857 table->insertRow(s_next.row(), cells); 1599 1858 listView->selectionModel()->setCurrentIndex(listView->model()->index(index.row()+1, 0), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); 1859 1860 setModified(true); 1600 1861 } 1601 1862 } … … 1622 1883 QLineEdit::Normal, 1623 1884 current_name, &ok ); 1624 1885 if ( ok && !text.isEmpty() ) { 1625 1886 // user entered something and pressed OK 1626 1887 i->setName(text); … … 1633 1894 } 1634 1895 1896 #ifdef PLAYLIST_DELETE_FROM_DISK 1635 1897 void Playlist::deleteSelectedFileFromDisk() { 1636 1898 qDebug("Playlist::deleteSelectedFileFromDisk"); … … 1683 1945 } 1684 1946 } 1947 #endif 1948 1949 void Playlist::copyURL() { 1950 qDebug("Playlist::copyURL"); 1951 1952 QModelIndexList indexes = listView->selectionModel()->selectedRows(); 1953 int count = indexes.count(); 1954 1955 QString text; 1956 1957 for (int n = 0; n < count; n++) { 1958 QModelIndex s_index = proxy->mapToSource(indexes.at(n)); 1959 int current = s_index.row(); 1960 text += itemData(current)->filename(); 1961 if (n < count-1) { 1962 #ifdef Q_OS_WIN 1963 text += "\r\n"; 1964 #else 1965 text += "\n"; 1966 #endif 1967 } 1968 } 1969 1970 if (!text.isEmpty()) QApplication::clipboard()->setText(text); 1971 } 1972 1973 void Playlist::openFolder() { 1974 qDebug("Playlist::openFolder"); 1975 1976 QModelIndex index = listView->currentIndex(); 1977 if (!index.isValid()) return; 1978 QModelIndex s_index = proxy->mapToSource(index); 1979 int current = s_index.row(); 1980 PLItem * i = itemData(current); 1981 QString filename = i->filename(); 1982 1983 qDebug() << "Playlist::openFolder: filename:" << filename; 1984 1985 QFileInfo fi(filename); 1986 if (fi.exists()) { 1987 QString src_folder = fi.absolutePath(); 1988 QDesktopServices::openUrl(QUrl::fromLocalFile(src_folder)); 1989 } 1990 } 1991 1992 #ifdef CHROMECAST_SUPPORT 1993 void Playlist::playOnChromecast() { 1994 qDebug("Playlist::playOnChromecast"); 1995 1996 QModelIndex index = listView->currentIndex(); 1997 if (!index.isValid()) return; 1998 QModelIndex s_index = proxy->mapToSource(index); 1999 int current = s_index.row(); 2000 PLItem * i = itemData(current); 2001 QString filename = i->filename(); 2002 QString video_url = i->videoURL(); 2003 2004 QString url = filename; 2005 if (!video_url.isEmpty()) url = video_url; 2006 2007 if (QFile::exists(filename)) { 2008 Chromecast::instance()->openLocal(url, i->name()); 2009 } else { 2010 Chromecast::instance()->openStream(url, i->name()); 2011 } 2012 } 2013 #else 2014 void Playlist::openURLInWeb() { 2015 qDebug("Playlist::openURLInWeb"); 2016 2017 QModelIndex index = listView->currentIndex(); 2018 if (!index.isValid()) return; 2019 QModelIndex s_index = proxy->mapToSource(index); 2020 int current = s_index.row(); 2021 PLItem * i = itemData(current); 2022 QString filename = i->filename(); 2023 QString video_url = i->videoURL(); 2024 2025 QString url = filename; 2026 if (!video_url.isEmpty()) url = video_url; 2027 2028 QDesktopServices::openUrl(QUrl(url)); 2029 } 2030 #endif 1685 2031 1686 2032 // Drag&drop … … 1731 2077 } 1732 2078 } 2079 2080 if (only_files.count() == 1) { 2081 // Check if the file is a playlist 2082 QString filename = only_files[0]; 2083 QFileInfo fi(filename); 2084 QString extension = fi.suffix().toLower(); 2085 if (extension == "m3u8" || extension == "m3u") { load_m3u(filename); return; } 2086 else 2087 if (extension == "pls") { load_pls(filename); return; } 2088 else 2089 if (extension == "xspf") { loadXSPF(filename); return; } 2090 } 2091 1733 2092 addFiles( only_files ); 2093 setModified(true); 1734 2094 } 1735 2095 … … 1783 2143 set->setValue( "save_playlist_in_config", save_playlist_in_config ); 1784 2144 set->setValue( "play_files_from_start", play_files_from_start ); 2145 set->setValue( "start_play_on_load", start_play_on_load ); 1785 2146 set->setValue( "automatically_play_next", automatically_play_next ); 1786 2147 set->setValue( "ignore_player_errors", ignore_player_errors ); … … 1792 2153 set->setValue( "size", size() ); 1793 2154 #endif 1794 set->setValue(QString("header_state/%1").arg(Helper::qtVersion()), listView->horizontalHeader()->saveState()); 2155 2156 set->setValue(QString("header_state/2/%1").arg(Helper::qtVersion()), listView->horizontalHeader()->saveState()); 1795 2157 1796 2158 set->setValue( "sort_column", proxy->sortColumn() ); 1797 2159 set->setValue( "sort_order", proxy->sortOrder() ); 1798 set->setValue( "filter_case_sensi vity", proxy->filterCaseSensitivity() );2160 set->setValue( "filter_case_sensitive", filterCaseSensitive() ); 1799 2161 set->setValue( "filter", filter_edit->text() ); 1800 set->setValue( "sort_case_sensivity", proxy->sortCaseSensitivity() ); 2162 set->setValue( "sort_case_sensitive", sortCaseSensitive() ); 2163 set->setValue( "auto_sort", autoSort() ); 2164 2165 set->setValue( "show_search", showSearchAct->isChecked() ); 1801 2166 1802 2167 set->endGroup(); … … 1818 2183 set->setValue( QString("item_%1_duration").arg(n), i->duration() ); 1819 2184 set->setValue( QString("item_%1_name").arg(n), i->name() ); 2185 set->setValue( QString("item_%1_params").arg(n), i->extraParams() ); 2186 set->setValue( QString("item_%1_video_url").arg(n), i->videoURL() ); 1820 2187 } 1821 2188 set->endArray(); 1822 2189 set->setValue( "current_item", findCurrentItem() ); 2190 set->setValue("filename", playlistFilename()); 1823 2191 set->setValue( "modified", modified ); 1824 2192 … … 1834 2202 1835 2203 if (set->contains("playlist/change_title")) set->remove("playlist/change_title"); 2204 if (set->contains("playlist/sort_case_sensivity")) set->remove("playlist/sort_case_sensivity"); 2205 if (set->contains("playlist/filter_case_sensivity")) set->remove("playlist/filter_case_sensivity"); 1836 2206 } 1837 2207 … … 1850 2220 save_playlist_in_config = set->value( "save_playlist_in_config", save_playlist_in_config ).toBool(); 1851 2221 play_files_from_start = set->value( "play_files_from_start", play_files_from_start ).toBool(); 2222 start_play_on_load = set->value( "start_play_on_load", start_play_on_load ).toBool(); 1852 2223 automatically_play_next = set->value( "automatically_play_next", automatically_play_next ).toBool(); 1853 2224 ignore_player_errors = set->value( "ignore_player_errors", ignore_player_errors ).toBool(); … … 1859 2230 resize( set->value("size", size()).toSize() ); 1860 2231 #endif 1861 listView->horizontalHeader()->restoreState(set->value(QString("header_state/%1").arg(Helper::qtVersion()), QByteArray()).toByteArray()); 2232 2233 listView->horizontalHeader()->restoreState(set->value(QString("header_state/2/%1").arg(Helper::qtVersion()), QByteArray()).toByteArray()); 1862 2234 1863 2235 int sort_column = set->value("sort_column", COL_NUM).toInt(); 1864 2236 int sort_order = set->value("sort_order", Qt::AscendingOrder).toInt(); 1865 int filter_case_sensivity = set->value("filter_case_sensivity", Qt::CaseInsensitive).toInt();2237 bool filter_case_sensitive = set->value("filter_case_sensitive", false).toBool(); 1866 2238 QString filter = set->value( "filter").toString(); 1867 int sort_case_sensivity = set->value("sort_case_sensivity", Qt::CaseInsensitive).toInt(); 2239 bool sort_case_sensitive = set->value("sort_case_sensitive", false).toBool(); 2240 bool auto_sort = set->value("auto_sort", false).toBool(); 2241 2242 showSearchAct->setChecked( set->value( "show_search", false).toBool() ); 1868 2243 1869 2244 set->endGroup(); … … 1888 2263 duration = set->value( QString("item_%1_duration").arg(n), -1 ).toDouble(); 1889 2264 name = set->value( QString("item_%1_name").arg(n), "" ).toString(); 1890 addItem( filename, name, duration ); 2265 QStringList params = set->value( QString("item_%1_params").arg(n), QStringList()).toStringList(); 2266 QString video_url = set->value( QString("item_%1_video_url").arg(n), "").toString(); 2267 addItem( filename, name, duration, params, video_url ); 1891 2268 } 1892 2269 set->endArray(); 1893 2270 setCurrentItem( set->value( "current_item", -1 ).toInt() ); 2271 setPlaylistFilename( set->value("filename", "").toString() ); 1894 2272 setModified( set->value( "modified", false ).toBool() ); 1895 2273 … … 1905 2283 #endif 1906 2284 1907 proxy->setFilterCaseSensitivity( (Qt::CaseSensitivity) filter_case_sensivity);1908 proxy->setSortCaseSensitivity( (Qt::CaseSensitivity) sort_case_sensivity);2285 setFilterCaseSensitive(filter_case_sensitive); 2286 setSortCaseSensitive(sort_case_sensitive); 1909 2287 proxy->sort(sort_column, (Qt::SortOrder) sort_order); 1910 2288 filter_edit->setText(filter); 2289 setAutoSort(auto_sort); 2290 2291 if (!listView->isColumnHidden(COL_NUM)) showPositionColumnAct->setChecked(true); 2292 if (!listView->isColumnHidden(COL_NAME)) showNameColumnAct->setChecked(true); 2293 if (!listView->isColumnHidden(COL_TIME)) showDurationColumnAct->setChecked(true); 2294 if (!listView->isColumnHidden(COL_FILENAME)) showFilenameColumnAct->setChecked(true); 1911 2295 } 1912 2296 … … 1914 2298 QString last_dir = latest_dir; 1915 2299 return last_dir; 2300 } 2301 2302 void Playlist::setPositionColumnVisible(bool b) { 2303 listView->setColumnHidden(COL_NUM, !b); 2304 } 2305 2306 void Playlist::setNameColumnVisible(bool b) { 2307 listView->setColumnHidden(COL_NAME, !b); 2308 } 2309 2310 void Playlist::setDurationColumnVisible(bool b) { 2311 listView->setColumnHidden(COL_TIME, !b); 2312 } 2313 2314 void Playlist::setFilenameColumnVisible(bool b) { 2315 listView->setColumnHidden(COL_FILENAME, !b); 2316 } 2317 2318 void Playlist::setAutoSort(bool b) { 2319 proxy->setDynamicSortFilter(b); 2320 } 2321 2322 bool Playlist::autoSort() { 2323 return proxy->dynamicSortFilter(); 2324 } 2325 2326 void Playlist::setSortCaseSensitive(bool b) { 2327 Qt::CaseSensitivity c = b ? Qt::CaseSensitive : Qt::CaseInsensitive; 2328 proxy->setSortCaseSensitivity(c); 2329 } 2330 2331 bool Playlist::sortCaseSensitive() { 2332 return (proxy->sortCaseSensitivity() == Qt::CaseSensitive); 2333 } 2334 2335 void Playlist::setFilterCaseSensitive(bool b) { 2336 Qt::CaseSensitivity c = b ? Qt::CaseSensitive : Qt::CaseInsensitive; 2337 proxy->setFilterCaseSensitivity(c); 2338 } 2339 2340 bool Playlist::filterCaseSensitive() { 2341 return (proxy->filterCaseSensitivity() == Qt::CaseSensitive); 1916 2342 } 1917 2343 … … 1960 2386 if (data.contains("#EXTM3U")) { 1961 2387 load_m3u(tfile, M3U8); 2388 setPlaylistFilename(""); 1962 2389 } 1963 2390 else 1964 2391 if (data.contains("[playlist]")) { 1965 2392 load_pls(tfile); 2393 setPlaylistFilename(""); 1966 2394 } 1967 2395 else 1968 2396 if (data.contains("xspf.org")) { 1969 2397 loadXSPF(tfile); 2398 setPlaylistFilename(""); 1970 2399 } 1971 2400 else {
Note:
See TracChangeset
for help on using the changeset viewer.