def sendSqlClicked(self, sql_stat): from PyQt4.QtGui import QMessageBox from lunchinator.table_models import TableModelBase self.specialized_db_conn().insert_command(sql_stat) if None==self.db_connection: self.db_connection, _ = get_db_connection(self.logger, self.options["query_db_connection"]) try: header, res = self.db_connection.queryWithHeader(sql_stat) except Exception as e: QMessageBox.warning(self.resultTable,"Error in SQL statement",str(e)) # self.logger.warning("SQL error:") return False columns = [] for h in header: columns.append((h,self.empty)) mod = TableModelBase(None, columns, self.logger) self.times_called = 0 for i,r in enumerate(res): mod.appendContentRow(i, r) if i>1000: break self.resultTable.setModel(mod) for c in xrange(mod.columnCount()): self.resultTable.getTable().resizeColumnToContents(c) return True
def setData(self, index, value, role): if self._tristate and role == Qt.CheckStateRole: newState, _ = value.toInt() if newState == Qt.Checked: curState, _ = index.data(Qt.CheckStateRole).toInt() if curState == Qt.Unchecked: value = QVariant(Qt.PartiallyChecked) return TableModelBase.setData(self, index, value, role)
def externalRowRemoved(self, key): TableModelBase.externalRowRemoved(self, key)