aboutsummaryrefslogtreecommitdiff
path: root/c/datalistview.cpp
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-17 19:01:26 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-17 19:01:26 +0200
commit78fbe9fcba52cad4b4c36aca7c385b3a8f45824a (patch)
tree63c1c602fc76ec33bc1751efaea685946daee5fe /c/datalistview.cpp
parent853a598befbb8823c5868c792f51cda3466fada1 (diff)
downloadEpisodeBrowser-78fbe9fcba52cad4b4c36aca7c385b3a8f45824a.tar.gz
DataListView: Use file view.
Diffstat (limited to 'c/datalistview.cpp')
-rw-r--r--c/datalistview.cpp56
1 files changed, 28 insertions, 28 deletions
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 <SWI-Prolog.h>
#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<DlvDataA>) {
+ 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<wchar_t*>(v[i]);
+ ListView_InsertItem(hWnd, &lviKey);
+
+ lviValue.iItem = j;
+ lviValue.iSubItem = 1;
+ lviValue.pszText = const_cast<wchar_t*>(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);