Ejemplo n.º 1
0
const AdBlockRule* AdBlockSubscription::rule(int offset) const {
  if (IS_IN_ARRAY(offset, m_rules)) {
    return m_rules[offset];
  }
  else {
    return 0;
  }
}
Ejemplo n.º 2
0
const AdBlockRule* AdBlockSubscription::disableRule(int offset) {
  if (!IS_IN_ARRAY(offset, m_rules)) {
    return 0;
  }

  AdBlockRule* rule = m_rules[offset];

  rule->setEnabled(false);
  AdBlockManager::instance()->addDisabledRule(rule->filter());
  emit subscriptionChanged();

  return rule;
}
Ejemplo n.º 3
0
const AdBlockRule* AdBlockSubscription::enableRule(int offset) {
  if (IS_IN_ARRAY(offset, m_rules)) {
    AdBlockRule* rule = m_rules[offset];

    rule->setEnabled(true);
    AdBlockManager::instance()->removeDisabledRule(rule->filter());
    emit subscriptionChanged();

    return rule;
  }
  else {
    return 0;
  }
}
Ejemplo n.º 4
0
static void gray_out_pixmap( int* src, int* dest, int width, int height )
{
    // assuming the pixels along the edges are of the background color

    int x = 0;
    int y = 1;

    do
    {
        int cur       = GET_ELEM(src,x,y);


        if ( IS_IN_ARRAY(x-1,y-1) )
        {
            int upperElem = GET_ELEM(src,x-1,y-1);

            // if the upper element is lighter than current
            if ( IS_GREATER(upperElem,cur) )
            {
                GET_ELEM(dest,x,y) = MASK_DARK;
            }
            else
            // if the current element is ligher than the upper
            if ( IS_GREATER(cur,upperElem) )
            {
                GET_ELEM(dest,x,y) = MASK_LIGHT;
            }
            else
            {
                if ( GET_ELEM(dest,x-1,y-1) == MASK_LIGHT )

                    GET_ELEM(dest,x,y) = MASK_BG;

                if ( GET_ELEM(dest,x-1,y-1 ) == MASK_DARK )

                    GET_ELEM(dest,x,y) = MASK_DARK;
                else
                    GET_ELEM(dest,x,y) = MASK_BG;
            }
        }

        // go zig-zag

        if ( IS_IN_ARRAY(x+1,y-1) )
        {
            ++x;
            --y;
        }
        else
        {
            while ( IS_IN_ARRAY(x-1,y+1) )
            {
                --x;
                ++y;
            }

            if ( IS_IN_ARRAY(x,y+1) )
            {
                ++y;
                continue;
            }
            else
            {
                if ( IS_IN_ARRAY(x+1,y) )
                {
                    ++x;
                    continue;
                }
                else break;
            }
        }

    } while (1);
}