2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Merge pull request #1015 from lioncash/gamelist

qt/gamelist: Minor cleanup-related changes
This commit is contained in:
James Rowe 2018-08-10 20:25:00 -06:00 committed by GitHub
commit 4f0818144e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@
#pragma once #pragma once
#include <array>
#include <atomic> #include <atomic>
#include <utility> #include <utility>
#include <QImage> #include <QImage>
@ -39,7 +40,6 @@ public:
* If this class receives valid SMDH data, it will also display game icons and titles. * If this class receives valid SMDH data, it will also display game icons and titles.
*/ */
class GameListItemPath : public GameListItem { class GameListItemPath : public GameListItem {
public: public:
static const int FullPathRole = Qt::UserRole + 1; static const int FullPathRole = Qt::UserRole + 1;
static const int TitleRole = Qt::UserRole + 2; static const int TitleRole = Qt::UserRole + 2;
@ -48,18 +48,18 @@ public:
GameListItemPath() = default; GameListItemPath() = default;
GameListItemPath(const QString& game_path, const std::vector<u8>& picture_data, GameListItemPath(const QString& game_path, const std::vector<u8>& picture_data,
const QString& game_name, const QString& game_type, u64 program_id) const QString& game_name, const QString& game_type, u64 program_id) {
: GameListItem() {
setData(game_path, FullPathRole); setData(game_path, FullPathRole);
setData(game_name, TitleRole); setData(game_name, TitleRole);
setData(qulonglong(program_id), ProgramIdRole); setData(qulonglong(program_id), ProgramIdRole);
setData(game_type, FileTypeRole); setData(game_type, FileTypeRole);
QPixmap picture; const u32 size = UISettings::values.icon_size;
u32 size = UISettings::values.icon_size;
if (!picture.loadFromData(picture_data.data(), picture_data.size()))
picture = GetDefaultIcon(size);
QPixmap picture;
if (!picture.loadFromData(picture_data.data(), static_cast<u32>(picture_data.size()))) {
picture = GetDefaultIcon(size);
}
picture = picture.scaled(size, size); picture = picture.scaled(size, size);
setData(picture, Qt::DecorationRole); setData(picture, Qt::DecorationRole);
@ -70,17 +70,16 @@ public:
std::string filename; std::string filename;
Common::SplitPath(data(FullPathRole).toString().toStdString(), nullptr, &filename, Common::SplitPath(data(FullPathRole).toString().toStdString(), nullptr, &filename,
nullptr); nullptr);
QString title = data(TitleRole).toString();
std::vector<QString> row_data{ const std::array<QString, 4> row_data{{
QString::fromStdString(filename), QString::fromStdString(filename),
data(FileTypeRole).toString(), data(FileTypeRole).toString(),
QString::fromStdString(fmt::format("0x{:016X}", data(ProgramIdRole).toULongLong())), QString::fromStdString(fmt::format("0x{:016X}", data(ProgramIdRole).toULongLong())),
data(TitleRole).toString(), data(TitleRole).toString(),
}; }};
auto row1 = row_data.at(UISettings::values.row_1_text_id); const auto& row1 = row_data.at(UISettings::values.row_1_text_id);
auto row2 = row_data.at(UISettings::values.row_2_text_id); const auto& row2 = row_data.at(UISettings::values.row_2_text_id);
if (row1.isEmpty() || row1 == row2) if (row1.isEmpty() || row1 == row2)
return row2; return row2;
@ -88,9 +87,9 @@ public:
return row1; return row1;
return row1 + "\n " + row2; return row1 + "\n " + row2;
} else {
return GameListItem::data(role);
} }
return GameListItem::data(role);
} }
}; };