From 7408c388d6f6b93d02a8cf3757f352cceddff6f5 Mon Sep 17 00:00:00 2001 From: AlexApps99 Date: Fri, 24 Jan 2020 20:56:38 +1300 Subject: [PATCH] Add path to File Name column of game grid Fixes https://bugs.dolphin-emu.org/issues/10567 --- Source/Core/Core/ConfigManager.cpp | 2 ++ Source/Core/Core/ConfigManager.h | 1 + Source/Core/DolphinQt/GameList/GameList.cpp | 4 ++++ .../Core/DolphinQt/GameList/GameListModel.cpp | 23 +++++++++++++++++++ .../Core/DolphinQt/GameList/GameListModel.h | 1 + Source/Core/DolphinQt/MenuBar.cpp | 1 + 6 files changed, 32 insertions(+) diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 0d9821111d..68bfb22ce4 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -188,6 +188,7 @@ void SConfig::SaveGameListSettings(IniFile& ini) gamelist->Set("ColumnTitle", m_showTitleColumn); gamelist->Set("ColumnNotes", m_showMakerColumn); gamelist->Set("ColumnFileName", m_showFileNameColumn); + gamelist->Set("ColumnFilePath", m_showFilePathColumn); gamelist->Set("ColumnID", m_showIDColumn); gamelist->Set("ColumnRegion", m_showRegionColumn); gamelist->Set("ColumnSize", m_showSizeColumn); @@ -464,6 +465,7 @@ void SConfig::LoadGameListSettings(IniFile& ini) gamelist->Get("ColumnTitle", &m_showTitleColumn, true); gamelist->Get("ColumnNotes", &m_showMakerColumn, true); gamelist->Get("ColumnFileName", &m_showFileNameColumn, false); + gamelist->Get("ColumnFilePath", &m_showFilePathColumn, false); gamelist->Get("ColumnID", &m_showIDColumn, false); gamelist->Get("ColumnRegion", &m_showRegionColumn, true); gamelist->Get("ColumnSize", &m_showSizeColumn, true); diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 60edd466b0..052f40285b 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -268,6 +268,7 @@ struct SConfig bool m_showTitleColumn; bool m_showMakerColumn; bool m_showFileNameColumn; + bool m_showFilePathColumn; bool m_showIDColumn; bool m_showRegionColumn; bool m_showSizeColumn; diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp index c93696755f..9f166db56e 100644 --- a/Source/Core/DolphinQt/GameList/GameList.cpp +++ b/Source/Core/DolphinQt/GameList/GameList.cpp @@ -145,6 +145,7 @@ void GameList::MakeListView() hor_header->setSectionResizeMode(GameListModel::COL_COUNTRY, QHeaderView::Fixed); hor_header->setSectionResizeMode(GameListModel::COL_SIZE, QHeaderView::Fixed); hor_header->setSectionResizeMode(GameListModel::COL_FILE_NAME, QHeaderView::Interactive); + hor_header->setSectionResizeMode(GameListModel::COL_FILE_PATH, QHeaderView::Interactive); hor_header->setSectionResizeMode(GameListModel::COL_TAGS, QHeaderView::Interactive); // There's some odd platform-specific behavior with default minimum section size @@ -188,6 +189,8 @@ void GameList::UpdateColumnVisibility() m_list->setColumnHidden(GameListModel::COL_SIZE, !SConfig::GetInstance().m_showSizeColumn); m_list->setColumnHidden(GameListModel::COL_FILE_NAME, !SConfig::GetInstance().m_showFileNameColumn); + m_list->setColumnHidden(GameListModel::COL_FILE_PATH, + !SConfig::GetInstance().m_showFilePathColumn); m_list->setColumnHidden(GameListModel::COL_TAGS, !SConfig::GetInstance().m_showTagsColumn); } @@ -908,6 +911,7 @@ void GameList::OnColumnVisibilityToggled(const QString& row, bool visible) {tr("Description"), GameListModel::COL_DESCRIPTION}, {tr("Maker"), GameListModel::COL_MAKER}, {tr("File Name"), GameListModel::COL_FILE_NAME}, + {tr("File Path"), GameListModel::COL_FILE_PATH}, {tr("Game ID"), GameListModel::COL_ID}, {tr("Region"), GameListModel::COL_COUNTRY}, {tr("File Size"), GameListModel::COL_SIZE}, diff --git a/Source/Core/DolphinQt/GameList/GameListModel.cpp b/Source/Core/DolphinQt/GameList/GameListModel.cpp index c5d8268f6d..fb5aa0020f 100644 --- a/Source/Core/DolphinQt/GameList/GameListModel.cpp +++ b/Source/Core/DolphinQt/GameList/GameListModel.cpp @@ -4,6 +4,7 @@ #include "DolphinQt/GameList/GameListModel.h" +#include #include #include "Core/ConfigManager.h" @@ -140,6 +141,26 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole) return QString::fromStdString(game.GetFileName()); break; + case COL_FILE_PATH: + if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole) + { + QString file_path = QDir::cleanPath(QString::fromStdString(game.GetFilePath())); + for (QString dir : Settings::Instance().GetPaths()) + { + dir = QDir::cleanPath(dir); + if (file_path.startsWith(dir)) + { + int path_index = dir.lastIndexOf(QLatin1Char('/'), -2); + if (path_index > -1) + { + file_path = file_path.mid(path_index + 1); + break; + } + } + } + return QDir::toNativeSeparators(file_path); + } + break; case COL_SIZE: if (role == Qt::DisplayRole) { @@ -186,6 +207,8 @@ QVariant GameListModel::headerData(int section, Qt::Orientation orientation, int return tr("Maker"); case COL_FILE_NAME: return tr("File Name"); + case COL_FILE_PATH: + return tr("File Path"); case COL_SIZE: return tr("Size"); case COL_TAGS: diff --git a/Source/Core/DolphinQt/GameList/GameListModel.h b/Source/Core/DolphinQt/GameList/GameListModel.h index de0501d53b..712ea42d71 100644 --- a/Source/Core/DolphinQt/GameList/GameListModel.h +++ b/Source/Core/DolphinQt/GameList/GameListModel.h @@ -55,6 +55,7 @@ public: COL_COUNTRY, COL_SIZE, COL_FILE_NAME, + COL_FILE_PATH, COL_TAGS, NUM_COLS }; diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index e5303e65ae..36be3e9304 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -606,6 +606,7 @@ void MenuBar::AddListColumnsMenu(QMenu* view_menu) {tr("Description"), &SConfig::GetInstance().m_showDescriptionColumn}, {tr("Maker"), &SConfig::GetInstance().m_showMakerColumn}, {tr("File Name"), &SConfig::GetInstance().m_showFileNameColumn}, + {tr("File Path"), &SConfig::GetInstance().m_showFilePathColumn}, {tr("Game ID"), &SConfig::GetInstance().m_showIDColumn}, {tr("Region"), &SConfig::GetInstance().m_showRegionColumn}, {tr("File Size"), &SConfig::GetInstance().m_showSizeColumn},