extragear/multimedia/amarok/src/meta/file

Maximilian Kossick maximilian.kossick at googlemail.com
Sun May 11 17:15:47 CEST 2008


write support is useful in multiple locations, e.g. in SqlMeta too. it
makes more seonse to put all of the taglib write code into a utility
function somewhere (probably in MetaUtility.h). That function could
have a signature like Meta::Field::writeFields( const QString
&filepath, const QVariantMap &changes ). Then we could easily create a
map containing all changed fields in MetaFile or SqlMeta and pass it
to the function. If necessary, we could add another function which
takes a Taglib file pointer (or whatever taglib class is most useful),
so that we do not have to create the taglib object again (the function
with the QString would then call the one with the taglib object in the
signature, so we would still have all the taglib write code in only
one place)

Max

On Sun, May 11, 2008 at 5:05 PM, Dan Meltzer
<hydrogen at notyetimplemented.com> wrote:
> SVN commit 806501 by dmeltzer:
>
> initial write support.. Doesn't support batch update currently.  Will soon
>
>
>  M  +21 -38    File.cpp
>  M  +1 -1      File_p.h
>
>
> --- trunk/extragear/multimedia/amarok/src/meta/file/File.cpp #806500:806501
> @@ -26,9 +26,6 @@
>  #include <QPointer>
>  #include <QString>
>
> -#include <kfilemetainfo.h>
> -#include <kfilemetainfoitem.h>
> -
>  using namespace MetaFile;
>
>  class EditCapabilityImpl : public Meta::EditCapability
> @@ -191,43 +188,39 @@
>  void
>  Track::setAlbum( const QString &newAlbum )
>  {
> -    AMAROK_NOTIMPLEMENTED
> -    #if 0
> -    d->metaInfo.item( Meta::Field::xesamPrettyToFullFieldName( Meta::Field::ALBUM ) ).setValue( newAlbum );
>     if( !d->batchUpdate )
>     {
> -        d->metaInfo.applyChanges();
> +        d->m_data.album = newAlbum;
> +        d->tag->setAlbum( QStringToTString( newAlbum ) );
>         notifyObservers();
>     }
> -    #endif
> +    else
> +        AMAROK_NOTIMPLEMENTED
>  }
>
>  void
>  Track::setArtist( const QString& newArtist )
>  {
> -    AMAROK_NOTIMPLEMENTED
> -    #if 0
> -    d->metaInfo.item( Meta::Field::xesamPrettyToFullFieldName( Meta::Field::ARTIST ) ).setValue( newArtist );
>     if( !d->batchUpdate )
>     {
> -        d->metaInfo.applyChanges();
> +        d->m_data.artist = newArtist;
> +        d->tag->setArtist( QStringToTString( newArtist ) );
>         notifyObservers();
>     }
> -    #endif
> +    else
> +        AMAROK_NOTIMPLEMENTED
>  }
>
>  void
>  Track::setGenre( const QString& newGenre )
>  {
> -    AMAROK_NOTIMPLEMENTED
> -    #if 0
> -    d->metaInfo.item( Meta::Field::xesamPrettyToFullFieldName( Meta::Field::GENRE ) ).setValue( newGenre );
>     if( !d->batchUpdate )
>     {
> -        d->metaInfo.applyChanges();
> +        d->tag->setGenre( QStringToTString( newGenre ) );
>         notifyObservers();
>     }
> -    #endif
> +    else
> +        AMAROK_NOTIMPLEMENTED
>  }
>
>  void
> @@ -247,29 +240,25 @@
>  void
>  Track::setYear( const QString& newYear )
>  {
> -    AMAROK_NOTIMPLEMENTED
> -    #if 0
> -    d->metaInfo.item( Meta::Field::xesamPrettyToFullFieldName( Meta::Field::YEAR ) ).setValue( newYear );
>     if( !d->batchUpdate )
>     {
> -        d->metaInfo.applyChanges();
> +        d->m_data.year = newYear.toInt();
> +        d->tag->setYear( newYear.toInt() );
>         notifyObservers();
>     }
> -    #endif
>  }
>
>  void
>  Track::setTitle( const QString &newTitle )
>  {
> -    AMAROK_NOTIMPLEMENTED
> -    #if 0
> -    d->metaInfo.item( Meta::Field::xesamPrettyToFullFieldName( Meta::Field::TITLE ) ).setValue( newTitle );
> +    DEBUG_BLOCK
>     if( !d->batchUpdate )
>     {
> -        d->metaInfo.applyChanges();
> +        DEBUG_LINE_INFO
> +        d->m_data.title = newTitle;
> +        d->tag->setTitle( QStringToTString( newTitle ) );
>         notifyObservers();
>     }
> -    #endif
>  }
>
>  QString
> @@ -289,15 +278,12 @@
>  void
>  Track::setComment( const QString& newComment )
>  {
> -    AMAROK_NOTIMPLEMENTED
> -    #if 0
> -    d->metaInfo.item( Meta::Field::xesamPrettyToFullFieldName( Meta::Field::COMMENT ) ).setValue( newComment );
>     if( !d->batchUpdate )
>     {
> -        d->metaInfo.applyChanges();
> +        d->m_data.comment = newComment;
> +        d->tag->setComment( QStringToTString( newComment ) );
>         notifyObservers();
>     }
> -    #endif
>  }
>
>  double
> @@ -337,15 +323,12 @@
>  void
>  Track::setTrackNumber( int newTrackNumber )
>  {
> -    AMAROK_NOTIMPLEMENTED
> -    #if 0
> -    d->metaInfo.item( Meta::Field::xesamPrettyToFullFieldName( Meta::Field::TRACKNUMBER ) ).setValue( newTrackNumber );
>     if( !d->batchUpdate )
>     {
> -        d->metaInfo.applyChanges();
> +        d->m_data.trackNumber = newTrackNumber;
> +        d->tag->setTrack( newTrackNumber );
>         notifyObservers();
>     }
> -    #endif
>  }
>
>  int
> --- trunk/extragear/multimedia/amarok/src/meta/file/File_p.h #806500:806501
> @@ -186,7 +186,7 @@
>         else
>             m_data.discNumber = disc.toInt();
>     }
> -
> +#undef strip
>     m_data.fileSize = QFile( url.url() ).size();
>  }
>
>


More information about the Amarok-devel mailing list