void PlaylistWindow::exportTab() { auto uuid = currentPlaylistWidget()->uuid(); QString file; file = QFileDialog::getSaveFileName(this, tr("Export File"), QString(), tr("Playlist files (*.m3u *.m3u8)")); auto pl = PlaylistCollection::getSingleton()->playlistOf(uuid); if (!file.isEmpty() && pl) emit exportPlaylist(file, pl->toStringList()); }
void KNMusicPlaylist::onActionExportPlaylist() { //Get the current playlist model form the viewer. KNMusicPlaylistModel *playlist=m_playlistViewer->playlist(); //Check the current playlist model. if(!playlist) { return; } //Generate a file dialog. QFileDialog exportPlaylist(this); //Set the file mode and the name filters. exportPlaylist.setFileMode(QFileDialog::AnyFile); exportPlaylist.setAcceptMode(QFileDialog::AcceptSave); //Set the default playlist file name. exportPlaylist.selectFile(playlist->title()); //Get the export filter. QStringList fileFilter=m_playlistManager->playlistFilter(); //Remove the all support one. fileFilter.removeFirst(); //Set the export filter. exportPlaylist.setNameFilters(fileFilter); //Launch the export file. if(exportPlaylist.exec() && !exportPlaylist.selectedFiles().isEmpty()) { //Get the index of the selected filter. int selectedParserIndex= fileFilter.indexOf(exportPlaylist.selectedNameFilter()); //Check the parser index. if(selectedParserIndex==-1) { //Something wrong happened, we cannot continue. return; } //Export the file. m_playlistManager->exportPlaylist( playlist, exportPlaylist.selectedFiles().first(), selectedParserIndex); } }