Advanced channel filters (#1748)

Adds custom channel filters complete with their own mini-language. Filters can be created in settings, and applied by clicking the three dots to open the Split menu and selecting "Set filters".
This commit is contained in:
dnsge
2020-10-18 15:16:56 +02:00
committed by Rasmus Karlsson
parent 812cbdf4f9
commit 4199a01b96
41 changed files with 2189 additions and 43 deletions
+12 -2
View File
@@ -16,7 +16,8 @@
namespace chatterino {
ChannelPtr SearchPopup::filter(const QString &text, const QString &channelName,
const LimitedQueueSnapshot<MessagePtr> &snapshot)
const LimitedQueueSnapshot<MessagePtr> &snapshot,
FilterSetPtr filterSet)
{
ChannelPtr channel(new Channel(channelName, Channel::Type::None));
@@ -40,6 +41,9 @@ ChannelPtr SearchPopup::filter(const QString &text, const QString &channelName,
}
}
if (accept && filterSet)
accept = filterSet->filter(message);
// If all predicates match, add the message to the channel
if (accept)
channel->addMessage(message);
@@ -59,6 +63,11 @@ SearchPopup::SearchPopup()
});
}
void SearchPopup::setChannelFilters(FilterSetPtr filters)
{
this->channelFilters_ = filters;
}
void SearchPopup::setChannel(const ChannelPtr &channel)
{
this->channelName_ = channel->getName();
@@ -76,7 +85,8 @@ void SearchPopup::updateWindowTitle()
void SearchPopup::search()
{
this->channelView_->setChannel(filter(this->searchInput_->text(),
this->channelName_, this->snapshot_));
this->channelName_, this->snapshot_,
this->channelFilters_));
}
void SearchPopup::initLayout()