35 |
35 |
36 def __init__(self, parent=None): |
36 def __init__(self, parent=None): |
37 """ |
37 """ |
38 Constructor |
38 Constructor |
39 |
39 |
40 @param parent reference to the parent widget (QWidget) |
40 @param parent reference to the parent widget |
|
41 @type QWidget |
41 """ |
42 """ |
42 super().__init__(parent) |
43 super().__init__(parent) |
43 |
44 |
44 layout = QVBoxLayout(self) |
45 layout = QVBoxLayout(self) |
45 layout.setContentsMargins(0, 0, 0, 0) |
46 layout.setContentsMargins(0, 0, 0, 0) |
111 @pyqtSlot(QTreeWidgetItem, int) |
112 @pyqtSlot(QTreeWidgetItem, int) |
112 def __itemActivated(self, itm, column): |
113 def __itemActivated(self, itm, column): |
113 """ |
114 """ |
114 Private slot handling the activation of an item. |
115 Private slot handling the activation of an item. |
115 |
116 |
116 @param itm reference to the item (QTreeWidgetItem) |
117 @param itm reference to the item |
117 @param column column that was activated (integer) |
118 @type QTreeWidgetItem |
|
119 @param column column that was activated |
|
120 @type int |
118 """ |
121 """ |
119 if itm is None: |
122 if itm is None: |
120 return |
123 return |
121 |
124 |
122 if not self.__activating: |
125 if not self.__activating: |
131 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) |
134 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) |
132 def __currentItemChanged(self, current, previous): |
135 def __currentItemChanged(self, current, previous): |
133 """ |
136 """ |
134 Private slot handling a change of the current item. |
137 Private slot handling a change of the current item. |
135 |
138 |
136 @param current reference to the new current item (QTreeWidgetItem) |
139 @param current reference to the new current item |
|
140 @type QTreeWidgetItem |
137 @param previous reference to the previous current item |
141 @param previous reference to the previous current item |
138 (QTreeWidgetItem) |
142 @type QTreeWidgetItem |
139 """ |
143 """ |
140 self.__schemaAction.setEnabled( |
144 self.__schemaAction.setEnabled( |
141 current is not None and current.parent() is not None |
145 current is not None and current.parent() is not None |
142 ) |
146 ) |
143 |
147 |
144 def __dbCaption(self, db): |
148 def __dbCaption(self, db): |
145 """ |
149 """ |
146 Private method to assemble a string for the caption. |
150 Private method to assemble a string for the caption. |
147 |
151 |
148 @param db reference to the database object (QSqlDatabase) |
152 @param db reference to the database object |
149 @return caption string (string) |
153 @type QSqlDatabase |
|
154 @return caption string |
|
155 @rtype str |
150 """ |
156 """ |
151 nm = db.driverName() |
157 nm = db.driverName() |
152 nm += ":" |
158 nm += ":" |
153 if db.userName(): |
159 if db.userName(): |
154 nm += db.userName() |
160 nm += db.userName() |
158 |
164 |
159 def __setBold(self, itm, bold): |
165 def __setBold(self, itm, bold): |
160 """ |
166 """ |
161 Private slot to set the font to bold. |
167 Private slot to set the font to bold. |
162 |
168 |
163 @param itm reference to the item to be changed (QTreeWidgetItem) |
169 @param itm reference to the item to be changed |
164 @param bold flag indicating bold (boolean) |
170 @type QTreeWidgetItem |
|
171 @param bold flag indicating bold |
|
172 @type bool |
165 """ |
173 """ |
166 font = itm.font(0) |
174 font = itm.font(0) |
167 font.setBold(bold) |
175 font.setBold(bold) |
168 itm.setFont(0, font) |
176 itm.setFont(0, font) |
169 |
177 |
170 def currentDatabase(self): |
178 def currentDatabase(self): |
171 """ |
179 """ |
172 Public method to get the current database. |
180 Public method to get the current database. |
173 |
181 |
174 @return reference to the current database (QSqlDatabase) |
182 @return reference to the current database |
|
183 @rtype QSqlDatabase |
175 """ |
184 """ |
176 return QSqlDatabase.database(self.__activeDb) |
185 return QSqlDatabase.database(self.__activeDb) |
177 |
186 |
178 def __setActive(self, itm): |
187 def __setActive(self, itm): |
179 """ |
188 """ |
180 Private slot to set an item to active. |
189 Private slot to set an item to active. |
181 |
190 |
182 @param itm reference to the item to set as the active item |
191 @param itm reference to the item to set as the active item |
183 (QTreeWidgetItem) |
192 @type QTreeWidgetItem |
184 """ |
193 """ |
185 for index in range(self.__connectionTree.topLevelItemCount()): |
194 for index in range(self.__connectionTree.topLevelItemCount()): |
186 if self.__connectionTree.topLevelItem(index).font(0).bold(): |
195 if self.__connectionTree.topLevelItem(index).font(0).bold(): |
187 self.__setBold(self.__connectionTree.topLevelItem(index), False) |
196 self.__setBold(self.__connectionTree.topLevelItem(index), False) |
188 |
197 |