Files
chatterino2/src/messages/search/MessageFlagsPredicate.hpp
Tal Neoran 77fa1322de Added is:<flags> search predicate (#2671)
Co-authored-by: Paweł <zneix@zneix.eu>
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
2021-05-01 12:21:45 +00:00

49 lines
1.4 KiB
C++

#pragma once
#include "common/FlagsEnum.hpp"
#include "messages/search/MessagePredicate.hpp"
namespace chatterino {
using MessageFlags = FlagsEnum<MessageFlag>;
/**
* @brief MessagePredicate checking for message flags.
*
* This predicate will only allow messages with a list of flags.
* Specified by user-friendly names for the flags.
*/
class MessageFlagsPredicate : public MessagePredicate
{
public:
/**
* @brief Create a MessageFlagsPredicate with a list of flags to search for.
*
* The flags can be specified by user-friendly names.
* "deleted" and "disabled" are used for the "Disabled" flag.
* "sub" and "subscription" are used for the "Subscription" flag.
* "timeout" is used for the "Timeout" flag.
* "highlighted" is used for the "Highlighted" flag.
* "system" is used for the "System" flag.
*
* @param flags a string comma seperated list of names for the flags a message should have
*/
MessageFlagsPredicate(const QString &flags);
/**
* @brief Checks whether the message has any of the flags passed
* in the constructor.
*
* @param message the message to check
* @return true if the message has at least one of the specified flags,
* false otherwise
*/
bool appliesTo(const Message &message);
private:
/// Holds the flags that will be searched for
MessageFlags flags_;
};
} // namespace chatterino