Merge pull request #1067 from AttorneyOnline/cleanup

Very cool and professional cleanup of clazy warnings
This commit is contained in:
in1tiate 2025-01-14 02:31:36 -06:00 committed by GitHub
commit 764b2f8944
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 73 additions and 62 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

@ -43,7 +43,7 @@ public:
inline VPath operator+(const VPath &str) const { return VPath(this->toQString() + str.toQString()); } inline VPath operator+(const VPath &str) const { return VPath(this->toQString() + str.toQString()); }
}; };
inline size_t qHash(const VPath &key, uint seed = qGlobalQHashSeed()) inline size_t qHash(const VPath &key, uint seed = QHashSeed::globalSeed())
{ {
return qHash(key.toQString(), seed); return qHash(key.toQString(), seed);
} }

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

@ -90,7 +90,7 @@ void AOChatboxLabel::paintEvent(QPaintEvent *event)
if (alignment() & Qt::AlignLeft) if (alignment() & Qt::AlignLeft)
{ {
x = rect.left() + l_indent - std::min(metrics.leftBearing(text()[0]), 0); x = rect.left() + l_indent - std::min(metrics.leftBearing(text().at(0)), 0);
} }
else if (alignment() & Qt::AlignRight) else if (alignment() & Qt::AlignRight)
{ {

View File

@ -46,7 +46,7 @@ void AOUtils::migrateEffects(QSettings &p_effects_ini)
// realization_scaling - This would not be appended to the key_list as it matches scaling property. // realization_scaling - This would not be appended to the key_list as it matches scaling property.
// realization_alt - This would be appened as it contains an underscore, but not a property. // realization_alt - This would be appened as it contains an underscore, but not a property.
// hearts - This would be appended as it does not contain a property // hearts - This would be appended as it does not contain a property
const QRegularExpression l_regex(QStringLiteral("(\\w+)_(%1)$").arg(l_property_list.join("|"))); static QRegularExpression l_regex(QStringLiteral("(\\w+)_(%1)$").arg(l_property_list.join("|")));
for (auto i = l_effect_map.begin(); i != l_effect_map.end(); i++) for (auto i = l_effect_map.begin(); i != l_effect_map.end(); i++)
{ {
if (l_regex.match(i.key()).hasMatch()) if (l_regex.match(i.key()).hasMatch())
@ -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);
@ -352,7 +352,7 @@ void Courtroom::filter_character_list()
for (int i = 0; i < char_list.size(); i++) for (int i = 0; i < char_list.size(); i++)
{ {
AOCharButton *current_char = ui_char_button_list.at(i); AOCharButton *current_char = ui_char_button_list.at(i);
QTreeWidgetItem *current_char_list_item = ui_char_list->findItems(QString::number(i), Qt::MatchExactly | Qt::MatchRecursive, 1)[0]; QTreeWidgetItem *current_char_list_item = ui_char_list->findItems(QString::number(i), Qt::MatchExactly | Qt::MatchRecursive, 1).at(0);
// It seems passwording characters is unimplemented yet? // It seems passwording characters is unimplemented yet?
// Until then, this will stay here, I suppose. // Until then, this will stay here, I suppose.

View File

@ -705,7 +705,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);
} }
@ -723,7 +723,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);
} }
@ -1408,7 +1408,7 @@ void Courtroom::set_background(QString p_background, bool display)
// Populate the dropdown list with all pos that exist on this bg // Populate the dropdown list with all pos that exist on this bg
QStringList pos_list = {}; QStringList pos_list = {};
for (const QString &key : default_pos.keys()) for (const QString &key : std::as_const(default_pos))
{ {
if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path(default_pos[key]))) || // if we have 2.8-style positions, e.g. def.png, wit.webp, hld.apng if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path(default_pos[key]))) || // if we have 2.8-style positions, e.g. def.png, wit.webp, hld.apng
file_exists(ao_app->get_image_suffix(ao_app->get_background_path(key)))) file_exists(ao_app->get_image_suffix(ao_app->get_background_path(key))))
@ -3120,7 +3120,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();
@ -3404,7 +3404,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))
@ -3765,7 +3765,8 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, int
// white-space: pre; stylesheet tag, but for whataver reason it doesn't work // white-space: pre; stylesheet tag, but for whataver reason it doesn't work
// no matter where I try it. If somoene else can get that piece of HTML // no matter where I try it. If somoene else can get that piece of HTML
// memery to work, please do. // memery to work, please do.
p_text_escaped.replace(QRegularExpression("^\\s|(?<=\\s)\\s"), "&nbsp;"); static QRegularExpression whitespace("^\\s|(?<=\\s)\\s");
p_text_escaped.replace(whitespace, "&nbsp;");
if (!align.isEmpty()) if (!align.isEmpty())
{ {
p_text_escaped.append("</div>"); p_text_escaped.append("</div>");
@ -5115,9 +5116,10 @@ void Courtroom::on_ooc_return_pressed()
casefile.setValue("doc", ""); casefile.setValue("doc", "");
casefile.setValue("status", command[2]); casefile.setValue("status", command[2]);
casefile.sync(); casefile.sync();
static QRegularExpression owner_regexp("<owner = ...>...");
for (int i = 0; i < local_evidence_list.size(); i++) for (int i = 0; i < local_evidence_list.size(); i++)
{ {
QString clean_evidence_dsc = local_evidence_list[i].description.replace(QRegularExpression("<owner = ...>..."), ""); QString clean_evidence_dsc = local_evidence_list[i].description.replace(owner_regexp, "");
clean_evidence_dsc = clean_evidence_dsc.replace(clean_evidence_dsc.lastIndexOf(">"), 1, ""); clean_evidence_dsc = clean_evidence_dsc.replace(clean_evidence_dsc.lastIndexOf(">"), 1, "");
casefile.beginGroup(QString::number(i)); casefile.beginGroup(QString::number(i));
casefile.sync(); casefile.sync();
@ -5428,7 +5430,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();
@ -5730,7 +5732,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);
} }
@ -5798,19 +5800,19 @@ void Courtroom::on_music_list_context_menu_requested(const QPoint &pos)
} }
menu->addAction(new QAction(tr("Fade Out Previous"), this)); menu->addAction(new QAction(tr("Fade Out Previous"), this));
menu->actions().back()->setCheckable(true); menu->actions().constLast()->setCheckable(true);
menu->actions().back()->setChecked(music_flags & FADE_OUT); menu->actions().constLast()->setChecked(music_flags & FADE_OUT);
connect(menu->actions().back(), &QAction::toggled, this, &Courtroom::music_fade_out); connect(menu->actions().constLast(), &QAction::toggled, this, &Courtroom::music_fade_out);
menu->addAction(new QAction(tr("Fade In"), this)); menu->addAction(new QAction(tr("Fade In"), this));
menu->actions().back()->setCheckable(true); menu->actions().constLast()->setCheckable(true);
menu->actions().back()->setChecked(music_flags & FADE_IN); menu->actions().constLast()->setChecked(music_flags & FADE_IN);
connect(menu->actions().back(), &QAction::toggled, this, &Courtroom::music_fade_in); connect(menu->actions().constLast(), &QAction::toggled, this, &Courtroom::music_fade_in);
menu->addAction(new QAction(tr("Synchronize"), this)); menu->addAction(new QAction(tr("Synchronize"), this));
menu->actions().back()->setCheckable(true); menu->actions().constLast()->setCheckable(true);
menu->actions().back()->setChecked(music_flags & SYNC_POS); menu->actions().constLast()->setChecked(music_flags & SYNC_POS);
connect(menu->actions().back(), &QAction::toggled, this, &Courtroom::music_synchronize); connect(menu->actions().constLast(), &QAction::toggled, this, &Courtroom::music_synchronize);
menu->addSeparator(); menu->addSeparator();
menu->addAction(QString("Open base music folder"), this, [=] { menu->addAction(QString("Open base music folder"), this, [=] {
@ -5930,7 +5932,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;
} }
@ -442,6 +442,7 @@ void DemoServer::playback()
} }
// Take the first arg as the command // Take the first arg as the command
QString command = f_contents.takeFirst(); QString command = f_contents.takeFirst();
Q_UNUSED(command); // this seems load-bearing. TODO: this should not be load-bearing
int duration = 0; int duration = 0;
if (!f_contents.isEmpty()) if (!f_contents.isEmpty())
{ {

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();
} }
@ -265,7 +265,6 @@ void Courtroom::show_emote_menu(const QPoint &pos)
emote_preview->updateViewportGeometry(); emote_preview->updateViewportGeometry();
update_emote_preview(); update_emote_preview();
})); }));
QString prefix;
QString f_pre = ao_app->get_pre_emote(current_char, emote_num); QString f_pre = ao_app->get_pre_emote(current_char, emote_num);
if (!f_pre.isEmpty() && f_pre != "-") if (!f_pre.isEmpty() && f_pre != "-")
{ {

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);
@ -563,11 +563,13 @@ void Lobby::check_for_updates()
QVersionNumber current_version = QVersionNumber::fromString(ao_app->get_version_string()); QVersionNumber current_version = QVersionNumber::fromString(ao_app->get_version_string());
QVersionNumber master_version = QVersionNumber::fromString(version); QVersionNumber master_version = QVersionNumber::fromString(version);
static QRegularExpression regexp_links("\\b(https?://\\S+\\.\\S+)\\b");
if (current_version < master_version) if (current_version < master_version)
{ {
ui_game_version_lbl->setText(tr("Version: %1 [OUTDATED]").arg(current_version.toString())); ui_game_version_lbl->setText(tr("Version: %1 [OUTDATED]").arg(current_version.toString()));
setWindowTitle(tr("[Your client is outdated]")); setWindowTitle(tr("[Your client is outdated]"));
const QString download_url = QString("https://github.com/AttorneyOnline/AO2-Client/releases/latest").replace(QRegularExpression("\\b(https?://\\S+\\.\\S+)\\b"), "<a href='\\1'>\\1</a>"); const QString download_url = QString("https://github.com/AttorneyOnline/AO2-Client/releases/latest").replace(regexp_links, "<a href='\\1'>\\1</a>");
const QString message = QString("Your client is outdated!<br>Your Version: %1<br>Current Version: %2<br>Download the latest version at<br>%3").arg(current_version.toString(), master_version.toString(), download_url); const QString message = QString("Your client is outdated!<br>Your Version: %1<br>Current Version: %2<br>Download the latest version at<br>%3").arg(current_version.toString(), master_version.toString(), download_url);
QMessageBox::warning(this, "Your client is outdated!", message); QMessageBox::warning(this, "Your client is outdated!", message);
} }
@ -583,7 +585,8 @@ void Lobby::set_player_count(int players_online, int max_players)
void Lobby::set_server_description(const QString &server_description) void Lobby::set_server_description(const QString &server_description)
{ {
ui_server_description_text->clear(); ui_server_description_text->clear();
QString result = server_description.toHtmlEscaped().replace("\n", "<br>").replace(QRegularExpression("\\b(https?://\\S+\\.\\S+)\\b"), "<a href='\\1'>\\1</a>"); static QRegularExpression regexp_links("\\b(https?://\\S+\\.\\S+)\\b");
QString result = server_description.toHtmlEscaped().replace("\n", "<br>").replace(regexp_links, "<a href='\\1'>\\1</a>");
ui_server_description_text->insertHtml(result); ui_server_description_text->insertHtml(result);
} }

View File

@ -2,5 +2,5 @@
QString ServerInfo::toString() const QString ServerInfo::toString() const
{ {
return QString("%1 (%2:%3)").arg(name.isEmpty() ? QStringLiteral("Unnamed Server") : name).arg(address).arg(port); return QString("%1 (%2:%3)").arg((name.isEmpty() ? QStringLiteral("Unnamed Server") : name), address, QString::number(port));
} }

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

@ -66,7 +66,7 @@ void AOApplication::server_packet_received(AOPacket packet)
client_id = content.at(0).toInt(); client_id = content.at(0).toInt();
m_serverdata.set_server_software(content.at(1)); m_serverdata.set_server_software(content.at(1));
net_manager->server_connected(true); emit net_manager->server_connected(true);
QStringList f_contents = {"AO2", get_version_string()}; QStringList f_contents = {"AO2", get_version_string()};
send_server_packet(AOPacket("ID", f_contents)); send_server_packet(AOPacket("ID", f_contents));
@ -160,10 +160,12 @@ void AOApplication::server_packet_received(AOPacket packet)
// Remove any characters not accepted in folder names for the server_name // Remove any characters not accepted in folder names for the server_name
// here // here
QString server_name_stripped = server_name; QString server_name_stripped = server_name;
static QRegularExpression illegal_filename_chars("[\\\\/:*?\"<>|\']");
if (Options::getInstance().logToDemoFileEnabled() && server_name != "Demo playback") if (Options::getInstance().logToDemoFileEnabled() && server_name != "Demo playback")
{ {
this->log_filename = QDateTime::currentDateTime().toUTC().toString("'logs/" + server_name_stripped.remove(QRegularExpression("[\\\\/:*?\"<>|\']")) + "/'yyyy-MM-dd hh-mm-ss t'.log'"); this->log_filename = QDateTime::currentDateTime().toUTC().toString("'logs/" + server_name_stripped.remove(illegal_filename_chars) + "/'yyyy-MM-dd hh-mm-ss t'.log'");
this->write_to_file("Joined server " + server_name_stripped + " hosted on address " + server_address + " on " + QDateTime::currentDateTime().toUTC().toString(), log_filename, true); this->write_to_file("Joined server " + server_name_stripped + " hosted on address " + server_address + " on " + QDateTime::currentDateTime().toUTC().toString(), log_filename, true);
} }
else else
@ -426,7 +428,7 @@ void AOApplication::server_packet_received(AOPacket packet)
{ {
QVector<EvidenceItem> f_evi_list; QVector<EvidenceItem> f_evi_list;
for (QString f_string : packet.content()) for (const QString &f_string : packet.content())
{ {
QStringList sub_contents = f_string.split("&"); QStringList sub_contents = f_string.split("&");
if (sub_contents.size() < 3) if (sub_contents.size() < 3)
@ -714,7 +716,6 @@ void AOApplication::server_packet_received(AOPacket packet)
void AOApplication::send_server_packet(AOPacket p_packet) void AOApplication::send_server_packet(AOPacket p_packet)
{ {
QString f_packet = p_packet.toString();
#ifdef DEBUG_NETWORK #ifdef DEBUG_NETWORK
qDebug() << "S:" << p_packet.to_string(); qDebug() << "S:" << p_packet.to_string();
#endif #endif

View File

@ -10,17 +10,22 @@ class ScrollText : public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText) Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QString separator READ separator WRITE setSeparator) Q_PROPERTY(QString separator READ separator WRITE setSeparator NOTIFY separatorChanged)
public: public:
explicit ScrollText(QWidget *parent = nullptr); explicit ScrollText(QWidget *parent = nullptr);
public Q_SLOTS:
QString text() const; QString text() const;
QString separator() const;
signals:
void textChanged(QString newText);
void separatorChanged(QString newSeparator);
public Q_SLOTS:
void setText(QString text); void setText(QString text);
QString separator() const;
void setSeparator(QString separator); void setSeparator(QString separator);
protected: protected:

View File

@ -144,7 +144,7 @@ QMultiMap<QString, QString> AOApplication::load_demo_logs_list() const
l_demo_folder.setFilter(QDir::Files); l_demo_folder.setFilter(QDir::Files);
l_demo_folder.setNameFilters(QStringList() << "*.demo"); l_demo_folder.setNameFilters(QStringList() << "*.demo");
for (QString l_demo_name : l_demo_folder.entryList()) for (const QString &l_demo_name : l_demo_folder.entryList())
{ {
l_demo_logs.insert(l_demo_folder_name, l_demo_name); l_demo_logs.insert(l_demo_folder_name, l_demo_name);
} }
@ -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)
{ {