aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--c/datalistview.cpp13
-rw-r--r--c/episodelistview.cpp8
2 files changed, 10 insertions, 11 deletions
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 <sstream>
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>
@@ -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<TCHAR> tstrKey;
std::basic_string<TCHAR> 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<TCHAR> 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);
}