def _on_table_show(self): self._tableWidget.clear() try: data = Query.select(self._query_sid, **self._filters) except Exception, err: QtGui.QMessageBox(QtGui.QMessageBox.Critical, self._tableWidget.tr('ERROR'), unicode(err), QtGui.QMessageBox.Ok, self._tableWidget).exec_() return
def __init__(self, query_sid, **filters): QueryTableWraper.__init__(self, query_sid, **filters) self.__offset = 0 try: self.__cursor = Query.make_cursor(query_sid, **filters) except Exception, err: print err #TODO: show message box with error message
def _on_table_show(self): if self.__cursor.closed: return rowCount = self._tableWidget.rowCount() try: data = Query.fetch_cursor(self.__cursor, self.__offset, self.__count) except Exception, err: QtGui.QMessageBox(QtGui.QMessageBox.Critical, self._tableWidget.tr('ERROR'), unicode(err), QtGui.QMessageBox.Ok, self._tableWidget).exec_() return
def _on_table_show(self): if self.__cursor.closed: return rowCount = self._tableWidget.rowCount() try: data = Query.fetch_cursor(self.__cursor, self.__offset, self.__count) except Exception, err: QtGui.QMessageBox(QtGui.QMessageBox.Critical, self._tableWidget.tr('ERROR'), unicode(err), QtGui.QMessageBox.Ok, self._tableWidget).exec_() return self.__offset += len(data) if len(data) != self.__count: Query.close_cursor(self.__cursor) self.__tableWidget.setRowCount( rowCount + len(data) ) for i, item in enumerate(data): for j, row_name in enumerate(self.__fields_map): self._tableWidget.setItem(rowCount+i, j, QTableWidgetItem(str(item[row_name]))) for key in self._hidden_fields: self._tableWidget.setItem(rowCount+i, self._fields[key], QTableWidgetItem(str(item[key]))) def __on_table_scroll(self, event=None): if type(event) == QtGui.QKeyEvent and (event.key() not in [QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown]): return QTableWidget.keyReleaseEvent(self._tableWidget, event)