# eric4.Helpviewer.AdBlock.AdBlockSubscription

Module implementing the AdBlock subscription class.

### Global Attributes

None

### Classes

AdBlockSubscription | Class implementing the AdBlock subscription.

### Functions

None

## AdBlockSubscription

Class implementing the AdBlock subscription.

### Signals

changed()
  emitted after the subscription has changed
rulesChanged()
  emitted after the subscription's rules have changed

### Derived from

QObject

### Class Attributes

None

### Class Methods

None

### Methods

AdBlockSubscription | Constructor
__loadRules | Private method to load the rules of the subscription.
__parseUrl | Private method to parse the AdBlock URL for the subscription.
__populateCache | Private method to populate the various rule caches.
__rulesDownloaded | Private slot to deal with the downloaded rules.
addRule | Public method to add a rule.
allRules | Public method to get the list of rules.
allow | Public method to check, if the given URL is allowed.
block | Public method to check, if the given URL should be blocked.
isEnabled | Public method to check, if the subscription is enabled.
lastUpdate | Public method to get the date and time of the last update.
location | Public method to get the subscription location.
pageRules | Public method to get the page rules of the subscription.
removeRule | Public method to remove a rule given the offset.
replaceRule | Public method to replace a rule given the offset.
rulesFileName | Public method to get the name of the rules file.
saveRules | Public method to save the subscription rules.
setEnabled | Public method to set the enabled status.
setLocation | Public method to set the subscription location.
setTitle | Public method to set the subscription title.
title | Public method to get the subscription title.
updateNow | Public method to update the subscription immediately.
url | Public method to generate the url for this subscription.

### Static Methods

None

#### AdBlockSubscription (Constructor)

AdBlockSubscription(url, parent = None, default = False)

Constructor

url
  AdBlock URL for the subscription (QUrl)
parent
  reference to the parent object (QObject)
default
  flag indicating a default subscription (Boolean)

#### AdBlockSubscription.__loadRules

__loadRules()

Private method to load the rules of the subscription.

#### AdBlockSubscription.__parseUrl

__parseUrl(url)

Private method to parse the AdBlock URL for the subscription.

url
  AdBlock URL for the subscription (QUrl)

#### AdBlockSubscription.__populateCache

__populateCache()

Private method to populate the various rule caches.

#### AdBlockSubscription.__rulesDownloaded

__rulesDownloaded()

Private slot to deal with the downloaded rules.

#### AdBlockSubscription.addRule

addRule(rule)

Public method to add a rule.

rule
  reference to the rule to add (AdBlockRule)

#### AdBlockSubscription.allRules

allRules()

Public method to get the list of rules.

Returns:
  list of rules (list of AdBlockRule)

#### AdBlockSubscription.allow

allow(urlString)

Public method to check, if the given URL is allowed.

Returns:
  reference to the rule object or None (AdBlockRule)

#### AdBlockSubscription.block

block(urlString)

Public method to check, if the given URL should be blocked.

Returns:
  reference to the rule object or None (AdBlockRule)

#### AdBlockSubscription.isEnabled

isEnabled()

Public method to check, if the subscription is enabled.

Returns:
  flag indicating the enabled status (boolean)

#### AdBlockSubscription.lastUpdate

lastUpdate()

Public method to get the date and time of the last update.

Returns:
  date and time of the last update (QDateTime)

#### AdBlockSubscription.location

location()

Public method to get the subscription location.

Returns:
  URL of the subscription location (QUrl)

#### AdBlockSubscription.pageRules

pageRules()

Public method to get the page rules of the subscription.

Returns:
  list of rule objects (list of AdBlockRule)

#### AdBlockSubscription.removeRule

removeRule(offset)

Public method to remove a rule given the offset.

offset
  offset of the rule to remove (integer)

#### AdBlockSubscription.replaceRule

replaceRule(rule, offset)

Public method to replace a rule given the offset.

rule
  reference to the rule to set (AdBlockRule)
offset
  offset of the rule to remove (integer)

#### AdBlockSubscription.rulesFileName

rulesFileName()

Public method to get the name of the rules file.

Returns:
  name of the rules file (QString)

#### AdBlockSubscription.saveRules

saveRules()

Public method to save the subscription rules.

#### AdBlockSubscription.setEnabled

setEnabled(enabled)

Public method to set the enabled status.

enabled
  flag indicating the enabled status (boolean)

#### AdBlockSubscription.setLocation

setLocation(url)

Public method to set the subscription location.

url
  URL of the subscription location (QUrl)

#### AdBlockSubscription.setTitle

setTitle(title)

Public method to set the subscription title.

title
  subscription title (string or QString)

#### AdBlockSubscription.title

title()

Public method to get the subscription title.

Returns:
  subscription title (QString)

#### AdBlockSubscription.updateNow

updateNow()

Public method to update the subscription immediately.

#### AdBlockSubscription.url

url()

Public method to generate the url for this subscription.

Returns:
  AdBlock URL for the subscription (QUrl)

Up