src/eric7/Network/IRC/IrcChannelWidget.py

branch
eric7
changeset 10428
a071d4065202
parent 9653
e67609152c5e
child 10439
21c28b0f9e41
equal deleted inserted replaced
10427:3733e2b23cf7 10428:a071d4065202
64 64
65 def __init__(self, name, parent=None): 65 def __init__(self, name, parent=None):
66 """ 66 """
67 Constructor 67 Constructor
68 68
69 @param name string with user name and privilege prefix (string) 69 @param name string with user name and privilege prefix
70 @param parent reference to the parent widget (QListWidget or 70 @type str
71 QListWidgetItem) 71 @param parent reference to the parent widget
72 @type QListWidget or QListWidgetItem
72 """ 73 """
73 super().__init__(name, parent) 74 super().__init__(name, parent)
74 75
75 self.__privilege = IrcUserItem.Normal 76 self.__privilege = IrcUserItem.Normal
76 self.__name = name 77 self.__name = name
81 82
82 def name(self): 83 def name(self):
83 """ 84 """
84 Public method to get the user name. 85 Public method to get the user name.
85 86
86 @return user name (string) 87 @return user name
88 @rtype str
87 """ 89 """
88 return self.__name 90 return self.__name
89 91
90 def setName(self, name): 92 def setName(self, name):
91 """ 93 """
92 Public method to set a new nick name. 94 Public method to set a new nick name.
93 95
94 @param name new nick name for the user (string) 96 @param name new nick name for the user
97 @type str
95 """ 98 """
96 self.__name = name 99 self.__name = name
97 self.__setText() 100 self.__setText()
98 101
99 def changePrivilege(self, privilege): 102 def changePrivilege(self, privilege):
100 """ 103 """
101 Public method to set or unset a user privilege. 104 Public method to set or unset a user privilege.
102 105
103 @param privilege privilege to set or unset (string) 106 @param privilege privilege to set or unset
107 @type str
104 """ 108 """
105 oper = privilege[0] 109 oper = privilege[0]
106 priv = privilege[1] 110 priv = privilege[1]
107 if priv in IrcUserItem.PrivilegeMapping: 111 if priv in IrcUserItem.PrivilegeMapping:
108 if oper == "+": 112 if oper == "+":
156 160
157 def __awayIcon(self, icon): 161 def __awayIcon(self, icon):
158 """ 162 """
159 Private method to convert an icon to an away icon. 163 Private method to convert an icon to an away icon.
160 164
161 @param icon icon to be converted (QIcon) 165 @param icon icon to be converted
162 @return away icon (QIcon) 166 @type QIcon
167 @return away icon
168 @rtype QIcon
163 """ 169 """
164 pix1 = icon.pixmap(16, 16) 170 pix1 = icon.pixmap(16, 16)
165 pix2 = EricPixmapCache.getPixmap("ircAway") 171 pix2 = EricPixmapCache.getPixmap("ircAway")
166 painter = QPainter(pix1) 172 painter = QPainter(pix1)
167 painter.drawPixmap(0, 0, pix2) 173 painter.drawPixmap(0, 0, pix2)
170 176
171 def parseWhoFlags(self, flags): 177 def parseWhoFlags(self, flags):
172 """ 178 """
173 Public method to parse the user flags reported by a WHO command. 179 Public method to parse the user flags reported by a WHO command.
174 180
175 @param flags user flags as reported by WHO (string) 181 @param flags user flags as reported by WHO
182 @type str
176 """ 183 """
177 # H The user is not away. 184 # H The user is not away.
178 # G The user is set away. 185 # G The user is set away.
179 # * The user is an IRC operator. 186 # * The user is an IRC operator.
180 # @ The user is a channel op in the channel listed in the first field. 187 # @ The user is a channel op in the channel listed in the first field.
194 201
195 def canChangeTopic(self): 202 def canChangeTopic(self):
196 """ 203 """
197 Public method to check, if the user is allowed to change the topic. 204 Public method to check, if the user is allowed to change the topic.
198 205
199 @return flag indicating that the topic can be changed (boolean) 206 @return flag indicating that the topic can be changed
207 @rtype bool
200 """ 208 """
201 return ( 209 return (
202 bool(self.__privilege & IrcUserItem.Operator) 210 bool(self.__privilege & IrcUserItem.Operator)
203 or bool(self.__privilege & IrcUserItem.Admin) 211 or bool(self.__privilege & IrcUserItem.Admin)
204 or bool(self.__privilege & IrcUserItem.Owner) 212 or bool(self.__privilege & IrcUserItem.Owner)
260 268
261 def __init__(self, parent=None): 269 def __init__(self, parent=None):
262 """ 270 """
263 Constructor 271 Constructor
264 272
265 @param parent reference to the parent widget (QWidget) 273 @param parent reference to the parent widget
274 @type QWidget
266 """ 275 """
267 super().__init__(parent) 276 super().__init__(parent)
268 self.setupUi(self) 277 self.setupUi(self)
269 278
270 self.__ui = ericApp().getObject("UserInterface") 279 self.__ui = ericApp().getObject("UserInterface")
571 580
572 def name(self): 581 def name(self):
573 """ 582 """
574 Public method to get the name of the channel. 583 Public method to get the name of the channel.
575 584
576 @return name of the channel (string) 585 @return name of the channel
586 @rtype str
577 """ 587 """
578 return self.__name 588 return self.__name
579 589
580 def setName(self, name): 590 def setName(self, name):
581 """ 591 """
582 Public method to set the name of the channel. 592 Public method to set the name of the channel.
583 593
584 @param name of the channel (string) 594 @param name of the channel
595 @type str
585 """ 596 """
586 self.__name = name 597 self.__name = name
587 598
588 def getUsersCount(self): 599 def getUsersCount(self):
589 """ 600 """
590 Public method to get the users count of the channel. 601 Public method to get the users count of the channel.
591 602
592 @return users count of the channel (integer) 603 @return users count of the channel
604 @rtype int
593 """ 605 """
594 return self.usersList.count() 606 return self.usersList.count()
595 607
596 def userName(self): 608 def userName(self):
597 """ 609 """
598 Public method to get the nick name of the user. 610 Public method to get the nick name of the user.
599 611
600 @return nick name of the user (string) 612 @return nick name of the user
613 @rtype str
601 """ 614 """
602 return self.__userName 615 return self.__userName
603 616
604 def setUserName(self, name): 617 def setUserName(self, name):
605 """ 618 """
606 Public method to set the user name for the channel. 619 Public method to set the user name for the channel.
607 620
608 @param name user name for the channel (string) 621 @param name user name for the channel
622 @type str
609 """ 623 """
610 self.__userName = name 624 self.__userName = name
611 625
612 def partMessage(self): 626 def partMessage(self):
613 """ 627 """
614 Public method to get the part message. 628 Public method to get the part message.
615 629
616 @return part message (string) 630 @return part message
631 @rtype str
617 """ 632 """
618 return self.__partMessage 633 return self.__partMessage
619 634
620 def setPartMessage(self, message): 635 def setPartMessage(self, message):
621 """ 636 """
622 Public method to set the part message. 637 Public method to set the part message.
623 638
624 @param message message to be used for PART messages (string) 639 @param message message to be used for PART messages
640 @type str
625 """ 641 """
626 self.__partMessage = message 642 self.__partMessage = message
627 643
628 def setPrivate(self, private, partner=""): 644 def setPrivate(self, private, partner=""):
629 """ 645 """
630 Public method to set the private chat mode. 646 Public method to set the private chat mode.
631 647
632 @param private flag indicating private chat mode (boolean) 648 @param private flag indicating private chat mode
633 @param partner name of the partner user (string) 649 @type bool
650 @param partner name of the partner user
651 @type str
634 """ 652 """
635 self.__private = private 653 self.__private = private
636 self.__privatePartner = partner 654 self.__privatePartner = partner
637 self.editTopicButton.setEnabled(private) 655 self.editTopicButton.setEnabled(private)
638 656
639 def setPrivateInfo(self, infoText): 657 def setPrivateInfo(self, infoText):
640 """ 658 """
641 Public method to set some info text for private chat mode. 659 Public method to set some info text for private chat mode.
642 660
643 @param infoText info text to be shown (string) 661 @param infoText info text to be shown
662 @type str
644 """ 663 """
645 if self.__private: 664 if self.__private:
646 self.topicLabel.setText(infoText) 665 self.topicLabel.setText(infoText)
647 666
648 def handleMessage(self, line): 667 def handleMessage(self, line):
649 """ 668 """
650 Public method to handle the message sent by the server. 669 Public method to handle the message sent by the server.
651 670
652 @param line server message (string) 671 @param line server message
653 @return flag indicating, if the message was handled (boolean) 672 @type str
673 @return flag indicating, if the message was handled
674 @rtype bool
654 """ 675 """
655 for patternRe, patternFunc in self.__patterns: 676 for patternRe, patternFunc in self.__patterns:
656 match = patternRe.match(line) 677 match = patternRe.match(line)
657 if match is not None and patternFunc(match): 678 if match is not None and patternFunc(match):
658 return True 679 return True
662 def __message(self, match): 683 def __message(self, match):
663 """ 684 """
664 Private method to handle messages to the channel. 685 Private method to handle messages to the channel.
665 686
666 @param match match object that matched the pattern 687 @param match match object that matched the pattern
667 @return flag indicating whether the message was handled (boolean) 688 @type re.Match
689 @return flag indicating whether the message was handled
690 @rtype bool
668 """ 691 """
669 # group(1) sender user name 692 # group(1) sender user name
670 # group(2) sender user@host 693 # group(2) sender user@host
671 # group(3) target nick 694 # group(3) target nick
672 # group(4) message 695 # group(4) message
689 712
690 def addMessage(self, sender, msg): 713 def addMessage(self, sender, msg):
691 """ 714 """
692 Public method to add a message from external. 715 Public method to add a message from external.
693 716
694 @param sender nick name of the sender (string) 717 @param sender nick name of the sender
695 @param msg message received from sender (string) 718 @type str
719 @param msg message received from sender
720 @type str
696 """ 721 """
697 self.__appendMessage( 722 self.__appendMessage(
698 '<font color="{0}">{2} <b>&lt;</b><font color="{1}">{3}</font>' 723 '<font color="{0}">{2} <b>&lt;</b><font color="{1}">{3}</font>'
699 "<b>&gt;</b> {4}</font>".format( 724 "<b>&gt;</b> {4}</font>".format(
700 Preferences.getIrc("ChannelMessageColour"), 725 Preferences.getIrc("ChannelMessageColour"),
719 744
720 def addUsers(self, users): 745 def addUsers(self, users):
721 """ 746 """
722 Public method to add users to the channel. 747 Public method to add users to the channel.
723 748
724 @param users list of user names to add (list of string) 749 @param users list of user names to add
750 @type list of str
725 """ 751 """
726 for user in users: 752 for user in users:
727 itm = self.__findUser(user) 753 itm = self.__findUser(user)
728 if itm is None: 754 if itm is None:
729 IrcUserItem(user, self.usersList) 755 IrcUserItem(user, self.usersList)
731 def __userJoin(self, match): 757 def __userJoin(self, match):
732 """ 758 """
733 Private method to handle a user joining the channel. 759 Private method to handle a user joining the channel.
734 760
735 @param match match object that matched the pattern 761 @param match match object that matched the pattern
736 @return flag indicating whether the message was handled (boolean) 762 @type re.Match
763 @return flag indicating whether the message was handled
764 @rtype bool
737 """ 765 """
738 if match.group(3).lower() == self.__name.lower(): 766 if match.group(3).lower() == self.__name.lower():
739 if self.__userName != match.group(1): 767 if self.__userName != match.group(1):
740 IrcUserItem(match.group(1), self.usersList) 768 IrcUserItem(match.group(1), self.usersList)
741 msg = self.tr("{0} has joined the channel {1} ({2}).").format( 769 msg = self.tr("{0} has joined the channel {1} ({2}).").format(
760 def __userPart(self, match): 788 def __userPart(self, match):
761 """ 789 """
762 Private method to handle a user leaving the channel. 790 Private method to handle a user leaving the channel.
763 791
764 @param match match object that matched the pattern 792 @param match match object that matched the pattern
765 @return flag indicating whether the message was handled (boolean) 793 @type re.Match
794 @return flag indicating whether the message was handled
795 @rtype bool
766 """ 796 """
767 if match.group(2).lower() == self.__name.lower(): 797 if match.group(2).lower() == self.__name.lower():
768 itm = self.__findUser(match.group(1)) 798 itm = self.__findUser(match.group(1))
769 self.usersList.takeItem(self.usersList.row(itm)) 799 self.usersList.takeItem(self.usersList.row(itm))
770 del itm 800 del itm
793 def __userQuit(self, match): 823 def __userQuit(self, match):
794 """ 824 """
795 Private method to handle a user logging off the server. 825 Private method to handle a user logging off the server.
796 826
797 @param match match object that matched the pattern 827 @param match match object that matched the pattern
798 @return flag indicating whether the message was handled (boolean) 828 @type re.Match
829 @return flag indicating whether the message was handled
830 @rtype bool
799 """ 831 """
800 itm = self.__findUser(match.group(1)) 832 itm = self.__findUser(match.group(1))
801 if itm: 833 if itm:
802 self.usersList.takeItem(self.usersList.row(itm)) 834 self.usersList.takeItem(self.usersList.row(itm))
803 del itm 835 del itm
822 def __userNickChange(self, match): 854 def __userNickChange(self, match):
823 """ 855 """
824 Private method to handle a nickname change of a user. 856 Private method to handle a nickname change of a user.
825 857
826 @param match match object that matched the pattern 858 @param match match object that matched the pattern
827 @return flag indicating whether the message was handled (boolean) 859 @type re.Match
860 @return flag indicating whether the message was handled
861 @rtype bool
828 """ 862 """
829 itm = self.__findUser(match.group(1)) 863 itm = self.__findUser(match.group(1))
830 if itm: 864 if itm:
831 itm.setName(match.group(2)) 865 itm.setName(match.group(2))
832 if match.group(1) == self.__userName: 866 if match.group(1) == self.__userName:
849 def __userList(self, match): 883 def __userList(self, match):
850 """ 884 """
851 Private method to handle the receipt of a list of users of the channel. 885 Private method to handle the receipt of a list of users of the channel.
852 886
853 @param match match object that matched the pattern 887 @param match match object that matched the pattern
854 @return flag indicating whether the message was handled (boolean) 888 @type re.Match
889 @return flag indicating whether the message was handled
890 @rtype bool
855 """ 891 """
856 if match.group(1).lower() == self.__name.lower(): 892 if match.group(1).lower() == self.__name.lower():
857 users = match.group(2).split() 893 users = match.group(2).split()
858 for user in users: 894 for user in users:
859 userPrivileges, userName = self.__extractPrivilege(user) 895 userPrivileges, userName = self.__extractPrivilege(user)
871 def __userAway(self, match): 907 def __userAway(self, match):
872 """ 908 """
873 Private method to handle a topic change of the channel. 909 Private method to handle a topic change of the channel.
874 910
875 @param match match object that matched the pattern 911 @param match match object that matched the pattern
876 @return flag indicating whether the message was handled (boolean) 912 @type re.Match
913 @return flag indicating whether the message was handled
914 @rtype bool
877 """ 915 """
878 if match.group(1).lower() == self.__name.lower(): 916 if match.group(1).lower() == self.__name.lower():
879 self.__addManagementMessage( 917 self.__addManagementMessage(
880 self.tr("Away"), 918 self.tr("Away"),
881 self.tr("{0} is away: {1}").format(match.group(2), match.group(3)), 919 self.tr("{0} is away: {1}").format(match.group(2), match.group(3)),
887 def __setTopic(self, match): 925 def __setTopic(self, match):
888 """ 926 """
889 Private method to handle a topic change of the channel. 927 Private method to handle a topic change of the channel.
890 928
891 @param match match object that matched the pattern 929 @param match match object that matched the pattern
892 @return flag indicating whether the message was handled (boolean) 930 @type re.Match
931 @return flag indicating whether the message was handled
932 @rtype bool
893 """ 933 """
894 if match.group(1).lower() == self.__name.lower(): 934 if match.group(1).lower() == self.__name.lower():
895 self.topicLabel.setText(match.group(2)) 935 self.topicLabel.setText(match.group(2))
896 self.__addManagementMessage( 936 self.__addManagementMessage(
897 IrcChannelWidget.MessageIndicator, 937 IrcChannelWidget.MessageIndicator,
906 def __topicCreated(self, match): 946 def __topicCreated(self, match):
907 """ 947 """
908 Private method to handle a topic created message. 948 Private method to handle a topic created message.
909 949
910 @param match match object that matched the pattern 950 @param match match object that matched the pattern
911 @return flag indicating whether the message was handled (boolean) 951 @type re.Match
952 @return flag indicating whether the message was handled
953 @rtype bool
912 """ 954 """
913 if match.group(1).lower() == self.__name.lower(): 955 if match.group(1).lower() == self.__name.lower():
914 self.__addManagementMessage( 956 self.__addManagementMessage(
915 IrcChannelWidget.MessageIndicator, 957 IrcChannelWidget.MessageIndicator,
916 self.tr("The topic was set by {0} on {1}.").format( 958 self.tr("The topic was set by {0} on {1}.").format(
927 def __channelUrl(self, match): 969 def __channelUrl(self, match):
928 """ 970 """
929 Private method to handle a channel URL message. 971 Private method to handle a channel URL message.
930 972
931 @param match match object that matched the pattern 973 @param match match object that matched the pattern
932 @return flag indicating whether the message was handled (boolean) 974 @type re.Match
975 @return flag indicating whether the message was handled
976 @rtype bool
933 """ 977 """
934 if match.group(1).lower() == self.__name.lower(): 978 if match.group(1).lower() == self.__name.lower():
935 self.__addManagementMessage( 979 self.__addManagementMessage(
936 IrcChannelWidget.MessageIndicator, 980 IrcChannelWidget.MessageIndicator,
937 ircFilter(self.tr("Channel URL: {0}").format(match.group(2))), 981 ircFilter(self.tr("Channel URL: {0}").format(match.group(2))),
943 def __channelModes(self, match): 987 def __channelModes(self, match):
944 """ 988 """
945 Private method to handle a message reporting the channel modes. 989 Private method to handle a message reporting the channel modes.
946 990
947 @param match match object that matched the pattern 991 @param match match object that matched the pattern
948 @return flag indicating whether the message was handled (boolean) 992 @type re.Match
993 @return flag indicating whether the message was handled
994 @rtype bool
949 """ 995 """
950 if match.group(1).lower() == self.__name.lower(): 996 if match.group(1).lower() == self.__name.lower():
951 modesDict = getChannelModesDict() 997 modesDict = getChannelModesDict()
952 modesParameters = match.group(2).split() 998 modesParameters = match.group(2).split()
953 modeString = modesParameters.pop(0) 999 modeString = modesParameters.pop(0)
978 def __channelCreated(self, match): 1024 def __channelCreated(self, match):
979 """ 1025 """
980 Private method to handle a channel created message. 1026 Private method to handle a channel created message.
981 1027
982 @param match match object that matched the pattern 1028 @param match match object that matched the pattern
983 @return flag indicating whether the message was handled (boolean) 1029 @type re.Match
1030 @return flag indicating whether the message was handled
1031 @rtype bool
984 """ 1032 """
985 if match.group(1).lower() == self.__name.lower(): 1033 if match.group(1).lower() == self.__name.lower():
986 self.__addManagementMessage( 1034 self.__addManagementMessage(
987 IrcChannelWidget.MessageIndicator, 1035 IrcChannelWidget.MessageIndicator,
988 self.tr("This channel was created on {0}.").format( 1036 self.tr("This channel was created on {0}.").format(
998 def __updateChannelModes(self, match): 1046 def __updateChannelModes(self, match):
999 """ 1047 """
1000 Private method to handle a message reporting the channel modes. 1048 Private method to handle a message reporting the channel modes.
1001 1049
1002 @param match match object that matched the pattern 1050 @param match match object that matched the pattern
1003 @return flag indicating whether the message was handled (boolean) 1051 @type re.Match
1052 @return flag indicating whether the message was handled
1053 @rtype bool
1004 """ 1054 """
1005 # group(1) user or server 1055 # group(1) user or server
1006 # group(2) channel 1056 # group(2) channel
1007 # group(3) modes and parameter list 1057 # group(3) modes and parameter list
1008 if match.group(2).lower() == self.__name.lower(): 1058 if match.group(2).lower() == self.__name.lower():
1156 def __setUserPrivilege(self, match): 1206 def __setUserPrivilege(self, match):
1157 """ 1207 """
1158 Private method to handle a change of user privileges for the channel. 1208 Private method to handle a change of user privileges for the channel.
1159 1209
1160 @param match match object that matched the pattern 1210 @param match match object that matched the pattern
1161 @return flag indicating whether the message was handled (boolean) 1211 @type re.Match
1212 @return flag indicating whether the message was handled
1213 @rtype bool
1162 """ 1214 """
1163 if match.group(2).lower() == self.__name.lower(): 1215 if match.group(2).lower() == self.__name.lower():
1164 itm = self.__findUser(match.group(4)) 1216 itm = self.__findUser(match.group(4))
1165 if itm: 1217 if itm:
1166 itm.changePrivilege(match.group(3)) 1218 itm.changePrivilege(match.group(3))
1178 def __ignore(self, match): 1230 def __ignore(self, match):
1179 """ 1231 """
1180 Private method to handle a channel message we are not interested in. 1232 Private method to handle a channel message we are not interested in.
1181 1233
1182 @param match match object that matched the pattern 1234 @param match match object that matched the pattern
1183 @return flag indicating whether the message was handled (boolean) 1235 @type re.Match
1236 @return flag indicating whether the message was handled
1237 @rtype bool
1184 """ 1238 """
1185 if match.group(1).lower() == self.__name.lower(): 1239 if match.group(1).lower() == self.__name.lower():
1186 return True 1240 return True
1187 1241
1188 return False 1242 return False
1190 def __help(self, match): 1244 def __help(self, match):
1191 """ 1245 """
1192 Private method to handle a help message. 1246 Private method to handle a help message.
1193 1247
1194 @param match match object that matched the pattern 1248 @param match match object that matched the pattern
1195 @return flag indicating whether the message was handled (boolean) 1249 @type re.Match
1250 @return flag indicating whether the message was handled
1251 @rtype bool
1196 """ 1252 """
1197 self.__addManagementMessage( 1253 self.__addManagementMessage(
1198 self.tr("Help"), "{0} {1}".format(match.group(1), ircFilter(match.group(2))) 1254 self.tr("Help"), "{0} {1}".format(match.group(1), ircFilter(match.group(2)))
1199 ) 1255 )
1200 return True 1256 return True
1202 def __handleCtcp(self, match): 1258 def __handleCtcp(self, match):
1203 """ 1259 """
1204 Private method to handle a CTCP channel command. 1260 Private method to handle a CTCP channel command.
1205 1261
1206 @param match reference to the match object 1262 @param match reference to the match object
1207 @return flag indicating, if the message was handled (boolean) 1263 @type re.Match
1264 @return flag indicating, if the message was handled
1265 @rtype bool
1208 """ 1266 """
1209 # group(1) sender user name 1267 # group(1) sender user name
1210 # group(2) sender user@host 1268 # group(2) sender user@host
1211 # group(3) target nick 1269 # group(3) target nick
1212 # group(4) message 1270 # group(4) message
1258 def setUserPrivilegePrefix(self, prefixes): 1316 def setUserPrivilegePrefix(self, prefixes):
1259 """ 1317 """
1260 Public method to set the user privilege to prefix mapping. 1318 Public method to set the user privilege to prefix mapping.
1261 1319
1262 @param prefixes dictionary with privilege as key and prefix as value 1320 @param prefixes dictionary with privilege as key and prefix as value
1321 @type dict
1263 """ 1322 """
1264 self.__prefixToPrivilege = {} 1323 self.__prefixToPrivilege = {}
1265 for privilege, prefix in prefixes.items(): 1324 for privilege, prefix in prefixes.items():
1266 if prefix: 1325 if prefix:
1267 self.__prefixToPrivilege[prefix] = privilege 1326 self.__prefixToPrivilege[prefix] = privilege
1268 1327
1269 def __findUser(self, name): 1328 def __findUser(self, name):
1270 """ 1329 """
1271 Private method to find the user in the list of users. 1330 Private method to find the user in the list of users.
1272 1331
1273 @param name user name to search for (string) 1332 @param name user name to search for
1274 @return reference to the list entry (QListWidgetItem) 1333 @type str
1334 @return reference to the list entry
1335 @rtype QListWidgetItem
1275 """ 1336 """
1276 for row in range(self.usersList.count()): 1337 for row in range(self.usersList.count()):
1277 itm = self.usersList.item(row) 1338 itm = self.usersList.item(row)
1278 if itm.name() == name: 1339 if itm.name() == name:
1279 return itm 1340 return itm
1282 1343
1283 def __extractPrivilege(self, name): 1344 def __extractPrivilege(self, name):
1284 """ 1345 """
1285 Private method to extract the user privileges out of the name. 1346 Private method to extract the user privileges out of the name.
1286 1347
1287 @param name user name and prefixes (string) 1348 @param name user name and prefixes
1288 @return list of privileges and user name (list of string, string) 1349 @type str
1350 @return tuple containing a list of privileges and user name
1351 @rtype tuple of (list of str, str)
1289 """ 1352 """
1290 privileges = [] 1353 privileges = []
1291 while name[0] in self.__prefixToPrivilege: 1354 while name[0] in self.__prefixToPrivilege:
1292 prefix = name[0] 1355 prefix = name[0]
1293 privileges.append(self.__prefixToPrivilege[prefix]) 1356 privileges.append(self.__prefixToPrivilege[prefix])
1299 1362
1300 def __addManagementMessage(self, indicator, message): 1363 def __addManagementMessage(self, indicator, message):
1301 """ 1364 """
1302 Private method to add a channel management message to the list. 1365 Private method to add a channel management message to the list.
1303 1366
1304 @param indicator indicator to be shown (string) 1367 @param indicator indicator to be shown
1305 @param message message to be shown (string) 1368 @type str
1369 @param message message to be shown
1370 @type str
1306 """ 1371 """
1307 if indicator == self.JoinIndicator: 1372 if indicator == self.JoinIndicator:
1308 color = Preferences.getIrc("JoinChannelColour") 1373 color = Preferences.getIrc("JoinChannelColour")
1309 elif indicator == self.LeaveIndicator: 1374 elif indicator == self.LeaveIndicator:
1310 color = Preferences.getIrc("LeaveChannelColour") 1375 color = Preferences.getIrc("LeaveChannelColour")
1318 1383
1319 def __appendMessage(self, message): 1384 def __appendMessage(self, message):
1320 """ 1385 """
1321 Private slot to append a message. 1386 Private slot to append a message.
1322 1387
1323 @param message message to be appended (string) 1388 @param message message to be appended
1389 @type str
1324 """ 1390 """
1325 if ( 1391 if (
1326 self.__hidden 1392 self.__hidden
1327 and self.__markerLine == "" 1393 and self.__markerLine == ""
1328 and Preferences.getIrc("MarkPositionWhenHidden") 1394 and Preferences.getIrc("MarkPositionWhenHidden")
1494 def on_messages_copyAvailable(self, yes): 1560 def on_messages_copyAvailable(self, yes):
1495 """ 1561 """
1496 Private slot to react to text selection/deselection of the messages 1562 Private slot to react to text selection/deselection of the messages
1497 edit. 1563 edit.
1498 1564
1499 @param yes flag signaling the availability of selected text (boolean) 1565 @param yes flag signaling the availability of selected text
1566 @type bool
1500 """ 1567 """
1501 self.__copyMessagesAct.setEnabled(yes) 1568 self.__copyMessagesAct.setEnabled(yes)
1502 1569
1503 @pyqtSlot(QPoint) 1570 @pyqtSlot(QPoint)
1504 def on_messages_customContextMenuRequested(self, pos): 1571 def on_messages_customContextMenuRequested(self, pos):
1505 """ 1572 """
1506 Private slot to show the context menu of the messages pane. 1573 Private slot to show the context menu of the messages pane.
1507 1574
1508 @param pos the position of the mouse pointer (QPoint) 1575 @param pos the position of the mouse pointer
1576 @type QPoint
1509 """ 1577 """
1510 enable = not self.messages.document().isEmpty() 1578 enable = not self.messages.document().isEmpty()
1511 self.__cutAllMessagesAct.setEnabled(enable) 1579 self.__cutAllMessagesAct.setEnabled(enable)
1512 self.__copyAllMessagesAct.setEnabled(enable) 1580 self.__copyAllMessagesAct.setEnabled(enable)
1513 self.__saveMessagesAct.setEnabled(enable) 1581 self.__saveMessagesAct.setEnabled(enable)
1626 @pyqtSlot(QPoint) 1694 @pyqtSlot(QPoint)
1627 def on_usersList_customContextMenuRequested(self, pos): 1695 def on_usersList_customContextMenuRequested(self, pos):
1628 """ 1696 """
1629 Private slot to show the context menu of the users list. 1697 Private slot to show the context menu of the users list.
1630 1698
1631 @param pos the position of the mouse pointer (QPoint) 1699 @param pos the position of the mouse pointer
1700 @type QPoint
1632 """ 1701 """
1633 enable = len(self.usersList.selectedItems()) > 0 1702 enable = len(self.usersList.selectedItems()) > 0
1634 enablePrivate = enable and not self.__private 1703 enablePrivate = enable and not self.__private
1635 itm = self.usersList.itemAt(pos) 1704 itm = self.usersList.itemAt(pos)
1636 if itm and enablePrivate: 1705 if itm and enablePrivate:
1647 1716
1648 def hideEvent(self, evt): 1717 def hideEvent(self, evt):
1649 """ 1718 """
1650 Protected method handling hide events. 1719 Protected method handling hide events.
1651 1720
1652 @param evt reference to the hide event (QHideEvent) 1721 @param evt reference to the hide event
1722 @type QHideEvent
1653 """ 1723 """
1654 self.__hidden = True 1724 self.__hidden = True
1655 1725
1656 def showEvent(self, evt): 1726 def showEvent(self, evt):
1657 """ 1727 """
1658 Protected method handling show events. 1728 Protected method handling show events.
1659 1729
1660 @param evt reference to the show event (QShowEvent) 1730 @param evt reference to the show event
1731 @type QShowEvent
1661 """ 1732 """
1662 self.__hidden = False 1733 self.__hidden = False
1663 1734
1664 def initAutoWho(self): 1735 def initAutoWho(self):
1665 """ 1736 """
1684 """ 1755 """
1685 Private method to handle a WHO entry returned by the server as 1756 Private method to handle a WHO entry returned by the server as
1686 requested automatically. 1757 requested automatically.
1687 1758
1688 @param match match object that matched the pattern 1759 @param match match object that matched the pattern
1689 @return flag indicating whether the message was handled (boolean) 1760 @type re.Match
1761 @return flag indicating whether the message was handled
1762 @rtype bool
1690 """ 1763 """
1691 # group(1) nick 1764 # group(1) nick
1692 # group(2) user flags 1765 # group(2) user flags
1693 if self.__autoWhoRequested: 1766 if self.__autoWhoRequested:
1694 itm = self.__findUser(match.group(1)) 1767 itm = self.__findUser(match.group(1))
1701 def __whoEnd(self, match): 1774 def __whoEnd(self, match):
1702 """ 1775 """
1703 Private method to handle the end of the WHO list. 1776 Private method to handle the end of the WHO list.
1704 1777
1705 @param match match object that matched the pattern 1778 @param match match object that matched the pattern
1706 @return flag indicating whether the message was handled (boolean) 1779 @type re.Match
1780 @return flag indicating whether the message was handled
1781 @rtype bool
1707 """ 1782 """
1708 if match.group(1).lower() == self.__name.lower(): 1783 if match.group(1).lower() == self.__name.lower():
1709 if self.__autoWhoRequested: 1784 if self.__autoWhoRequested:
1710 self.__autoWhoRequested = False 1785 self.__autoWhoRequested = False
1711 self.initAutoWho() 1786 self.initAutoWho()
1722 """ 1797 """
1723 Private method to handle a WHO entry returned by the server as 1798 Private method to handle a WHO entry returned by the server as
1724 requested manually. 1799 requested manually.
1725 1800
1726 @param match match object that matched the pattern 1801 @param match match object that matched the pattern
1727 @return flag indicating whether the message was handled (boolean) 1802 @type re.Match
1803 @return flag indicating whether the message was handled
1804 @rtype bool
1728 """ 1805 """
1729 # group(1) channel 1806 # group(1) channel
1730 # group(2) user 1807 # group(2) user
1731 # group(3) host 1808 # group(3) host
1732 # group(4) nick 1809 # group(4) nick
1747 def __whoIsUser(self, match): 1824 def __whoIsUser(self, match):
1748 """ 1825 """
1749 Private method to handle the WHOIS user reply. 1826 Private method to handle the WHOIS user reply.
1750 1827
1751 @param match match object that matched the pattern 1828 @param match match object that matched the pattern
1752 @return flag indicating whether the message was handled (boolean) 1829 @type re.Match
1830 @return flag indicating whether the message was handled
1831 @rtype bool
1753 """ 1832 """
1754 # group(1) nick 1833 # group(1) nick
1755 # group(2) user 1834 # group(2) user
1756 # group(3) host 1835 # group(3) host
1757 # group(4) real name 1836 # group(4) real name
1770 def __whoIsChannels(self, match): 1849 def __whoIsChannels(self, match):
1771 """ 1850 """
1772 Private method to handle the WHOIS channels reply. 1851 Private method to handle the WHOIS channels reply.
1773 1852
1774 @param match match object that matched the pattern 1853 @param match match object that matched the pattern
1775 @return flag indicating whether the message was handled (boolean) 1854 @type re.Match
1855 @return flag indicating whether the message was handled
1856 @rtype bool
1776 """ 1857 """
1777 # group(1) nick 1858 # group(1) nick
1778 # group(2) channels 1859 # group(2) channels
1779 if match.group(1) == self.__whoIsNick: 1860 if match.group(1) == self.__whoIsNick:
1780 userChannels = [] 1861 userChannels = []
1854 def __whoIsServer(self, match): 1935 def __whoIsServer(self, match):
1855 """ 1936 """
1856 Private method to handle the WHOIS server reply. 1937 Private method to handle the WHOIS server reply.
1857 1938
1858 @param match match object that matched the pattern 1939 @param match match object that matched the pattern
1859 @return flag indicating whether the message was handled (boolean) 1940 @type re.Match
1941 @return flag indicating whether the message was handled
1942 @rtype bool
1860 """ 1943 """
1861 # group(1) nick 1944 # group(1) nick
1862 # group(2) server 1945 # group(2) server
1863 # group(3) server info 1946 # group(3) server info
1864 if match.group(1) == self.__whoIsNick: 1947 if match.group(1) == self.__whoIsNick:
1875 def __whoIsOperator(self, match): 1958 def __whoIsOperator(self, match):
1876 """ 1959 """
1877 Private method to handle the WHOIS operator reply. 1960 Private method to handle the WHOIS operator reply.
1878 1961
1879 @param match match object that matched the pattern 1962 @param match match object that matched the pattern
1880 @return flag indicating whether the message was handled (boolean) 1963 @type re.Match
1964 @return flag indicating whether the message was handled
1965 @rtype bool
1881 """ 1966 """
1882 # group(1) nick 1967 # group(1) nick
1883 # group(2) message 1968 # group(2) message
1884 if match.group(1) == self.__whoIsNick: 1969 if match.group(1) == self.__whoIsNick:
1885 if match.group(2).lower().startswith("is an irc operator"): 1970 if match.group(2).lower().startswith("is an irc operator"):
1898 def __whoIsIdle(self, match): 1983 def __whoIsIdle(self, match):
1899 """ 1984 """
1900 Private method to handle the WHOIS idle reply. 1985 Private method to handle the WHOIS idle reply.
1901 1986
1902 @param match match object that matched the pattern 1987 @param match match object that matched the pattern
1903 @return flag indicating whether the message was handled (boolean) 1988 @type re.Match
1989 @return flag indicating whether the message was handled
1990 @rtype bool
1904 """ 1991 """
1905 # group(1) nick 1992 # group(1) nick
1906 # group(2) idle seconds 1993 # group(2) idle seconds
1907 # group(3) signon time 1994 # group(3) signon time
1908 if match.group(1) == self.__whoIsNick: 1995 if match.group(1) == self.__whoIsNick:
1979 def __whoIsEnd(self, match): 2066 def __whoIsEnd(self, match):
1980 """ 2067 """
1981 Private method to handle the end of WHOIS reply. 2068 Private method to handle the end of WHOIS reply.
1982 2069
1983 @param match match object that matched the pattern 2070 @param match match object that matched the pattern
1984 @return flag indicating whether the message was handled (boolean) 2071 @type re.Match
2072 @return flag indicating whether the message was handled
2073 @rtype bool
1985 """ 2074 """
1986 # group(1) nick 2075 # group(1) nick
1987 # group(2) end message 2076 # group(2) end message
1988 if match.group(1) == self.__whoIsNick: 2077 if match.group(1) == self.__whoIsNick:
1989 self.__whoIsNick = "" 2078 self.__whoIsNick = ""
1998 def __whoIsIdentify(self, match): 2087 def __whoIsIdentify(self, match):
1999 """ 2088 """
2000 Private method to handle the WHOIS identify and identified replies. 2089 Private method to handle the WHOIS identify and identified replies.
2001 2090
2002 @param match match object that matched the pattern 2091 @param match match object that matched the pattern
2003 @return flag indicating whether the message was handled (boolean) 2092 @type re.Match
2093 @return flag indicating whether the message was handled
2094 @rtype bool
2004 """ 2095 """
2005 # group(1) nick 2096 # group(1) nick
2006 # group(2) identified message 2097 # group(2) identified message
2007 if match.group(1) == self.__whoIsNick: 2098 if match.group(1) == self.__whoIsNick:
2008 self.__addManagementMessage( 2099 self.__addManagementMessage(
2016 def __whoIsHelper(self, match): 2107 def __whoIsHelper(self, match):
2017 """ 2108 """
2018 Private method to handle the WHOIS helper reply. 2109 Private method to handle the WHOIS helper reply.
2019 2110
2020 @param match match object that matched the pattern 2111 @param match match object that matched the pattern
2021 @return flag indicating whether the message was handled (boolean) 2112 @type re.Match
2113 @return flag indicating whether the message was handled
2114 @rtype bool
2022 """ 2115 """
2023 # group(1) nick 2116 # group(1) nick
2024 # group(2) helper message 2117 # group(2) helper message
2025 if match.group(1) == self.__whoIsNick: 2118 if match.group(1) == self.__whoIsNick:
2026 self.__addManagementMessage( 2119 self.__addManagementMessage(
2034 def __whoIsAccount(self, match): 2127 def __whoIsAccount(self, match):
2035 """ 2128 """
2036 Private method to handle the WHOIS account reply. 2129 Private method to handle the WHOIS account reply.
2037 2130
2038 @param match match object that matched the pattern 2131 @param match match object that matched the pattern
2039 @return flag indicating whether the message was handled (boolean) 2132 @type re.Match
2133 @return flag indicating whether the message was handled
2134 @rtype bool
2040 """ 2135 """
2041 # group(1) nick 2136 # group(1) nick
2042 # group(2) login name 2137 # group(2) login name
2043 if match.group(1) == self.__whoIsNick: 2138 if match.group(1) == self.__whoIsNick:
2044 self.__addManagementMessage( 2139 self.__addManagementMessage(
2054 def __whoIsActually(self, match): 2149 def __whoIsActually(self, match):
2055 """ 2150 """
2056 Private method to handle the WHOIS actually reply. 2151 Private method to handle the WHOIS actually reply.
2057 2152
2058 @param match match object that matched the pattern 2153 @param match match object that matched the pattern
2059 @return flag indicating whether the message was handled (boolean) 2154 @type re.Match
2155 @return flag indicating whether the message was handled
2156 @rtype bool
2060 """ 2157 """
2061 # group(1) nick 2158 # group(1) nick
2062 # group(2) actual user@host 2159 # group(2) actual user@host
2063 # group(3) actual IP 2160 # group(3) actual IP
2064 if match.group(1) == self.__whoIsNick: 2161 if match.group(1) == self.__whoIsNick:
2075 def __whoIsSecure(self, match): 2172 def __whoIsSecure(self, match):
2076 """ 2173 """
2077 Private method to handle the WHOIS secure reply. 2174 Private method to handle the WHOIS secure reply.
2078 2175
2079 @param match match object that matched the pattern 2176 @param match match object that matched the pattern
2080 @return flag indicating whether the message was handled (boolean) 2177 @type re.Match
2178 @return flag indicating whether the message was handled
2179 @rtype bool
2081 """ 2180 """
2082 # group(1) nick 2181 # group(1) nick
2083 if match.group(1) == self.__whoIsNick: 2182 if match.group(1) == self.__whoIsNick:
2084 self.__addManagementMessage( 2183 self.__addManagementMessage(
2085 self.tr("Whois"), 2184 self.tr("Whois"),
2092 def __whoIsConnection(self, match): 2191 def __whoIsConnection(self, match):
2093 """ 2192 """
2094 Private method to handle the WHOIS connection reply. 2193 Private method to handle the WHOIS connection reply.
2095 2194
2096 @param match match object that matched the pattern 2195 @param match match object that matched the pattern
2097 @return flag indicating whether the message was handled (boolean) 2196 @type re.Match
2197 @return flag indicating whether the message was handled
2198 @rtype bool
2098 """ 2199 """
2099 # group(1) nick 2200 # group(1) nick
2100 # group(2) host name 2201 # group(2) host name
2101 # group(3) IP 2202 # group(3) IP
2102 if match.group(1) == self.__whoIsNick: 2203 if match.group(1) == self.__whoIsNick:
2136 @pyqtSlot(QUrl) 2237 @pyqtSlot(QUrl)
2137 def on_messages_anchorClicked(self, url): 2238 def on_messages_anchorClicked(self, url):
2138 """ 2239 """
2139 Private slot to open links in the default browser. 2240 Private slot to open links in the default browser.
2140 2241
2141 @param url URL to be opened (QUrl) 2242 @param url URL to be opened
2243 @type QUrl
2142 """ 2244 """
2143 QDesktopServices.openUrl(url) 2245 QDesktopServices.openUrl(url)

eric ide

mercurial