yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

Merge pull request #3611 from FearlessTobi/port-4956

Port citra-emu/citra#4956: "Fixes to game list sorting"
This commit is contained in:
bunnei 2020-04-11 12:44:36 -04:00 committed by GitHub
commit 8938f9941c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 8 deletions

View File

@ -315,7 +315,7 @@ GameList::GameList(FileSys::VirtualFilesystem vfs, FileSys::ManualContentProvide
item_model->setHeaderData(COLUMN_FILE_TYPE - 1, Qt::Horizontal, tr("File type"));
item_model->setHeaderData(COLUMN_SIZE - 1, Qt::Horizontal, tr("Size"));
}
item_model->setSortRole(GameListItemPath::TitleRole);
item_model->setSortRole(GameListItemPath::SortRole);
connect(main_window, &GMainWindow::UpdateThemedIcons, this, &GameList::onUpdateThemedIcons);
connect(tree_view, &QTreeView::activated, this, &GameList::ValidateEntry);
@ -441,6 +441,8 @@ void GameList::DonePopulating(QStringList watch_list) {
if (children_total > 0) {
search_field->setFocus();
}
item_model->sort(tree_view->header()->sortIndicatorSection(),
tree_view->header()->sortIndicatorOrder());
}
void GameList::PopupContextMenu(const QPoint& menu_location) {
@ -666,8 +668,6 @@ void GameList::LoadInterfaceLayout() {
// so make it as large as possible as default.
header->resizeSection(COLUMN_NAME, header->width());
}
item_model->sort(header->sortIndicatorSection(), header->sortIndicatorOrder());
}
const QStringList GameList::supported_file_extensions = {

View File

@ -65,10 +65,10 @@ public:
*/
class GameListItemPath : public GameListItem {
public:
static const int TitleRole = SortRole;
static const int FullPathRole = SortRole + 1;
static const int ProgramIdRole = SortRole + 2;
static const int FileTypeRole = SortRole + 3;
static const int TitleRole = SortRole + 1;
static const int FullPathRole = SortRole + 2;
static const int ProgramIdRole = SortRole + 3;
static const int FileTypeRole = SortRole + 4;
GameListItemPath() = default;
GameListItemPath(const QString& game_path, const std::vector<u8>& picture_data,
@ -95,7 +95,7 @@ public:
}
QVariant data(int role) const override {
if (role == Qt::DisplayRole) {
if (role == Qt::DisplayRole || role == SortRole) {
std::string filename;
Common::SplitPath(data(FullPathRole).toString().toStdString(), nullptr, &filename,
nullptr);
@ -110,6 +110,9 @@ public:
const auto& row1 = row_data.at(UISettings::values.row_1_text_id);
const int row2_id = UISettings::values.row_2_text_id;
if (role == SortRole)
return row1.toLower();
if (row2_id == 4) // None
return row1;
@ -123,6 +126,13 @@ public:
return GameListItem::data(role);
}
/**
* Override to prevent automatic sorting.
*/
bool operator<(const QStandardItem& other) const override {
return false;
}
};
class GameListItemCompat : public GameListItem {
@ -289,6 +299,10 @@ public:
int type() const override {
return static_cast<int>(GameListItemType::AddDir);
}
bool operator<(const QStandardItem& other) const override {
return false;
}
};
class GameList;