self._history = history.RpnCalcHistory(
self._historyView,
- self._userEntry, self._errorDisplay,
+ self._userEntry, self._app.errorLog,
self._constantPlugins.constants, self._operatorPlugins.operators
)
self._load_history()
@misc_utils.log_exception(_moduleLogger)
def _on_child_close(self, something = None):
- self._child = None
+ with qui_utils.notify_error(self._app.errorLog):
+ self._child = None
@misc_utils.log_exception(_moduleLogger)
def _on_copy(self, *args):
- eqNode = self._historyView.peek()
- resultNode = eqNode.simplify()
- self._app._clipboard.setText(str(resultNode))
+ with qui_utils.notify_error(self._app.errorLog):
+ eqNode = self._historyView.peek()
+ resultNode = eqNode.simplify()
+ self._app._clipboard.setText(str(resultNode))
@misc_utils.log_exception(_moduleLogger)
def _on_paste(self, *args):
- result = str(self._app._clipboard.text())
- self._userEntry.append(result)
+ with qui_utils.notify_error(self._app.errorLog):
+ result = str(self._app._clipboard.text())
+ self._userEntry.append(result)
@misc_utils.log_exception(_moduleLogger)
def _on_entry_direct(self, keys, modifiers):
- if "shift" in modifiers:
- keys = keys.upper()
- self._userEntry.append(keys)
+ with qui_utils.notify_error(self._app.errorLog):
+ if "shift" in modifiers:
+ keys = keys.upper()
+ self._userEntry.append(keys)
@misc_utils.log_exception(_moduleLogger)
def _on_push(self, *args):
- self._history.push_entry()
+ with qui_utils.notify_error(self._app.errorLog):
+ self._history.push_entry()
@misc_utils.log_exception(_moduleLogger)
def _on_unpush(self, *args):
- self._historyView.unpush()
+ with qui_utils.notify_error(self._app.errorLog):
+ self._historyView.unpush()
@misc_utils.log_exception(_moduleLogger)
def _on_entry_backspace(self, *args):
- self._userEntry.pop()
+ with qui_utils.notify_error(self._app.errorLog):
+ self._userEntry.pop()
@misc_utils.log_exception(_moduleLogger)
def _on_entry_clear(self, *args):
- self._userEntry.clear()
+ with qui_utils.notify_error(self._app.errorLog):
+ self._userEntry.clear()
@misc_utils.log_exception(_moduleLogger)
def _on_clear_all(self, *args):
- self._history.clear()
+ with qui_utils.notify_error(self._app.errorLog):
+ self._history.clear()
def run():
self.__serialRenderer = operation.render_number()
@property
- def errorReporter(self):
- return self.__errorReporter
-
- @property
def OPERATIONS(self):
return self.__operations
node = self._apply_operation(Node)
return node
except StandardError, e:
- self.errorReporter.push_exception()
+ self.__errorReporter.push_exception()
return None
def serialize_stack(self):
http://helm.cs.unibo.it/mml-widget/ (MathML widget in C++)
"""
+from __future__ import with_statement
+
import logging
from PyQt4 import QtGui
def __init__(self, errorReporter):
super(QCalcHistory, self).__init__()
self._prettyRenderer = operation.render_number()
- self._errorReporter = errorReporter
+ self._errorLog = errorReporter
self._historyStore = QtGui.QStandardItemModel()
self._historyStore.setHorizontalHeaderLabels(["", "Equation", "Result"])
def toplevel(self):
return self._historyView
- @property
- def errorReporter(self):
- return self._errorReporter
-
def push(self, node):
simpleNode = node.simplify()
@misc_utils.log_exception(_moduleLogger)
def _on_row_activated(self, index):
- if index.column() == self._CLOSE_COLUMN:
- self._historyStore.removeRow(index.row(), index.parent())
- self._rowCount -= 1
- elif index.column() == self._EQ_COLUMN:
- self._duplicate_row(index)
- elif index.column() == self._RESULT_COLUMN:
- self._duplicate_row(index)
- else:
- raise NotImplementedError("Unsupported column to activate %s" % index.column())
+ with qui_utils.notify_error(self._errorLog):
+ if index.column() == self._CLOSE_COLUMN:
+ self._historyStore.removeRow(index.row(), index.parent())
+ self._rowCount -= 1
+ elif index.column() == self._EQ_COLUMN:
+ self._duplicate_row(index)
+ elif index.column() == self._RESULT_COLUMN:
+ self._duplicate_row(index)
+ else:
+ raise NotImplementedError("Unsupported column to activate %s" % index.column())
@misc_utils.log_exception(_moduleLogger)
def _on_item_changed(self, item):
- if self._programmaticUpdate:
- _moduleLogger.info("Blocking updating %r recursively" % item)
- return
- self._programmaticUpdate = True
- try:
- if item.column() in [self._EQ_COLUMN, self._RESULT_COLUMN]:
- self._update_input(item)
- else:
- raise NotImplementedError("Unsupported column to edit %s" % item.column())
- except StandardError, e:
- self.errorReporter.push_exception()
- finally:
- self._programmaticUpdate = False
+ with qui_utils.notify_error(self._errorLog):
+ if self._programmaticUpdate:
+ _moduleLogger.info("Blocking updating %r recursively" % item)
+ return
+ self._programmaticUpdate = True
+ try:
+ if item.column() in [self._EQ_COLUMN, self._RESULT_COLUMN]:
+ self._update_input(item)
+ else:
+ raise NotImplementedError("Unsupported column to edit %s" % item.column())
+ except StandardError, e:
+ self._errorReporter.push_exception()
+ finally:
+ self._programmaticUpdate = False
def _duplicate_row(self, index):
item = self._historyStore.item(index.row(), self._EQ_COLUMN)
@misc_utils.log_exception(_moduleLogger)
def _on_toggle_fullscreen(self, checked = False):
- self._mainWindow.set_fullscreen(checked)
+ with qui_utils.notify_error(self._errorLog):
+ self._mainWindow.set_fullscreen(checked)
@misc_utils.log_exception(_moduleLogger)
def _on_toggle_orientation(self, checked = False):
- self._mainWindow.set_orientation(checked)
+ with qui_utils.notify_error(self._errorLog):
+ self._mainWindow.set_orientation(checked)
@misc_utils.log_exception(_moduleLogger)
def _on_about(self, checked = True):
@misc_utils.log_exception(_moduleLogger)
def _on_log(self, checked = False):
- with open(self._constants._user_logpath_, "r") as f:
- logLines = f.xreadlines()
- log = "".join(logLines)
- self._clipboard.setText(log)
+ with qui_utils.notify_error(self._errorLog):
+ with open(self._constants._user_logpath_, "r") as f:
+ logLines = f.xreadlines()
+ log = "".join(logLines)
+ self._clipboard.setText(log)
@misc_utils.log_exception(_moduleLogger)
def _on_quit(self, checked = False):
- self._close_windows()
+ with qui_utils.notify_error(self._errorLog):
+ self._close_windows()
class WindowWrapper(object):
@misc_utils.log_exception(_moduleLogger)
def _on_close_window(self, checked = True):
- self.close()
+ with qui_utils.notify_error(self._errorLog):
+ self.close()