diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/game_list.cpp | 6 | ||||
| -rw-r--r-- | src/yuzu/game_list_p.h | 24 |
2 files changed, 22 insertions, 8 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index a2b88c787..dccbabcbf 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp | |||
| @@ -315,7 +315,7 @@ GameList::GameList(FileSys::VirtualFilesystem vfs, FileSys::ManualContentProvide | |||
| 315 | item_model->setHeaderData(COLUMN_FILE_TYPE - 1, Qt::Horizontal, tr("File type")); | 315 | item_model->setHeaderData(COLUMN_FILE_TYPE - 1, Qt::Horizontal, tr("File type")); |
| 316 | item_model->setHeaderData(COLUMN_SIZE - 1, Qt::Horizontal, tr("Size")); | 316 | item_model->setHeaderData(COLUMN_SIZE - 1, Qt::Horizontal, tr("Size")); |
| 317 | } | 317 | } |
| 318 | item_model->setSortRole(GameListItemPath::TitleRole); | 318 | item_model->setSortRole(GameListItemPath::SortRole); |
| 319 | 319 | ||
| 320 | connect(main_window, &GMainWindow::UpdateThemedIcons, this, &GameList::onUpdateThemedIcons); | 320 | connect(main_window, &GMainWindow::UpdateThemedIcons, this, &GameList::onUpdateThemedIcons); |
| 321 | connect(tree_view, &QTreeView::activated, this, &GameList::ValidateEntry); | 321 | connect(tree_view, &QTreeView::activated, this, &GameList::ValidateEntry); |
| @@ -441,6 +441,8 @@ void GameList::DonePopulating(QStringList watch_list) { | |||
| 441 | if (children_total > 0) { | 441 | if (children_total > 0) { |
| 442 | search_field->setFocus(); | 442 | search_field->setFocus(); |
| 443 | } | 443 | } |
| 444 | item_model->sort(tree_view->header()->sortIndicatorSection(), | ||
| 445 | tree_view->header()->sortIndicatorOrder()); | ||
| 444 | } | 446 | } |
| 445 | 447 | ||
| 446 | void GameList::PopupContextMenu(const QPoint& menu_location) { | 448 | void GameList::PopupContextMenu(const QPoint& menu_location) { |
| @@ -666,8 +668,6 @@ void GameList::LoadInterfaceLayout() { | |||
| 666 | // so make it as large as possible as default. | 668 | // so make it as large as possible as default. |
| 667 | header->resizeSection(COLUMN_NAME, header->width()); | 669 | header->resizeSection(COLUMN_NAME, header->width()); |
| 668 | } | 670 | } |
| 669 | |||
| 670 | item_model->sort(header->sortIndicatorSection(), header->sortIndicatorOrder()); | ||
| 671 | } | 671 | } |
| 672 | 672 | ||
| 673 | const QStringList GameList::supported_file_extensions = { | 673 | const QStringList GameList::supported_file_extensions = { |
diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index 7cde72d1b..3e6d5a7cd 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h | |||
| @@ -65,10 +65,10 @@ public: | |||
| 65 | */ | 65 | */ |
| 66 | class GameListItemPath : public GameListItem { | 66 | class GameListItemPath : public GameListItem { |
| 67 | public: | 67 | public: |
| 68 | static const int TitleRole = SortRole; | 68 | static const int TitleRole = SortRole + 1; |
| 69 | static const int FullPathRole = SortRole + 1; | 69 | static const int FullPathRole = SortRole + 2; |
| 70 | static const int ProgramIdRole = SortRole + 2; | 70 | static const int ProgramIdRole = SortRole + 3; |
| 71 | static const int FileTypeRole = SortRole + 3; | 71 | static const int FileTypeRole = SortRole + 4; |
| 72 | 72 | ||
| 73 | GameListItemPath() = default; | 73 | GameListItemPath() = default; |
| 74 | GameListItemPath(const QString& game_path, const std::vector<u8>& picture_data, | 74 | GameListItemPath(const QString& game_path, const std::vector<u8>& picture_data, |
| @@ -95,7 +95,7 @@ public: | |||
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | QVariant data(int role) const override { | 97 | QVariant data(int role) const override { |
| 98 | if (role == Qt::DisplayRole) { | 98 | if (role == Qt::DisplayRole || role == SortRole) { |
| 99 | std::string filename; | 99 | std::string filename; |
| 100 | Common::SplitPath(data(FullPathRole).toString().toStdString(), nullptr, &filename, | 100 | Common::SplitPath(data(FullPathRole).toString().toStdString(), nullptr, &filename, |
| 101 | nullptr); | 101 | nullptr); |
| @@ -110,6 +110,9 @@ public: | |||
| 110 | const auto& row1 = row_data.at(UISettings::values.row_1_text_id); | 110 | const auto& row1 = row_data.at(UISettings::values.row_1_text_id); |
| 111 | const int row2_id = UISettings::values.row_2_text_id; | 111 | const int row2_id = UISettings::values.row_2_text_id; |
| 112 | 112 | ||
| 113 | if (role == SortRole) | ||
| 114 | return row1.toLower(); | ||
| 115 | |||
| 113 | if (row2_id == 4) // None | 116 | if (row2_id == 4) // None |
| 114 | return row1; | 117 | return row1; |
| 115 | 118 | ||
| @@ -123,6 +126,13 @@ public: | |||
| 123 | 126 | ||
| 124 | return GameListItem::data(role); | 127 | return GameListItem::data(role); |
| 125 | } | 128 | } |
| 129 | |||
| 130 | /** | ||
| 131 | * Override to prevent automatic sorting. | ||
| 132 | */ | ||
| 133 | bool operator<(const QStandardItem& other) const override { | ||
| 134 | return false; | ||
| 135 | } | ||
| 126 | }; | 136 | }; |
| 127 | 137 | ||
| 128 | class GameListItemCompat : public GameListItem { | 138 | class GameListItemCompat : public GameListItem { |
| @@ -289,6 +299,10 @@ public: | |||
| 289 | int type() const override { | 299 | int type() const override { |
| 290 | return static_cast<int>(GameListItemType::AddDir); | 300 | return static_cast<int>(GameListItemType::AddDir); |
| 291 | } | 301 | } |
| 302 | |||
| 303 | bool operator<(const QStandardItem& other) const override { | ||
| 304 | return false; | ||
| 305 | } | ||
| 292 | }; | 306 | }; |
| 293 | 307 | ||
| 294 | class GameList; | 308 | class GameList; |