def refresh(self): """ Public slot to refresh the connection tree. """ self.__connectionTree.clear() self.emit(SIGNAL("cleared()")) connectionNames = QSqlDatabase.connectionNames() foundActiveDb = False for name in connectionNames: root = QTreeWidgetItem(self.__connectionTree) db = QSqlDatabase.database(name, False) root.setText(0, self.__dbCaption(db)) if name == self.__activeDb: foundActiveDb = True self.__setActive(root) if db.isOpen(): tables = db.tables() for table in tables: itm = QTreeWidgetItem(root) itm.setText(0, table) if not foundActiveDb and connectionNames: self.__activeDb = connectionNames[0] self.__setActive(self.__connectionTree.topLevelItem(0))
def __uiStartUp(self): """ Private slot to do some actions after the UI has started and the main loop is up. """ for warning in self.__warnings: KQMessageBox.warning(self, self.trUtf8("SQL Browser startup problem"), warning) if QSqlDatabase.connectionNames().isEmpty(): self.__browser.addConnectionByDialog()
def __setActive(self, itm): """ Private slot to set an item to active. @param itm reference to the item to set as the active item (QTreeWidgetItem) """ for index in range(self.__connectionTree.topLevelItemCount()): if self.__connectionTree.topLevelItem(index).font(0).bold(): self.__setBold(self.__connectionTree.topLevelItem(index), False) if itm is None: return self.__setBold(itm, True) self.__activeDb = QSqlDatabase.connectionNames()[ self.__connectionTree.indexOfTopLevelItem(itm)]