Network/IRC/IrcChannelWidget.py

changeset 2445
e3fadb2b85c7
parent 2442
1dcfd570fa12
child 2446
aed80104991a
equal deleted inserted replaced
2444:0fdd7f9ebd0b 2445:e3fadb2b85c7
159 privilege = IrcUserItem.Admin 159 privilege = IrcUserItem.Admin
160 if flags.startswith("G"): 160 if flags.startswith("G"):
161 privilege |= IrcUserItem.Away 161 privilege |= IrcUserItem.Away
162 self.__privilege = privilege 162 self.__privilege = privilege
163 self.__setIcon() 163 self.__setIcon()
164
165 def canChangeTopic(self):
166 """
167 Public method to check, if the user is allowed to change the topic.
168
169 @return flag indicating that the topic can be changed (boolean)
170 """
171 return(bool(self.__privilege & IrcUserItem.Operator) or \
172 bool(self.__privilege & IrcUserItem.Admin) or \
173 bool(self.__privilege & IrcUserItem.Owner))
164 174
165 175
166 class IrcChannelWidget(QWidget, Ui_IrcChannelWidget): 176 class IrcChannelWidget(QWidget, Ui_IrcChannelWidget):
167 """ 177 """
168 Class implementing the IRC channel widget. 178 Class implementing the IRC channel widget.
195 205
196 self.__ui = e5App().getObject("UserInterface") 206 self.__ui = e5App().getObject("UserInterface")
197 self.__ircWidget = parent 207 self.__ircWidget = parent
198 208
199 self.editTopicButton.setIcon(UI.PixmapCache.getIcon("ircEditTopic.png")) 209 self.editTopicButton.setIcon(UI.PixmapCache.getIcon("ircEditTopic.png"))
210 self.editTopicButton.hide()
200 211
201 height = self.usersList.height() + self.messages.height() 212 height = self.usersList.height() + self.messages.height()
202 self.splitter.setSizes([height * 0.3, height * 0.7]) 213 self.splitter.setSizes([height * 0.3, height * 0.7])
203 214
204 self.__initMessagesMenu() 215 self.__initMessagesMenu()
615 itm = self.__findUser(userName) 626 itm = self.__findUser(userName)
616 if itm is None: 627 if itm is None:
617 itm = IrcUserItem(userName, self.usersList) 628 itm = IrcUserItem(userName, self.usersList)
618 for privilege in userPrivileges: 629 for privilege in userPrivileges:
619 itm.changePrivilege(privilege) 630 itm.changePrivilege(privilege)
620 return True 631
621 632 self.__setEditTopicButton()
622 return False 633 return True
623 634
635 return False
636
624 def __userAway(self, match): 637 def __userAway(self, match):
625 """ 638 """
626 Private method to handle a topic change of the channel. 639 Private method to handle a topic change of the channel.
627 640
628 @param match match object that matched the pattern 641 @param match match object that matched the pattern
886 """ 899 """
887 if match.group(2).lower() == self.__name: 900 if match.group(2).lower() == self.__name:
888 itm = self.__findUser(match.group(4)) 901 itm = self.__findUser(match.group(4))
889 if itm: 902 if itm:
890 itm.changePrivilege(match.group(3)) 903 itm.changePrivilege(match.group(3))
904 self.__setEditTopicButton()
891 self.__addManagementMessage(IrcChannelWidget.MessageIndicator, 905 self.__addManagementMessage(IrcChannelWidget.MessageIndicator,
892 self.trUtf8("{0} sets mode for {1}: {2}.").format( 906 self.trUtf8("{0} sets mode for {1}: {2}.").format(
893 match.group(1), match.group(4), match.group(3))) 907 match.group(1), match.group(4), match.group(3)))
894 return True 908 return True
895 909
1657 match.group(1), match.group(2), match.group(3))) 1671 match.group(1), match.group(2), match.group(3)))
1658 return True 1672 return True
1659 1673
1660 return False 1674 return False
1661 1675
1676 def __setEditTopicButton(self):
1677 """
1678 Private method to set the visibility of the Edit Topic button.
1679 """
1680 itm = self.__findUser(self.__userName)
1681 if itm:
1682 self.editTopicButton.setVisible(itm.canChangeTopic())
1683
1662 @pyqtSlot() 1684 @pyqtSlot()
1663 def on_editTopicButton_clicked(self): 1685 def on_editTopicButton_clicked(self):
1664 """ 1686 """
1665 Private slot to change the topic of the channel. 1687 Private slot to change the topic of the channel.
1666 """ 1688 """

eric ide

mercurial