aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-04-27 14:20:07 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-04-27 14:20:07 +0200
commitdd855b6091c1eb9835cd2466ed2e225dd4f850a4 (patch)
tree62e7f22f035c65889510ef63ed9b7d87582a6a4e
parentc884c09ac88c0d22a21f839593d77c7173c41b60 (diff)
downloadEpisodeBrowser-dd855b6091c1eb9835cd2466ed2e225dd4f850a4.tar.gz
Update episode order after rating.
-rw-r--r--c/defs.h1
-rw-r--r--c/episodelistview.c17
-rw-r--r--c/main.c16
3 files changed, 28 insertions, 6 deletions
diff --git a/c/defs.h b/c/defs.h
index afc742f..14b7626 100644
--- a/c/defs.h
+++ b/c/defs.h
@@ -16,6 +16,7 @@ int LvHeight(HWND, int);
/* episodelistview.c */
HWND ElvCreate();
+void ElvDoSort(void);
LRESULT ElvHandleNotify(LPARAM);
void ElvRedraw(void);
void ElvSetTop(int);
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. */
diff --git a/c/main.c b/c/main.c
index 25d90d2..dc18a4f 100644
--- a/c/main.c
+++ b/c/main.c
@@ -346,10 +346,24 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
PI(t+1,0) break;
r: P("episode_data","rate_episode",2,t);
ElvUpdateItem(&lvi);
- ElvRedraw();
break;
}
}
+ switch (LOWORD(wParam)) {
+ case IDM_RATE10:
+ case IDM_RATE9:
+ case IDM_RATE8:
+ case IDM_RATE7:
+ case IDM_RATE6:
+ case IDM_RATE5:
+ case IDM_RATE4:
+ case IDM_RATE3:
+ case IDM_RATE2:
+ case IDM_RATE1:
+ case IDM_RATE0:
+ ElvRedraw();
+ ElvDoSort();
+ }
b: break;
}
}