Network/IRC/IrcNetworkEditDialog.py

Sat, 01 Dec 2012 11:48:52 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 01 Dec 2012 11:48:52 +0100
changeset 2238
9977d3081ab6
parent 2237
baddb671c326
child 2239
a47b50e80a20
permissions
-rw-r--r--

Continued with the IRC management.

2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2012 Detlev Offenbach <detlev@die-offenbachs.de>
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog for editing IRC network definitions.
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
10 import copy
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
11
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt4.QtCore import pyqtSlot
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt4.QtGui import QDialog, QDialogButtonBox, QTreeWidgetItem
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
15 from E5Gui import E5MessageBox
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
16
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from .Ui_IrcNetworkEditDialog import Ui_IrcNetworkEditDialog
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
19 from .IrcNetworkManager import IrcIdentity, IrcChannel
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
20 from .IrcChannelEditDialog import IrcChannelEditDialog
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
21 from .IrcServerEditDialog import IrcServerEditDialog
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 import UI.PixmapCache
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 class IrcNetworkEditDialog(QDialog, Ui_IrcNetworkEditDialog):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 Class implementing a dialog for editing IRC network definitions.
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 def __init__(self, manager, networkName, parent=None):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Constructor
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param manager reference to the IRC network manager object (IrcNetworkManager)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @param networkName name of the network to work on (string)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @param parent reference to the parent widget (QWidget)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 super().__init__(parent)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.setupUi(self)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__manager = manager
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.editIdentitiesButton.setIcon(UI.PixmapCache.getIcon("ircConfigure.png"))
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
44 self.editServerButton.setIcon(UI.PixmapCache.getIcon("ircConfigure.png"))
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.editChannelButton.setIcon(UI.PixmapCache.getIcon("ircConfigure.png"))
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.addChannelButton.setIcon(UI.PixmapCache.getIcon("plus.png"))
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.deleteChannelButton.setIcon(UI.PixmapCache.getIcon("minus.png"))
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
51 # TODO: add the ADD mode
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
52 self.__network = copy.deepcopy(self.__manager.getNetwork(networkName))
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
53
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
54 # network name
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.networkEdit.setText(networkName)
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
56
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
57 # identities
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 identities = list(sorted(self.__manager.getIdentityNames()))
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 identities[identities.index(IrcIdentity.DefaultIdentityName)] = \
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 IrcIdentity.DefaultIdentityDisplay
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.identityCombo.addItems(identities)
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
62 identity = self.__network.getIdentityName()
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
63 if identity == IrcIdentity.DefaultIdentityName:
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
64 identity = IrcIdentity.DefaultIdentityDisplay
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
65 index = self.identityCombo.findText(identity)
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
66 if index == -1:
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
67 index = 0
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
68 self.identityCombo.setCurrentIndex(index)
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
69
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
70 # server
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
71 self.serverEdit.setText(self.__network.getServerName())
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
72
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
73 # channels
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
74 for channelName in sorted(self.__network.getChannelNames()):
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
75 channel = self.__network.getChannel(channelName)
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
76 if channel.autoJoin():
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
77 autoJoin = self.trUtf8("Yes")
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
78 else:
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
79 autoJoin = self.trUtf8("No")
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
80 QTreeWidgetItem(self.channelList, [channelName, autoJoin])
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.__updateOkButton()
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
83 self.on_channelList_itemSelectionChanged()
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 def __updateOkButton(self):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 Private method to update the OK button state.
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 enable = True
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 enable &= self.networkEdit.text() != ""
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
91 enable &= self.serverEdit.text() != ""
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.__okButton.setEnabled(enable)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 @pyqtSlot(str)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 def on_networkEdit_textChanged(self, txt):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 Private slot to handle changes of the network name.
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 @param txt text entered into the network name edit (string)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.__updateOkButton()
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
104 @pyqtSlot(str)
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
105 def on_identityCombo_activated(self, identity):
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
106 """
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
107 Private slot to handle the selection of an identity.
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
108
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
109 @param identity selected entity (string)
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
110 """
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
111 self.__network.setIdentityName(identity)
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
112
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 @pyqtSlot()
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 def on_editIdentitiesButton_clicked(self):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 Slot documentation goes here.
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 """
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 # TODO: not implemented yet
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 raise NotImplementedError
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 @pyqtSlot()
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
122 def on_editServerButton_clicked(self):
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
123 """
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
124 Private slot to edit the server configuration.
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 """
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
126 dlg = IrcServerEditDialog(self.__network.getServer())
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
127 if dlg.exec_() == QDialog.Accepted:
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
128 self.__network.setServer(dlg.getServer())
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
129 self.serverEdit.setText(self.__network.getServerName())
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 @pyqtSlot()
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 def on_addChannelButton_clicked(self):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 """
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
134 Private slot to add a channel.
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 """
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
136 self.__editChannel(None)
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 @pyqtSlot()
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 def on_editChannelButton_clicked(self):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 """
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
141 Private slot to edit the selected channel.
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 """
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
143 itm = self.channelList.selectedItems()[0]
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
144 if itm:
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
145 self.__editChannel(itm)
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 @pyqtSlot()
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 def on_deleteChannelButton_clicked(self):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 """
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
150 Private slot to delete the selected channel.
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
152 itm = self.channelList.selectedItems()[0]
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
153 if itm:
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
154 res = E5MessageBox.yesNo(self,
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
155 self.trUtf8("Delete Channel"),
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
156 self.trUtf8("""Do you really want to delete channel <b>{0}</b>?""")\
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
157 .format(itm.text(0)))
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
158 if res:
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
159 self.__network.deleteChannel(itm.text(0))
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
160
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
161 index = self.channelList.indexOfTopLevelItem(itm)
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
162 self.channelList.takeTopLevelItem(index)
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
163 del itm
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 @pyqtSlot(QTreeWidgetItem, int)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 def on_channelList_itemActivated(self, item, column):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 """
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
168 Private slot to handle the activation of a channel entry.
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
169
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
170 @param item reference to the activated item (QTreeWidgetItem)
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
171 @param column column the activation occurred in (integer)
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 """
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
173 self.__editChannel(item)
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 @pyqtSlot()
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 def on_channelList_itemSelectionChanged(self):
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 """
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
178 Private slot to handle changes of the selection of channels.
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
179 """
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
180 selectedItems = self.channelList.selectedItems()
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
181 if len(selectedItems) == 0:
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
182 enable = False
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
183 else:
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
184 enable = True
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
185 self.editChannelButton.setEnabled(enable)
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
186 self.deleteChannelButton.setEnabled(enable)
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
187
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
188 def __editChannel(self, itm):
2234
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
189 """
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
190 Private method to edit a channel.
1e33501a0d33 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2233
diff changeset
191
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
192 @param itm reference to the item to be edited (QTreeWidgetItem)
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 """
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
194 if itm:
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
195 channel = self.__network.getChannel(itm.text(0))
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
196 name = channel.getName()
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
197 key = channel.getKey()
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
198 autoJoin = channel.autoJoin()
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
199 else:
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
200 # add a new channel
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
201 name = ""
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
202 key = ""
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
203 autoJoin = False
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
204
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
205 dlg = IrcChannelEditDialog(name, key, autoJoin, itm is not None, self)
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
206 if dlg.exec_() == QDialog.Accepted:
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
207 name, key, autoJoin = dlg.getData()
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
208 channel = IrcChannel(name)
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
209 channel.setKey(key)
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
210 channel.setAutoJoin(autoJoin)
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
211 if itm:
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
212 if autoJoin:
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
213 itm.setText(1, self.trUtf8("Yes"))
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
214 else:
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
215 itm.setText(1, self.trUtf8("No"))
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
216 self.__network.setChannel(channel)
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
217 else:
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
218 if autoJoin:
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
219 autoJoinTxt = self.trUtf8("Yes")
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
220 else:
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
221 autoJoinTxt = self.trUtf8("No")
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
222 QTreeWidgetItem(self.channelList, [name, autoJoinTxt])
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
223 self.__network.addChannel(channel)
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
224
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
225 def getNetwork(self):
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
226 """
2236
e30d5f978919 Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2235
diff changeset
227 Public method to get the network object.
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
228
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
229 @return edited network object (IrcNetwork)
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
230 """
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
231 self.__network.setName(self.networkEdit.text())
2235
266800cbe7cc Continued with IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2234
diff changeset
232 return self.__network

eric ide

mercurial