14 |
14 |
15 from .Ui_IrcNetworkListDialog import Ui_IrcNetworkListDialog |
15 from .Ui_IrcNetworkListDialog import Ui_IrcNetworkListDialog |
16 |
16 |
17 from .IrcNetworkManager import IrcIdentity |
17 from .IrcNetworkManager import IrcIdentity |
18 from .IrcNetworkEditDialog import IrcNetworkEditDialog |
18 from .IrcNetworkEditDialog import IrcNetworkEditDialog |
|
19 from .IrcIdentitiesEditDialog import IrcIdentitiesEditDialog |
19 |
20 |
20 |
21 |
21 class IrcNetworkListDialog(QDialog, Ui_IrcNetworkListDialog): |
22 class IrcNetworkListDialog(QDialog, Ui_IrcNetworkListDialog): |
22 """ |
23 """ |
23 Class implementing a dialog to list the configured IRC networks. |
24 Class implementing a dialog to list the configured IRC networks. |
32 super().__init__(parent) |
33 super().__init__(parent) |
33 self.setupUi(self) |
34 self.setupUi(self) |
34 |
35 |
35 self.__manager = manager |
36 self.__manager = manager |
36 |
37 |
37 networkNames = self.__manager.getNetworkNames() |
38 self.__refreshNetworksList() |
38 for networkName in networkNames: |
|
39 topitm = QTreeWidgetItem(self.networksList, [networkName]) |
|
40 self.__refreshNetworkEntry(topitm) |
|
41 topitm.setExpanded(True) |
|
42 self.__resizeColumns() |
|
43 |
|
44 self.__checkButtons() |
|
45 |
39 |
46 def __resizeColumns(self): |
40 def __resizeColumns(self): |
47 """ |
41 """ |
48 Private slot to resize all columns to their contents. |
42 Private slot to resize all columns to their contents. |
49 """ |
43 """ |
101 [self.trUtf8("Channels"), ", ".join(network.getChannelNames())]) |
95 [self.trUtf8("Channels"), ", ".join(network.getChannelNames())]) |
102 QTreeWidgetItem(itm, |
96 QTreeWidgetItem(itm, |
103 [self.trUtf8("Auto-Connect"), autoConnect]) |
97 [self.trUtf8("Auto-Connect"), autoConnect]) |
104 |
98 |
105 self.__resizeColumns() |
99 self.__resizeColumns() |
|
100 |
|
101 def __refreshNetworksList(self): |
|
102 """ |
|
103 Private method to refresh the complete networks list. |
|
104 """ |
|
105 self.networksList.clear() |
|
106 |
|
107 networkNames = self.__manager.getNetworkNames() |
|
108 for networkName in networkNames: |
|
109 topitm = QTreeWidgetItem(self.networksList, [networkName]) |
|
110 self.__refreshNetworkEntry(topitm) |
|
111 topitm.setExpanded(True) |
|
112 self.__resizeColumns() |
|
113 |
|
114 self.__checkButtons() |
106 |
115 |
107 @pyqtSlot() |
116 @pyqtSlot() |
108 def on_networksList_itemSelectionChanged(self): |
117 def on_networksList_itemSelectionChanged(self): |
109 """ |
118 """ |
110 Privat slot to handle changes of the selection of networks. |
119 Privat slot to handle changes of the selection of networks. |
215 autoConnect = self.trUtf8("Yes") if on else self.trUtf8("No") |
224 autoConnect = self.trUtf8("Yes") if on else self.trUtf8("No") |
216 for index in range(itm.childCount()): |
225 for index in range(itm.childCount()): |
217 citm = itm.child(index) |
226 citm = itm.child(index) |
218 if citm.text(0) == self.trUtf8("Auto-Connect"): |
227 if citm.text(0) == self.trUtf8("Auto-Connect"): |
219 citm.setText(1, autoConnect) |
228 citm.setText(1, autoConnect) |
|
229 |
|
230 @pyqtSlot() |
|
231 def on_editIdentitiesButton_clicked(self): |
|
232 """ |
|
233 Private slot to edit the identities. |
|
234 """ |
|
235 dlg = IrcIdentitiesEditDialog(self.__manager, "", self) |
|
236 dlg.exec_() |
|
237 |
|
238 selectedNetwork = self.networksList.selectedItems() |
|
239 if selectedNetwork: |
|
240 selectedNetworkName = selectedNetwork[0].text(0) |
|
241 else: |
|
242 selectedNetworkName = "" |
|
243 self.__refreshNetworksList() |
|
244 if selectedNetworkName: |
|
245 for index in range(self.networksList.topLevelItemCount()): |
|
246 itm = self.networksList.topLevelItem(index) |
|
247 if itm.text(0) == selectedNetworkName: |
|
248 itm.setSelected(True) |
|
249 break |