Network/IRC/IrcNetworkEditDialog.py

changeset 2236
e30d5f978919
parent 2235
266800cbe7cc
child 2237
baddb671c326
equal deleted inserted replaced
2235:266800cbe7cc 2236:e30d5f978919
9 9
10 import copy 10 import copy
11 11
12 from PyQt4.QtCore import pyqtSlot 12 from PyQt4.QtCore import pyqtSlot
13 from PyQt4.QtGui import QDialog, QDialogButtonBox, QTreeWidgetItem 13 from PyQt4.QtGui import QDialog, QDialogButtonBox, QTreeWidgetItem
14
15 from E5Gui import E5MessageBox
14 16
15 from .Ui_IrcNetworkEditDialog import Ui_IrcNetworkEditDialog 17 from .Ui_IrcNetworkEditDialog import Ui_IrcNetworkEditDialog
16 18
17 from .IrcNetworkManager import IrcIdentity, IrcChannel 19 from .IrcNetworkManager import IrcIdentity, IrcChannel
18 from .IrcChannelEditDialog import IrcChannelEditDialog 20 from .IrcChannelEditDialog import IrcChannelEditDialog
63 if index == -1: 65 if index == -1:
64 index = 0 66 index = 0
65 self.identityCombo.setCurrentIndex(index) 67 self.identityCombo.setCurrentIndex(index)
66 68
67 # servers 69 # servers
68 self.serverCombo.addItems(self.__manager.getServerNames()) 70 self.serverEdit.setText(self.__network.getServerNames()[0])
69 server = self.__network.getServerName()
70 index = self.serverCombo.findText(server)
71 if index == -1:
72 index = 0
73 self.serverCombo.setCurrentIndex(index)
74 71
75 # channels 72 # channels
76 for channelName in sorted(self.__network.getChannelNames()): 73 for channelName in sorted(self.__network.getChannelNames()):
77 channel = self.__network.getChannel(channelName) 74 channel = self.__network.getChannel(channelName)
78 if channel.autoJoin(): 75 if channel.autoJoin():
88 """ 85 """
89 Private method to update the OK button state. 86 Private method to update the OK button state.
90 """ 87 """
91 enable = True 88 enable = True
92 enable &= self.networkEdit.text() != "" 89 enable &= self.networkEdit.text() != ""
93 enable &= self.serverCombo.currentText() != "" 90 enable &= self.serverEdit.text() != ""
94 91
95 self.__okButton.setEnabled(enable) 92 self.__okButton.setEnabled(enable)
96 93
97 @pyqtSlot(str) 94 @pyqtSlot(str)
98 def on_networkEdit_textChanged(self, txt): 95 def on_networkEdit_textChanged(self, txt):
109 Slot documentation goes here. 106 Slot documentation goes here.
110 """ 107 """
111 # TODO: not implemented yet 108 # TODO: not implemented yet
112 raise NotImplementedError 109 raise NotImplementedError
113 110
114 @pyqtSlot(str)
115 def on_serverCombo_activated(self, txt):
116 """
117 Private slot to handle the selection of a server.
118
119 @param txt selected server (string)
120 """
121 self.__updateOkButton()
122
123 @pyqtSlot() 111 @pyqtSlot()
124 def on_editServersButton_clicked(self): 112 def on_editServersButton_clicked(self):
125 """ 113 """
126 Slot documentation goes here. 114 Slot documentation goes here.
127 """ 115 """
129 raise NotImplementedError 117 raise NotImplementedError
130 118
131 @pyqtSlot() 119 @pyqtSlot()
132 def on_addChannelButton_clicked(self): 120 def on_addChannelButton_clicked(self):
133 """ 121 """
134 Slot documentation goes here. 122 Private slot to add a channel.
135 """ 123 """
136 # TODO: not implemented yet 124 self.__editChannel(None)
137 raise NotImplementedError
138 125
139 @pyqtSlot() 126 @pyqtSlot()
140 def on_editChannelButton_clicked(self): 127 def on_editChannelButton_clicked(self):
141 """ 128 """
142 Private slot to edit the selected channel. 129 Private slot to edit the selected channel.
146 self.__editChannel(itm) 133 self.__editChannel(itm)
147 134
148 @pyqtSlot() 135 @pyqtSlot()
149 def on_deleteChannelButton_clicked(self): 136 def on_deleteChannelButton_clicked(self):
150 """ 137 """
151 Slot documentation goes here. 138 Private slot to delete the selected channel.
152 """ 139 """
153 # TODO: not implemented yet 140 itm = self.channelList.selectedItems()[0]
154 raise NotImplementedError 141 if itm:
142 res = E5MessageBox.yesNo(self,
143 self.trUtf8("Delete Channel"),
144 self.trUtf8("""Do you really want to delete channel <b>{0}</b>?""")\
145 .format(itm.text(0)))
146 if res:
147 self.__network.deleteChannel(itm.text(0))
148
149 index = self.channelList.indexOfTopLevelItem(itm)
150 self.channelList.takeTopLevelItem(index)
151 del itm
155 152
156 @pyqtSlot(QTreeWidgetItem, int) 153 @pyqtSlot(QTreeWidgetItem, int)
157 def on_channelList_itemActivated(self, item, column): 154 def on_channelList_itemActivated(self, item, column):
158 """ 155 """
159 Private slot to handle the activation of a channel entry. 156 Private slot to handle the activation of a channel entry.
211 else: 208 else:
212 autoJoinTxt = self.trUtf8("No") 209 autoJoinTxt = self.trUtf8("No")
213 QTreeWidgetItem(self.channelList, [name, autoJoinTxt]) 210 QTreeWidgetItem(self.channelList, [name, autoJoinTxt])
214 self.__network.addChannel(channel) 211 self.__network.addChannel(channel)
215 212
216 def getData(self): 213 def getNetwork(self):
217 """ 214 """
218 Public method to get the network data. 215 Public method to get the network object.
219 216
220 @return edited network object (IrcNetwork) 217 @return edited network object (IrcNetwork)
221 """ 218 """
222 return self.__network 219 return self.__network

eric ide

mercurial