Skip to content

Commit

Permalink
owreport: disable save and print for empty report
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcv committed Jul 31, 2018
1 parent 84e1c87 commit ba02a6d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Orange/widgets/report/owreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ def _setup_ui_(self):
box = gui.hBox(self.controlArea)
box.setContentsMargins(-6, 0, -6, 0)
self.save_button = gui.button(
box, self, "Save", callback=self.save_report
box, self, "Save", callback=self.save_report, disabled=True
)
self.print_button = gui.button(
box, self, "Print", callback=self._print_report
box, self, "Print", callback=self._print_report, disabled=True
)

class PyBridge(QObject):
Expand Down Expand Up @@ -232,11 +232,13 @@ def _table_selection_changed(self, new_selection, _):

def _remove_item(self, row):
self.table_model.removeRow(row)
self._empty_report()
self.report_changed = True
self._build_html()

def clear(self):
self.table_model.clear()
self._empty_report()
self.report_changed = True
self._build_html()

Expand All @@ -246,9 +248,15 @@ def _add_item(self, widget):
item = ReportItem(name, widget.report_html, self._get_scheme(),
widget.__module__, widget.icon)
self.table_model.add_item(item)
self._empty_report()
self.report_changed = True
return item

def _empty_report(self):
# disable save and print if no reports
self.save_button.setEnabled(self.table_model.rowCount())
self.print_button.setEnabled(self.table_model.rowCount())

def _build_html(self):
html = self.report_html_template
html += "<body>"
Expand Down

0 comments on commit ba02a6d

Please sign in to comment.