PlaylistUpdaterInterface* PlaylistUpdaterInterface::loadForPlaylist( const playlist_ptr& pl ) { TomahawkSettings* s = TomahawkSettings::instance(); const QString key = QString( "playlistupdaters/%1" ).arg( pl->guid() ); if ( s->contains( QString( "%1/type" ).arg( key ) ) ) { // Ok, we have one we can try to load const QString type = s->value( QString( "%1/type" ).arg( key ) ).toString(); PlaylistUpdaterInterface* updater = 0; if ( type == "xspf" ) updater = new XspfUpdater( pl ); // You forgot to register your new updater type with the factory above. 00ps. if ( !updater ) { Q_ASSERT( false ); return 0; } updater->setAutoUpdate( s->value( QString( "%1/autoupdate" ).arg( key ) ).toBool() ); updater->setInterval( s->value( QString( "%1/interval" ).arg( key ) ).toInt() ); updater->loadFromSettings( key ); return updater; } return 0; }
void PlaylistUpdaterInterface::save() { TomahawkSettings* s = TomahawkSettings::instance(); const QString key = QString( "playlistupdaters/%1" ).arg( m_playlist->guid() ); if ( !s->contains( QString( "%1/type" ).arg( key ) ) ) { s->setValue( QString( "%1/type" ).arg( key ), type() ); } saveToSettings( key ); }
void PlaylistUpdaterInterface::doSave() { TomahawkSettings* s = TomahawkSettings::instance(); const QString key = QString( "playlistupdaters/%1" ).arg( m_playlist->guid() ); if ( !s->contains( QString( "%1/type" ).arg( key ) ) ) { s->setValue( QString( "%1/type" ).arg( key ), type() ); s->setValue( QString( "%1/autoupdate" ).arg( key ), m_autoUpdate ); s->setValue( QString( "%1/interval" ).arg( key ), m_timer->interval() ); saveToSettings( key ); } }
PlaylistUpdaterInterface* PlaylistUpdaterInterface::loadForPlaylist( const playlist_ptr& pl ) { TomahawkSettings* s = TomahawkSettings::instance(); const QString key = QString( "playlistupdaters/%1" ).arg( pl->guid() ); if ( s->contains( QString( "%1/type" ).arg( key ) ) ) { // Ok, we have one we can try to load const QString type = s->value( QString( "%1/type" ).arg( key ) ).toString(); PlaylistUpdaterInterface* updater = 0; if ( !s_factories.contains( type ) ) { Q_ASSERT( false ); // You forgot to register your new updater type with the factory.... return 0; } updater = s_factories[ type ]->create( pl, key ); return updater; } return 0; }