From c3729d06d0545116fa468820074fab38ac8fe39b Mon Sep 17 00:00:00 2001 From: Megamouse Date: Tue, 12 Nov 2024 20:21:44 +0100 Subject: [PATCH] Qt: Replace some instances of QMap, QPair and QList --- rpcs3/Emu/Memory/vm.cpp | 4 +- rpcs3/Input/ds4_pad_handler.cpp | 2 +- rpcs3/Input/dualsense_pad_handler.cpp | 2 +- rpcs3/rpcs3qt/flow_layout.cpp | 52 ++++++++++++------------- rpcs3/rpcs3qt/flow_layout.h | 12 +++--- rpcs3/rpcs3qt/flow_widget.cpp | 34 ++++++---------- rpcs3/rpcs3qt/flow_widget.h | 11 +++--- rpcs3/rpcs3qt/game_list_base.cpp | 2 +- rpcs3/rpcs3qt/game_list_base.h | 2 +- rpcs3/rpcs3qt/game_list_frame.cpp | 16 ++++---- rpcs3/rpcs3qt/game_list_frame.h | 6 +-- rpcs3/rpcs3qt/game_list_grid.cpp | 6 +-- rpcs3/rpcs3qt/game_list_grid.h | 2 +- rpcs3/rpcs3qt/game_list_table.cpp | 6 +-- rpcs3/rpcs3qt/game_list_table.h | 4 +- rpcs3/rpcs3qt/gui_application.cpp | 14 +++---- rpcs3/rpcs3qt/log_frame.cpp | 18 ++++----- rpcs3/rpcs3qt/log_frame.h | 2 +- rpcs3/rpcs3qt/main_window.cpp | 4 +- rpcs3/rpcs3qt/patch_manager_dialog.cpp | 33 +++++++++------- rpcs3/rpcs3qt/patch_manager_dialog.h | 2 +- rpcs3/rpcs3qt/qt_utils.cpp | 12 ++---- rpcs3/rpcs3qt/qt_utils.h | 4 +- rpcs3/rpcs3qt/settings_dialog.cpp | 11 ++---- rpcs3/rpcs3qt/settings_dialog.h | 2 +- rpcs3/rpcs3qt/trophy_manager_dialog.cpp | 3 -- 26 files changed, 126 insertions(+), 140 deletions(-) diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index cff8ce466d..30fba645dc 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -1491,7 +1491,7 @@ namespace vm { if (auto rsxthr = g_fxo->try_get()) { - for (const auto [event_data1, event_data2] : event_data) + for (const auto& [event_data1, event_data2] : event_data) { rsxthr->on_notify_post_memory_unmapped(event_data1, event_data2); } @@ -1991,7 +1991,7 @@ namespace vm { if (auto rsxthr = g_fxo->try_get()) { - for (const auto [event_data1, event_data2] : unmap_data) + for (const auto& [event_data1, event_data2] : unmap_data) { rsxthr->on_notify_post_memory_unmapped(event_data1, event_data2); } diff --git a/rpcs3/Input/ds4_pad_handler.cpp b/rpcs3/Input/ds4_pad_handler.cpp index a80b185f63..3cbd0fb61f 100644 --- a/rpcs3/Input/ds4_pad_handler.cpp +++ b/rpcs3/Input/ds4_pad_handler.cpp @@ -538,7 +538,7 @@ bool ds4_pad_handler::GetCalibrationData(DS4Device* ds4Dev) const // Make sure data 'looks' valid, dongle will report invalid calibration data with no controller connected - for (size_t i = 0; i < ds4Dev->calib_data.size(); i++) + for (usz i = 0; i < ds4Dev->calib_data.size(); i++) { CalibData& data = ds4Dev->calib_data[i]; diff --git a/rpcs3/Input/dualsense_pad_handler.cpp b/rpcs3/Input/dualsense_pad_handler.cpp index 0400e69d08..b9dbcd6d29 100644 --- a/rpcs3/Input/dualsense_pad_handler.cpp +++ b/rpcs3/Input/dualsense_pad_handler.cpp @@ -489,7 +489,7 @@ bool dualsense_pad_handler::get_calibration_data(DualSenseDevice* dev) const // Make sure data 'looks' valid, dongle will report invalid calibration data with no controller connected - for (size_t i = 0; i < dev->calib_data.size(); i++) + for (usz i = 0; i < dev->calib_data.size(); i++) { CalibData& data = dev->calib_data[i]; diff --git a/rpcs3/rpcs3qt/flow_layout.cpp b/rpcs3/rpcs3qt/flow_layout.cpp index 6bb58c6a75..579ae59404 100644 --- a/rpcs3/rpcs3qt/flow_layout.cpp +++ b/rpcs3/rpcs3qt/flow_layout.cpp @@ -54,20 +54,20 @@ flow_layout::flow_layout(QWidget* parent, int margin, bool dynamic_spacing, int hSpacing, int vSpacing) : QLayout(parent) , m_dynamic_spacing(dynamic_spacing) - , m_hSpaceInitial(hSpacing) - , m_vSpaceInitial(vSpacing) - , m_hSpace(hSpacing) - , m_vSpace(vSpacing) + , m_h_space_initial(hSpacing) + , m_v_space_initial(vSpacing) + , m_h_space(hSpacing) + , m_v_space(vSpacing) { setContentsMargins(margin, margin, margin, margin); } flow_layout::flow_layout(int margin, bool dynamic_spacing, int hSpacing, int vSpacing) : m_dynamic_spacing(dynamic_spacing) - , m_hSpaceInitial(hSpacing) - , m_vSpaceInitial(vSpacing) - , m_hSpace(hSpacing) - , m_vSpace(vSpacing) + , m_h_space_initial(hSpacing) + , m_v_space_initial(vSpacing) + , m_h_space(hSpacing) + , m_v_space(vSpacing) { setContentsMargins(margin, margin, margin, margin); } @@ -84,21 +84,21 @@ void flow_layout::clear() delete item->widget(); delete item; } - itemList.clear(); + m_item_list.clear(); m_positions.clear(); } void flow_layout::addItem(QLayoutItem* item) { m_positions.append(position{ .row = -1, .col = -1 }); - itemList.append(item); + m_item_list.append(item); } int flow_layout::horizontalSpacing() const { - if (m_hSpace >= 0) + if (m_h_space >= 0) { - return m_hSpace; + return m_h_space; } return smartSpacing(QStyle::PM_LayoutHorizontalSpacing); @@ -106,9 +106,9 @@ int flow_layout::horizontalSpacing() const int flow_layout::verticalSpacing() const { - if (m_vSpace >= 0) + if (m_v_space >= 0) { - return m_vSpace; + return m_v_space; } return smartSpacing(QStyle::PM_LayoutVerticalSpacing); @@ -116,20 +116,20 @@ int flow_layout::verticalSpacing() const int flow_layout::count() const { - return itemList.size(); + return m_item_list.size(); } QLayoutItem* flow_layout::itemAt(int index) const { - return itemList.value(index); + return m_item_list.value(index); } QLayoutItem* flow_layout::takeAt(int index) { - if (index >= 0 && index < itemList.size()) + if (index >= 0 && index < m_item_list.size()) { m_positions.takeAt(index); - return itemList.takeAt(index); + return m_item_list.takeAt(index); } return nullptr; @@ -164,7 +164,7 @@ QSize flow_layout::sizeHint() const QSize flow_layout::minimumSize() const { QSize size; - for (const QLayoutItem* item : itemList) + for (const QLayoutItem* item : m_item_list) { if (item) { @@ -196,9 +196,9 @@ int flow_layout::doLayout(const QRect& rect, bool testOnly) const int width = 0; int index = 0; - for (; index < itemList.size(); index++) + for (; index < m_item_list.size(); index++) { - if (QLayoutItem* item = itemList.at(index)) + if (QLayoutItem* item = m_item_list.at(index)) { const int new_width = width + item->sizeHint().width() + (width > 0 ? min_spacing : 0); @@ -213,22 +213,22 @@ int flow_layout::doLayout(const QRect& rect, bool testOnly) const } // Try to evenly distribute the items across the width - m_hSpace = (index == 0) ? -1 : ((available_width - width) / index); + m_h_space = (index == 0) ? -1 : ((available_width - width) / index); if (fits_into_width) { // Make sure there aren't huge gaps between the items - m_hSpace = smartSpacing(QStyle::PM_LayoutHorizontalSpacing); + m_h_space = smartSpacing(QStyle::PM_LayoutHorizontalSpacing); } } else { - m_hSpace = m_hSpaceInitial; + m_h_space = m_h_space_initial; } - for (int i = 0, row = 0, col = 0; i < itemList.size(); i++) + for (int i = 0, row = 0, col = 0; i < m_item_list.size(); i++) { - QLayoutItem* item = itemList.at(i); + QLayoutItem* item = m_item_list.at(i); if (!item) continue; diff --git a/rpcs3/rpcs3qt/flow_layout.h b/rpcs3/rpcs3qt/flow_layout.h index e8a4df65bd..c04fa8ab6d 100644 --- a/rpcs3/rpcs3qt/flow_layout.h +++ b/rpcs3/rpcs3qt/flow_layout.h @@ -68,7 +68,7 @@ public: ~flow_layout(); void clear(); - const QList& item_list() const { return itemList; } + const QList& item_list() const { return m_item_list; } const QList& positions() const { return m_positions; } int rows() const { return m_rows; } int cols() const { return m_cols; } @@ -90,12 +90,12 @@ private: int doLayout(const QRect& rect, bool testOnly) const; int smartSpacing(QStyle::PixelMetric pm) const; - QList itemList; + QList m_item_list; bool m_dynamic_spacing{}; - int m_hSpaceInitial{-1}; - int m_vSpaceInitial{-1}; - mutable int m_hSpace{-1}; - mutable int m_vSpace{-1}; + int m_h_space_initial{-1}; + int m_v_space_initial{-1}; + mutable int m_h_space{-1}; + mutable int m_v_space{-1}; mutable QList m_positions; mutable int m_rows{}; diff --git a/rpcs3/rpcs3qt/flow_widget.cpp b/rpcs3/rpcs3qt/flow_widget.cpp index 74e716ed40..13754f6c66 100644 --- a/rpcs3/rpcs3qt/flow_widget.cpp +++ b/rpcs3/rpcs3qt/flow_widget.cpp @@ -34,7 +34,7 @@ void flow_widget::add_widget(flow_widget_item* widget) { if (widget) { - m_widgets << widget; + m_widgets.push_back(widget); m_flow_layout->addWidget(widget); connect(widget, &flow_widget_item::navigate, this, &flow_widget::on_navigate); @@ -48,14 +48,9 @@ void flow_widget::clear() m_flow_layout->clear(); } -QList& flow_widget::items() -{ - return m_widgets; -} - flow_widget_item* flow_widget::selected_item() const { - if (m_selected_index >= 0 && m_selected_index < m_widgets.size()) + if (m_selected_index >= 0 && static_cast(m_selected_index) < m_widgets.size()) { return ::at32(m_widgets, m_selected_index); } @@ -63,11 +58,6 @@ flow_widget_item* flow_widget::selected_item() const return nullptr; } -QScrollArea* flow_widget::scroll_area() const -{ - return m_scroll_area; -} - void flow_widget::paintEvent(QPaintEvent* /*event*/) { // Needed for stylesheets to apply to QWidgets @@ -77,7 +67,7 @@ void flow_widget::paintEvent(QPaintEvent* /*event*/) style()->drawPrimitive(QStyle::PE_Widget, &option, &painter, this); } -int flow_widget::find_item(const flow_layout::position& pos) +s64 flow_widget::find_item(const flow_layout::position& pos) { if (pos.row < 0 || pos.col < 0) { @@ -86,7 +76,7 @@ int flow_widget::find_item(const flow_layout::position& pos) const auto& positions = m_flow_layout->positions(); - for (int i = 0; i < positions.size(); i++) + for (s64 i = 0; i < positions.size(); i++) { if (const auto& other = ::at32(positions, i); other.row == pos.row && other.col == pos.col) { @@ -97,7 +87,7 @@ int flow_widget::find_item(const flow_layout::position& pos) return -1; } - flow_layout::position flow_widget::find_item(flow_widget_item* item) +flow_layout::position flow_widget::find_item(flow_widget_item* item) { if (item) { @@ -105,7 +95,7 @@ int flow_widget::find_item(const flow_layout::position& pos) const auto& positions = m_flow_layout->positions(); ensure(item_list.size() == positions.size()); - for (int i = 0; i < item_list.size(); i++) + for (s64 i = 0; i < item_list.size(); i++) { if (const auto& layout_item = ::at32(item_list, i); layout_item && layout_item->widget() == item) { @@ -196,9 +186,9 @@ flow_layout::position flow_widget::find_next_item(flow_layout::position current_ void flow_widget::select_item(flow_widget_item* item) { const flow_layout::position selected_pos = find_item(item); - const int selected_index = find_item(selected_pos); + const s64 selected_index = find_item(selected_pos); - if (selected_index < 0 || selected_index >= items().size()) + if (selected_index < 0 || static_cast(selected_index) >= items().size()) { m_selected_index = -1; return; @@ -207,12 +197,12 @@ void flow_widget::select_item(flow_widget_item* item) m_selected_index = selected_index; Q_EMIT ItemSelectionChanged(m_selected_index); - for (int i = 0; i < items().size(); i++) + for (usz i = 0; i < items().size(); i++) { if (flow_widget_item* item = items().at(i)) { // We need to polish the widgets in order to re-apply any stylesheet changes for the selected property. - item->selected = i == m_selected_index; + item->selected = m_selected_index >= 0 && i == static_cast(m_selected_index); item->polish_style(); } } @@ -229,8 +219,8 @@ void flow_widget::on_item_focus() void flow_widget::on_navigate(flow_navigation value) { const flow_layout::position selected_pos = find_next_item(find_item(static_cast(QObject::sender())), value); - const int selected_index = find_item(selected_pos); - if (selected_index < 0 || selected_index >= items().size()) + const s64 selected_index = find_item(selected_pos); + if (selected_index < 0 || static_cast(selected_index) >= items().size()) { return; } diff --git a/rpcs3/rpcs3qt/flow_widget.h b/rpcs3/rpcs3qt/flow_widget.h index cd9ab5b95b..433d05ad0e 100644 --- a/rpcs3/rpcs3qt/flow_widget.h +++ b/rpcs3/rpcs3qt/flow_widget.h @@ -1,5 +1,6 @@ #pragma once +#include "util/types.hpp" #include "flow_widget_item.h" #include "flow_layout.h" @@ -18,9 +19,9 @@ public: void add_widget(flow_widget_item* widget); void clear(); - QList& items(); + std::vector& items() { return m_widgets; } flow_widget_item* selected_item() const; - QScrollArea* scroll_area() const; + QScrollArea* scroll_area() const { return m_scroll_area; } void paintEvent(QPaintEvent* event) override; @@ -36,12 +37,12 @@ protected: void mouseDoubleClickEvent(QMouseEvent* event) override; private: - int find_item(const flow_layout::position& pos); + s64 find_item(const flow_layout::position& pos); flow_layout::position find_item(flow_widget_item* item); flow_layout::position find_next_item(flow_layout::position current_pos, flow_navigation value); flow_layout* m_flow_layout{}; QScrollArea* m_scroll_area{}; - QList m_widgets{}; - int m_selected_index = -1; + std::vector m_widgets; + s64 m_selected_index = -1; }; diff --git a/rpcs3/rpcs3qt/game_list_base.cpp b/rpcs3/rpcs3qt/game_list_base.cpp index df6ce992fe..a8a0cd959f 100644 --- a/rpcs3/rpcs3qt/game_list_base.cpp +++ b/rpcs3/rpcs3qt/game_list_base.cpp @@ -14,7 +14,7 @@ game_list_base::game_list_base() { } -void game_list_base::repaint_icons(QList& game_data, const QColor& icon_color, const QSize& icon_size, qreal device_pixel_ratio) +void game_list_base::repaint_icons(std::vector& game_data, const QColor& icon_color, const QSize& icon_size, qreal device_pixel_ratio) { m_icon_size = icon_size; m_icon_color = icon_color; diff --git a/rpcs3/rpcs3qt/game_list_base.h b/rpcs3/rpcs3qt/game_list_base.h index 8e3bb1ab51..5e21097b05 100644 --- a/rpcs3/rpcs3qt/game_list_base.h +++ b/rpcs3/rpcs3qt/game_list_base.h @@ -43,7 +43,7 @@ public: void set_icon_color(QColor color) { m_icon_color = std::move(color); } void set_draw_compat_status_to_grid(bool enabled) { m_draw_compat_status_to_grid = enabled; } - virtual void repaint_icons(QList& game_data, const QColor& icon_color, const QSize& icon_size, qreal device_pixel_ratio); + virtual void repaint_icons(std::vector& game_data, const QColor& icon_color, const QSize& icon_size, qreal device_pixel_ratio); // Returns the visible version string in the game list static std::string GetGameVersion(const game_info& game); diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index 136cdccf0d..b569f4cec1 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -258,7 +258,7 @@ void game_list_frame::OnColClicked(int col) m_gui_settings->SetValue(gui::gl_sortAsc, m_col_sort_order == Qt::AscendingOrder, false); m_gui_settings->SetValue(gui::gl_sortCol, col, true); - m_game_list->sort(m_game_data.count(), m_sort_column, m_col_sort_order); + m_game_list->sort(m_game_data.size(), m_sort_column, m_col_sort_order); } // Get visibility of entries @@ -546,7 +546,7 @@ void game_list_frame::Refresh(const bool from_drive, const std::vectorclear_list(); const int scroll_position = m_game_list->verticalScrollBar()->value(); m_game_list->populate(matching_apps, m_notes, m_titles, selected_item, m_play_hover_movies); - m_game_list->sort(m_game_data.count(), m_sort_column, m_col_sort_order); + m_game_list->sort(m_game_data.size(), m_sort_column, m_col_sort_order); RepaintIcons(); if (scroll_after) @@ -2277,11 +2277,11 @@ void game_list_frame::RemoveHDD1Cache(const std::string& base_dir, const std::st game_list_log.fatal("Only %d/%d HDD1 cache directories could be removed in %s (%s)", dirs_removed, dirs_total, base_dir, title_id); } -void game_list_frame::BatchCreateCPUCaches(const QList& game_data) +void game_list_frame::BatchCreateCPUCaches(const std::vector& game_data) { const std::string vsh_path = g_cfg_vfs.get_dev_flash() + "vsh/module/"; - const bool vsh_exists = game_data.isEmpty() && fs::is_file(vsh_path + "vsh.self"); - const u32 total = !game_data.isEmpty() ? game_data.size() : (m_game_data.size() + (vsh_exists ? 1 : 0)); + const bool vsh_exists = game_data.empty() && fs::is_file(vsh_path + "vsh.self"); + const usz total = !game_data.empty() ? game_data.size() : (m_game_data.size() + (vsh_exists ? 1 : 0)); if (total == 0) { @@ -2296,7 +2296,7 @@ void game_list_frame::BatchCreateCPUCaches(const QList& game_data) const QString main_label = tr("Creating all LLVM caches"); - progress_dialog* pdlg = new progress_dialog(tr("LLVM Cache Batch Creation"), main_label, tr("Cancel"), 0, total, false, this); + progress_dialog* pdlg = new progress_dialog(tr("LLVM Cache Batch Creation"), main_label, tr("Cancel"), 0, ::narrow(total), false, this); pdlg->setWindowFlags(Qt::Window | Qt::WindowMinimizeButtonHint); pdlg->setAutoClose(false); pdlg->setAutoReset(false); @@ -2329,7 +2329,7 @@ void game_list_frame::BatchCreateCPUCaches(const QList& game_data) } } - for (const auto& game : (game_data.isEmpty() ? m_game_data : game_data)) + for (const auto& game : (game_data.empty() ? m_game_data : game_data)) { if (pdlg->wasCanceled() || g_system_progress_canceled) { @@ -2995,7 +2995,7 @@ void game_list_frame::SetPlayHoverGifs(bool play) } } -const QList& game_list_frame::GetGameInfo() const +const std::vector& game_list_frame::GetGameInfo() const { return m_game_data; } diff --git a/rpcs3/rpcs3qt/game_list_frame.h b/rpcs3/rpcs3qt/game_list_frame.h index 4fc5eb5bd4..ce6bc906c6 100644 --- a/rpcs3/rpcs3qt/game_list_frame.h +++ b/rpcs3/rpcs3qt/game_list_frame.h @@ -58,14 +58,14 @@ public: game_compatibility* GetGameCompatibility() const { return m_game_compat; } - const QList& GetGameInfo() const; + const std::vector& GetGameInfo() const; void CreateShortcuts(const game_info& gameinfo, const std::set& locations); bool IsEntryVisible(const game_info& game, bool search_fallback = false) const; public Q_SLOTS: - void BatchCreateCPUCaches(const QList& game_data = QList{}); + void BatchCreateCPUCaches(const std::vector& game_data = {}); void BatchRemovePPUCaches(); void BatchRemoveSPUCaches(); void BatchRemoveCustomConfigurations(); @@ -181,7 +181,7 @@ private: std::shared_ptr m_gui_settings; std::shared_ptr m_emu_settings; std::shared_ptr m_persistent_settings; - QList m_game_data; + std::vector m_game_data; struct path_entry { std::string path; diff --git a/rpcs3/rpcs3qt/game_list_grid.cpp b/rpcs3/rpcs3qt/game_list_grid.cpp index a7ef829db9..fd8301a297 100644 --- a/rpcs3/rpcs3qt/game_list_grid.cpp +++ b/rpcs3/rpcs3qt/game_list_grid.cpp @@ -137,7 +137,7 @@ void game_list_grid::populate( select_item(selected_item); } -void game_list_grid::repaint_icons(QList& game_data, const QColor& icon_color, const QSize& icon_size, qreal device_pixel_ratio) +void game_list_grid::repaint_icons(std::vector& game_data, const QColor& icon_color, const QSize& icon_size, qreal device_pixel_ratio) { m_icon_size = icon_size; m_icon_color = icon_color; @@ -178,9 +178,9 @@ void game_list_grid::repaint_icons(QList& game_data, const QColor& ic void game_list_grid::FocusAndSelectFirstEntryIfNoneIs() { - if (items().empty() == false) + if (!items().empty()) { - items().first()->setFocus(); + items().front()->setFocus(); } } diff --git a/rpcs3/rpcs3qt/game_list_grid.h b/rpcs3/rpcs3qt/game_list_grid.h index 44e68b84d6..730458b625 100644 --- a/rpcs3/rpcs3qt/game_list_grid.h +++ b/rpcs3/rpcs3qt/game_list_grid.h @@ -21,7 +21,7 @@ public: const std::string& selected_item_id, bool play_hover_movies) override; - void repaint_icons(QList& game_data, const QColor& icon_color, const QSize& icon_size, qreal device_pixel_ratio) override; + void repaint_icons(std::vector& game_data, const QColor& icon_color, const QSize& icon_size, qreal device_pixel_ratio) override; bool eventFilter(QObject* watched, QEvent* event) override; void keyPressEvent(QKeyEvent* event) override; diff --git a/rpcs3/rpcs3qt/game_list_table.cpp b/rpcs3/rpcs3qt/game_list_table.cpp index c766e4e8bb..32a9419a74 100644 --- a/rpcs3/rpcs3qt/game_list_table.cpp +++ b/rpcs3/rpcs3qt/game_list_table.cpp @@ -113,11 +113,11 @@ void game_list_table::adjust_icon_column() resizeColumnToContents(static_cast(gui::game_list_columns::count) - 1); } -void game_list_table::sort(int game_count, int sort_column, Qt::SortOrder col_sort_order) +void game_list_table::sort(usz game_count, int sort_column, Qt::SortOrder col_sort_order) { // Back-up old header sizes to handle unwanted column resize in case of zero search results const int old_row_count = rowCount(); - const int old_game_count = game_count; + const usz old_game_count = game_count; std::vector column_widths(columnCount()); for (int i = 0; i < columnCount(); i++) @@ -395,7 +395,7 @@ void game_list_table::populate( selectRow(selected_row); } -void game_list_table::repaint_icons(QList& game_data, const QColor& icon_color, const QSize& icon_size, qreal device_pixel_ratio) +void game_list_table::repaint_icons(std::vector& game_data, const QColor& icon_color, const QSize& icon_size, qreal device_pixel_ratio) { game_list_base::repaint_icons(game_data, icon_color, icon_size, device_pixel_ratio); adjust_icon_column(); diff --git a/rpcs3/rpcs3qt/game_list_table.h b/rpcs3/rpcs3qt/game_list_table.h index cd84231c0f..e3d6930342 100644 --- a/rpcs3/rpcs3qt/game_list_table.h +++ b/rpcs3/rpcs3qt/game_list_table.h @@ -20,7 +20,7 @@ public: void adjust_icon_column(); - void sort(int game_count, int sort_column, Qt::SortOrder col_sort_order); + void sort(usz game_count, int sort_column, Qt::SortOrder col_sort_order); void set_custom_config_icon(const game_info& game); @@ -31,7 +31,7 @@ public: const std::string& selected_item_id, bool play_hover_movies) override; - void repaint_icons(QList& game_data, const QColor& icon_color, const QSize& icon_size, qreal device_pixel_ratio) override; + void repaint_icons(std::vector& game_data, const QColor& icon_color, const QSize& icon_size, qreal device_pixel_ratio) override; Q_SIGNALS: void size_on_disk_ready(const game_info& game); diff --git a/rpcs3/rpcs3qt/gui_application.cpp b/rpcs3/rpcs3qt/gui_application.cpp index 13dfe40560..673872c2e6 100644 --- a/rpcs3/rpcs3qt/gui_application.cpp +++ b/rpcs3/rpcs3qt/gui_application.cpp @@ -974,23 +974,23 @@ void gui_application::OnChangeStyleSheetRequest() { QString stylesheet_path; QString stylesheet_dir; - QList locs; - locs << m_gui_settings->GetSettingsDir(); + std::vector locs; + locs.push_back(m_gui_settings->GetSettingsDir()); #if !defined(_WIN32) #ifdef __APPLE__ - locs << QCoreApplication::applicationDirPath() + "/../Resources/GuiConfigs/"; + locs.push_back(QCoreApplication::applicationDirPath() + "/../Resources/GuiConfigs/"); #else #ifdef DATADIR const QString data_dir = (DATADIR); - locs << data_dir + "/GuiConfigs/"; + locs.push_back(data_dir + "/GuiConfigs/"); #endif - locs << QCoreApplication::applicationDirPath() + "/../share/rpcs3/GuiConfigs/"; + locs.push_back(QCoreApplication::applicationDirPath() + "/../share/rpcs3/GuiConfigs/"); #endif - locs << QCoreApplication::applicationDirPath() + "/GuiConfigs/"; + locs.push_back(QCoreApplication::applicationDirPath() + "/GuiConfigs/"); #endif - for (auto&& loc : locs) + for (QDir& loc : locs) { QFileInfo file_info(loc.absoluteFilePath(stylesheet_name + QStringLiteral(".qss"))); if (file_info.exists()) diff --git a/rpcs3/rpcs3qt/log_frame.cpp b/rpcs3/rpcs3qt/log_frame.cpp index 42d9a315bc..cde2803a30 100644 --- a/rpcs3/rpcs3qt/log_frame.cpp +++ b/rpcs3/rpcs3qt/log_frame.cpp @@ -479,21 +479,21 @@ void log_frame::LoadSettings() void log_frame::RepaintTextColors() { // Backup old colors - QList old_colors = m_color; + std::vector old_colors = m_color; QColor old_stack_color = m_color_stack; const QColor color = gui::utils::get_foreground_color(); // Get text color. Do this once to prevent possible slowdown m_color.clear(); - m_color.append(gui::utils::get_label_color("log_level_always", Qt::darkCyan, Qt::cyan)); - m_color.append(gui::utils::get_label_color("log_level_fatal", Qt::darkMagenta, Qt::magenta)); - m_color.append(gui::utils::get_label_color("log_level_error", Qt::red, Qt::red)); - m_color.append(gui::utils::get_label_color("log_level_todo", Qt::darkYellow, Qt::darkYellow)); - m_color.append(gui::utils::get_label_color("log_level_success", Qt::darkGreen, Qt::green)); - m_color.append(gui::utils::get_label_color("log_level_warning", Qt::darkYellow, Qt::darkYellow)); - m_color.append(gui::utils::get_label_color("log_level_notice", color, color)); - m_color.append(gui::utils::get_label_color("log_level_trace", color, color)); + m_color.push_back(gui::utils::get_label_color("log_level_always", Qt::darkCyan, Qt::cyan)); + m_color.push_back(gui::utils::get_label_color("log_level_fatal", Qt::darkMagenta, Qt::magenta)); + m_color.push_back(gui::utils::get_label_color("log_level_error", Qt::red, Qt::red)); + m_color.push_back(gui::utils::get_label_color("log_level_todo", Qt::darkYellow, Qt::darkYellow)); + m_color.push_back(gui::utils::get_label_color("log_level_success", Qt::darkGreen, Qt::green)); + m_color.push_back(gui::utils::get_label_color("log_level_warning", Qt::darkYellow, Qt::darkYellow)); + m_color.push_back(gui::utils::get_label_color("log_level_notice", color, color)); + m_color.push_back(gui::utils::get_label_color("log_level_trace", color, color)); m_color_stack = gui::utils::get_label_color("log_stack", color, color); diff --git a/rpcs3/rpcs3qt/log_frame.h b/rpcs3/rpcs3qt/log_frame.h index f7e7484215..7909990c27 100644 --- a/rpcs3/rpcs3qt/log_frame.h +++ b/rpcs3/rpcs3qt/log_frame.h @@ -49,7 +49,7 @@ private: QTimer* m_timer = nullptr; - QList m_color; + std::vector m_color; QColor m_color_stack; QPlainTextEdit* m_log = nullptr; std::string m_old_log_text; diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 7f49ace6c1..0efe7070af 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -2399,7 +2399,7 @@ void main_window::ShowOptionalGamePreparations(const QString& title, const QStri locations.insert(gui::utils::shortcut_location::applications); } - QList game_data; + std::vector game_data; for (const auto& [boot_path, title_id] : paths) { @@ -2422,7 +2422,7 @@ void main_window::ShowOptionalGamePreparations(const QString& title, const QStri } } - if (!game_data.isEmpty()) + if (!game_data.empty()) { m_game_list_frame->BatchCreateCPUCaches(game_data); } diff --git a/rpcs3/rpcs3qt/patch_manager_dialog.cpp b/rpcs3/rpcs3qt/patch_manager_dialog.cpp index 1b250f789b..74b25a0b5c 100644 --- a/rpcs3/rpcs3qt/patch_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/patch_manager_dialog.cpp @@ -323,24 +323,29 @@ void patch_manager_dialog::populate_tree() const QString q_description = QString::fromStdString(description); QString visible_description = q_description; - const QList> match_criteria = QList>() - << QPair(description_role, q_description) - << QPair(persistance_role, true); + const std::vector> match_criteria = + { + std::pair(description_role, q_description), + std::pair(persistance_role, true) + }; // Add counter to leafs if the name already exists due to different hashes of the same game (PPU, SPU, PRX, OVL) - if (const auto matches = gui::utils::find_children_by_data(serial_level_item, match_criteria, false); matches.count() > 0) + std::vector matches; + gui::utils::find_children_by_data(serial_level_item, matches, match_criteria, false); + + if (!matches.empty()) { - if (auto only_match = matches.count() == 1 ? matches[0] : nullptr) + if (auto only_match = matches.size() == 1 ? matches[0] : nullptr) { only_match->setText(0, q_description + QStringLiteral(" (01)")); } - const int counter = matches.count() + 1; + const usz counter = matches.size() + 1; visible_description += QStringLiteral(" ("); if (counter < 10) visible_description += '0'; visible_description += QString::number(counter) + ')'; } - QMap q_config_values; + QVariantMap q_config_values; for (const auto& [key, default_config_value] : patch.default_config_values) { @@ -375,8 +380,10 @@ void patch_manager_dialog::populate_tree() } } - const QList> match_criteria = QList>() - << QPair(persistance_role, true); + const std::vector> match_criteria = + { + std::pair(persistance_role, true) + }; for (int i = ui->patch_tree->topLevelItemCount() - 1; i >= 0; i--) { @@ -578,7 +585,7 @@ void patch_manager_dialog::update_patch_info(const patch_manager_dialog::gui_pat ui->configurable_double_spin_box->setVisible(false); // Fetch the config values of this item - const QVariant& variant = info.config_values.value(key); + const QVariant& variant = ::at32(info.config_values, key); ensure(variant.canConvert()); const patch_engine::patch_config_value config_value = variant.value(); @@ -662,7 +669,7 @@ void patch_manager_dialog::handle_item_selected(QTreeWidgetItem* current, QTreeW info.notes = QString::fromStdString(found_info.notes); info.description = QString::fromStdString(found_info.description); info.patch_version = QString::fromStdString(found_info.patch_version); - info.config_values = current->data(0, config_values_role).toMap(); + info.config_values = current->data(0, config_values_role).toMap().toStdMap(); info.config_value_key = current->data(0, config_key_role).toString(); if (current != previous) @@ -670,11 +677,9 @@ void patch_manager_dialog::handle_item_selected(QTreeWidgetItem* current, QTreeW // Update the config value combo box with the new config keys ui->configurable_selector->blockSignals(true); ui->configurable_selector->clear(); - for (const QString& key : info.config_values.keys()) + for (const auto& [key, variant] : info.config_values) { - const QVariant& variant = info.config_values.value(key); ensure(variant.canConvert()); - const patch_engine::patch_config_value config_value = variant.value(); ui->configurable_selector->addItem(key, key); } if (ui->configurable_selector->count() > 0) diff --git a/rpcs3/rpcs3qt/patch_manager_dialog.h b/rpcs3/rpcs3qt/patch_manager_dialog.h index fd4ed40b81..c554f6f309 100644 --- a/rpcs3/rpcs3qt/patch_manager_dialog.h +++ b/rpcs3/rpcs3qt/patch_manager_dialog.h @@ -31,7 +31,7 @@ class patch_manager_dialog : public QDialog QString description; QString patch_version; QString config_value_key; - QMap config_values; + std::map config_values; }; const QString tr_all_titles = tr("All titles - Warning: These patches apply to all games!"); diff --git a/rpcs3/rpcs3qt/qt_utils.cpp b/rpcs3/rpcs3qt/qt_utils.cpp index e041f5b9a6..647db7388d 100644 --- a/rpcs3/rpcs3qt/qt_utils.cpp +++ b/rpcs3/rpcs3qt/qt_utils.cpp @@ -501,10 +501,8 @@ namespace gui return nullptr; } - QList find_children_by_data(QTreeWidgetItem* parent, const QList>& criteria, bool recursive) + void find_children_by_data(QTreeWidgetItem* parent, std::vector& children, const std::vector>& criteria, bool recursive) { - QList list; - if (parent) { for (int i = 0; i < parent->childCount(); i++) @@ -524,18 +522,16 @@ namespace gui if (match) { - list << item; + children.push_back(item); } if (recursive) { - list << find_children_by_data(item, criteria, recursive); + find_children_by_data(item, children, criteria, recursive); } } } } - - return list; } QTreeWidgetItem* add_child(QTreeWidgetItem *parent, const QString& text, int column) @@ -561,7 +557,7 @@ namespace gui } } - void remove_children(QTreeWidgetItem* parent, const QList>& criteria, bool recursive) + void remove_children(QTreeWidgetItem* parent, const std::vector>& criteria, bool recursive) { if (parent) { diff --git a/rpcs3/rpcs3qt/qt_utils.h b/rpcs3/rpcs3qt/qt_utils.h index ea8db3245d..11e4341927 100644 --- a/rpcs3/rpcs3qt/qt_utils.h +++ b/rpcs3/rpcs3qt/qt_utils.h @@ -131,7 +131,7 @@ namespace gui QTreeWidgetItem* find_child(QTreeWidgetItem* parent, const QString& text); // Finds all children of a QTreeWidgetItem that match the given criteria - QList find_children_by_data(QTreeWidgetItem* parent, const QList>& criteria, bool recursive); + void find_children_by_data(QTreeWidgetItem* parent, std::vector& children, const std::vector>& criteria, bool recursive); // Constructs and adds a child to a QTreeWidgetItem QTreeWidgetItem* add_child(QTreeWidgetItem* parent, const QString& text, int column = 0); @@ -140,7 +140,7 @@ namespace gui void remove_children(QTreeWidgetItem* parent); // Removes all children of a QTreeWidgetItem that don't match the given criteria - void remove_children(QTreeWidgetItem* parent, const QList>& criteria, bool recursive); + void remove_children(QTreeWidgetItem* parent, const std::vector>& criteria, bool recursive); // Sort a QTreeWidget (currently only column 0) void sort_tree(QTreeWidget* tree, Qt::SortOrder sort_order, bool recursive); diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index da862377e1..1b5cc421a7 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -2644,7 +2644,7 @@ int settings_dialog::exec() void settings_dialog::SubscribeDescription(QLabel* description) { description->setFixedHeight(description->sizeHint().height()); - m_description_labels.append(QPair(description, description->text())); + m_description_labels.push_back(std::pair(description, description->text())); } void settings_dialog::SubscribeTooltip(QObject* object, const QString& tooltip) @@ -2677,11 +2677,9 @@ bool settings_dialog::eventFilter(QObject* object, QEvent* event) { const int i = ui->tab_widget_settings->currentIndex(); - if (i < m_description_labels.size()) + if (i >= 0 && static_cast(i) < m_description_labels.size()) { - QLabel* label = m_description_labels[i].first; - - if (label) + if (QLabel* label = m_description_labels[i].first) { if (event->type() == QEvent::Enter) { @@ -2689,8 +2687,7 @@ bool settings_dialog::eventFilter(QObject* object, QEvent* event) } else if (event->type() == QEvent::Leave) { - const QString description = m_description_labels[i].second; - label->setText(description); + label->setText(m_description_labels[i].second); } } } diff --git a/rpcs3/rpcs3qt/settings_dialog.h b/rpcs3/rpcs3qt/settings_dialog.h index ce0696e57d..203fd1c8f9 100644 --- a/rpcs3/rpcs3qt/settings_dialog.h +++ b/rpcs3/rpcs3qt/settings_dialog.h @@ -62,7 +62,7 @@ private: QString m_discord_state; // Descriptions - QList> m_description_labels; + std::vector> m_description_labels; QHash m_descriptions; void SubscribeDescription(QLabel* description); void SubscribeTooltip(QObject* object, const QString& tooltip); diff --git a/rpcs3/rpcs3qt/trophy_manager_dialog.cpp b/rpcs3/rpcs3qt/trophy_manager_dialog.cpp index b918330d9e..981a7a3408 100644 --- a/rpcs3/rpcs3qt/trophy_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/trophy_manager_dialog.cpp @@ -569,11 +569,8 @@ void trophy_manager_dialog::ResizeGameIcons() placeholder.fill(Qt::transparent); qRegisterMetaType>("QVector"); - QList indices; for (int i = 0; i < m_game_table->rowCount(); ++i) { - indices.append(i); - if (QTableWidgetItem* icon_item = m_game_table->item(i, static_cast(gui::trophy_game_list_columns::icon))) { icon_item->setData(Qt::DecorationRole, placeholder);