void EncoderLame::fillSongInfo( KCDDB::CDInfo info, int track, const QString &comment ){ trackInfo.clear(); trackInfo.append("--tt"); trackInfo.append(info.track(track-1).get(Title).toString()); trackInfo.append("--ta"); trackInfo.append(info.track(track-1).get(Artist).toString()); trackInfo.append("--tl"); trackInfo.append(info.get(Title).toString()); trackInfo.append("--ty"); trackInfo.append(QString("%1").arg(info.get(Year).toString())); trackInfo.append("--tc"); trackInfo.append(comment); trackInfo.append("--tn"); trackInfo.append(QString("%1").arg(track)); const QString genre = info.get(Genre).toString(); if ( d->genreList.indexOf( genre ) != -1 ) { trackInfo.append("--tg"); trackInfo.append(genre); } }
void CDInfoDialog::setInfo( const KCDDB::CDInfo &info, const KCDDB::TrackOffsetList &trackStartFrames ) { d->info = info; d->ui->m_artist->setText(info.get(Artist).toString().trimmed()); d->ui->m_title->setText(info.get(Title).toString().trimmed()); d->ui->m_category->setItemText(d->ui->m_category->currentIndex(), d->categories.cddb2i18n(info.get(Category).toString())); // Make sure the revision is set before the genre to allow the genreChanged() handler to fire. d->ui->m_revision->setText(QString::number(info.get(QLatin1String( "revision" )).toInt())); d->ui->m_genre->setItemText(d->ui->m_genre->currentIndex(), d->genres.cddb2i18n(info.get(Genre).toString())); d->ui->m_year->setValue(info.get(Year).toInt()); d->ui->m_comment->setText(info.get(Comment).toString().trimmed()); d->ui->m_id->setText(info.get(QLatin1String( "discid" )).toString().trimmed()); // Now do the individual tracks. unsigned tracks = info.numberOfTracks(); if (tracks > 0) { d->ui->m_length->setText(framesTime(trackStartFrames[tracks] - trackStartFrames[0])); } m_trackModel->clear(); QStringList labels; labels << i18n("Track") << i18n("Length") << i18n("Title") << i18n("Artist") << i18n("Comment"); m_trackModel->setHorizontalHeaderLabels(labels); for (unsigned i = 0; i < tracks; i++) { QList<QStandardItem *> trackItems = QList<QStandardItem *>(); TrackInfo ti(info.track(i)); QStandardItem *trackNumberItem = new QStandardItem(QString().sprintf("%02d", i + 1)); trackNumberItem->setEditable(false); trackItems << trackNumberItem; QStandardItem *trackLengthItem = new QStandardItem(framesTime(trackStartFrames[i + 1] - trackStartFrames[i])); trackLengthItem->setEditable(false); trackItems << trackLengthItem; QStandardItem *trackTitleItem = new QStandardItem(ti.get(Title).toString()); trackItems << trackTitleItem; QStandardItem *trackArtistItem = new QStandardItem(ti.get(Artist).toString()); trackItems << trackArtistItem; QStandardItem *trackCommentItem = new QStandardItem(ti.get(Comment).toString()); trackItems << trackCommentItem; m_trackModel->appendRow(trackItems); } // FIXME KDE4: handle playorder here too, once KCDDBInfo::CDInfo is updated. if (info.get(Artist).toString() == QLatin1String( "Various" ) || d->ui->m_multiple->isChecked()){ d->ui->m_trackList->resizeColumnToContents(Private::TRACK_ARTIST); } }
KCDDB::CDInfo CDInfoDialog::info() const { KCDDB::CDInfo info = d->info; info.set(Artist, d->ui->m_artist->text().trimmed()); info.set(Title, d->ui->m_title->text().trimmed()); info.set(Category, d->categories.i18n2cddb(d->ui->m_category->currentText())); info.set(Genre, d->genres.i18n2cddb(d->ui->m_genre->currentText())); info.set(Year, d->ui->m_year->value()); info.set(Comment, d->ui->m_comment->text().trimmed()); info.set(QLatin1String( "revision" ), d->ui->m_revision->text().trimmed().toUInt()); info.set(QLatin1String( "discid" ), d->ui->m_id->text().trimmed()); for (int t = 0; t < m_trackModel->rowCount(); ++t) { TrackInfo& track = info.track(t); track.set(Artist, m_trackModel->index(t, Private::TRACK_ARTIST).data().toString().trimmed()); track.set(Title, m_trackModel->index(t, Private::TRACK_TITLE).data().toString().trimmed()); track.set(Comment, m_trackModel->index(t, Private::TRACK_COMMENT).data().toString().trimmed()); // FIXME KDE4: handle track lengths here too, once KCDDBInfo::CDInfo is updated. } // FIXME KDE4: handle playorder here too, once KCDDBInfo::CDInfo is updated. return info; }
void FreeDBImporter::readCDROM() { #ifdef HAVE_KCDDB QString drivePath = m_driveCombo->currentText(); if(drivePath.isEmpty()) { setStatusMessage(i18n("<qt>Tellico was unable to access the CD-ROM device - <i>%1</i>.</qt>", drivePath)); myDebug() << "no drive!"; return; } // now it's ok to add device to saved list m_driveCombo->addItem(drivePath); QStringList drives; for(int i = 0; i < m_driveCombo->count(); ++i) { if(drives.indexOf(m_driveCombo->itemText(i)) == -1) { drives += m_driveCombo->itemText(i); } } { KConfigGroup config(KGlobal::config(), QLatin1String("ImportOptions - FreeDB")); config.writeEntry("CD-ROM Devices", drives); config.writeEntry("Last Device", drivePath); config.writeEntry("Cache Files Only", false); } QByteArray drive = QFile::encodeName(drivePath); QList<uint> lengths; KCDDB::TrackOffsetList list; #if 0 // a1107d0a - Kruder & Dorfmeister - The K&D Sessions - Disc One. /* list << 150 // First track start. << 29462 << 66983 << 96785 << 135628 << 168676 << 194147 << 222158 << 247076 << 278203 // Last track start. << 316732; // Disc end. */ /* list << 150 // First track start. << 3296 << 14437 << 41279 << 51362 << 56253 << 59755 << 61324 << 66059 << 69073 << 77790 << 83214 << 89726 << 92078 << 106325 << 113117 << 116040 << 119877 << 124377 << 145466 << 157583 << 167208 << 173486 << 180120 << 185279 << 193270 << 206451 << 217303 // Last track start. << 224925; // Disc end. list << 150 << 106965 << 127220 << 151925 << 176085 << 234500; */ #else list = offsetList(drive, lengths); #endif if(list.isEmpty()) { setStatusMessage(i18n("<qt>Tellico was unable to access the CD-ROM device - <i>%1</i>.</qt>", drivePath)); return; } // myDebug() << list; // the result info, could be multiple ones KCDDB::CDInfo info; KCDDB::Client client; client.setBlockingMode(true); KCDDB::Result r = client.lookup(list); const KCDDB::CDInfoList responseList = client.lookupResponse(); // KCDDB sometimes doesn't return MultipleRecordFound properly, so check length of response, too if(r == KCDDB::MultipleRecordFound || responseList.count() > 1) { QStringList list; foreach(const KCDDB::CDInfo& info, responseList) { list.append(QString::fromLatin1("%1, %2, %3").arg(info.get(KCDDB::Artist).toString()) .arg(info.get(KCDDB::Title).toString()) .arg(info.get(KCDDB::Genre).toString())); }