mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-12 10:37:02 +00:00
UI: Improve wxListView sorting and add sort order indicators (#1597)
This commit is contained in:
parent
f3fe6f3455
commit
95dc590d2c
7 changed files with 55 additions and 68 deletions
|
|
@ -64,6 +64,8 @@ wxTitleManagerList::wxTitleManagerList(wxWindow* parent, wxWindowID id)
|
|||
|
||||
m_callbackIdTitleList = CafeTitleList::RegisterCallback([](CafeTitleListCallbackEvent* evt, void* ctx) { ((wxTitleManagerList*)ctx)->HandleTitleListCallback(evt); }, this);
|
||||
m_callbackIdSaveList = CafeSaveList::RegisterCallback([](CafeSaveListCallbackEvent* evt, void* ctx) { ((wxTitleManagerList*)ctx)->HandleSaveListCallback(evt); }, this);
|
||||
|
||||
ShowSortIndicator(ColumnTitleId);
|
||||
}
|
||||
|
||||
wxTitleManagerList::~wxTitleManagerList()
|
||||
|
|
@ -1173,54 +1175,48 @@ bool wxTitleManagerList::SortFunc(int column, const Type_t& v1, const Type_t& v2
|
|||
{
|
||||
if(entry1.version == entry2.version)
|
||||
return SortFunc(ColumnTitleId, v1, v2);
|
||||
|
||||
return std::underlying_type_t<EntryType>(entry1.version) < std::underlying_type_t<EntryType>(entry2.version);
|
||||
|
||||
return entry1.version < entry2.version;
|
||||
}
|
||||
else if (column == ColumnRegion)
|
||||
{
|
||||
if(entry1.region == entry2.region)
|
||||
return SortFunc(ColumnTitleId, v1, v2);
|
||||
|
||||
return std::underlying_type_t<EntryType>(entry1.region) < std::underlying_type_t<EntryType>(entry2.region);
|
||||
|
||||
return std::underlying_type_t<CafeConsoleRegion>(entry1.region) < std::underlying_type_t<CafeConsoleRegion>(entry2.region);
|
||||
}
|
||||
else if (column == ColumnFormat)
|
||||
{
|
||||
if(entry1.format == entry2.format)
|
||||
return SortFunc(ColumnType, v1, v2);
|
||||
|
||||
return std::underlying_type_t<EntryType>(entry1.format) < std::underlying_type_t<EntryType>(entry2.format);
|
||||
return std::underlying_type_t<EntryFormat>(entry1.format) < std::underlying_type_t<EntryFormat>(entry2.format);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
void wxTitleManagerList::SortEntries(int column)
|
||||
{
|
||||
if(column == -1)
|
||||
bool ascending;
|
||||
if (column == -1)
|
||||
{
|
||||
column = m_last_column_sorted;
|
||||
m_last_column_sorted = -1;
|
||||
column = GetSortIndicator();
|
||||
if (column == -1)
|
||||
column = ColumnTitleId;
|
||||
ascending = IsAscendingSortIndicator();
|
||||
}
|
||||
|
||||
else
|
||||
ascending = GetUpdatedAscendingSortIndicator(column);
|
||||
|
||||
if (column != ColumnTitleId && column != ColumnName && column != ColumnType && column != ColumnVersion && column != ColumnRegion && column != ColumnFormat)
|
||||
return;
|
||||
|
||||
if (m_last_column_sorted != column)
|
||||
{
|
||||
m_last_column_sorted = column;
|
||||
m_sort_less = true;
|
||||
}
|
||||
else
|
||||
m_sort_less = !m_sort_less;
|
||||
|
||||
std::sort(m_sorted_data.begin(), m_sorted_data.end(),
|
||||
[this, column](const Type_t& v1, const Type_t& v2) -> bool
|
||||
{
|
||||
const bool result = SortFunc(column, v1, v2);
|
||||
return m_sort_less ? result : !result;
|
||||
});
|
||||
|
||||
[this, column, ascending](const Type_t& v1, const Type_t& v2) -> bool {
|
||||
return ascending ? SortFunc(column, v1, v2) : SortFunc(column, v2, v1);
|
||||
});
|
||||
|
||||
ShowSortIndicator(column, ascending);
|
||||
RefreshPage();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue