aboutsummaryrefslogtreecommitdiff
path: root/c/episodelistview.c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-04-05 04:15:20 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-04-05 04:15:20 +0200
commit4d6cbcdc97fd79befca82ed9ddc0d96ce86f744f (patch)
tree07c4cb66a4914c4cd38b723928c69d39b507c451 /c/episodelistview.c
parentec4bf0b3d1fac134793dd4cccff24e42ce682f09 (diff)
downloadEpisodeBrowser-4d6cbcdc97fd79befca82ed9ddc0d96ce86f744f.tar.gz
Add episode ratings.
Diffstat (limited to 'c/episodelistview.c')
-rw-r--r--c/episodelistview.c56
1 files changed, 45 insertions, 11 deletions
diff --git a/c/episodelistview.c b/c/episodelistview.c
index 6b00b31..26122c7 100644
--- a/c/episodelistview.c
+++ b/c/episodelistview.c
@@ -25,9 +25,14 @@ ElvCreate()
ListView_InsertColumn(HElv, 0, &lvc);
lvc.iSubItem = 1;
+ lvc.pszText = TEXT("/");
+ lvc.cx = Dpi(20);
+ ListView_InsertColumn(HElv, 1, &lvc);
+
+ lvc.iSubItem = 1;
lvc.pszText = TEXT("Title");
lvc.cx = 500;
- ListView_InsertColumn(HElv, 1, &lvc);
+ ListView_InsertColumn(HElv, 2, &lvc);
return HElv;
}
@@ -145,7 +150,9 @@ ElvSelectRecent()
iItem = ListView_FindItem(HElv, -1, &lvfi);
if (iItem == -1) return;
-s: ElvSetTop(iItem > 5? iItem-5: 0);
+s:
+ ListView_SetItemState(HElv, -1, LVIF_STATE, LVIS_SELECTED);
+ ElvSetTop(iItem > 5? iItem-5: 0);
ListView_SetItemState(HElv, iItem,
LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
LpLviElvSelection->iItem = iItem;
@@ -159,7 +166,7 @@ void
ElvUpdate()
{
int iEpisodes, iTop;
- LVITEM lviEpisode, lviName;
+ LVITEM lviEpisode, lviName, lviRating;
term_t t;
SendMessage(HElv, WM_SETREDRAW, FALSE, 0);
@@ -168,6 +175,7 @@ ElvUpdate()
lviEpisode.mask = LVIF_TEXT|LVIF_PARAM;
lviName.mask = LVIF_TEXT;
+ lviRating.mask = LVIF_TEXT;
t = T(1);
P("episode_data","ensure_episode_data",0,t) return;
@@ -176,19 +184,28 @@ ElvUpdate()
for (int i = 0; i < iEpisodes; i++) {
char *szName;
- int cb;
- TCHAR *tszEpisode, *tszName;
- term_t t;
+ int cb, iRating;
+ TCHAR *tszEpisode, *tszName, tszRating[10];
+ term_t t, t2;
+
+ tszName = NULL;
+ tszRating[0] = 0;
/* Format name string. */
t = T(2);
PI(t,i+1) return;
- tszName = NULL;
P("episode_data","episode_title",2,t) goto ep;
GAC(t+1,&szName) goto ep;
tszName = TszFromSz(szName, CP_UTF8);
if (!tszName) return;
+ /* Format rating string. */
+ t2 = T(2);
+ PI(t2,i+1) return;
+ P("episode_data","episode_rating",2,t2) goto ep;
+ GI(t2+1,&iRating) goto ep;
+ _itot(iRating, tszRating, 10);
+
/* Format episode number string. */
ep: cb = 100;
tszEpisode = malloc(cb*sizeof(TCHAR));
@@ -202,9 +219,16 @@ ElvUpdate()
lviEpisode.lParam = i+1;
ListView_InsertItem(HElv, &lviEpisode);
+ if (*tszRating) {
+ lviRating.iItem = i;
+ lviRating.iSubItem = 1;
+ lviRating.pszText = tszRating;
+ ListView_SetItem(HElv, &lviRating);
+ }
+
if (tszName) {
lviName.iItem = i;
- lviName.iSubItem = 1;
+ lviName.iSubItem = 2;
lviName.pszText = tszName;
ListView_SetItem(HElv, &lviName);
}
@@ -228,8 +252,9 @@ void
ElvUpdateName(LPLVITEM lpLvi)
{
char *szName;
- TCHAR *tszName;
- term_t t;
+ int iRating;
+ TCHAR *tszName, tszRating[10];
+ term_t t, t2;
t = T(2);
PI(t,lpLvi->lParam) return;
@@ -241,6 +266,15 @@ ElvUpdateName(LPLVITEM lpLvi)
tszName = TszFromSz(szName, CP_UTF8);
if (!tszName) return;
+ ListView_SetItemText(HElv, lpLvi->iItem, 2, tszName);
- ListView_SetItemText(HElv, lpLvi->iItem, 1, tszName);
+ t2 = T(2);
+ PI(t2,lpLvi->lParam) return;
+ P("episode_data","episode_rating",2,t2) {
+ ListView_SetItemText(HElv, lpLvi->iItem, 1, TEXT(""));
+ return;
+ }
+ GI(t2+1,&iRating) return;
+ _itot(iRating, tszRating, 10);
+ ListView_SetItemText(HElv, lpLvi->iItem, 1, tszRating);
}