76 tree = AdBlockTreeWidget(subscription, self.subscriptionsTabWidget) |
76 tree = AdBlockTreeWidget(subscription, self.subscriptionsTabWidget) |
77 if subscription.isEnabled(): |
77 if subscription.isEnabled(): |
78 icon = UI.PixmapCache.getIcon("adBlockPlus.png") |
78 icon = UI.PixmapCache.getIcon("adBlockPlus.png") |
79 else: |
79 else: |
80 icon = UI.PixmapCache.getIcon("adBlockPlusDisabled.png") |
80 icon = UI.PixmapCache.getIcon("adBlockPlusDisabled.png") |
81 self.subscriptionsTabWidget.addTab(tree, icon, subscription.title()) |
81 self.subscriptionsTabWidget.addTab( |
|
82 tree, icon, subscription.title()) |
82 |
83 |
83 self.__loaded = True |
84 self.__loaded = True |
84 QCoreApplication.processEvents() |
85 QCoreApplication.processEvents() |
85 |
86 |
86 QTimer.singleShot(50, self.__loadSubscriptions) |
87 QTimer.singleShot(50, self.__loadSubscriptions) |
94 @param refresh flag indicating to refresh the tree (boolean) |
95 @param refresh flag indicating to refresh the tree (boolean) |
95 """ |
96 """ |
96 from .AdBlockTreeWidget import AdBlockTreeWidget |
97 from .AdBlockTreeWidget import AdBlockTreeWidget |
97 tree = AdBlockTreeWidget(subscription, self.subscriptionsTabWidget) |
98 tree = AdBlockTreeWidget(subscription, self.subscriptionsTabWidget) |
98 index = self.subscriptionsTabWidget.insertTab( |
99 index = self.subscriptionsTabWidget.insertTab( |
99 self.subscriptionsTabWidget.count() - 1, tree, subscription.title()) |
100 self.subscriptionsTabWidget.count() - 1, tree, |
|
101 subscription.title()) |
100 self.subscriptionsTabWidget.setCurrentIndex(index) |
102 self.subscriptionsTabWidget.setCurrentIndex(index) |
101 QCoreApplication.processEvents() |
103 QCoreApplication.processEvents() |
102 if refresh: |
104 if refresh: |
103 tree.refresh() |
105 tree.refresh() |
104 self.__setSubscriptionEnabled(subscription, True) |
106 self.__setSubscriptionEnabled(subscription, True) |
120 menu.addAction(self.trUtf8("Add Rule"), self.__addCustomRule)\ |
122 menu.addAction(self.trUtf8("Add Rule"), self.__addCustomRule)\ |
121 .setEnabled(subscriptionEditable) |
123 .setEnabled(subscriptionEditable) |
122 menu.addAction(self.trUtf8("Remove Rule"), self.__removeCustomRule)\ |
124 menu.addAction(self.trUtf8("Remove Rule"), self.__removeCustomRule)\ |
123 .setEnabled(subscriptionEditable) |
125 .setEnabled(subscriptionEditable) |
124 menu.addSeparator() |
126 menu.addSeparator() |
125 menu.addAction(self.trUtf8("Browse Subscriptions..."), self.__browseSubscriptions) |
127 menu.addAction( |
126 menu.addAction(self.trUtf8("Remove Subscription"), self.__removeSubscription)\ |
128 self.trUtf8("Browse Subscriptions..."), self.__browseSubscriptions) |
|
129 menu.addAction( |
|
130 self.trUtf8("Remove Subscription"), self.__removeSubscription)\ |
127 .setEnabled(subscriptionRemovable) |
131 .setEnabled(subscriptionRemovable) |
128 if self.__currentSubscription: |
132 if self.__currentSubscription: |
129 menu.addSeparator() |
133 menu.addSeparator() |
130 if subscriptionEnabled: |
134 if subscriptionEnabled: |
131 txt = self.trUtf8("Disable Subscription") |
135 txt = self.trUtf8("Disable Subscription") |
132 else: |
136 else: |
133 txt = self.trUtf8("Enable Subscription") |
137 txt = self.trUtf8("Enable Subscription") |
134 menu.addAction(txt, self.__switchSubscriptionEnabled) |
138 menu.addAction(txt, self.__switchSubscriptionEnabled) |
135 menu.addSeparator() |
139 menu.addSeparator() |
136 menu.addAction(self.trUtf8("Update Subscription"), self.__updateSubscription)\ |
140 menu.addAction( |
|
141 self.trUtf8("Update Subscription"), self.__updateSubscription)\ |
137 .setEnabled(not subscriptionEditable) |
142 .setEnabled(not subscriptionEditable) |
138 menu.addAction(self.trUtf8("Update All Subscriptions"), |
143 menu.addAction(self.trUtf8("Update All Subscriptions"), |
139 self.__updateAllSubscriptions) |
144 self.__updateAllSubscriptions) |
140 menu.addSeparator() |
145 menu.addSeparator() |
141 menu.addAction(self.trUtf8("Learn more about writing rules..."), |
146 menu.addAction(self.trUtf8("Learn more about writing rules..."), |
201 requiresSubscriptions = \ |
206 requiresSubscriptions = \ |
202 self.__manager.getRequiresSubscriptions(self.__currentSubscription) |
207 self.__manager.getRequiresSubscriptions(self.__currentSubscription) |
203 for subscription in requiresSubscriptions: |
208 for subscription in requiresSubscriptions: |
204 requiresTitles.append(subscription.title()) |
209 requiresTitles.append(subscription.title()) |
205 if requiresTitles: |
210 if requiresTitles: |
206 message = self.trUtf8("<p>Do you really want to remove subscription" |
211 message = self.trUtf8( |
|
212 "<p>Do you really want to remove subscription" |
207 " <b>{0}</b> and all subscriptions requiring it?</p>" |
213 " <b>{0}</b> and all subscriptions requiring it?</p>" |
208 "<ul><li>{1}</li></ul>").format( |
214 "<ul><li>{1}</li></ul>").format( |
209 self.__currentSubscription.title(), |
215 self.__currentSubscription.title(), |
210 "</li><li>".join(requiresTitles)) |
216 "</li><li>".join(requiresTitles)) |
211 else: |
217 else: |
212 message = self.trUtf8("<p>Do you really want to remove subscription" |
218 message = self.trUtf8( |
|
219 "<p>Do you really want to remove subscription" |
213 " <b>{0}</b>?</p>").format(self.__currentSubscription.title()) |
220 " <b>{0}</b>?</p>").format(self.__currentSubscription.title()) |
214 res = E5MessageBox.yesNo(self, |
221 res = E5MessageBox.yesNo(self, |
215 self.trUtf8("Remove Subscription"), |
222 self.trUtf8("Remove Subscription"), |
216 message) |
223 message) |
217 |
224 |
236 |
243 |
237 def __setSubscriptionEnabled(self, subscription, enable): |
244 def __setSubscriptionEnabled(self, subscription, enable): |
238 """ |
245 """ |
239 Private slot to set the enabled state of a subscription. |
246 Private slot to set the enabled state of a subscription. |
240 |
247 |
241 @param subscription subscription to set the state for (AdBlockSubscription) |
248 @param subscription subscription to set the state for |
|
249 (AdBlockSubscription) |
242 @param enable state to set to (boolean) |
250 @param enable state to set to (boolean) |
243 """ |
251 """ |
244 if enable: |
252 if enable: |
245 # enable required one as well |
253 # enable required one as well |
246 sub = self.__manager.subscription(subscription.requiresLocation()) |
254 sub = self.__manager.subscription(subscription.requiresLocation()) |
282 Private slot handling the selection of another tab. |
290 Private slot handling the selection of another tab. |
283 |
291 |
284 @param index index of the new current tab (integer) |
292 @param index index of the new current tab (integer) |
285 """ |
293 """ |
286 if index != -1: |
294 if index != -1: |
287 self.__currentTreeWidget = self.subscriptionsTabWidget.widget(index) |
295 self.__currentTreeWidget = \ |
288 self.__currentSubscription = self.__currentTreeWidget.subscription() |
296 self.subscriptionsTabWidget.widget(index) |
|
297 self.__currentSubscription = \ |
|
298 self.__currentTreeWidget.subscription() |
289 |
299 |
290 @pyqtSlot(str) |
300 @pyqtSlot(str) |
291 def on_searchEdit_textChanged(self, filter): |
301 def on_searchEdit_textChanged(self, filter): |
292 """ |
302 """ |
293 Private slot to set a new filter on the current widget. |
303 Private slot to set a new filter on the current widget. |