33 @param parent reference to the parent object (QObject) |
33 @param parent reference to the parent object (QObject) |
34 """ |
34 """ |
35 QObject.__init__(self, parent) |
35 QObject.__init__(self, parent) |
36 |
36 |
37 self.__loaded = False |
37 self.__loaded = False |
|
38 self.__subscriptionsLoaded = False |
38 self.__enabled = False |
39 self.__enabled = False |
39 self.__adBlockDialog = None |
40 self.__adBlockDialog = None |
40 self.__adBlockNetwork = None |
41 self.__adBlockNetwork = None |
41 self.__adBlockPage = None |
42 self.__adBlockPage = None |
42 self.__subscriptions = [] |
43 self.__subscriptions = [] |
187 """ |
190 """ |
188 if not self.__loaded: |
191 if not self.__loaded: |
189 return |
192 return |
190 |
193 |
191 Preferences.setHelp("AdBlockEnabled", self.__enabled) |
194 Preferences.setHelp("AdBlockEnabled", self.__enabled) |
192 subscriptions = [] |
195 if self.__subscriptionsLoaded: |
193 for subscription in self.__subscriptions: |
196 subscriptions = [] |
194 if subscription is None: |
197 for subscription in self.__subscriptions: |
195 continue |
198 if subscription is None: |
196 subscriptions.append(bytes(subscription.url().toEncoded()).decode()) |
199 continue |
197 subscription.saveRules() |
200 subscriptions.append(bytes(subscription.url().toEncoded()).decode()) |
198 Preferences.setHelp("AdBlockSubscriptions", subscriptions) |
201 subscription.saveRules() |
|
202 Preferences.setHelp("AdBlockSubscriptions", subscriptions) |
199 |
203 |
200 def load(self): |
204 def load(self): |
201 """ |
205 """ |
202 Public method to load the AdBlock subscriptions. |
206 Public method to load the AdBlock subscriptions. |
203 """ |
207 """ |
205 return |
209 return |
206 |
210 |
207 self.__loaded = True |
211 self.__loaded = True |
208 |
212 |
209 self.__enabled = Preferences.getHelp("AdBlockEnabled") |
213 self.__enabled = Preferences.getHelp("AdBlockEnabled") |
|
214 if self.__enabled: |
|
215 self.__loadSubscriptions() |
|
216 |
|
217 def __loadSubscriptions(): |
|
218 """ |
|
219 Private method to load the set of subscriptions. |
|
220 """ |
|
221 if self.__subscriptionsLoaded: |
|
222 return |
210 |
223 |
211 defaultSubscriptions = [] |
224 defaultSubscriptions = [] |
212 defaultSubscriptions.append( |
225 defaultSubscriptions.append( |
213 bytes(self.__customSubscriptionUrl().toEncoded()).decode()) |
226 bytes(self.__customSubscriptionUrl().toEncoded()).decode()) |
214 defaultSubscriptions.append( |
227 defaultSubscriptions.append( |
223 self.connect(adBlockSubscription, SIGNAL("rulesChanged()"), |
236 self.connect(adBlockSubscription, SIGNAL("rulesChanged()"), |
224 self, SIGNAL("rulesChanged()")) |
237 self, SIGNAL("rulesChanged()")) |
225 self.connect(adBlockSubscription, SIGNAL("changed()"), |
238 self.connect(adBlockSubscription, SIGNAL("changed()"), |
226 self, SIGNAL("rulesChanged()")) |
239 self, SIGNAL("rulesChanged()")) |
227 self.__subscriptions.append(adBlockSubscription) |
240 self.__subscriptions.append(adBlockSubscription) |
|
241 |
|
242 self.__subscriptionsLoaded = True |
228 |
243 |
229 def showDialog(self): |
244 def showDialog(self): |
230 """ |
245 """ |
231 Public slot to show the AdBlock subscription management dialog. |
246 Public slot to show the AdBlock subscription management dialog. |
232 """ |
247 """ |