FileSystem: Migrate component extractors to std::string_view

This commit is contained in:
Connor McLaughlin
2021-02-16 00:48:14 +10:00
parent 8c7aec2edf
commit cacf12c209
6 changed files with 38 additions and 54 deletions

View File

@ -1,4 +1,5 @@
#include "gamelistmodel.h"
#include "common/file_system.h"
#include "common/string_util.h"
#include "core/system.h"
#include <QtGui/QIcon>
@ -159,7 +160,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
case Column_FileTitle:
{
const std::string_view file_title(System::GetTitleForPath(ge.path.c_str()));
const std::string_view file_title(FileSystem::GetFileTitleFromPath(ge.path));
return QString::fromUtf8(file_title.data(), static_cast<int>(file_title.length()));
}
@ -195,7 +196,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
case Column_FileTitle:
{
const std::string_view file_title(System::GetTitleForPath(ge.path.c_str()));
const std::string_view file_title(FileSystem::GetFileTitleFromPath(ge.path));
return QString::fromUtf8(file_title.data(), static_cast<int>(file_title.length()));
}
@ -359,8 +360,8 @@ bool GameListModel::lessThan(const QModelIndex& left_index, const QModelIndex& r
case Column_FileTitle:
{
const std::string_view file_title_left(System::GetTitleForPath(left.path.c_str()));
const std::string_view file_title_right(System::GetTitleForPath(right.path.c_str()));
const std::string_view file_title_left(FileSystem::GetFileTitleFromPath(left.path));
const std::string_view file_title_right(FileSystem::GetFileTitleFromPath(right.path));
if (file_title_left == file_title_right)
return titlesLessThan(left_row, right_row, ascending);