From 661e7f1b24ad19ff8d838252ad203916a778bde0 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 11 Mar 2023 04:01:36 +0200 Subject: [PATCH 24/24] Qt: Avoid deprecated zero parameter QString:count() See osdn #47547 Signed-off-by: Marko Lindqvist --- client/gui-qt/chatline.cpp | 12 +++++++----- client/gui-qt/citydlg.cpp | 2 +- client/gui-qt/hudwidget.cpp | 13 ++++++++----- client/gui-qt/optiondlg.cpp | 11 ++++++----- client/gui-qt/themes.cpp | 4 ++-- 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/client/gui-qt/chatline.cpp b/client/gui-qt/chatline.cpp index 7de086f5ba..7dbdb0535f 100644 --- a/client/gui-qt/chatline.cpp +++ b/client/gui-qt/chatline.cpp @@ -572,7 +572,7 @@ QString apply_tags(QString str, const struct text_tag_list *tags, text_tag_list_iterate(tags, ptag) { if ((text_tag_stop_offset(ptag) == FT_OFFSET_UNSET)) { - stop = qba.count(); + stop = qba.length(); } else { stop = text_tag_stop_offset(ptag); } @@ -652,12 +652,13 @@ QString apply_tags(QString str, const struct text_tag_list *tags, } } text_tag_list_iterate_end; - /* insert html starting from last items */ - last_i = str.count(); + // Insert html starting from last items + last_i = str.length(); QMultiMap::const_iterator i = mm.constEnd(); QMultiMap::const_iterator j = mm.constEnd(); + while (i != mm.constBegin()) { - --i; + i--; if (i.key() < last_i) { final_string = final_string.prepend(QString(qba.mid(i.key(), last_i - i.key())) @@ -676,7 +677,8 @@ QString apply_tags(QString str, const struct text_tag_list *tags, final_string = final_string.prepend(i.value()); } } - if (last_i == str.count()) { + + if (last_i == str.length()) { return str; } diff --git a/client/gui-qt/citydlg.cpp b/client/gui-qt/citydlg.cpp index 21ec20fb79..0e26c54c97 100644 --- a/client/gui-qt/citydlg.cpp +++ b/client/gui-qt/citydlg.cpp @@ -268,7 +268,7 @@ void progress_bar::paintEvent(QPaintEvent *event) i = text().indexOf('\n'); s1 = text().left(i); - s2 = text().right(text().count() - i); + s2 = text().right(text().length() - i); if (2 * f_pixel_size >= 3 * pbh / 2) { tmp_font.setPixelSize(pbh / 3); diff --git a/client/gui-qt/hudwidget.cpp b/client/gui-qt/hudwidget.cpp index 9eb29f632e..14eddaf7cb 100644 --- a/client/gui-qt/hudwidget.cpp +++ b/client/gui-qt/hudwidget.cpp @@ -132,9 +132,10 @@ int hud_message_box::set_text_title(QString s1, QString s2, bool return_exec) if (s1.contains('\n')) { int i; + i = s1.indexOf('\n'); cs1 = s1.left(i); - cs2 = s1.right(s1.count() - i); + cs2 = s1.right(s1.length() - i); mult = 2; w2 = qMax(fm_text->horizontalAdvance(cs1), fm_text->horizontalAdvance(cs2)); @@ -406,9 +407,10 @@ void hud_input_box::set_text_title_definput(QString s1, QString s2, layout = new QVBoxLayout; if (s1.contains('\n')) { int i; + i = s1.indexOf('\n'); cs1 = s1.left(i); - cs2 = s1.right(s1.count() - i); + cs2 = s1.right(s1.length() - i); mult = 2; w2 = qMax(fm_text->horizontalAdvance(cs1), fm_text->horizontalAdvance(cs2)); @@ -688,13 +690,14 @@ void hud_units::update_actions(unit_list *punits) p.end(); pix = pix2; } - /* Draw movement points */ + + // Draw movement points move_pt_text = move_points_text(punit->moves_left, false); if (move_pt_text.contains('/')) { fraction2 = move_pt_text.right(1); - move_pt_text.remove(move_pt_text.count() - 2, 2); + move_pt_text.remove(move_pt_text.length() - 2, 2); fraction1 = move_pt_text.right(1); - move_pt_text.remove(move_pt_text.count() - 1, 1); + move_pt_text.remove(move_pt_text.length() - 1, 1); } crop = QRect(5, 5, pix.width() - 5, pix.height() - 5); font.setCapitalization(QFont::Capitalize); diff --git a/client/gui-qt/optiondlg.cpp b/client/gui-qt/optiondlg.cpp index 5cb18c4153..cbe6bb0916 100644 --- a/client/gui-qt/optiondlg.cpp +++ b/client/gui-qt/optiondlg.cpp @@ -69,7 +69,7 @@ QString split_text(QString text, bool cut) sl = text.split("\n"); foreach (const QString &s, sl) { st = s; - while (st.count() >= 80) { + while (st.length() >= 80) { str = st.left(80); i = str.lastIndexOf(' '); if (i == -1) { @@ -85,8 +85,8 @@ QString split_text(QString text, bool cut) } } str = st; - if (str.left(str.count()) != "") { - result = result + str.left(str.count()) + '\n'; + if (str.left(str.length()) != "") { + result = result + str.left(str.length()) + '\n'; } j++; if (j >= 12 && cut) { @@ -95,6 +95,7 @@ QString split_text(QString text, bool cut) } } result.remove(result.lastIndexOf('\n'), 1); + return result; } @@ -108,8 +109,8 @@ QString cut_helptext(QString text) /* Remove all lines from help which has '*' in first 3 chars */ sl = text.split('\n'); - foreach (const QString & s, sl) { - if (s.count() > 2) { + foreach (const QString &s, sl) { + if (s.length() > 2) { if (s.at(0) != '*' && s.at(1) != '*' && s.at(2) != '*') { ret_str = ret_str + s + '\n'; } diff --git a/client/gui-qt/themes.cpp b/client/gui-qt/themes.cpp index 5ad4b6f8bd..9d339a90c4 100644 --- a/client/gui-qt/themes.cpp +++ b/client/gui-qt/themes.cpp @@ -139,7 +139,7 @@ char **qtg_get_gui_specific_themes_directories(int *count) /*************************************************************************//** Return an array of names of usable themes in the given directory. Array size is stored in count. - The caller is responsible for freeing the array and the names + The caller is responsible for freeing the array and the names. *****************************************************************************/ char **qtg_get_useable_themes_in_directory(const char *directory, int *count) { @@ -179,7 +179,7 @@ char **qtg_get_useable_themes_in_directory(const char *directory, int *count) QByteArray tn_bytes; qba = theme_list[i].toLocal8Bit(); - data = new char[theme_list[i].toLocal8Bit().count() + 1]; + data = new char[theme_list[i].toLocal8Bit().length() + 1]; tn_bytes = theme_list[i].toLocal8Bit(); strcpy(data, tn_bytes.data()); array[i] = data; -- 2.39.2