From 3a133c4063cbb81bee9f5bc55427be75d8e584e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sun, 24 Jul 2022 02:04:38 +0200 Subject: Use Query object in DataListView::ShowEpisode. --- c/datalistview.cpp | 13 +++++++------ c/episodelistview.cpp | 8 +++----- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'c') diff --git a/c/datalistview.cpp b/c/datalistview.cpp index 82b62e6..a1bb255 100644 --- a/c/datalistview.cpp +++ b/c/datalistview.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -48,12 +49,13 @@ void DataListView::ShowEpisode(const int iEpisode) lviValue.mask = LVIF_TEXT; Frame f; - 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); + const int iArity = 3; + const term_t t = PL_new_term_refs(iArity); + if (!PlPut(t, iEpisode)) return; - for (int i = 0; PL_next_solution(q); i++) { + Query q (NULL, PL_predicate("episode_datum", iArity, "episode_data"), t); + + for (int i = 0; q.NextSolution(); i++) { std::basic_string tstrKey; std::basic_string tstrValue; @@ -72,7 +74,6 @@ void DataListView::ShowEpisode(const int iEpisode) ListView_SetItem(hWnd, &lviValue); } - PL_cut_query(q); UpdateLayout(); LVFINDINFO lvfi; diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp index 7b9653e..5de5e2e 100644 --- a/c/episodelistview.cpp +++ b/c/episodelistview.cpp @@ -431,21 +431,19 @@ void EpisodeListView::Update() void EpisodeListView::UpdateItem(const LVITEM* const pLvi) { std::basic_string tstrName; - int iRating; - static TCHAR tszRating[3]; - if (!Pl("episode_data","episode_title",pLvi->lParam,&tstrName)) { if (!Pl("episode_data","update_episode_data")) goto r; - if (!Pl("episode_data","episode_title",pLvi->lParam,&tstrName)) - goto r; + if (!Pl("episode_data","episode_title",pLvi->lParam,&tstrName)) goto r; } ListView_SetItemText(hWnd, pLvi->iItem, ELVSITITLE, tstrName.data()); + int iRating; r: if (!Pl("episode_data","episode_rating",pLvi->lParam,&iRating)) { ListView_SetItemText(hWnd, pLvi->iItem, ELVSIRATING, (TCHAR*)TEXT("")); return; } + TCHAR tszRating[3]; _stprintf_s(tszRating, sizeof(tszRating), TEXT("%d"), iRating); ListView_SetItemText(hWnd, pLvi->iItem, ELVSIRATING, tszRating); } -- cgit v1.2.3