# eric5.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
enabledChanged(bool)
  emitted after the enabled state was 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.
__validateCheckSum | Private method to check the subscription file's checksum.
adBlockDisabledForUrl | Public method to check, if AdBlock is disabled for the given URL.
addRule | Public method to add a rule.
allRules | Public method to get the list of rules.
canBeRemoved | Public method to check, if the subscription can be removed.
canEditRules | Public method to check, if rules can be edited.
checkForUpdate | Public method to check for an update.
elemHideDisabledForUrl | Public method to check, if element hiding is disabled for the given URL.
elementHidingRules | Public method to get the element hiding rules.
elementHidingRulesForDomain | Public method to get the element hiding rules for the given domain.
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.
match | Public method to check the subscription for a matching rule.
removeRule | Public method to remove a rule given the offset.
replaceRule | Public method to replace a rule given the offset.
requiresLocation | Public method to get the location of a required subscription.
rule | Public method to get a specific rule.
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.
setRuleEnabled | Public method to enable a specific rule.
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, custom, parent=None, default=False)

Constructor

url
  AdBlock URL for the subscription (QUrl)
custom
  flag indicating a custom subscription (boolean)
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.__validateCheckSum

__validateCheckSum(fileName)

Private method to check the subscription file's checksum.

fileName
  name of the file containing the subscription (string)

Returns:
  flag indicating a valid file (boolean). A file is considered valid, if the checksum is OK or the file does not contain a checksum (i.e. cannot be checked).

#### AdBlockSubscription.adBlockDisabledForUrl

adBlockDisabledForUrl(url)

Public method to check, if AdBlock is disabled for the given URL.

url
  URL to check (QUrl)

Returns:
  flag indicating disabled state (boolean)

#### AdBlockSubscription.addRule

addRule(rule)

Public method to add a rule.

rule
  reference to the rule to add (AdBlockRule)

Returns:
  offset of the rule (integer)

#### AdBlockSubscription.allRules

allRules()

Public method to get the list of rules.

Returns:
  list of rules (list of AdBlockRule)

#### AdBlockSubscription.canBeRemoved

canBeRemoved()

Public method to check, if the subscription can be removed.

Returns:
  flag indicating removal is allowed (boolean)

#### AdBlockSubscription.canEditRules

canEditRules()

Public method to check, if rules can be edited.

Returns:
  flag indicating rules may be edited (boolean)

#### AdBlockSubscription.checkForUpdate

checkForUpdate()

Public method to check for an update.

#### AdBlockSubscription.elemHideDisabledForUrl

elemHideDisabledForUrl(url)

Public method to check, if element hiding is disabled for the given URL.

url
  URL to check (QUrl)

Returns:
  flag indicating disabled state (boolean)

#### AdBlockSubscription.elementHidingRules

elementHidingRules()

Public method to get the element hiding rules.

Returns:
  element hiding rules (string)

#### AdBlockSubscription.elementHidingRulesForDomain

elementHidingRulesForDomain(domain)

Public method to get the element hiding rules for the given domain.

domain
  domain name (string)

Returns:
  element hiding rules (string)

#### 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.match

match(req, urlDomain, urlString)

Public method to check the subscription for a matching rule.

req
  reference to the network request (QNetworkRequest)
urlDomain
  domain of the URL (string)
urlString
  URL (string)

Returns:
  reference to the rule object or None (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)

Returns:
  requested rule (AdBlockRule)

#### AdBlockSubscription.requiresLocation

requiresLocation()

Public method to get the location of a required subscription.

Returns:
  location of a required subscription (string)

#### AdBlockSubscription.rule

rule(offset)

Public method to get a specific rule.

offset
  offset of the rule (integer)

Returns:
  requested rule (AdBlockRule)

#### AdBlockSubscription.rulesFileName

rulesFileName()

Public method to get the name of the rules file.

Returns:
  name of the rules file (string)

#### 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.setRuleEnabled

setRuleEnabled(offset, enabled)

Public method to enable a specific rule.

offset
  offset of the rule (integer)
enabled
  new enabled state (boolean)

Returns:
  reference to the changed rule (AdBlockRule)

#### AdBlockSubscription.setTitle

setTitle(title)

Public method to set the subscription title.

title
  subscription title (string)

#### AdBlockSubscription.title

title()

Public method to get the subscription title.

Returns:
  subscription title (string)

#### 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