use std::as_const instead of qAsConst

This commit is contained in:
in1tiate 2025-01-11 01:45:28 -06:00
parent 115c1ccd1d
commit 4dae73c848
14 changed files with 33 additions and 33 deletions

View File

@ -435,7 +435,7 @@ void CharacterAnimationLayer::loadCharacterEmote(QString character, QString file
QVector<VPath> path_list; QVector<VPath> path_list;
QVector<QString> prefixed_emote_list; QVector<QString> prefixed_emote_list;
for (const QString &prefix : qAsConst(prefixes)) for (const QString &prefix : std::as_const(prefixes))
{ {
path_list << ao_app->get_character_path(character, prefix + m_emote); path_list << ao_app->get_character_path(character, prefix + m_emote);
prefixed_emote_list << prefix + m_emote; prefixed_emote_list << prefix + m_emote;
@ -479,13 +479,13 @@ void CharacterAnimationLayer::setFrameEffects(QStringList data)
const EffectType effect_type = EFFECT_TYPE_LIST.at(i); const EffectType effect_type = EFFECT_TYPE_LIST.at(i);
QStringList emotes = data.at(i).split("^"); QStringList emotes = data.at(i).split("^");
for (const QString &emote : qAsConst(emotes)) for (const QString &emote : std::as_const(emotes))
{ {
QStringList emote_effects = emote.split("|"); QStringList emote_effects = emote.split("|");
const QString emote_name = emote_effects.takeFirst(); const QString emote_name = emote_effects.takeFirst();
for (const QString &raw_effect : qAsConst(emote_effects)) for (const QString &raw_effect : std::as_const(emote_effects))
{ {
QStringList frame_data = raw_effect.split("="); QStringList frame_data = raw_effect.split("=");
@ -553,7 +553,7 @@ void CharacterAnimationLayer::notifyFrameEffect(int frameNumber)
auto it = m_effects.constFind(frameNumber); auto it = m_effects.constFind(frameNumber);
if (it != m_effects.constEnd()) if (it != m_effects.constEnd())
{ {
for (const FrameEffect &effect : qAsConst(*it)) for (const FrameEffect &effect : std::as_const(*it))
{ {
if (effect.emote_name == m_resolved_emote) if (effect.emote_name == m_resolved_emote)
{ {

View File

@ -72,7 +72,7 @@ AnimationFrame AnimationLoader::frame(int frameNumber)
m_task_signal.wait(&m_task_lock); m_task_signal.wait(&m_task_lock);
} }
AnimationFrame frame = qAsConst(m_frames)[frameNumber]; AnimationFrame frame = std::as_const(m_frames)[frameNumber];
m_task_lock.unlock(); m_task_lock.unlock();
return frame; return frame;

View File

@ -37,7 +37,7 @@ QString AOPacket::toString(bool ensureEncoded)
QString message = m_header; QString message = m_header;
if (!m_content.isEmpty()) if (!m_content.isEmpty())
{ {
for (QString item : qAsConst(m_content)) for (QString item : std::as_const(m_content))
{ {
if (ensureEncoded) if (ensureEncoded)
{ {

View File

@ -57,7 +57,7 @@ void AOUtils::migrateEffects(QSettings &p_effects_ini)
} }
int i = 0; int i = 0;
for (const QString &i_effect_key : qAsConst(l_key_list)) for (const QString &i_effect_key : std::as_const(l_key_list))
{ {
p_effects_ini.beginGroup(QString::number(i++)); p_effects_ini.beginGroup(QString::number(i++));
p_effects_ini.setValue("name", i_effect_key); p_effects_ini.setValue("name", i_effect_key);

View File

@ -116,7 +116,7 @@ void Courtroom::set_char_select_page()
ui_char_select_left->hide(); ui_char_select_left->hide();
ui_char_select_right->hide(); ui_char_select_right->hide();
for (AOCharButton *i_button : qAsConst(ui_char_button_list)) for (AOCharButton *i_button : std::as_const(ui_char_button_list))
{ {
i_button->hide(); i_button->hide();
i_button->move(0, 0); i_button->move(0, 0);

View File

@ -704,7 +704,7 @@ void Courtroom::set_mute_list()
QStringList sorted_mute_list; QStringList sorted_mute_list;
for (const CharacterSlot &i_char : qAsConst(char_list)) for (const CharacterSlot &i_char : std::as_const(char_list))
{ {
sorted_mute_list.append(i_char.name); sorted_mute_list.append(i_char.name);
} }
@ -722,7 +722,7 @@ void Courtroom::set_pair_list()
{ {
QStringList sorted_pair_list; QStringList sorted_pair_list;
for (const CharacterSlot &i_char : qAsConst(char_list)) for (const CharacterSlot &i_char : std::as_const(char_list))
{ {
sorted_pair_list.append(i_char.name); sorted_pair_list.append(i_char.name);
} }
@ -3084,7 +3084,7 @@ void Courtroom::do_transition(QString p_desk_mod, QString oldPosId, QString newP
void Courtroom::post_transition_cleanup() void Courtroom::post_transition_cleanup()
{ {
for (kal::CharacterAnimationLayer *layer : qAsConst(ui_vp_char_list)) for (kal::CharacterAnimationLayer *layer : std::as_const(ui_vp_char_list))
{ {
bool is_visible = layer->isVisible(); bool is_visible = layer->isVisible();
layer->stopPlayback(); layer->stopPlayback();
@ -3368,7 +3368,7 @@ void Courtroom::handle_callwords()
// No more file IO on every message. // No more file IO on every message.
QStringList call_words = Options::getInstance().callwords(); QStringList call_words = Options::getInstance().callwords();
// Loop through each word in the call words list // Loop through each word in the call words list
for (const QString &word : qAsConst(call_words)) for (const QString &word : std::as_const(call_words))
{ {
// If our message contains that specific call word // If our message contains that specific call word
if (f_message.contains(word, Qt::CaseInsensitive)) if (f_message.contains(word, Qt::CaseInsensitive))
@ -5392,7 +5392,7 @@ void Courtroom::set_sfx_dropdown()
sound_list += ao_app->get_list_file(VPath("soundlist.ini")); sound_list += ao_app->get_list_file(VPath("soundlist.ini"));
QStringList display_sounds; QStringList display_sounds;
for (const QString &sound : qAsConst(sound_list)) for (const QString &sound : std::as_const(sound_list))
{ {
QStringList unpacked = sound.split("="); QStringList unpacked = sound.split("=");
QString display = unpacked[0].trimmed(); QString display = unpacked[0].trimmed();
@ -5694,7 +5694,7 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index)
// Redo the character list. // Redo the character list.
QStringList sorted_pair_list; QStringList sorted_pair_list;
for (const CharacterSlot &i_char : qAsConst(char_list)) for (const CharacterSlot &i_char : std::as_const(char_list))
{ {
sorted_pair_list.append(i_char.name); sorted_pair_list.append(i_char.name);
} }
@ -5862,7 +5862,7 @@ void Courtroom::music_stop(bool no_effects)
if (!music_list.contains(fake_song)) if (!music_list.contains(fake_song))
{ {
// Loop through our music list // Loop through our music list
for (const QString &song : qAsConst(music_list)) for (const QString &song : std::as_const(music_list))
{ {
// Pick first song that does not contain a file extension // Pick first song that does not contain a file extension
if (!song.contains('.')) if (!song.contains('.'))

View File

@ -361,7 +361,7 @@ void DemoServer::load_demo(QString filename)
out.setCodec("UTF-8"); out.setCodec("UTF-8");
#endif #endif
out << p_demo_data.dequeue(); out << p_demo_data.dequeue();
for (const QString &line : qAsConst(p_demo_data)) for (const QString &line : std::as_const(p_demo_data))
{ {
out << "\n" << line; out << "\n" << line;
} }

View File

@ -110,7 +110,7 @@ void Courtroom::set_emote_page()
ui_emote_left->hide(); ui_emote_left->hide();
ui_emote_right->hide(); ui_emote_right->hide();
for (AOEmoteButton *i_button : qAsConst(ui_emote_list)) for (AOEmoteButton *i_button : std::as_const(ui_emote_list))
{ {
i_button->hide(); i_button->hide();
} }

View File

@ -305,7 +305,7 @@ void Courtroom::set_evidence_page()
ui_evidence_left->hide(); ui_evidence_left->hide();
ui_evidence_right->hide(); ui_evidence_right->hide();
for (AOEvidenceButton *i_button : qAsConst(ui_evidence_list)) for (AOEvidenceButton *i_button : std::as_const(ui_evidence_list))
{ {
i_button->hide(); i_button->hide();
} }
@ -481,7 +481,7 @@ void Courtroom::on_evidence_clicked(int p_id)
} }
ui_evidence_name->setText(local_evidence_list.at(f_real_id).name); ui_evidence_name->setText(local_evidence_list.at(f_real_id).name);
for (AOEvidenceButton *i_button : qAsConst(ui_evidence_list)) for (AOEvidenceButton *i_button : std::as_const(ui_evidence_list))
{ {
i_button->setSelected(false); i_button->setSelected(false);
} }
@ -508,7 +508,7 @@ void Courtroom::on_evidence_double_clicked(int p_id)
} }
} }
for (AOEvidenceButton *i_button : qAsConst(ui_evidence_list)) for (AOEvidenceButton *i_button : std::as_const(ui_evidence_list))
{ {
i_button->setSelected(false); i_button->setSelected(false);
} }

View File

@ -466,7 +466,7 @@ void Lobby::list_servers()
ui_serverlist_search->setText(""); ui_serverlist_search->setText("");
int i = 0; int i = 0;
for (const ServerInfo &i_server : qAsConst(ao_app->get_server_list())) for (const ServerInfo &i_server : std::as_const(ao_app->get_server_list()))
{ {
QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_serverlist_tree); QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_serverlist_tree);
treeItem->setData(0, Qt::DisplayRole, i); treeItem->setData(0, Qt::DisplayRole, i);

View File

@ -660,7 +660,7 @@ QVector<ServerInfo> Options::favorites()
auto grouplist = favorite.childGroups(); auto grouplist = favorite.childGroups();
{ // remove all negative and non-numbers { // remove all negative and non-numbers
auto filtered_grouplist = grouplist; auto filtered_grouplist = grouplist;
for (const QString &group : qAsConst(grouplist)) for (const QString &group : std::as_const(grouplist))
{ {
bool ok = false; bool ok = false;
const int l_num = group.toInt(&ok); const int l_num = group.toInt(&ok);
@ -674,7 +674,7 @@ QVector<ServerInfo> Options::favorites()
grouplist = std::move(filtered_grouplist); grouplist = std::move(filtered_grouplist);
} }
for (const QString &group : qAsConst(grouplist)) for (const QString &group : std::as_const(grouplist))
{ {
ServerInfo f_server; ServerInfo f_server;
favorite.beginGroup(group); favorite.beginGroup(group);
@ -763,7 +763,7 @@ QString Options::getUIAsset(QString f_asset_name)
l_paths.prepend(":/base/themes/" + theme() + "/" + subTheme() + "/" + f_asset_name); l_paths.prepend(":/base/themes/" + theme() + "/" + subTheme() + "/" + f_asset_name);
} }
for (const QString &l_path : qAsConst(l_paths)) for (const QString &l_path : std::as_const(l_paths))
{ {
if (QFile::exists(l_path)) if (QFile::exists(l_path))
{ {

View File

@ -811,7 +811,7 @@ QStringList AOApplication::get_effects(QString p_char)
std::sort(l_group_list.begin(), l_group_list.end(), [](const QString &lhs, const QString &rhs) { return lhs.toInt() < rhs.toInt(); }); std::sort(l_group_list.begin(), l_group_list.end(), [](const QString &lhs, const QString &rhs) { return lhs.toInt() < rhs.toInt(); });
for (const QString &i_group : qAsConst(l_group_list)) for (const QString &i_group : std::as_const(l_group_list))
{ {
const QString l_key = i_group + "/name"; const QString l_key = i_group + "/name";
if (!l_effects_ini.contains(l_key)) if (!l_effects_ini.contains(l_key))

View File

@ -194,7 +194,7 @@ void AOOptionsDialog::updateValues()
l_sorting.setNumericMode(true); l_sorting.setNumericMode(true);
std::sort(l_themes.begin(), l_themes.end(), l_sorting); std::sort(l_themes.begin(), l_themes.end(), l_sorting);
for (const QString &l_theme : qAsConst(l_themes)) for (const QString &l_theme : std::as_const(l_themes))
{ {
if (!themes.contains(l_theme)) if (!themes.contains(l_theme))
{ {
@ -205,7 +205,7 @@ void AOOptionsDialog::updateValues()
} }
QStringList l_subthemes = QDir(ao_app->get_real_path(ao_app->get_theme_path(""))).entryList(QDir::Dirs | QDir::NoDotAndDotDot); QStringList l_subthemes = QDir(ao_app->get_real_path(ao_app->get_theme_path(""))).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (const QString &l_subtheme : qAsConst(l_subthemes)) for (const QString &l_subtheme : std::as_const(l_subthemes))
{ {
if (l_subtheme.toLower() != "server" && l_subtheme.toLower() != "default" && l_subtheme.toLower() != "effects" && l_subtheme.toLower() != "misc") if (l_subtheme.toLower() != "server" && l_subtheme.toLower() != "default" && l_subtheme.toLower() != "effects" && l_subtheme.toLower() != "misc")
{ {
@ -221,7 +221,7 @@ void AOOptionsDialog::updateValues()
ui_privacy_policy->setHtml(document); ui_privacy_policy->setHtml(document);
}); });
for (const OptionEntry &entry : qAsConst(optionEntries)) for (const OptionEntry &entry : std::as_const(optionEntries))
{ {
entry.load(); entry.load();
} }
@ -230,7 +230,7 @@ void AOOptionsDialog::updateValues()
void AOOptionsDialog::savePressed() void AOOptionsDialog::savePressed()
{ {
bool l_reload_theme_required = (ui_theme_combobox->currentText() != Options::getInstance().theme()) || (ui_theme_scaling_factor_sb->value() != Options::getInstance().themeScalingFactor()); bool l_reload_theme_required = (ui_theme_combobox->currentText() != Options::getInstance().theme()) || (ui_theme_scaling_factor_sb->value() != Options::getInstance().themeScalingFactor());
for (const OptionEntry &entry : qAsConst(optionEntries)) for (const OptionEntry &entry : std::as_const(optionEntries))
{ {
entry.save(); entry.save();
} }
@ -281,7 +281,7 @@ void AOOptionsDialog::themeChanged(int i)
QStringList l_subthemes = QDir(ao_app->get_real_path(ao_app->get_theme_path("", ui_theme_combobox->itemText(i)))).entryList(QDir::Dirs | QDir::NoDotAndDotDot); QStringList l_subthemes = QDir(ao_app->get_real_path(ao_app->get_theme_path("", ui_theme_combobox->itemText(i)))).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (const QString &l_subthemes : qAsConst(l_subthemes)) for (const QString &l_subthemes : std::as_const(l_subthemes))
{ {
if (l_subthemes.toLower() != "server" && l_subthemes.toLower() != "default" && l_subthemes.toLower() != "effects" && l_subthemes.toLower() != "misc") if (l_subthemes.toLower() != "server" && l_subthemes.toLower() != "default" && l_subthemes.toLower() != "effects" && l_subthemes.toLower() != "misc")
{ {

View File

@ -72,7 +72,7 @@ void PlayerListWidget::updatePlayer(const PlayerUpdate &update)
void PlayerListWidget::reloadPlayers() void PlayerListWidget::reloadPlayers()
{ {
for (const PlayerData &player : qAsConst(m_player_map)) for (const PlayerData &player : std::as_const(m_player_map))
{ {
updatePlayer(player.id, false); updatePlayer(player.id, false);
} }
@ -81,7 +81,7 @@ void PlayerListWidget::reloadPlayers()
void PlayerListWidget::setAuthenticated(bool f_state) void PlayerListWidget::setAuthenticated(bool f_state)
{ {
m_is_authenticated = f_state; m_is_authenticated = f_state;
for (const PlayerData &data : qAsConst(m_player_map)) for (const PlayerData &data : std::as_const(m_player_map))
{ {
updatePlayer(data.id, false); updatePlayer(data.id, false);
filterPlayerList(); filterPlayerList();
@ -150,7 +150,7 @@ void PlayerListWidget::removePlayer(int playerId)
void PlayerListWidget::filterPlayerList() void PlayerListWidget::filterPlayerList()
{ {
int area_id = m_player_map.value(ao_app->client_id).area_id; int area_id = m_player_map.value(ao_app->client_id).area_id;
for (QListWidgetItem *item : qAsConst(m_item_map)) for (QListWidgetItem *item : std::as_const(m_item_map))
{ {
if (!item) if (!item)
{ {