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