diff options
-rw-r--r-- | c/data.cpp | 2 | ||||
-rw-r--r-- | c/episodelistview.cpp | 31 | ||||
-rw-r--r-- | c/util.h | 1 |
3 files changed, 18 insertions, 16 deletions
@@ -84,7 +84,6 @@ void FetchData() /* The episode data are contained in table rows matching a * (very!) specific XPath query. This is fragile * theoretically, but unlikely to break practically. */ - HtmlDocPtr doc = ctxt->myDoc; XmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc); XmlXPathObjectPtr xpathObj = xmlXPathEvalExpression( @@ -110,7 +109,6 @@ void FetchData() /* Each datum is contained within a specific cell in * the row. The child element count above ensures that * none of the following nodes are null. */ - const xmlNodePtr nodeEp = xmlFirstElementChild(node); const xmlNodePtr nodeTitle = xmlNextElementSibling(xmlNextElementSibling(nodeEp)); const xmlNodePtr nodeDate = xmlNextElementSibling(nodeTitle); diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp index 14aa192..645c11f 100644 --- a/c/episodelistview.cpp +++ b/c/episodelistview.cpp @@ -1,3 +1,4 @@ +#include <cassert> #include <vector> #include <windows.h> #include <commctrl.h> @@ -176,20 +177,11 @@ LRESULT EpisodeListView::HandleNotify(const LPARAM lParam) } case NM_DBLCLK: /* Open clicked episode. */ - { - LVITEM lvi = {LVIF_PARAM, -1}; - if (FindNextItem(&lvi, LVNI_FOCUSED)) - Pl("local_episodes","open_episode_locally",lvi.lParam) - || Pl("local_episodes","open_episode_online",lvi.lParam); - return 0; - } - case NM_RETURN: /* Open all selected episodes. */ { LVITEM lvi = {LVIF_PARAM, -1}; while (FindNextItem(&lvi, LVNI_SELECTED)) - Pl("local_episodes","open_episode_locally",lvi.lParam) - || Pl("local_episodes","open_episode_online",lvi.lParam); + OpenLocally(lvi.lParam) || OpenOnline(lvi.lParam); return 0; } @@ -270,6 +262,8 @@ void EpisodeListView::SetTop(const int iItem) void EpisodeListView::SelectUnwatched(int dir) { + dir = dir > 0? 1: -1; + /* Get focused episode. */ LVITEM lviFocus = {LVIF_PARAM, -1}; if (!FindNextItem(&lviFocus, LVNI_FOCUSED)) @@ -282,13 +276,22 @@ void EpisodeListView::SelectUnwatched(int dir) lvfi.lParam = lviFocus.lParam; do { - if (!Pl("track_episodes",dir > 0? "next_unwatched": "previous_unwatched", - lvfi.lParam,&iEpNew)) - return; + /* Loop through episodes to find next/previous + * unwatched episode. */ + iEpNew = lvfi.lParam; + for (;;) { + iEpNew += dir; + if (iEpNew == 0 || iEpNew == g_cfg.cEp || !g_fvElv[iEpNew-1].siEp[0]) + return; + if (!g_fvElv[iEpNew-1].bWatched) + break; + } + /* Select the episode, if it is in the list view. If + * not, try again a thousand times. */ lvfi.lParam = iEpNew; if ((iItemNew = ListView_FindItem(hWnd, -1, &lvfi)) != -1) { - ListView_SetItemState(hWnd,-1,LVIF_STATE,LVIS_SELECTED); + ListView_SetItemState(hWnd, -1, LVIF_STATE, LVIS_SELECTED); ListView_SetSelectionMark(hWnd, iItemNew); ListView_SetItemState(hWnd, iItemNew, LVIS_SELECTED|LVIS_FOCUSED, @@ -23,6 +23,7 @@ inline int Cmp(const int a, const int b) return -1; } +/* Generic RAII type. */ template <typename T, auto F, typename U, auto E = 0> struct Managed { |