Falkon Adblock dialog and remove rule

AdBlock Dialog

During the development of the AdBlock stuff I need to frequently interact with AdBlock Dialog window to modify the “Custom Rules” filter list. Since due to historical reasons and probably for the ease of use the dialog uses QTreeWidget and each item added to this list is mapped to the source QVector list (QList now) by an index number stored in the data section of the widget item.

I hope you already see where the source of my frustration and potential issues is (maybe relevant bug?). After the item was removed from the list, the underlying indexes in data section in other items where not updated which let to not deleting rules, deleting incorrect rules, crashing and maybe some other weird stuff.

SO I went to fix it with heavy guns, I wrote a simple model based on QAbstractListModel to handle the mapping between the items and underlying storage container. I chose list model because it is simpler to work with (yes, I lack experience with Qt models) and because I thought QListView would do a better job than the QTreeView. I was wrong, it turned out that QTreeView is much faster to display the data on the screen than the QListView, so I switched to it and I kept the simpler list idea (my head already hurts). to replace the original top level item, I enabled the header and use it for the same purpose. It does not look as nice as the previous version, but I hope it will be more stable and also faster to show.

The code can be found on KDE Invent.

Adblock Dialog: on left before the change, on right after the change.

Adblock Dialog: on left before the change, on right after the change.

Remove rule

Somehow I was exploring the ABP Test Pages again and when I saw the Remove rule I thought “this can be done” and went to play with it. It is the same as CSS hiding rules with an additional {remove:true} at the end. But it needs another JavaScript to work, so I am happy that the technology progressed and there is querySelectorAll(css) to select elements based on the CSS selectors. With a simple for look to remove all selected elements the deed was done.

This way, Falkon might have support for another rarely used AdBlock rule.

The code can be found on KDE Invent.

Ending thoughts

I like working on things which are rarely used.

I also updated the Falkon ABP Test Page results.

Articles from blogs I follow:

Why is your open source project still hosted on GitHub?

Perhaps the younger generation don't know anything about the past "evils" of Microsoft and naively believe that Microsoft is now the good friend to open source, but the truth is that all Microsoft acquisitions of open source projects is a busi…

via unixdigest.com May 22, 2025

StarFive VisionFive v2 and FreeBSD

This week I powered up the StarFive VisionFive v2 board that I have. I figured I would give FreeBSD another whirl on it, in the vague hope that RISC-V boards are a more cohesive family than ARM boards were five years ago. tl;dr: I didn’t get it to work as…

via [bobulate] May 20, 2025

Steve Ballmer was an underrated CEO

There's a common narrative that Microsoft was moribund under Steve Ballmer and then later saved by the miraculous leadership of Satya Nadella. This is the dominant narrative in every online discussion about the topic I've seen and it's a commo…

via danluu.com October 28, 2024

Generated by openring