eric6/Network/IRC/IrcNetworkListDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2012 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to list the configured IRC networks.
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
10 from PyQt5.QtCore import pyqtSlot
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
11 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from E5Gui import E5MessageBox
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from .Ui_IrcNetworkListDialog import Ui_IrcNetworkListDialog
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class IrcNetworkListDialog(QDialog, Ui_IrcNetworkListDialog):
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing a dialog to list the configured IRC networks.
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 def __init__(self, manager, parent=None):
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Constructor
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @param manager reference to the IRC network manager (IrcNetworkManager)
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @param parent reference to the parent widget (QWidget)
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2404
diff changeset
29 super(IrcNetworkListDialog, self).__init__(parent)
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 self.setupUi(self)
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 self.__manager = manager
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
34 self.__refreshNetworksList()
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 def __resizeColumns(self):
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 Private slot to resize all columns to their contents.
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 for col in range(self.networksList.columnCount()):
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.networksList.resizeColumnToContents(col)
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 def __checkButtons(self):
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
45 Private slot to set the enabled state of the buttons.
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 enable = True
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 selectedItems = self.networksList.selectedItems()
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 if len(selectedItems) == 0:
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 enable = False
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 else:
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 for itm in selectedItems:
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 enable &= itm.parent() is None
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.editButton.setEnabled(enable)
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.deleteButton.setEnabled(enable)
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
57 self.autoConnectButton.setEnabled(enable)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
58
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
59 if enable:
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
60 itm = self.networksList.selectedItems()[0]
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
61 check = self.__manager.getNetwork(itm.text(0)).autoConnect()
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
62 self.autoConnectButton.setChecked(check)
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
64 def __refreshNetworkEntry(self, itm):
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
65 """
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
66 Private method to (re-)set the data of a network entry.
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
67
2266
f885a0bc2ccc Updated source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2241
diff changeset
68 @param itm reference to the network entry (QTreeWidgetItem)
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
69 """
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
70 # step 1: delete all child entries
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
71 children = itm.takeChildren()
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
72 for child in children:
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
73 del child
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
74
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
75 # step 2: (re-)add the child entries
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
76 from .IrcNetworkManager import IrcIdentity
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
77 networkName = itm.text(0)
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
78 network = self.__manager.getNetwork(networkName)
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
79 server = network.getServer()
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
80 identityName = network.getIdentityName()
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
81 if identityName == IrcIdentity.DefaultIdentityName:
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
82 identityName = IrcIdentity.DefaultIdentityDisplay
7255
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
83 autoConnect = (
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
84 self.tr("Yes") if network.autoConnect() else self.tr("No")
d595f6f9cbf8 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
85 )
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
86
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
87 QTreeWidgetItem(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
88 itm,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
89 [self.tr("Identity"), identityName])
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
90 QTreeWidgetItem(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
91 itm,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
92 [self.tr("Server"), "{0}:{1}".format(
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
93 server.getName(), server.getPort())])
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
94 QTreeWidgetItem(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
95 itm,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
96 [self.tr("Channels"), ", ".join(network.getChannelNames())])
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
97 QTreeWidgetItem(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
98 itm,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
99 [self.tr("Auto-Connect"), autoConnect])
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
100
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
101 self.__resizeColumns()
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
102
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
103 def __refreshNetworksList(self):
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
104 """
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
105 Private method to refresh the complete networks list.
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
106 """
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
107 self.networksList.clear()
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
108
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
109 networkNames = self.__manager.getNetworkNames()
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
110 for networkName in networkNames:
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
111 topitm = QTreeWidgetItem(self.networksList, [networkName])
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
112 self.__refreshNetworkEntry(topitm)
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
113 topitm.setExpanded(True)
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
114 self.__resizeColumns()
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
115
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
116 self.__checkButtons()
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
117
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 @pyqtSlot()
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 def on_networksList_itemSelectionChanged(self):
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
121 Private slot to handle changes of the selection of networks.
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self.__checkButtons()
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 @pyqtSlot()
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 def on_newButton_clicked(self):
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 """
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
128 Private slot to add a new network entry.
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 """
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
130 from .IrcNetworkEditDialog import IrcNetworkEditDialog
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
131 dlg = IrcNetworkEditDialog(self.__manager, "", self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
132 if dlg.exec() == QDialog.Accepted:
2241
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
133 network = dlg.getNetwork()
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
134 self.__manager.addNetwork(network)
030924019d88 Implemented SSL support for IRC.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2239
diff changeset
135 self.__refreshNetworksList()
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 @pyqtSlot()
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 def on_editButton_clicked(self):
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
140 Private slot to edit the selected network.
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 """
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
142 itm = self.networksList.selectedItems()[0]
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
143 if itm:
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
144 from .IrcNetworkEditDialog import IrcNetworkEditDialog
2233
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
145 networkName = itm.text(0)
26b34180a943 Started implementing the IRC network edit dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2232
diff changeset
146 dlg = IrcNetworkEditDialog(self.__manager, networkName, self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
147 if dlg.exec() == QDialog.Accepted:
2238
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
148 network = dlg.getNetwork()
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
149 self.__manager.setNetwork(network, networkName)
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
150 if network.getName() != networkName:
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
151 itm.setText(0, network.getName())
9977d3081ab6 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2237
diff changeset
152 self.__refreshNetworkEntry(itm)
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 @pyqtSlot()
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 def on_deleteButton_clicked(self):
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 Private slot to delete the selected entry.
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 itm = self.networksList.selectedItems()[0]
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 if itm.parent() is None:
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 networkName = itm.text(0)
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
162 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
163 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
164 self.tr("Delete Irc Network"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
165 self.tr(
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
166 """Do you really want to delete IRC network <b>{0}</b>?""")
3036
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
167 .format(networkName))
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 if res:
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 index = self.networksList.indexOfTopLevelItem(itm)
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 self.networksList.takeTopLevelItem(index)
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 del itm
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 self.__manager.deleteNetwork(networkName)
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 @pyqtSlot(QTreeWidgetItem)
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 def on_networksList_itemExpanded(self, item):
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 Private slot handling the expansion of a top level item.
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
179
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
180 @param item reference to the expanded item (QTreeWidgetItem)
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 self.__resizeColumns()
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 @pyqtSlot(QTreeWidgetItem)
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 def on_networksList_itemCollapsed(self, item):
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 Private slot handling the collapse of a top level item.
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
188
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
189 @param item reference to the collapsed item (QTreeWidgetItem)
2232
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 """
47290dad6d0b Started implementing the IRC network management dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 self.__resizeColumns()
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
192
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
193 @pyqtSlot(bool)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
194 def on_autoConnectButton_clicked(self, checked):
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
195 """
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
196 Private slot handling the auto-connect selection.
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
197
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
198 @param checked flag indicating the state of the button (boolean)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
199 """
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
200 itm = self.networksList.selectedItems()[0]
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
201 if itm.parent() is None:
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
202 networkName = itm.text(0)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
203 if checked:
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
204 # enable the selected network, disable all others
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
205 # step 1: update network objects
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
206 for name in self.__manager.getNetworkNames():
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
207 network = self.__manager.getNetwork(networkName)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
208 if name == networkName:
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
209 network.setAutoConnect(True)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
210 else:
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
211 network.setAutoConnect(False)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
212 self.__manager.networkChanged()
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
213
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
214 # step 2: update list entries
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
215 for index in range(self.networksList.topLevelItemCount()):
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
216 titm = self.networksList.topLevelItem(index)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
217 if titm.text(0) == networkName:
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
218 self.__setAutoConnectEntry(titm, True)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
219 else:
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
220 self.__setAutoConnectEntry(titm, False)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
221 else:
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
222 # step 1: update network object
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
223 network = self.__manager.getNetwork(networkName)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
224 network.setAutoConnect(False)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
225 self.__manager.networkChanged()
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
226
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
227 # step 2: update list entry
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
228 self.__setAutoConnectEntry(itm, False)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
229
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
230 def __setAutoConnectEntry(self, itm, on):
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
231 """
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
232 Private method to set the auto-connect entry of a network item.
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
233
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
234 @param itm reference to the network item (QTreeWidgetItem)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
235 @param on flag indicating the auto-connect state (boolean)
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
236 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
237 autoConnect = self.tr("Yes") if on else self.tr("No")
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
238 for index in range(itm.childCount()):
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
239 citm = itm.child(index)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
240 if citm.text(0) == self.tr("Auto-Connect"):
2237
baddb671c326 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2236
diff changeset
241 citm.setText(1, autoConnect)
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
242
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
243 @pyqtSlot()
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
244 def on_editIdentitiesButton_clicked(self):
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
245 """
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
246 Private slot to edit the identities.
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
247 """
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
248 from .IrcIdentitiesEditDialog import IrcIdentitiesEditDialog
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
249 dlg = IrcIdentitiesEditDialog(self.__manager, "", self)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
250 dlg.exec()
2239
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
251
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
252 selectedNetwork = self.networksList.selectedItems()
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
253 if selectedNetwork:
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
254 selectedNetworkName = selectedNetwork[0].text(0)
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
255 else:
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
256 selectedNetworkName = ""
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
257 self.__refreshNetworksList()
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
258 if selectedNetworkName:
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
259 for index in range(self.networksList.topLevelItemCount()):
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
260 itm = self.networksList.topLevelItem(index)
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
261 if itm.text(0) == selectedNetworkName:
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
262 itm.setSelected(True)
a47b50e80a20 Continued with the IRC management.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2238
diff changeset
263 break

eric ide

mercurial