bool Playlist::loadM3UPlaylist(QIODevice *device) { QTextStream stream(device); stream.setCodec("UTF-8"); PlaylistTrack track; while (!stream.atEnd()) { QString line = stream.readLine(); if (line.startsWith(QLatin1Char('#'))) { if (line.startsWith(QLatin1String("#EXTINF:"))) { int index = line.indexOf(QLatin1Char(','), 8); bool ok; int length = line.mid(8, index - 8).toInt(&ok); if (ok && (length >= 0)) { track.length = QTime().addSecs(length); } track.title = line.mid(index + 1); } } else { track.url = fromFileOrUrl(line); appendTrack(track); track = PlaylistTrack(); } } return true; }
bool Playlist::loadKaffeinePlaylist(QIODevice *device) { QDomDocument document; if (!document.setContent(device)) { return false; } QDomElement root = document.documentElement(); if (root.nodeName() != QLatin1String("playlist")) { return false; } for (QDomNode node = root.firstChild(); !node.isNull(); node = node.nextSibling()) { if (!node.isElement() || (node.nodeName() != QLatin1String("entry"))) { continue; } PlaylistTrack track; track.url = fromFileOrUrl(node.attributes().namedItem(QLatin1String("url")).nodeValue()); track.title = node.attributes().namedItem(QLatin1String("title")).nodeValue(); track.artist = node.attributes().namedItem(QLatin1String("artist")).nodeValue(); track.album = node.attributes().namedItem(QLatin1String("album")).nodeValue(); bool ok; int trackNumber = node.attributes().namedItem(QLatin1String("track")).nodeValue().toInt(&ok); if (ok && (trackNumber >= 0)) { track.trackNumber = trackNumber; } QString length = node.attributes().namedItem(QLatin1String("length")).nodeValue(); if (length.size() == 7) { length.prepend(QLatin1Char('0')); } track.length = QTime::fromString(length, Qt::ISODate); if (QTime().msecsTo(track.length) == 0) { track.length = QTime(); } appendTrack(track); } return true; }
void wmpBootStrap::readAttributes( IWMPMedia* media ) { BootStrapItem details; //iterate through each attribute for( std::map<_bstr_t, BootStrapDetails>::iterator iter = attributes.begin(); iter != attributes.end(); iter++ ) { _bstr_t value; BSTR attribute = iter->first; TEST_OR_CONTINUE( media->getItemInfo( attribute , &value.GetBSTR() ) ); //escape invalid xml characters std::wstring valueStr = value; switch( iter->second ) { case ARTIST: details.artist = valueStr; break; case ALBUM: details.album = valueStr; break; case TRACK: details.track = valueStr; break; case DURATION: details.duration = valueStr; break; case PLAYCOUNT: details.playcount = valueStr; break; case FILENAME: details.filename = valueStr; break; case TIMESTAMP: //TODO: convert string timestamp into epochs. // this requires checking user's default locale break; } } appendTrack( &details ); }
TrackEditor::TrackEditor(QWidget *parent) : QMainWindow(parent), // m_idev_factory(), m_serial_port(0), m_device_io(0), m_dev_data(0), m_command_mode_step(-1), m_command_response_step(-1), m_device_file(0), m_socket_notifier(0), m_nema_string(""), m_line(""), m_log_buf(), m_tmp_buf(), m_read_start(-1), m_retry_count(-1), m_expect_binary_data(-1), m_binary_data_already_read(-1), m_lastsection(false), m_blocksize(-1), m_track_collection(0), m_selection_model(0), m_track_filename("") { ui.setupUi(this); // set m_track_collection to 0 to prevent setTrackCollection() from trying to delete it. m_track_collection = 0; PlotData::initializeMaps(); connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(close())); connect(ui.action_Connect, SIGNAL(triggered()), this, SLOT(connectDevice())); connect(ui.action_Disconnect, SIGNAL(triggered()), this, SLOT(disconnectDevice())); connect(ui.action_Load_Track, SIGNAL(triggered()), this, SLOT(loadTrack())); connect(ui.actionAppend_Track, SIGNAL(triggered()), this, SLOT(appendTrack())); connect(ui.action_Save_Track, SIGNAL(triggered()), this, SLOT(saveTrack())); connect(ui.action_Save_Track_As, SIGNAL(triggered()), this, SLOT(saveTrackAs())); connect(ui.action_Read_Log, SIGNAL(triggered()), this, SLOT(readLog())); ui.action_Read_Log->setDisabled(true); connect(ui.action_Start_Recording, SIGNAL(triggered()), this, SLOT(startRecording())); connect(ui.action_Stop_Recording, SIGNAL(triggered()), this, SLOT(stopRecording())); connect(ui.actionStart_Animation, SIGNAL(triggered()), &m_animation, SLOT(start())); connect(ui.actionStop_Animation, SIGNAL(triggered()), &m_animation, SLOT(stop())); connect(ui.actionFaster, SIGNAL(triggered()), &m_animation, SLOT(incSpeed())); connect(ui.actionSlower, SIGNAL(triggered()), &m_animation, SLOT(decSpeed())); connect(ui.actionX_0_125, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX0125())); connect(ui.actionX_0_25, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX025())); connect(ui.actionX_0_5, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX05())); connect(ui.actionX_1, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX1())); connect(ui.actionX_2, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX2())); connect(ui.actionX_4, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX4())); connect(ui.actionX_8, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX8())); connect(ui.actionX_16, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX16())); connect(ui.actionX_32, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX32())); connect(ui.actionX_64, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX64())); connect(ui.actionX_128, SIGNAL(triggered()), &m_animation, SLOT(setTimeScaleX128())); connect(ui.actionSettings, SIGNAL(triggered()), this, SLOT(showSettingsDlg())); connect(ui.action_About, SIGNAL(triggered()), this, SLOT(showAboutDialog())); connect(this, SIGNAL(setText(QString)), ui.nemaText, SLOT(appendPlainText(QString))); m_track_view = new TrackView(ui.scrollArea); ui.scrollArea->setWidget(m_track_view); connect(&m_animation, SIGNAL(setMarkers(QList<CMarker>)), m_track_view, SLOT(setMarkers(QList<CMarker>))); connect(ui.actionZoom_in, SIGNAL(triggered()), m_track_view, SLOT(zoomIn())); connect(ui.actionZoom_out, SIGNAL(triggered()), m_track_view, SLOT(zoomOut())); ui.treeView->setSelectionMode(QAbstractItemView::ExtendedSelection); m_selection_model = ui.treeView->selectionModel(); connect(m_selection_model, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged(QItemSelection,QItemSelection))); m_diagrams_layout = new CDiagramsLayout(ui.diagramWidget); ui.diagramWidget->setLayout(m_diagrams_layout); connect(m_diagrams_layout, SIGNAL(setMarkers(QList<CMarker>)), m_track_view, SLOT(setMarkers(QList<CMarker>))); m_settings = new CSettings(); m_settings->load(); QList<enum plotTypeY> distList; distList = m_settings->getDistQuantities(); QList<enum plotTypeY> timeList; timeList = m_settings->getTimeQuantities(); QList<enum plotTypeY> trackPointsList; trackPointsList = m_settings->getTrackpointsQuantities(); m_diagrams_layout->setQuantities(distList, timeList, trackPointsList ); setTrackCollection(new TrackCollection); m_device_io = 0; m_dev_data = 0; m_expect_binary_data = 0; m_command_mode_step = 0; m_command_response_step = 0; m_track_filename.clear(); connect(ui.treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(treeViewClicked(QModelIndex))); ui.treeView->setEditTriggers( QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed ); m_progress_dlg = new QDialog(this); prg_dlg.setupUi(m_progress_dlg); m_progress_dlg->setModal(false); connect(prg_dlg.cancelButton, SIGNAL(clicked()), this, SLOT(readLogFinished())); statusBar()->addWidget(m_animation.statusBarWidget()); statusBar()->addPermanentWidget(m_track_view->statusBarWidget()); restoreLayout(); }