mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-10-26 13:42:48 -05:00 
			
		
		
		
	Merge pull request #4606 from lioncash/constexpr
game_list_p: Mark some constants as constexpr
This commit is contained in:
		| @@ -49,10 +49,10 @@ class GameListItem : public QStandardItem { | |||||||
|  |  | ||||||
| public: | public: | ||||||
|     // used to access type from item index |     // used to access type from item index | ||||||
|     static const int TypeRole = Qt::UserRole + 1; |     static constexpr int TypeRole = Qt::UserRole + 1; | ||||||
|     static const int SortRole = Qt::UserRole + 2; |     static constexpr int SortRole = Qt::UserRole + 2; | ||||||
|     GameListItem() = default; |     GameListItem() = default; | ||||||
|     GameListItem(const QString& string) : QStandardItem(string) { |     explicit GameListItem(const QString& string) : QStandardItem(string) { | ||||||
|         setData(string, SortRole); |         setData(string, SortRole); | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
| @@ -65,10 +65,10 @@ public: | |||||||
|  */ |  */ | ||||||
| class GameListItemPath : public GameListItem { | class GameListItemPath : public GameListItem { | ||||||
| public: | public: | ||||||
|     static const int TitleRole = SortRole + 1; |     static constexpr int TitleRole = SortRole + 1; | ||||||
|     static const int FullPathRole = SortRole + 2; |     static constexpr int FullPathRole = SortRole + 2; | ||||||
|     static const int ProgramIdRole = SortRole + 3; |     static constexpr int ProgramIdRole = SortRole + 3; | ||||||
|     static const int FileTypeRole = SortRole + 4; |     static constexpr int FileTypeRole = SortRole + 4; | ||||||
|  |  | ||||||
|     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, | ||||||
| @@ -110,18 +110,22 @@ public: | |||||||
|             const auto& row1 = row_data.at(UISettings::values.row_1_text_id); |             const auto& row1 = row_data.at(UISettings::values.row_1_text_id); | ||||||
|             const int row2_id = UISettings::values.row_2_text_id; |             const int row2_id = UISettings::values.row_2_text_id; | ||||||
|  |  | ||||||
|             if (role == SortRole) |             if (role == SortRole) { | ||||||
|                 return row1.toLower(); |                 return row1.toLower(); | ||||||
|  |             } | ||||||
|  |  | ||||||
|             if (row2_id == 4) // None |             // None | ||||||
|  |             if (row2_id == 4) { | ||||||
|                 return row1; |                 return row1; | ||||||
|  |             } | ||||||
|  |  | ||||||
|             const auto& row2 = row_data.at(row2_id); |             const auto& row2 = row_data.at(row2_id); | ||||||
|  |  | ||||||
|             if (row1 == row2) |             if (row1 == row2) { | ||||||
|                 return row1; |                 return row1; | ||||||
|  |             } | ||||||
|  |  | ||||||
|             return QString(row1 + QStringLiteral("\n    ") + row2); |             return QStringLiteral("%1\n    %2").arg(row1, row2); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return GameListItem::data(role); |         return GameListItem::data(role); | ||||||
| @@ -131,7 +135,7 @@ public: | |||||||
| class GameListItemCompat : public GameListItem { | class GameListItemCompat : public GameListItem { | ||||||
|     Q_DECLARE_TR_FUNCTIONS(GameListItemCompat) |     Q_DECLARE_TR_FUNCTIONS(GameListItemCompat) | ||||||
| public: | public: | ||||||
|     static const int CompatNumberRole = SortRole; |     static constexpr int CompatNumberRole = SortRole; | ||||||
|     GameListItemCompat() = default; |     GameListItemCompat() = default; | ||||||
|     explicit GameListItemCompat(const QString& compatibility) { |     explicit GameListItemCompat(const QString& compatibility) { | ||||||
|         setData(type(), TypeRole); |         setData(type(), TypeRole); | ||||||
| @@ -181,7 +185,7 @@ public: | |||||||
|  */ |  */ | ||||||
| class GameListItemSize : public GameListItem { | class GameListItemSize : public GameListItem { | ||||||
| public: | public: | ||||||
|     static const int SizeRole = SortRole; |     static constexpr int SizeRole = SortRole; | ||||||
|  |  | ||||||
|     GameListItemSize() = default; |     GameListItemSize() = default; | ||||||
|     explicit GameListItemSize(const qulonglong size_bytes) { |     explicit GameListItemSize(const qulonglong size_bytes) { | ||||||
| @@ -217,7 +221,7 @@ public: | |||||||
|  |  | ||||||
| class GameListDir : public GameListItem { | class GameListDir : public GameListItem { | ||||||
| public: | public: | ||||||
|     static const int GameDirRole = Qt::UserRole + 2; |     static constexpr int GameDirRole = Qt::UserRole + 2; | ||||||
|  |  | ||||||
|     explicit GameListDir(UISettings::GameDir& directory, |     explicit GameListDir(UISettings::GameDir& directory, | ||||||
|                          GameListItemType dir_type = GameListItemType::CustomDir) |                          GameListItemType dir_type = GameListItemType::CustomDir) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 bunnei
					bunnei