void LibraryModel::SaveGenerator(QSettings* s, int i, GeneratorPtr generator) const { s->setArrayIndex(i); s->setValue("name", generator->name()); s->setValue("type", generator->type()); s->setValue("data", generator->Save()); }
void PlaylistManager::PlaySmartPlaylist(GeneratorPtr generator, bool as_new, bool clear) { if (as_new) { New(generator->name()); } if (clear) { current()->Clear(); } current()->InsertSmartPlaylist(generator); }
void Wizard::SetGenerator(GeneratorPtr gen) { // Find the right type and jump to the start page for (int i=0 ; i<plugins_.count() ; ++i) { if (plugins_[i]->type() == gen->type()) { TypeChanged(i); // TODO: Put this back in when the setStartId is removed from the ctor // next(); break; } } // Set the name finish_page_->ui_->name->setText(gen->name()); finish_page_->ui_->dynamic->setChecked(gen->is_dynamic()); // Tell the plugin to load plugins_[type_index_]->SetGenerator(gen); }
void LibraryModel::UpdateGenerator(const QModelIndex& index, GeneratorPtr gen) { if (index.parent() != ItemToIndex(smart_playlist_node_)) return; LibraryItem* item = IndexToItem(index); if (!item) return; // Update the config QSettings s; s.beginGroup(kSmartPlaylistsSettingsGroup); // Count the existing items const int count = s.beginReadArray(backend_->songs_table()); s.endArray(); s.beginWriteArray(backend_->songs_table(), count); SaveGenerator(&s, index.row(), gen); // Update the text of the item item->display_text = gen->name(); item->sort_text = item->display_text; item->key = gen->type(); item->smart_playlist_data = gen->Save(); item->ChangedNotify(); }