5 |
5 |
6 """ |
6 """ |
7 Module implementing the AdBlock configuration dialog. |
7 Module implementing the AdBlock configuration dialog. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import pyqtSlot, QUrl |
10 from PyQt4.QtCore import pyqtSlot, Qt, QUrl |
11 from PyQt4.QtGui import QDialog, QMenu, QToolButton, QApplication, QDesktopServices |
11 from PyQt4.QtGui import QDialog, QMenu, QToolButton, QApplication, QDesktopServices |
12 |
12 |
13 from E5Gui.E5TreeSortFilterProxyModel import E5TreeSortFilterProxyModel |
13 from E5Gui.E5TreeSortFilterProxyModel import E5TreeSortFilterProxyModel |
14 |
14 |
15 import Helpviewer.HelpWindow |
15 import Helpviewer.HelpWindow |
111 @param rule string defining the rule to be added (string) |
111 @param rule string defining the rule to be added (string) |
112 """ |
112 """ |
113 manager = Helpviewer.HelpWindow.HelpWindow.adblockManager() |
113 manager = Helpviewer.HelpWindow.HelpWindow.adblockManager() |
114 subscription = manager.customRules() |
114 subscription = manager.customRules() |
115 assert subscription is not None |
115 assert subscription is not None |
116 subscription.addRule(AdBlockRule(rule)) |
116 subscription.addRule(AdBlockRule(rule, subscription)) |
117 QApplication.processEvents() |
117 QApplication.processEvents() |
118 |
118 |
119 parent = self.__adBlockModel.subscriptionIndex(subscription) |
119 parent = self.__adBlockModel.subscriptionIndex(subscription) |
120 cnt = self.__adBlockModel.rowCount(parent) |
120 cnt = self.__adBlockModel.rowCount(parent) |
121 ruleIndex = self.__adBlockModel.index(cnt - 1, 0, parent) |
121 ruleIndex = self.__adBlockModel.index(cnt - 1, 0, parent) |
170 Preferences.setHelp("AdBlockUpdatePeriod", value) |
170 Preferences.setHelp("AdBlockUpdatePeriod", value) |
171 |
171 |
172 manager = Helpviewer.HelpWindow.HelpWindow.adblockManager() |
172 manager = Helpviewer.HelpWindow.HelpWindow.adblockManager() |
173 for subscription in manager.subscriptions(): |
173 for subscription in manager.subscriptions(): |
174 subscription.checkForUpdate() |
174 subscription.checkForUpdate() |
|
175 |
|
176 def showRule(self, rule): |
|
177 """ |
|
178 Public slot to show the given rule. |
|
179 |
|
180 @param rule rule to be shown (AdBlockRule) |
|
181 """ |
|
182 if rule is None: |
|
183 return |
|
184 |
|
185 subscription = rule.subscription() |
|
186 if subscription is None: |
|
187 return |
|
188 |
|
189 self.searchEdit.clear() |
|
190 |
|
191 subscriptionIndex = self.__adBlockModel.subscriptionIndex(subscription) |
|
192 subscriptionProxyIndex = self.__proxyModel.mapFromSource(subscriptionIndex) |
|
193 filter = rule.filter() |
|
194 if filter: |
|
195 indexes = self.__proxyModel.match( |
|
196 subscriptionProxyIndex, Qt.DisplayRole, filter, 1, |
|
197 Qt.MatchStartsWith | Qt.MatchRecursive) |
|
198 if indexes: |
|
199 self.subscriptionsTree.expand(subscriptionProxyIndex) |
|
200 self.subscriptionsTree.scrollTo(indexes[0]) |
|
201 self.subscriptionsTree.setCurrentIndex(indexes[0]) |
|
202 self.raise_() |