[PATCH] quick-fix CDDB info in kscd

Alexander Kern alex.kern at gmx.de
Mon Dec 24 09:01:43 GMT 2007


Am Montag 24 Dezember 2007 06:12:39 schrieb Benjamin K. Stuhl:
> (CC'ing the last few people from svn praise for kscd)
>
> All,
>   It looks like a conversion to move the CD metadata in to KCompactDisc
> was started but not finished yet, and so CDDB information completely
> fails to display in kscd. Since 4.0 is getting close, here's a patch
> to display the information directly from KCDDB. I've tested it with both
> the Phonon and wmlib backends and it seems to work well. Ok to apply?
>
> Thanks,
> -- BKS
>
> Index: kdemultimedia/kscd/kscd.cpp
> ===================================================================
> --- kdemultimedia/kscd/kscd.cpp	(revision 752293)
> +++ kdemultimedia/kscd/kscd.cpp	(working copy)
> @@ -1033,17 +1033,43 @@
>      artistlabel->setText(infoStatus);
>  }
>
> +/*
> + * KDE 4.0 quick fix: it looks like the conversion to mode
> + * CDDB info into KCompactDisc wasn't finished, so we work around
> + * it here for now by explicitly overriding data from m_cd with
> + * data from cddbInfo iff cddbInfo.isValid() &&
> + * cddbInfo.numberOfTracks() == m_cd->tracks()
> + */
> +
>  void KSCD::restoreArtistLabel()
>  {
> -    if(m_cd->tracks())
> -        showArtistLabel(QString("%1 - %2").arg(m_cd->discArtist(),
> m_cd->discTitle())); -    else
> +    if(m_cd->tracks()) {
> +        QString artist, title;
> +
> +        if (cddbInfo.isValid() && cddbInfo.numberOfTracks() ==
> m_cd->tracks()) { +            artist =
> cddbInfo.get(KCDDB::Artist).toString();
> +            title = cddbInfo.get(KCDDB::Title).toString();
> +        } else {
> +            artist = m_cd->discArtist();
> +            title = m_cd->discTitle();
> +        }
> +
> +        showArtistLabel(QString("%1 - %2").arg(artist, title));
> +    } else {
>          showArtistLabel(i18n("NO DISC"));
> +    }
>  }
>
>  void KSCD::information(QAction *action)
>  {
> -    const QString artist = m_cd->trackArtist();
> +    QString artist = m_cd->trackArtist();
> +
> +    // see comment before restoreArtistLabel()
> +    if (cddbInfo.isValid() && cddbInfo.numberOfTracks() == m_cd->tracks())
> { +        const KCDDB::TrackInfo& t = cddbInfo.track(m_cd->track() - 1); +
>        artist = t.get(KCDDB::Artist).toString();
> +    }
> +
>      if(artist.isEmpty())
>          return;
>
> @@ -1130,26 +1156,48 @@
>
>  QString KSCD::currentTrackTitle()
>  {
> +    if (cddbInfo.isValid() && cddbInfo.numberOfTracks() == m_cd->tracks())
> { +        const KCDDB::TrackInfo& t = cddbInfo.track(m_cd->track() - 1); +
>        return t.get(KCDDB::Title).toString();
> +    }
> +
>      return m_cd->trackTitle();
>  }
>
>  QString KSCD::currentAlbum()
>  {
> +    if (cddbInfo.isValid() && cddbInfo.numberOfTracks() == m_cd->tracks())
> { +        return cddbInfo.get(KCDDB::Title).toString();
> +    }
> +
>      return m_cd->discTitle();
>  }
>
>  QString KSCD::currentArtist()
>  {
> +    if (cddbInfo.isValid() && cddbInfo.numberOfTracks() == m_cd->tracks())
> { +        const KCDDB::TrackInfo& t = cddbInfo.track(m_cd->track() - 1); +
>        return t.get(KCDDB::Artist).toString();
> +    }
> +
>      return m_cd->trackArtist();
>  }
>
>  QStringList KSCD::trackList()
>  {
> -  QStringList tracks;
> -  for (uint i = 0; i < m_cd->tracks(); ++i)
> -    tracks << m_cd->trackTitle(i);
> +    QStringList tracks;
>
> -  return tracks;
> +    if (cddbInfo.isValid() && cddbInfo.numberOfTracks() == m_cd->tracks())
> { +        for (uint i = 0; i < m_cd->tracks(); ++i) {
> +            const KCDDB::TrackInfo& t = cddbInfo.track(i);
> +            tracks << t.get(KCDDB::Artist).toString();
> +        }
> +    } else {
> +        for (uint i = 0; i < m_cd->tracks(); ++i)
> +            tracks << m_cd->trackTitle(i);
> +    }
> +
> +    return tracks;
>  }
>
>  void KSCD::populateSongList()
> @@ -1164,11 +1212,20 @@
>          mysec = (tmp % 60);
>          QString str1;
>          str1.sprintf("%02u: ", i);
> +
>          QString str2;
>          str2.sprintf(" (%02u:%02u) ", mymin,  mysec);
> -        if (m_cd->discArtist() != m_cd->trackArtist(i))
> -            str1.append(m_cd->trackArtist(i)).append(" - ");
> -        str1.append(m_cd->trackTitle(i));
> +        if (cddbInfo.isValid() && cddbInfo.numberOfTracks() ==
> m_cd->tracks()) { +            const KCDDB::TrackInfo& t = cddbInfo.track(i
> - 1);
> +
> +            if (cddbInfo.get(KCDDB::Artist).toString() !=
> t.get(KCDDB::Artist).toString()) +               
> str1.append(t.get(KCDDB::Artist).toString()).append(" - "); +           
> str1.append(t.get(KCDDB::Title).toString());
> +        } else {
> +            if (m_cd->discArtist() != m_cd->trackArtist(i))
> +                str1.append(m_cd->trackArtist(i)).append(" - ");
> +            str1.append(m_cd->trackTitle(i));
> +        }
>          str1.append(str2);
>          songListCB->addItem(str1);
>      }


I am OK with patch

Merry Christmas

Best Wishes
Mit freundlichen Grüßen

Alex Kern




More information about the kde-core-devel mailing list