def push(self, node): simpleNode = node.simplify() closeIcon = self._closeIcon icon = QtGui.QStandardItem(closeIcon, "") icon.setEditable(False) icon.setCheckable(False) equation = QtGui.QStandardItem(operation.render_operation(self._prettyRenderer, node)) equation.setData(node) equation.setCheckable(False) eqFont = equation.font() eqFont.setPointSize(max(eqFont.pointSize() - 3, 5)) equation.setFont(eqFont) result = QtGui.QStandardItem(operation.render_operation(self._prettyRenderer, simpleNode)) result.setData(simpleNode) result.setEditable(False) result.setCheckable(False) row = (icon, equation, result) self._historyStore.appendRow(row) index = result.index() self._historyView.scrollToBottom() self._rowCount += 1
def push(self, node): simpleNode = node.simplify() self.__historyStore.append([ gtk.STOCK_CLOSE, operation.render_operation(self.__prettyRenderer, node), operation.render_operation(self.__prettyRenderer, simpleNode), node, simpleNode ]) selection = self._historyView.get_selection() selectionPath = (len(self.__historyStore)-1, ) selection.select_path(selectionPath) self._historyView.scroll_to_cell(selectionPath)
def _update_input(self, item): node = item.data() try: eqNode = self._parse_value(str(item.text())) newText = operation.render_operation(self._prettyRenderer, eqNode) eqItem = self._historyStore.item(item.row(), self._EQ_COLUMN) eqItem.setData(eqNode) eqItem.setText(newText) resultNode = eqNode.simplify() resultText = operation.render_operation(self._prettyRenderer, resultNode) resultItem = self._historyStore.item(item.row(), self._RESULT_COLUMN) resultItem.setData(resultNode) resultItem.setText(resultText) except: oldText = operation.render_operation(self._prettyRenderer, node) item.setText(oldText) raise