src/eric7/SqlBrowser/SqlConnectionDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
18 18
19 class SqlConnectionDialog(QDialog, Ui_SqlConnectionDialog): 19 class SqlConnectionDialog(QDialog, Ui_SqlConnectionDialog):
20 """ 20 """
21 Class implementing a dialog to enter the connection parameters. 21 Class implementing a dialog to enter the connection parameters.
22 """ 22 """
23
23 def __init__(self, parent=None): 24 def __init__(self, parent=None):
24 """ 25 """
25 Constructor 26 Constructor
26 27
27 @param parent reference to the parent widget (QWidget) 28 @param parent reference to the parent widget (QWidget)
28 """ 29 """
29 super().__init__(parent) 30 super().__init__(parent)
30 self.setupUi(self) 31 self.setupUi(self)
31 32
32 self.databasePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) 33 self.databasePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
33 34
34 self.okButton = self.buttonBox.button( 35 self.okButton = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok)
35 QDialogButtonBox.StandardButton.Ok) 36
36
37 drivers = QSqlDatabase.drivers() 37 drivers = QSqlDatabase.drivers()
38 38
39 # remove compatibility names 39 # remove compatibility names
40 if "QMYSQL3" in drivers: 40 if "QMYSQL3" in drivers:
41 drivers.remove("QMYSQL3") 41 drivers.remove("QMYSQL3")
42 if "QOCI8" in drivers: 42 if "QOCI8" in drivers:
43 drivers.remove("QOCI8") 43 drivers.remove("QOCI8")
45 drivers.remove("QODBC3") 45 drivers.remove("QODBC3")
46 if "QPSQL7" in drivers: 46 if "QPSQL7" in drivers:
47 drivers.remove("QPSQL7") 47 drivers.remove("QPSQL7")
48 if "QTDS7" in drivers: 48 if "QTDS7" in drivers:
49 drivers.remove("QTDS7") 49 drivers.remove("QTDS7")
50 50
51 self.driverCombo.addItems(drivers) 51 self.driverCombo.addItems(drivers)
52 52
53 self.__updateDialog() 53 self.__updateDialog()
54 54
55 msh = self.minimumSizeHint() 55 msh = self.minimumSizeHint()
56 self.resize(max(self.width(), msh.width()), msh.height()) 56 self.resize(max(self.width(), msh.width()), msh.height())
57 57
58 def __updateDialog(self): 58 def __updateDialog(self):
59 """ 59 """
60 Private slot to update the dialog depending on its contents. 60 Private slot to update the dialog depending on its contents.
61 """ 61 """
62 driver = self.driverCombo.currentText() 62 driver = self.driverCombo.currentText()
63 if driver.startswith("QSQLITE"): 63 if driver.startswith("QSQLITE"):
64 self.databasePicker.setPickerEnabled(True) 64 self.databasePicker.setPickerEnabled(True)
65 else: 65 else:
66 self.databasePicker.setPickerEnabled(False) 66 self.databasePicker.setPickerEnabled(False)
67 67
68 if self.databasePicker.text() == "" or driver == "": 68 if self.databasePicker.text() == "" or driver == "":
69 self.okButton.setEnabled(False) 69 self.okButton.setEnabled(False)
70 else: 70 else:
71 self.okButton.setEnabled(True) 71 self.okButton.setEnabled(True)
72 72
73 @pyqtSlot(int) 73 @pyqtSlot(int)
74 def on_driverCombo_activated(self, index): 74 def on_driverCombo_activated(self, index):
75 """ 75 """
76 Private slot handling the selection of a database driver. 76 Private slot handling the selection of a database driver.
77 77
78 @param index index of the selected entry 78 @param index index of the selected entry
79 @type int 79 @type int
80 """ 80 """
81 self.__updateDialog() 81 self.__updateDialog()
82 82
83 @pyqtSlot(str) 83 @pyqtSlot(str)
84 def on_databasePicker_textChanged(self, txt): 84 def on_databasePicker_textChanged(self, txt):
85 """ 85 """
86 Private slot handling the change of the database name. 86 Private slot handling the change of the database name.
87 87
88 @param txt text of the edit (string) 88 @param txt text of the edit (string)
89 """ 89 """
90 self.__updateDialog() 90 self.__updateDialog()
91 91
92 def getData(self): 92 def getData(self):
93 """ 93 """
94 Public method to retrieve the connection data. 94 Public method to retrieve the connection data.
95 95
96 @return tuple giving the driver name (string), the database name 96 @return tuple giving the driver name (string), the database name
97 (string), the user name (string), the password (string), the 97 (string), the user name (string), the password (string), the
98 host name (string) and the port (integer) 98 host name (string) and the port (integer)
99 """ 99 """
100 return ( 100 return (

eric ide

mercurial