More const detach fixes

This commit is contained in:
Jonas Kvinge
2024-08-23 20:30:59 +02:00
parent be09011bb7
commit 7ebcc73a49
54 changed files with 195 additions and 180 deletions

View File

@@ -186,7 +186,7 @@ void SmartPlaylistQueryWizardPlugin::SetGenerator(PlaylistGeneratorPtr g) {
for (const SmartPlaylistSearchTerm &term : std::as_const(search.terms_)) {
AddSearchTerm();
search_page_->terms_.last()->SetTerm(term);
search_page_->terms_.constLast()->SetTerm(term);
}
// Sort order

View File

@@ -122,7 +122,7 @@ void SmartPlaylistsModel::Init() {
// How many defaults do we have to write?
int unwritten_defaults = 0;
for (int i = version; i < default_smart_playlists_.count(); ++i) {
unwritten_defaults += static_cast<int>(default_smart_playlists_[i].count());
unwritten_defaults += static_cast<int>(default_smart_playlists_.value(i).count());
}
// Save the defaults if there are any unwritten ones
@@ -134,7 +134,8 @@ void SmartPlaylistsModel::Init() {
// Append the new ones
s.beginWriteArray(collection_backend_->songs_table(), playlist_index + unwritten_defaults);
for (; version < default_smart_playlists_.count(); ++version) {
for (PlaylistGeneratorPtr gen : std::as_const(default_smart_playlists_[version])) {
const GeneratorList generators = default_smart_playlists_.value(version);
for (PlaylistGeneratorPtr gen : generators) {
SaveGenerator(&s, playlist_index++, gen);
}
}

View File

@@ -110,7 +110,7 @@ void SmartPlaylistWizard::SetGenerator(PlaylistGeneratorPtr 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()) {
if (plugins_.value(i)->type() == gen->type()) {
TypeChanged(i);
// TODO: Put this back in when the setStartId is removed from the ctor next();
break;
@@ -130,7 +130,8 @@ void SmartPlaylistWizard::SetGenerator(PlaylistGeneratorPtr gen) {
finish_page_->ui_->dynamic->setChecked(gen->is_dynamic());
// Tell the plugin to load
plugins_[type_index_]->SetGenerator(gen);
SmartPlaylistWizardPlugin *plugin = plugins_.value(type_index_);
plugin->SetGenerator(gen);
}
@@ -158,7 +159,7 @@ void SmartPlaylistWizard::AddPlugin(SmartPlaylistWizardPlugin *plugin) {
void SmartPlaylistWizard::TypeChanged(const int index) {
type_index_ = index;
type_page_->next_id_ = plugins_[type_index_]->start_page();
type_page_->next_id_ = plugins_.value(type_index_)->start_page();
}
@@ -179,7 +180,7 @@ PlaylistGeneratorPtr SmartPlaylistWizard::CreateGenerator() const {
void SmartPlaylistWizard::initializePage(const int id) {
if (id == finish_id_) {
finish_page_->ui_->dynamic_container->setEnabled(plugins_[type_index_]->is_dynamic());
finish_page_->ui_->dynamic_container->setEnabled(plugins_.value(type_index_)->is_dynamic());
}
QWizard::initializePage(id);