def _build_html(self):
n_widgets = len(self.widget_list_items)
if not n_widgets:
self.report_view.setHtml("")
return
selected_row = self.widget_list.currentRow()
if selected_row < 0 and n_widgets:
selected_row = n_widgets - 1
self.widget_list.setCurrentRow(selected_row)
html = self.report_html_template
html += "<body>"
for i, (item_name, item_icon) in enumerate(self.widget_list_items):
html += "<div id="%s" class="%s">%s</div>" % (
id(item_icon),
"selected" if i == selected_row else "normal",
self.report_view_items[(item_name, item_icon)]
)