コード例 #1
0
ファイル: __init__.py プロジェクト: hannesrauhe/lunchinator
    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
コード例 #2
0
 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)
コード例 #3
0
 def externalRowRemoved(self, key):
     TableModelBase.externalRowRemoved(self, key)