From dd855b6091c1eb9835cd2466ed2e225dd4f850a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 27 Apr 2022 14:20:07 +0200 Subject: Update episode order after rating. --- c/episodelistview.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'c/episodelistview.c') diff --git a/c/episodelistview.c b/c/episodelistview.c index eaa7e1b..08bd0db 100644 --- a/c/episodelistview.c +++ b/c/episodelistview.c @@ -42,6 +42,16 @@ ElvCreate() return HElv; } +void +ElvDoSort() +{ + int iEpFocus; + ListView_SortItemsEx(HElv, ElvSort, ISort); + iEpFocus = ListView_GetNextItem(HElv, -1, LVNI_FOCUSED); + if (iEpFocus == -1) return; + ListView_EnsureVisible(HElv, iEpFocus, TRUE); +} + LRESULT ElvHandleNotify(LPARAM lParam) { @@ -60,17 +70,14 @@ ElvHandleNotify(LPARAM lParam) break; case LVN_COLUMNCLICK: /* Sort by column. */ { - int iColumn, iEpFocus; + int iColumn; term_t t; t = T(1); iColumn = lpNmLv->iSubItem+1; ISort = abs(ISort) == iColumn? -ISort: iColumn; PI(t,ISort) goto s; P("cfg","set_sort",1,t); - s: ListView_SortItemsEx(HElv, ElvSort, ISort); - iEpFocus = ListView_GetNextItem(HElv, -1, LVNI_FOCUSED); - if (iEpFocus == -1) break; - ListView_EnsureVisible(HElv, iEpFocus, TRUE); + s: ElvDoSort(); break; } case NM_CUSTOMDRAW: /* Make unwatched episodes bold. */ -- cgit v1.2.3