mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-27 01:22:37 -06:00
Use the displayed text for sorting GameListItemPath.
By default, DisplayRole is used as the SortRole. This behaviour is what's expected by the user. Made it so that an access to SortRole is equivalent to one to DisplayRole. Also fixes a bug with directory sorting.
This commit is contained in:
parent
acf1fe5ee1
commit
476dcb1915
2 changed files with 18 additions and 7 deletions
|
@ -294,7 +294,7 @@ GameList::GameList(GMainWindow* parent) : QWidget{parent} {
|
||||||
item_model->setHeaderData(COLUMN_REGION, Qt::Horizontal, tr("Region"));
|
item_model->setHeaderData(COLUMN_REGION, Qt::Horizontal, tr("Region"));
|
||||||
item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type"));
|
item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type"));
|
||||||
item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size"));
|
item_model->setHeaderData(COLUMN_SIZE, 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);
|
||||||
|
|
|
@ -146,11 +146,11 @@ static const std::unordered_map<UISettings::GameListIconSize, int> IconSizes{
|
||||||
*/
|
*/
|
||||||
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 ExtdataIdRole = SortRole + 3;
|
static const int ExtdataIdRole = SortRole + 4;
|
||||||
static const int LongTitleRole = SortRole + 4;
|
static const int LongTitleRole = SortRole + 5;
|
||||||
|
|
||||||
GameListItemPath() = default;
|
GameListItemPath() = default;
|
||||||
GameListItemPath(const QString& game_path, const std::vector<u8>& smdh_data, u64 program_id,
|
GameListItemPath(const QString& game_path, const std::vector<u8>& smdh_data, u64 program_id,
|
||||||
|
@ -196,7 +196,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 path, filename, extension;
|
std::string path, filename, extension;
|
||||||
Common::SplitPath(data(FullPathRole).toString().toStdString(), &path, &filename,
|
Common::SplitPath(data(FullPathRole).toString().toStdString(), &path, &filename,
|
||||||
&extension);
|
&extension);
|
||||||
|
@ -374,6 +374,13 @@ public:
|
||||||
return static_cast<int>(dir_type);
|
return static_cast<int>(dir_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override to prevent automatic sorting.
|
||||||
|
*/
|
||||||
|
bool operator<(const QStandardItem& other) const override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GameListItemType dir_type;
|
GameListItemType dir_type;
|
||||||
};
|
};
|
||||||
|
@ -391,6 +398,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 a new issue