40 self.table.addAction(self.deleteRowAction) |
40 self.table.addAction(self.deleteRowAction) |
41 |
41 |
42 if len(QSqlDatabase.drivers()) == 0: |
42 if len(QSqlDatabase.drivers()) == 0: |
43 E5MessageBox.information( |
43 E5MessageBox.information( |
44 self, |
44 self, |
45 self.trUtf8("No database drivers found"), |
45 self.tr("No database drivers found"), |
46 self.trUtf8( |
46 self.tr( |
47 """This tool requires at least one Qt database driver. """ |
47 """This tool requires at least one Qt database driver. """ |
48 """Please check the Qt documentation how to build the """ |
48 """Please check the Qt documentation how to build the """ |
49 """Qt SQL plugins.""")) |
49 """Qt SQL plugins.""")) |
50 |
50 |
51 self.connections.tableActivated.connect( |
51 self.connections.tableActivated.connect( |
52 self.on_connections_tableActivated) |
52 self.on_connections_tableActivated) |
53 self.connections.schemaRequested.connect( |
53 self.connections.schemaRequested.connect( |
54 self.on_connections_schemaRequested) |
54 self.on_connections_schemaRequested) |
55 self.connections.cleared.connect(self.on_connections_cleared) |
55 self.connections.cleared.connect(self.on_connections_cleared) |
56 |
56 |
57 self.statusMessage.emit(self.trUtf8("Ready")) |
57 self.statusMessage.emit(self.tr("Ready")) |
58 |
58 |
59 @pyqtSlot() |
59 @pyqtSlot() |
60 def on_clearButton_clicked(self): |
60 def on_clearButton_clicked(self): |
61 """ |
61 """ |
62 Private slot to clear the SQL entry widget. |
62 Private slot to clear the SQL entry widget. |
157 driver, dbName, user, password, host, port) |
157 driver, dbName, user, password, host, port) |
158 |
158 |
159 if err.type() != QSqlError.NoError: |
159 if err.type() != QSqlError.NoError: |
160 E5MessageBox.warning( |
160 E5MessageBox.warning( |
161 self, |
161 self, |
162 self.trUtf8("Unable to open database"), |
162 self.tr("Unable to open database"), |
163 self.trUtf8( |
163 self.tr( |
164 """An error occurred while opening the connection.""")) |
164 """An error occurred while opening the connection.""")) |
165 |
165 |
166 def showTable(self, table): |
166 def showTable(self, table): |
167 """ |
167 """ |
168 Public slot to show the contents of a table. |
168 Public slot to show the contents of a table. |
297 self.table.setModel(model) |
297 self.table.setModel(model) |
298 |
298 |
299 if model.lastError().type() != QSqlError.NoError: |
299 if model.lastError().type() != QSqlError.NoError: |
300 self.statusMessage.emit(model.lastError().text()) |
300 self.statusMessage.emit(model.lastError().text()) |
301 elif model.query().isSelect(): |
301 elif model.query().isSelect(): |
302 self.statusMessage.emit(self.trUtf8("Query OK.")) |
302 self.statusMessage.emit(self.tr("Query OK.")) |
303 else: |
303 else: |
304 self.statusMessage.emit( |
304 self.statusMessage.emit( |
305 self.trUtf8("Query OK, number of affected rows: {0}") |
305 self.tr("Query OK, number of affected rows: {0}") |
306 .format(model.query().numRowsAffected())) |
306 .format(model.query().numRowsAffected())) |
307 |
307 |
308 self.table.resizeColumnsToContents() |
308 self.table.resizeColumnsToContents() |
309 |
309 |
310 self.updateActions() |
310 self.updateActions() |