mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2024-12-26 08:41:22 -08:00
Merge pull request #3611 from FearlessTobi/port-4956
Port citra-emu/citra#4956: "Fixes to game list sorting"
This commit is contained in:
commit
8938f9941c
@ -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_FILE_TYPE - 1, Qt::Horizontal, tr("File type"));
|
||||||
item_model->setHeaderData(COLUMN_SIZE - 1, Qt::Horizontal, tr("Size"));
|
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(main_window, &GMainWindow::UpdateThemedIcons, this, &GameList::onUpdateThemedIcons);
|
||||||
connect(tree_view, &QTreeView::activated, this, &GameList::ValidateEntry);
|
connect(tree_view, &QTreeView::activated, this, &GameList::ValidateEntry);
|
||||||
@ -441,6 +441,8 @@ void GameList::DonePopulating(QStringList watch_list) {
|
|||||||
if (children_total > 0) {
|
if (children_total > 0) {
|
||||||
search_field->setFocus();
|
search_field->setFocus();
|
||||||
}
|
}
|
||||||
|
item_model->sort(tree_view->header()->sortIndicatorSection(),
|
||||||
|
tree_view->header()->sortIndicatorOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameList::PopupContextMenu(const QPoint& menu_location) {
|
void GameList::PopupContextMenu(const QPoint& menu_location) {
|
||||||
@ -666,8 +668,6 @@ void GameList::LoadInterfaceLayout() {
|
|||||||
// so make it as large as possible as default.
|
// so make it as large as possible as default.
|
||||||
header->resizeSection(COLUMN_NAME, header->width());
|
header->resizeSection(COLUMN_NAME, header->width());
|
||||||
}
|
}
|
||||||
|
|
||||||
item_model->sort(header->sortIndicatorSection(), header->sortIndicatorOrder());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList GameList::supported_file_extensions = {
|
const QStringList GameList::supported_file_extensions = {
|
||||||
|
@ -65,10 +65,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
class GameListItemPath : public GameListItem {
|
class GameListItemPath : public GameListItem {
|
||||||
public:
|
public:
|
||||||
static const int TitleRole = SortRole;
|
static const int TitleRole = SortRole + 1;
|
||||||
static const int FullPathRole = SortRole + 1;
|
static const int FullPathRole = SortRole + 2;
|
||||||
static const int ProgramIdRole = SortRole + 2;
|
static const int ProgramIdRole = SortRole + 3;
|
||||||
static const int FileTypeRole = SortRole + 3;
|
static const 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,
|
||||||
@ -95,7 +95,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
QVariant data(int role) const override {
|
QVariant data(int role) const override {
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole || role == SortRole) {
|
||||||
std::string filename;
|
std::string filename;
|
||||||
Common::SplitPath(data(FullPathRole).toString().toStdString(), nullptr, &filename,
|
Common::SplitPath(data(FullPathRole).toString().toStdString(), nullptr, &filename,
|
||||||
nullptr);
|
nullptr);
|
||||||
@ -110,6 +110,9 @@ 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)
|
||||||
|
return row1.toLower();
|
||||||
|
|
||||||
if (row2_id == 4) // None
|
if (row2_id == 4) // None
|
||||||
return row1;
|
return row1;
|
||||||
|
|
||||||
@ -123,6 +126,13 @@ public:
|
|||||||
|
|
||||||
return GameListItem::data(role);
|
return GameListItem::data(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override to prevent automatic sorting.
|
||||||
|
*/
|
||||||
|
bool operator<(const QStandardItem& other) const override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GameListItemCompat : public GameListItem {
|
class GameListItemCompat : public GameListItem {
|
||||||
@ -289,6 +299,10 @@ public:
|
|||||||
int type() const override {
|
int type() const override {
|
||||||
return static_cast<int>(GameListItemType::AddDir);
|
return static_cast<int>(GameListItemType::AddDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator<(const QStandardItem& other) const override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GameList;
|
class GameList;
|
||||||
|
Loading…
Reference in New Issue
Block a user