eric6/Network/IRC/IrcNetworkListDialog.py

Sat, 11 Apr 2020 14:13:25 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 11 Apr 2020 14:13:25 +0200
changeset 7522
e0e05a1b576f
parent 7360
9190402e4505
child 7759
51aa6c6b66f7
permissions
-rw-r--r--

Styles: added some Qt style sheets and some highlighter styles.

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

eric ide

mercurial