aboutsummaryrefslogtreecommitdiff
path: root/c/episodelistview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c/episodelistview.cpp')
-rw-r--r--c/episodelistview.cpp44
1 files changed, 18 insertions, 26 deletions
diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp
index 132941c..0c8c60d 100644
--- a/c/episodelistview.cpp
+++ b/c/episodelistview.cpp
@@ -51,9 +51,7 @@ LRESULT EpisodeListView::HandleNotify(const LPARAM lParam)
if ((pNmLv->uChanged & LVIF_STATE) &&
(pNmLv->uNewState & LVIS_FOCUSED)) {
extern DataListView* const g_pDlv;
- m_lviFocus.iItem = pNmLv->iItem;
- m_lviFocus.lParam = pNmLv->lParam;
- UpdateItem(&m_lviFocus);
+ UpdateItem(pNmLv->iItem, pNmLv->lParam);
g_pDlv->ShowEpisode(pNmLv->lParam);
}
break;
@@ -100,23 +98,19 @@ LRESULT EpisodeListView::HandleNotify(const LPARAM lParam)
}
case NM_DBLCLK: /* Open clicked episode. */
{
- if (!Pl("local_episodes","open_episode_locally",
- m_lviFocus.lParam))
- Pl("local_episodes","open_episode_online",
- m_lviFocus.lParam);
+ 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);
break;
}
case NM_RETURN: /* Open all selected episodes. */
{
LVITEM lvi = {LVIF_PARAM, -1};
- while (FindNextItem(&lvi, LVNI_SELECTED)) {
- if (!ListView_GetItem(hWnd, &lvi)) goto b;
- if (!Pl("local_episodes","open_episode_locally",
- lvi.lParam))
- Pl("local_episodes","open_episode_online",
- lvi.lParam);
- }
- b: break;
+ while (FindNextItem(&lvi, LVNI_SELECTED))
+ Pl("local_episodes","open_episode_locally",lvi.lParam)
+ || Pl("local_episodes","open_episode_online",lvi.lParam);
+ break;
}
case NM_RCLICK:
{
@@ -176,9 +170,7 @@ s: ListView_SetItemState(hWnd, -1, LVIF_STATE, LVIS_SELECTED);
SetTop(iItem > 5? iItem-5: 0);
ListView_SetItemState(hWnd, iItem,
LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
- m_lviFocus.iItem = iItem;
- m_lviFocus.lParam = iEpisode;
- UpdateItem(&m_lviFocus);
+ UpdateItem(iItem, iEpisode);
g_pDlv->ShowEpisode(iEpisode);
}
@@ -353,7 +345,7 @@ void EpisodeListView::Update()
lviEpisode.pszText = wszEpisode;
lviEpisode.lParam = iEp;
ListView_InsertItem(hWnd, &lviEpisode);
- UpdateItem(&lviEpisode);
+ UpdateItem(lviEpisode.iItem, lviEpisode.lParam);
}
}
@@ -410,24 +402,24 @@ void EpisodeListView::Update()
}
/* Update episode name and rating. */
-void EpisodeListView::UpdateItem(const LVITEM* const pLvi)
+void EpisodeListView::UpdateItem(const int iItem, const LPARAM lParam)
{
wstring_owner wsoName;
- if (!Pl("episode_data","episode_title",pLvi->lParam,&wsoName)) {
+ if (!Pl("episode_data","episode_title",lParam,&wsoName)) {
if (!Pl("episode_data","update_episode_data")) goto r;
- if (!Pl("episode_data","episode_title",pLvi->lParam,&wsoName)) goto r;
+ if (!Pl("episode_data","episode_title",lParam,&wsoName)) goto r;
}
- ListView_SetItemText(hWnd, pLvi->iItem, ELVSITITLE, wsoName.p);
+ ListView_SetItemText(hWnd, iItem, ELVSITITLE, wsoName.p);
r: int iRating;
- if (!Pl("episode_data","episode_rating",pLvi->lParam,&iRating)) {
- ListView_SetItemText(hWnd, pLvi->iItem, ELVSIRATING, (wchar_t*)L"");
+ if (!Pl("episode_data","episode_rating",lParam,&iRating)) {
+ ListView_SetItemText(hWnd, iItem, ELVSIRATING, (wchar_t*)L"");
return;
}
wchar_t wszRating[3];
swprintf_s(wszRating, sizeof(wszRating)/sizeof(*wszRating), L"%d", iRating);
- ListView_SetItemText(hWnd, pLvi->iItem, ELVSIRATING, wszRating);
+ ListView_SetItemText(hWnd, iItem, ELVSIRATING, wszRating);
}
LRESULT CALLBACK EpisodeListView::WndProc(const HWND hWnd, const UINT uMsg,