From 78fbe9fcba52cad4b4c36aca7c385b3a8f45824a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 17 Aug 2022 19:01:26 +0200 Subject: DataListView: Use file view. --- c/datalistview.cpp | 56 +++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'c/datalistview.cpp') diff --git a/c/datalistview.cpp b/c/datalistview.cpp index 6d3d79c..6e598f5 100644 --- a/c/datalistview.cpp +++ b/c/datalistview.cpp @@ -5,11 +5,11 @@ #include #include "resource.h" +#include "data.h" #include "datalistview.h" #include "episodelistview.h" #include "listview.h" #include "layout.h" -#include "pl.h" #include "wcharptr.h" DataListView::DataListView(const HWND hWndParent) @@ -53,35 +53,34 @@ void DataListView::SetHeight(int h) void DataListView::ShowEpisode(const int iEpisode) { - extern EpisodeListView* const g_elv; + const DlvDataA& d = m_fv[iEpisode]; ListView_DeleteAllItems(hWnd); - - Frame f; - const int arity = 3; - const term_t t = PL_new_term_refs(arity); - if (!PlPut(t, iEpisode)) return; - - Query q (nullptr, PL_predicate("episode_datum", arity, "episode_data"), t); - LVITEM lviKey = {LVIF_TEXT}; - LVITEM lviValue = {LVIF_TEXT}; - - for (int i = 0; q.NextSolution(std::nothrow); i++) { - WcharPtr key; - WcharPtr value; - - if (!(PlGet(t+1, &key) && PlGet(t+2, &value))) - continue; - - lviKey.iItem = i; - lviKey.iSubItem = 0; - lviKey.pszText = key; - ListView_InsertItem(hWnd, &lviKey); - - lviValue.iItem = i; - lviValue.iSubItem = 1; - lviValue.pszText = value; - ListView_SetItem(hWnd, &lviValue); + if (d.version == Version) { + const wchar_t* v[] = { + L"Date", d.date, + L"Source", d.source, + L"Hint", d.hint, + L"Screenwriter", d.screenwriter}; + + LVITEM lviKey = {LVIF_TEXT}; + LVITEM lviValue = {LVIF_TEXT}; + + for (size_t i = 0, j = 0; i < sizeof(v)/sizeof(*v); i += 2) { + if (v[i+1][0]) { + lviKey.iItem = j; + lviKey.iSubItem = 0; + lviKey.pszText = const_cast(v[i]); + ListView_InsertItem(hWnd, &lviKey); + + lviValue.iItem = j; + lviValue.iSubItem = 1; + lviValue.pszText = const_cast(v[i+1]); + ListView_SetItem(hWnd, &lviValue); + + j++; + } + } } UpdateLayout(); @@ -89,6 +88,7 @@ void DataListView::ShowEpisode(const int iEpisode) LVFINDINFO lvfi; lvfi.flags = LVFI_PARAM; lvfi.lParam = iEpisode; + extern EpisodeListView* const g_elv; int iItem = ListView_FindItem(g_elv->hWnd, -1, &lvfi); if (iItem != -1) ListView_EnsureVisible(g_elv->hWnd, iItem, TRUE); -- cgit v1.2.3