Added in:<channels> search predicate (#2634)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Tal Neoran
2021-04-17 14:18:22 +03:00
committed by GitHub
parent b540bd0b69
commit cceadf473a
6 changed files with 77 additions and 2 deletions
+11 -2
View File
@@ -8,6 +8,7 @@
#include "common/Channel.hpp"
#include "messages/Message.hpp"
#include "messages/search/AuthorPredicate.hpp"
#include "messages/search/ChannelPredicate.hpp"
#include "messages/search/LinkPredicate.hpp"
#include "messages/search/SubstringPredicate.hpp"
#include "util/Shortcut.hpp"
@@ -164,9 +165,10 @@ std::vector<std::unique_ptr<MessagePredicate>> SearchPopup::parsePredicates(
{
static QRegularExpression predicateRegex(R"(^(\w+):([\w,]+)$)");
auto predicates = std::vector<std::unique_ptr<MessagePredicate>>();
std::vector<std::unique_ptr<MessagePredicate>> predicates;
auto words = input.split(' ', QString::SkipEmptyParts);
auto authors = QStringList();
QStringList authors;
QStringList channels;
for (auto it = words.begin(); it != words.end();)
{
@@ -186,6 +188,10 @@ std::vector<std::unique_ptr<MessagePredicate>> SearchPopup::parsePredicates(
{
predicates.push_back(std::make_unique<LinkPredicate>());
}
else if (name == "in")
{
channels.append(value);
}
else
{
remove = false;
@@ -203,6 +209,9 @@ std::vector<std::unique_ptr<MessagePredicate>> SearchPopup::parsePredicates(
if (!authors.empty())
predicates.push_back(std::make_unique<AuthorPredicate>(authors));
if (!channels.empty())
predicates.push_back(std::make_unique<ChannelPredicate>(channels));
if (!words.empty())
predicates.push_back(
std::make_unique<SubstringPredicate>(words.join(" ")));