#include #include #include #include #include "resource.h" #include "common.h" #include "datalistview.h" #include "episodelistview.h" #include "listview.h" #include "main.h" #include "pl.h" extern EpisodeListView *g_lpElv; DataListView::DataListView(const HWND hWndParent) : ListView(hWndParent, (HMENU)IDC_DATALISTVIEW, LVS_NOCOLUMNHEADER) { LVCOLUMN lvc; lvc.mask = LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM; lvc.iSubItem = DLVSIKEY; lvc.pszText = TEXT("Key"); lvc.cx = Dpi(42); ListView_InsertColumn(m_hWnd, DLVSIKEY, &lvc); lvc.iSubItem = DLVSIVALUE; lvc.pszText = TEXT("Value"); lvc.cx = 500; ListView_InsertColumn(m_hWnd, DLVSIVALUE, &lvc); } void DataListView::ShowEpisode(const int iEpisode) { ListView_DeleteAllItems(m_hWnd); LVITEM lviKey, lviValue; lviKey.mask = LVIF_TEXT; lviValue.mask = LVIF_TEXT; const term_t t = PL_new_term_refs(3); if (!PL_put_integer(t,iEpisode)) return; const qid_t q = PL_open_query(NULL, PL_Q_NORMAL, PL_predicate("episode_datum", 3, "episode_data"), t); for (int i = 0; PL_next_solution(q); i++) { TCHAR *tszKey; TCHAR *tszValue; if (!(PlGet(t+1, &tszKey) && PlGet(t+2, &tszValue))) continue; lviKey.mask = LVIF_TEXT; lviKey.iItem = i; lviKey.iSubItem = 0; lviKey.pszText = tszKey; ListView_InsertItem(m_hWnd, &lviKey); lviValue.iItem = i; lviValue.iSubItem = 1; lviValue.pszText = tszValue; ListView_SetItem(m_hWnd, &lviValue); } PL_cut_query(q); UpdateLayout(); LVFINDINFO lvfi; lvfi.flags = LVFI_PARAM; lvfi.lParam = iEpisode; int iItem = ListView_FindItem(g_lpElv->Handle(), -1, &lvfi); if (iItem != -1) ListView_EnsureVisible(g_lpElv->Handle(), iItem, TRUE); }