Helpviewer/FlashCookieManager/FlashCookieManagerDialog.py

changeset 4363
c00061f670c7
parent 4362
1a171c85b275
child 4370
54dbb658f9e6
equal deleted inserted replaced
4362:1a171c85b275 4363:c00061f670c7
6 """ 6 """
7 Module implementing a dialog to manage the flash cookies. 7 Module implementing a dialog to manage the flash cookies.
8 """ 8 """
9 9
10 from PyQt5.QtCore import pyqtSlot, Qt, QPoint, QTimer 10 from PyQt5.QtCore import pyqtSlot, Qt, QPoint, QTimer
11 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QApplication, QMenu 11 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QApplication, QMenu, \
12 QInputDialog, QLineEdit
12 13
13 from E5Gui import E5MessageBox 14 from E5Gui import E5MessageBox
14 15
15 from .Ui_FlashCookieManagerDialog import Ui_FlashCookieManagerDialog 16 from .Ui_FlashCookieManagerDialog import Ui_FlashCookieManagerDialog
16 17
58 self.removeBlackButton.setEnabled(enable) 59 self.removeBlackButton.setEnabled(enable)
59 60
60 @pyqtSlot() 61 @pyqtSlot()
61 def on_removeWhiteButton_clicked(self): 62 def on_removeWhiteButton_clicked(self):
62 """ 63 """
63 Slot documentation goes here. 64 Private slot to remove a server from the whitelist.
64 """ 65 """
65 # TODO: not implemented yet 66 for itm in self.whiteList.selectedItems():
66 raise NotImplementedError 67 row = self.whiteList.row(itm)
68 self.whiteList.takeItem(row)
69 del itm
67 70
68 @pyqtSlot() 71 @pyqtSlot()
69 def on_addWhiteButton_clicked(self): 72 def on_addWhiteButton_clicked(self):
70 """ 73 """
71 Slot documentation goes here. 74 Private slot to add a server to the whitelist.
72 """ 75 """
73 # TODO: not implemented yet 76 origin, ok = QInputDialog.getText(
74 raise NotImplementedError 77 self,
78 self.tr("Add to whitelist"),
79 self.tr("Origin:"),
80 QLineEdit.Normal)
81 if ok and bool(origin):
82 self.__addWhitelist(origin)
83
84 def __addWhitelist(self, origin):
85 """
86 Private method to add a cookie origin to the whitelist.
87 """
88 if not origin:
89 return
90
91 if len(self.blackList.findItems(origin, Qt.MatchFixedString)) > 0:
92 E5MessageBox.information(
93 self,
94 self.tr("Add to whitelist"),
95 self.tr("""The server '{0}' is already in the blacklist."""
96 """ Please remove it first.""").format(origin))
97 return
98
99 if len(self.whiteList.findItems(origin, Qt.MatchFixedString)) == 0:
100 self.whiteList.addItem(origin)
75 101
76 @pyqtSlot() 102 @pyqtSlot()
77 def on_removeBlackButton_clicked(self): 103 def on_removeBlackButton_clicked(self):
78 """ 104 """
79 Slot documentation goes here. 105 Private slot to remove a server from the blacklist.
80 """ 106 """
81 # TODO: not implemented yet 107 for itm in self.blackList.selectedItems():
82 raise NotImplementedError 108 row = self.blackList.row(itm)
109 self.blackList.takeItem(row)
110 del itm
83 111
84 @pyqtSlot() 112 @pyqtSlot()
85 def on_addBlackButton_clicked(self): 113 def on_addBlackButton_clicked(self):
86 """ 114 """
87 Slot documentation goes here. 115 Private slot to add a server to the blacklist.
88 """ 116 """
89 # TODO: not implemented yet 117 origin, ok = QInputDialog.getText(
90 raise NotImplementedError 118 self,
119 self.tr("Add to blacklist"),
120 self.tr("Origin:"),
121 QLineEdit.Normal)
122 if ok and bool(origin):
123 self.__addBlacklist(origin)
124
125 def __addBlacklist(self, origin):
126 """
127 Private method to add a cookie origin to the blacklist.
128 """
129 if not origin:
130 return
131
132 if len(self.whiteList.findItems(origin, Qt.MatchFixedString)) > 0:
133 E5MessageBox.information(
134 self,
135 self.tr("Add to blacklist"),
136 self.tr("""The server '{0}' is already in the whitelist."""
137 """ Please remove it first.""").format(origin))
138 return
139
140 if len(self.blackList.findItems(origin, Qt.MatchFixedString)) == 0:
141 self.blackList.addItem(origin)
91 142
92 @pyqtSlot(str) 143 @pyqtSlot(str)
93 def on_filterEdit_textChanged(self, p0): 144 def on_filterEdit_textChanged(self, filter):
94 """ 145 """
95 Slot documentation goes here. 146 Private slot to filter the cookies list.
96 """ 147
97 return 148 @param filter filter text
98 # TODO: not implemented yet 149 @type str
99 raise NotImplementedError 150 """
151 if not filter:
152 # show all in collapsed state
153 for index in range(self.cookiesList.topLevelItemCount()):
154 self.cookiesList.topLevelItem(index).setHidden(False)
155 self.cookiesList.topLevelItem(index).setExpanded(False)
156 else:
157 # show matching in expanded state
158 filter = filter.lower()
159 for index in range(self.cookiesList.topLevelItemCount()):
160 txt = "." + self.cookiesList.topLevelItem(index)\
161 .text(0).lower()
162 self.cookiesList.topLevelItem(index).setHidden(
163 filter not in txt)
164 self.cookiesList.topLevelItem(index).setExpanded(True)
100 165
101 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) 166 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
102 def on_cookiesList_currentItemChanged(self, current, previous): 167 def on_cookiesList_currentItemChanged(self, current, previous):
103 """ 168 """
104 Private slot handling a change of the current cookie item. 169 Private slot handling a change of the current cookie item.

eric ide

mercurial