17 from .Ui_IrcNetworkEditDialog import Ui_IrcNetworkEditDialog |
17 from .Ui_IrcNetworkEditDialog import Ui_IrcNetworkEditDialog |
18 |
18 |
19 from .IrcNetworkManager import IrcIdentity, IrcChannel |
19 from .IrcNetworkManager import IrcIdentity, IrcChannel |
20 from .IrcChannelEditDialog import IrcChannelEditDialog |
20 from .IrcChannelEditDialog import IrcChannelEditDialog |
21 from .IrcServerEditDialog import IrcServerEditDialog |
21 from .IrcServerEditDialog import IrcServerEditDialog |
|
22 from .IrcIdentitiesEditDialog import IrcIdentitiesEditDialog |
22 |
23 |
23 import UI.PixmapCache |
24 import UI.PixmapCache |
24 |
25 |
25 |
26 |
26 class IrcNetworkEditDialog(QDialog, Ui_IrcNetworkEditDialog): |
27 class IrcNetworkEditDialog(QDialog, Ui_IrcNetworkEditDialog): |
53 |
54 |
54 # network name |
55 # network name |
55 self.networkEdit.setText(networkName) |
56 self.networkEdit.setText(networkName) |
56 |
57 |
57 # identities |
58 # identities |
58 identities = list(sorted(self.__manager.getIdentityNames())) |
59 self.__refreshIdentityCombo(self.__network.getIdentityName()) |
59 identities[identities.index(IrcIdentity.DefaultIdentityName)] = \ |
|
60 IrcIdentity.DefaultIdentityDisplay |
|
61 self.identityCombo.addItems(identities) |
|
62 identity = self.__network.getIdentityName() |
|
63 if identity == IrcIdentity.DefaultIdentityName: |
|
64 identity = IrcIdentity.DefaultIdentityDisplay |
|
65 index = self.identityCombo.findText(identity) |
|
66 if index == -1: |
|
67 index = 0 |
|
68 self.identityCombo.setCurrentIndex(index) |
|
69 |
60 |
70 # server |
61 # server |
71 self.serverEdit.setText(self.__network.getServerName()) |
62 self.serverEdit.setText(self.__network.getServerName()) |
72 |
63 |
73 # channels |
64 # channels |
99 |
90 |
100 @param txt text entered into the network name edit (string) |
91 @param txt text entered into the network name edit (string) |
101 """ |
92 """ |
102 self.__updateOkButton() |
93 self.__updateOkButton() |
103 |
94 |
|
95 def __refreshIdentityCombo(self, currentIdentity): |
|
96 """ |
|
97 Private method to refresh the identity combo. |
|
98 |
|
99 @param currentIdentity name of the identity to select (string) |
|
100 """ |
|
101 self.identityCombo.clear() |
|
102 |
|
103 identities = list(sorted(self.__manager.getIdentityNames())) |
|
104 identities[identities.index(IrcIdentity.DefaultIdentityName)] = \ |
|
105 IrcIdentity.DefaultIdentityDisplay |
|
106 self.identityCombo.addItems(identities) |
|
107 if currentIdentity == IrcIdentity.DefaultIdentityName: |
|
108 currentIdentity = IrcIdentity.DefaultIdentityDisplay |
|
109 index = self.identityCombo.findText(currentIdentity) |
|
110 if index == -1: |
|
111 index = 0 |
|
112 self.identityCombo.setCurrentIndex(index) |
|
113 |
104 @pyqtSlot(str) |
114 @pyqtSlot(str) |
105 def on_identityCombo_activated(self, identity): |
115 def on_identityCombo_currentIndexChanged(self, identity): |
106 """ |
116 """ |
107 Private slot to handle the selection of an identity. |
117 Private slot to handle the selection of an identity. |
108 |
118 |
109 @param identity selected entity (string) |
119 @param identity selected entity (string) |
110 """ |
120 """ |
|
121 if identity == IrcIdentity.DefaultIdentityDisplay: |
|
122 identity = IrcIdentity.DefaultIdentityName |
111 self.__network.setIdentityName(identity) |
123 self.__network.setIdentityName(identity) |
112 |
124 |
113 @pyqtSlot() |
125 @pyqtSlot() |
114 def on_editIdentitiesButton_clicked(self): |
126 def on_editIdentitiesButton_clicked(self): |
115 """ |
127 """ |
116 Slot documentation goes here. |
128 Private slot to edit the identities. |
117 """ |
129 """ |
118 # TODO: not implemented yet |
130 currentIdentity = self.identityCombo.currentText() |
119 raise NotImplementedError |
131 dlg = IrcIdentitiesEditDialog(self.__manager, currentIdentity, self) |
|
132 dlg.exec_() |
|
133 self.__refreshIdentityCombo(currentIdentity) |
120 |
134 |
121 @pyqtSlot() |
135 @pyqtSlot() |
122 def on_editServerButton_clicked(self): |
136 def on_editServerButton_clicked(self): |
123 """ |
137 """ |
124 Private slot to edit the server configuration. |
138 Private slot to edit the server configuration. |