1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 16:29:43 +01:00

add migration code

This commit is contained in:
Leo Franchi 2012-04-30 18:25:37 -04:00
parent 319a03b791
commit b1a5626e94
2 changed files with 29 additions and 4 deletions

View File

@ -55,8 +55,8 @@ SpotifyUpdaterFactory::create( const Tomahawk::playlist_ptr& pl, const QVariantH
// Register the updater with the account
const QString spotifyId = settings.value( "spotifyId" ).toString();
const QString latestRev = settings.value( "%1/latestrev" ).toString();
const bool sync = settings.value( "%1/sync" ).toBool();
const QString latestRev = settings.value( "latestrev" ).toString();
const bool sync = settings.value( "sync" ).toBool();
Q_ASSERT( !spotifyId.isEmpty() );
SpotifyPlaylistUpdater* updater = new SpotifyPlaylistUpdater( m_account.data(), latestRev, spotifyId, pl );

View File

@ -486,7 +486,32 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
else if ( oldVersion == 9 )
{
// Upgrade single-updater-per-playlist to list-per-playlist
beginGroup( "playlistupdaters" );
const QStringList playlists = childGroups();
PlaylistUpdaterInterface::SerializedUpdaters updaters;
foreach ( const QString& playlist, playlists )
{
beginGroup( playlist );
const QString type = value( "type" ).toString();
QVariantHash extraData;
foreach ( const QString& key, childKeys() )
{
if ( key == "type" )
continue;
extraData[ key ] = value( key );
}
updaters[ playlist ] = PlaylistUpdaterInterface::SerializedUpdater( type, extraData );
endGroup();
}
endGroup();
setPlaylistUpdaters( updaters );
}
}
@ -1223,14 +1248,14 @@ TomahawkSettings::setImportXspfPath( const QString& path )
PlaylistUpdaterInterface::SerializedUpdaters
TomahawkSettings::playlistUpdaters() const
{
return value( "playlistupdaters" ).value< PlaylistUpdaterInterface::SerializedUpdaters >();
return value( "playlist/updaters" ).value< PlaylistUpdaterInterface::SerializedUpdaters >();
}
void
TomahawkSettings::setPlaylistUpdaters( const PlaylistUpdaterInterface::SerializedUpdaters& updaters )
{
setValue( "playlistupdaters", QVariant::fromValue< PlaylistUpdaterInterface::SerializedUpdaters >( updaters ) );
setValue( "playlist/updaters", QVariant::fromValue< PlaylistUpdaterInterface::SerializedUpdaters >( updaters ) );
}