From be53097577708ad51509877b8ce8a63fa942645f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 10 Aug 2018 18:07:43 -0400 Subject: [PATCH 1/3] qt/game_list: Remove redundant base class constructor from initializer list This is called automatically anyways. --- src/yuzu/game_list_p.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index 114a0fc7f..4f7e1ab37 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h @@ -39,7 +39,6 @@ public: * If this class receives valid SMDH data, it will also display game icons and titles. */ class GameListItemPath : public GameListItem { - public: static const int FullPathRole = Qt::UserRole + 1; static const int TitleRole = Qt::UserRole + 2; @@ -48,8 +47,7 @@ public: GameListItemPath() = default; GameListItemPath(const QString& game_path, const std::vector& picture_data, - const QString& game_name, const QString& game_type, u64 program_id) - : GameListItem() { + const QString& game_name, const QString& game_type, u64 program_id) { setData(game_path, FullPathRole); setData(game_name, TitleRole); setData(qulonglong(program_id), ProgramIdRole); From aaf671a309a65f120190a72af88e3b016025d348 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 10 Aug 2018 18:12:26 -0400 Subject: [PATCH 2/3] gt/game_list: Use std::array in GameListItemPath's data() function We don't need to use a heap-allocated std::vector here, given we explicitly know the bounds. --- src/yuzu/game_list_p.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index 4f7e1ab37..039c7dc67 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include #include @@ -39,6 +40,7 @@ public: * If this class receives valid SMDH data, it will also display game icons and titles. */ class GameListItemPath : public GameListItem { + public: static const int FullPathRole = Qt::UserRole + 1; static const int TitleRole = Qt::UserRole + 2; @@ -68,17 +70,16 @@ public: std::string filename; Common::SplitPath(data(FullPathRole).toString().toStdString(), nullptr, &filename, nullptr); - QString title = data(TitleRole).toString(); - std::vector row_data{ + const std::array row_data{{ QString::fromStdString(filename), data(FileTypeRole).toString(), QString::fromStdString(fmt::format("0x{:016X}", data(ProgramIdRole).toULongLong())), data(TitleRole).toString(), - }; + }}; - auto row1 = row_data.at(UISettings::values.row_1_text_id); - auto row2 = row_data.at(UISettings::values.row_2_text_id); + const auto& row1 = row_data.at(UISettings::values.row_1_text_id); + const auto& row2 = row_data.at(UISettings::values.row_2_text_id); if (row1.isEmpty() || row1 == row2) return row2; @@ -86,9 +87,9 @@ public: return row1; return row1 + "\n " + row2; - } else { - return GameListItem::data(role); } + + return GameListItem::data(role); } }; From 8eb97706b869b2c07ac915600f41345c7fdc6479 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 10 Aug 2018 18:15:06 -0400 Subject: [PATCH 3/3] qt/game_list: Resolve truncation warning within GameListItemPath's constructor Silences a warning about truncating from size_t to u32 --- src/yuzu/game_list_p.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index 039c7dc67..8fe5e8b80 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h @@ -40,7 +40,6 @@ public: * If this class receives valid SMDH data, it will also display game icons and titles. */ class GameListItemPath : public GameListItem { - public: static const int FullPathRole = Qt::UserRole + 1; static const int TitleRole = Qt::UserRole + 2; @@ -55,11 +54,12 @@ public: setData(qulonglong(program_id), ProgramIdRole); setData(game_type, FileTypeRole); - QPixmap picture; - u32 size = UISettings::values.icon_size; - if (!picture.loadFromData(picture_data.data(), picture_data.size())) - picture = GetDefaultIcon(size); + const u32 size = UISettings::values.icon_size; + QPixmap picture; + if (!picture.loadFromData(picture_data.data(), static_cast(picture_data.size()))) { + picture = GetDefaultIcon(size); + } picture = picture.scaled(size, size); setData(picture, Qt::DecorationRole);