2019-09-09 15:21:49 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "messages/search/MessagePredicate.hpp"
|
|
|
|
|
2022-12-31 15:41:01 +01:00
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
|
|
|
|
2019-09-09 15:21:49 +02:00
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief MessagePredicate checking for the author/sender of a message.
|
|
|
|
*
|
|
|
|
* This predicate will only allow messages that are sent by a list of users,
|
|
|
|
* specified by their user names.
|
|
|
|
*/
|
|
|
|
class AuthorPredicate : public MessagePredicate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @brief Create an AuthorPredicate with a list of users to search for.
|
|
|
|
*
|
2022-12-04 12:34:13 +01:00
|
|
|
* @param authors one or more comma-separated user names that a message should be sent from
|
|
|
|
* @param negate when set, excludes list of user names from results
|
2019-09-09 15:21:49 +02:00
|
|
|
*/
|
2022-12-04 12:34:13 +01:00
|
|
|
AuthorPredicate(const QString &authors, bool negate);
|
2019-09-09 15:21:49 +02:00
|
|
|
|
2022-12-04 12:34:13 +01:00
|
|
|
protected:
|
2019-09-09 15:21:49 +02:00
|
|
|
/**
|
|
|
|
* @brief Checks whether the message is authored by any of the users passed
|
|
|
|
* in the constructor.
|
|
|
|
*
|
|
|
|
* @param message the message to check
|
|
|
|
* @return true if the message was authored by one of the specified users,
|
|
|
|
* false otherwise
|
|
|
|
*/
|
2022-12-04 12:34:13 +01:00
|
|
|
bool appliesToImpl(const Message &message) override;
|
2019-09-09 15:21:49 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// Holds the user names that will be searched for
|
|
|
|
QStringList authors_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace chatterino
|