aboutsummaryrefslogtreecommitdiff
path: root/c/episodelistview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c/episodelistview.cpp')
-rw-r--r--c/episodelistview.cpp146
1 files changed, 73 insertions, 73 deletions
diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp
index ffd8879..1c5c9ae 100644
--- a/c/episodelistview.cpp
+++ b/c/episodelistview.cpp
@@ -31,8 +31,8 @@ EpisodeListView::EpisodeListView(const HWND hWndParent)
lvc.cx = Dpi(30);
ListView_InsertColumn(hWnd, ELVSIRATING, &lvc);
- if (!Pl("cfg","get_sort",&m_iSort))
- m_iSort = 1;
+ if (!Pl("cfg","get_sort",&m_iSortCol))
+ m_iSortCol = 1;
}
void EpisodeListView::EnsureFocusVisible()
@@ -44,30 +44,30 @@ void EpisodeListView::EnsureFocusVisible()
LRESULT EpisodeListView::HandleNotify(const LPARAM lParam)
{
- const NMLISTVIEW* const pNmLv = (NMLISTVIEW*)lParam;
+ const NMLISTVIEW* const nm = (NMLISTVIEW*)lParam;
- switch (pNmLv->hdr.code) {
+ switch (nm->hdr.code) {
case LVN_ITEMCHANGED: /* Select/focus episode. */
- if ((pNmLv->uChanged & LVIF_STATE) &&
- (pNmLv->uNewState & LVIS_FOCUSED)) {
- extern DataListView* const g_pDlv;
- UpdateItem(pNmLv->iItem, pNmLv->lParam);
- g_pDlv->ShowEpisode(pNmLv->lParam);
+ if ((nm->uChanged & LVIF_STATE) &&
+ (nm->uNewState & LVIS_FOCUSED)) {
+ extern DataListView* const g_dlv;
+ UpdateItem(nm->iItem, nm->lParam);
+ g_dlv->ShowEpisode(nm->lParam);
}
break;
case LVN_COLUMNCLICK: /* Sort by column. */
{
- const int iColumn = pNmLv->iSubItem+1;
- m_iSort = abs(m_iSort) == iColumn? -m_iSort: iColumn;
- Pl("cfg","set_sort",m_iSort);
+ const int iColumn = nm->iSubItem+1;
+ m_iSortCol = abs(m_iSortCol) == iColumn? -m_iSortCol: iColumn;
+ Pl("cfg","set_sort",m_iSortCol);
Sort();
ShowFocus();
break;
}
case LVN_KEYDOWN: /* Navigate episodes by keyboard. */
{
- const NMLVKEYDOWN *const pNmLvKd = (NMLVKEYDOWN*)lParam;
- switch (pNmLvKd->wVKey) {
+ const NMLVKEYDOWN *const nm = (NMLVKEYDOWN*)lParam;
+ switch (nm->wVKey) {
case VK_LEFT:
SelectUnwatched(-1);
break;
@@ -79,16 +79,16 @@ LRESULT EpisodeListView::HandleNotify(const LPARAM lParam)
}
case NM_CUSTOMDRAW: /* Make unwatched episodes bold. */
{
- const NMLVCUSTOMDRAW* const pLvCd = (NMLVCUSTOMDRAW*)lParam;
- switch (pLvCd->nmcd.dwDrawStage) {
+ const NMLVCUSTOMDRAW* const nm = (NMLVCUSTOMDRAW*)lParam;
+ switch (nm->nmcd.dwDrawStage) {
case CDDS_PREPAINT:
return CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
{
extern HFONT g_hfBold;
- if (!Pl("track_episodes","watched",pLvCd->nmcd.lItemlParam)) {
- require(SelectObject(pLvCd->nmcd.hdc, g_hfBold));
+ if (!Pl("track_episodes","watched",nm->nmcd.lItemlParam)) {
+ require(SelectObject(nm->nmcd.hdc, g_hfBold));
return CDRF_NEWFONT;
}
break;
@@ -114,10 +114,10 @@ LRESULT EpisodeListView::HandleNotify(const LPARAM lParam)
}
case NM_RCLICK:
{
- extern HMENU g_hPopupMenu;
- const DWORD dwPos = GetMessagePos();
- require(TrackPopupMenu(g_hPopupMenu, TPM_RIGHTBUTTON,
- LOWORD(dwPos), HIWORD(dwPos), 0,
+ extern HMENU g_hMenuPopup;
+ const DWORD pos = GetMessagePos();
+ require(TrackPopupMenu(g_hMenuPopup, TPM_RIGHTBUTTON,
+ LOWORD(pos), HIWORD(pos), 0,
m_hWndParent, (const RECT*)NULL));
break;
}
@@ -135,10 +135,10 @@ void EpisodeListView::Redraw()
void EpisodeListView::ResizeColumns(int w)
{
ListView_SetColumnWidth(hWnd, ELVSIEPISODE, LVSCW_AUTOSIZE);
- int cxColumn = ListView_GetColumnWidth(hWnd, ELVSIEPISODE)+Dpi(4);
- ListView_SetColumnWidth(hWnd, ELVSIEPISODE, cxColumn);
- cxColumn += ListView_GetColumnWidth(hWnd, ELVSIRATING);
- ListView_SetColumnWidth(hWnd, ELVSITITLE, w-cxColumn-Metric<SM_CXVSCROLL>-Dpi(4));
+ int cx = ListView_GetColumnWidth(hWnd, ELVSIEPISODE)+Dpi(4);
+ ListView_SetColumnWidth(hWnd, ELVSIEPISODE, cx);
+ cx += ListView_GetColumnWidth(hWnd, ELVSIRATING);
+ ListView_SetColumnWidth(hWnd, ELVSITITLE, w-cx-Metric<SM_CXVSCROLL>-Dpi(4));
}
/* Select previously focused episode. */
@@ -146,7 +146,7 @@ void EpisodeListView::RestoreFocus()
{
int i, iEpisode, iItem;
LVFINDINFO lvfi;
- extern DataListView* const g_pDlv;
+ extern DataListView* const g_dlv;
iItem = 0;
if (!Pl("cfg","get_focus",&iEpisode)) return;
@@ -167,7 +167,7 @@ void EpisodeListView::RestoreFocus()
return;
s: UpdateItem(iItem, iEpisode);
- g_pDlv->ShowEpisode(iEpisode);
+ g_dlv->ShowEpisode(iEpisode);
ListView_SetItemState(hWnd, -1, LVIF_STATE, LVIS_SELECTED);
SetTop(iItem > 5? iItem-5: 0);
ListView_SetItemState(hWnd, iItem,
@@ -183,13 +183,13 @@ void EpisodeListView::SaveFocus()
void EpisodeListView::SetTop(const int iItem)
{
- const int iLast = ListView_GetItemCount(hWnd)-1;
- ListView_EnsureVisible(hWnd, iLast, TRUE);
+ const int iItemLast = ListView_GetItemCount(hWnd)-1;
+ ListView_EnsureVisible(hWnd, iItemLast, TRUE);
ListView_EnsureVisible(hWnd, iItem, TRUE);
}
/* Select next/previous unwatched episode. */
-void EpisodeListView::SelectUnwatched(int iDir)
+void EpisodeListView::SelectUnwatched(int dir)
{
/* Get focused episode. */
LVITEM lviFocus = {LVIF_PARAM, -1};
@@ -203,7 +203,7 @@ void EpisodeListView::SelectUnwatched(int iDir)
lvfi.lParam = lviFocus.lParam;
do {
- if (!Pl("track_episodes",iDir > 0? "next_unwatched": "previous_unwatched",
+ if (!Pl("track_episodes",dir > 0? "next_unwatched": "previous_unwatched",
lvfi.lParam,&iEpNew))
return;
@@ -233,47 +233,47 @@ void EpisodeListView::Sort()
ListView_SortItemsEx(hWnd, EpisodeListView::SortProc, (LPARAM)this);
}
-int CALLBACK EpisodeListView::SortProc(const LPARAM iItem1, const LPARAM iItem2, const LPARAM lExtra)
+int CALLBACK EpisodeListView::SortProc(const LPARAM iItem1, const LPARAM iItem2, const LPARAM extra)
{
- EpisodeListView* const pElv = (EpisodeListView*)lExtra;
+ EpisodeListView* const elv = (EpisodeListView*)extra;
LVITEM lvi1 = {LVIF_PARAM, (int)iItem1};
- if (!ListView_GetItem(pElv->hWnd, &lvi1)) return 0;
+ if (!ListView_GetItem(elv->hWnd, &lvi1)) return 0;
LVITEM lvi2 = {LVIF_PARAM, (int)iItem2};
- if (!ListView_GetItem(pElv->hWnd, &lvi2)) return 0;
+ if (!ListView_GetItem(elv->hWnd, &lvi2)) return 0;
- /* abs(m_iSort) is the 1-based index of the column to sort by.
- * If m_iSort is negative, the order is descending. */
- const int iOrder = Cmp(pElv->m_iSort, 0);
+ /* abs(m_iSortCol) is the 1-based index of the column to sort by.
+ * If m_iSortCol is negative, the order is descending. */
+ const int order = Cmp(elv->m_iSortCol, 0);
- switch (abs(pElv->m_iSort)-1) {
+ switch (abs(elv->m_iSortCol)-1) {
case ELVSIEPISODE:
- return iOrder*Cmp(lvi1.lParam, lvi2.lParam);
+ return order*Cmp(lvi1.lParam, lvi2.lParam);
case ELVSIRATING:
{
- int iRating1, iRating2;
- iRating1 = pElv->m_iSort > 0? 99: -1;
- iRating2 = pElv->m_iSort > 0? 99: -1;
- Pl("episode_data","episode_rating",lvi1.lParam,&iRating1);
- Pl("episode_data","episode_rating",lvi2.lParam,&iRating2);
- if (iRating1 == iRating2)
+ int rating1, rating2;
+ rating1 = elv->m_iSortCol > 0? 99: -1;
+ rating2 = elv->m_iSortCol > 0? 99: -1;
+ Pl("episode_data","episode_rating",lvi1.lParam,&rating1);
+ Pl("episode_data","episode_rating",lvi2.lParam,&rating2);
+ if (rating1 == rating2)
return Cmp(lvi1.lParam, lvi2.lParam);
- return iOrder*Cmp(iRating1, iRating2);
+ return order*Cmp(rating1, rating2);
}
case ELVSITITLE:
{
Mark m;
- wstring_owner wso1, wso2;
+ wstring_owner s1, s2;
int cch, cch1, cch2;
- if (!Pl("episode_data","episode_title",lvi1.lParam,&wso1))
+ if (!Pl("episode_data","episode_title",lvi1.lParam,&s1))
return 0;
- if (!Pl("episode_data","episode_title",lvi2.lParam,&wso2))
+ if (!Pl("episode_data","episode_title",lvi2.lParam,&s2))
return 0;
- cch1 = wcslen(wso1.p);
- cch2 = wcslen(wso2.p);
+ cch1 = wcslen(s1.p);
+ cch2 = wcslen(s2.p);
cch = cch1 > cch2? cch2: cch1;
- return iOrder*_wcsnicmp(wso1.p, wso2.p, cch);
+ return order*_wcsnicmp(s1.p, s2.p, cch);
}
default:
return 0;
@@ -320,15 +320,15 @@ void EpisodeListView::Update()
int cItem = 0;
{
- wchar_t wszEpisode[16];
+ wchar_t siEp[16];
LVITEM lviEpisode = {LVIF_TEXT|LVIF_PARAM};
for (int iEp = 1; iEp <= cEp; iEp++) {
- extern char g_szLimitScreenwriter[];
+ extern char g_currentScreenwriter[];
extern int g_bViewTVOriginal, g_bViewWatched;
- if (g_szLimitScreenwriter[0]
+ if (g_currentScreenwriter[0]
&& !Pl("episode_data","episode_datum",
- iEp,"Screenwriter",g_szLimitScreenwriter))
+ iEp,"Screenwriter",g_currentScreenwriter))
continue;
if (!g_bViewWatched)
@@ -337,12 +337,12 @@ void EpisodeListView::Update()
if (!g_bViewTVOriginal)
if (Pl("episode_data","tv_original",iEp)) continue;
- swprintf_s(wszEpisode, sizeof(wszEpisode)/sizeof(*wszEpisode), L"%d", iEp);
+ swprintf_s(siEp, sizeof(siEp)/sizeof(*siEp), L"%d", iEp);
/* Insert item. */
lviEpisode.iItem = cItem++;
lviEpisode.iSubItem = ELVSIEPISODE;
- lviEpisode.pszText = wszEpisode;
+ lviEpisode.pszText = siEp;
lviEpisode.lParam = iEp;
ListView_InsertItem(hWnd, &lviEpisode);
UpdateItem(lviEpisode.iItem, lviEpisode.lParam);
@@ -394,9 +394,9 @@ void EpisodeListView::Update()
/* Show number of displayed items in status bar. */
extern HWND g_hWndStatus;
- wchar_t wszDisp[16];
- swprintf_s(wszDisp, sizeof(wszDisp)/sizeof(*wszDisp), L"%d", cItem);
- SendMessage(g_hWndStatus, SB_SETTEXT, MAKEWPARAM(1,0), (LPARAM)wszDisp);
+ wchar_t disp[16];
+ swprintf_s(disp, sizeof(disp)/sizeof(*disp), L"%d", cItem);
+ SendMessage(g_hWndStatus, SB_SETTEXT, MAKEWPARAM(1,0), (LPARAM)disp);
SendMessage(hWnd, WM_SETREDRAW, TRUE, 0);
}
@@ -404,22 +404,22 @@ void EpisodeListView::Update()
/* Update episode name and rating. */
void EpisodeListView::UpdateItem(const int iItem, const LPARAM lParam)
{
- wstring_owner wsoName;
- if (!Pl("episode_data","episode_title",lParam,&wsoName)) {
+ wstring_owner name;
+ if (!Pl("episode_data","episode_title",lParam,&name)) {
if (!Pl("episode_data","update_episode_data")) goto r;
- if (!Pl("episode_data","episode_title",lParam,&wsoName)) goto r;
+ if (!Pl("episode_data","episode_title",lParam,&name)) goto r;
}
- ListView_SetItemText(hWnd, iItem, ELVSITITLE, wsoName.p);
+ ListView_SetItemText(hWnd, iItem, ELVSITITLE, name.p);
-r: int iRating;
- if (!Pl("episode_data","episode_rating",lParam,&iRating)) {
+r: int rating;
+ if (!Pl("episode_data","episode_rating",lParam,&rating)) {
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, iItem, ELVSIRATING, wszRating);
+ wchar_t sRating[3];
+ swprintf_s(sRating, sizeof(sRating)/sizeof(*sRating), L"%d", rating);
+ ListView_SetItemText(hWnd, iItem, ELVSIRATING, sRating);
}
LRESULT CALLBACK EpisodeListView::WndProc(const HWND hWnd, const UINT uMsg,
@@ -433,7 +433,7 @@ LRESULT CALLBACK EpisodeListView::WndProc(const HWND hWnd, const UINT uMsg,
* along to the main window procedure, so that it may be
* handled by the NM_RETURN case in HandleNotify. */
- const LRESULT lResult = CallWindowProc(m_prevProc, hWnd, uMsg, wParam, lParam);
+ const LRESULT lResult = CallWindowProc(m_proc0, hWnd, uMsg, wParam, lParam);
if (lParam && ((MSG*)lParam)->message == WM_KEYDOWN
&& ((MSG*)lParam)->wParam == VK_RETURN)
return DLGC_WANTMESSAGE;