aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--c/episodelistview.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/c/episodelistview.c b/c/episodelistview.c
index 985a8ca..780633c 100644
--- a/c/episodelistview.c
+++ b/c/episodelistview.c
@@ -166,16 +166,29 @@ s: ListView_SetItemState(HElv, -1, LVIF_STATE, LVIS_SELECTED);
void
ElvUpdate()
{
- int i, iEpisode, iEpisodes, iItem, iItemFound;
- LVITEM lviEpisode, lviTop;
- LVFINDINFO lvfiTopNew;
+ int i, iEpisode, iEpisodes, iEpisodeSelected[2048], iItem, iItemTopNew;
+ LVITEM lviEpisode, lviSelected, lviTop;
+ LVFINDINFO lvfi;
term_t t;
lviEpisode.mask = LVIF_TEXT|LVIF_PARAM;
+
+ /* Save scrolling position. */
lviTop.iItem = ListView_GetTopIndex(HElv);
lviTop.mask = LVIF_PARAM;
ListView_GetItem(HElv, &lviTop);
+ /* Save selected episodes. */
+ i = 0;
+ lviSelected.mask = LVIF_PARAM;
+ lviSelected.iItem = -1;
+ while ((lviSelected.iItem = ListView_GetNextItem(
+ HElv, lviSelected.iItem, LVNI_SELECTED)) != -1) {
+ if (!ListView_GetItem(HElv, &lviSelected)) continue;
+ iEpisodeSelected[i++] = lviSelected.lParam;
+ }
+ iEpisodeSelected[i] = 0;
+
SendMessage(HElv, WM_SETREDRAW, FALSE, 0);
ListView_DeleteAllItems(HElv);
@@ -214,26 +227,24 @@ ElvUpdate()
free(tszEpisode);
}
+ lvfi.flags = LVFI_PARAM;
+
/* Reset scrolling position (roughly). */
i = 0;
- lvfiTopNew.flags = LVFI_PARAM;
do
- lvfiTopNew.lParam = lviTop.lParam+i;
- while ((iItemFound = ListView_FindItem(HElv, -1, &lvfiTopNew)) == -1
+ lvfi.lParam = lviTop.lParam+i;
+ while ((iItemTopNew = ListView_FindItem(HElv, -1, &lvfi)) == -1
&& i++ < 100);
- if (iItemFound != -1)
- ElvSetTop(iItemFound);
+ if (iItemTopNew != -1)
+ ElvSetTop(iItemTopNew);
/* Reset selection. */
- i = 0;
- lvfiTopNew.flags = LVFI_PARAM;
- do
- lvfiTopNew.lParam = LpLviElvSelection->lParam+i;
- while ((iItemFound = ListView_FindItem(HElv, -1, &lvfiTopNew)) == -1
- && i++ < 100);
- if (LpLviElvSelection)
- ListView_SetItemState(HElv, iItemFound,
- LVIS_SELECTED, LVIS_SELECTED);
+ for (i = 0; iEpisodeSelected[i]; i++) {
+ int iSel;
+ lvfi.lParam = iEpisodeSelected[i];
+ if ((iSel = ListView_FindItem(HElv, -1, &lvfi)) == -1) break;
+ ListView_SetItemState(HElv, iSel, LVIS_SELECTED, LVIS_SELECTED);
+ }
SendMessage(HElv, WM_SETREDRAW, TRUE, 0);
ElvRedraw();