mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
720e5aa25f
* Ran clang-format * Implement user-specific search in message history This functionality was originally requested in #1236. This commit changes the SearchPopup::performSearch method so that only messages from specific users can be shown. In order to filter for a specific user, enter their username with a leading '@' in the search popup. You can also add an additional search phrase which will also be considered in the search. * Naive implementation for "from:" tags Rebase later? * Cleverer (?) version using Predicates Commit adds two POC predicates: one for the author of messages, and one for substring search in messages. Problems/TODOs: * Best way to register new predicates? * Clean up tags (e.g. "from:") or not? * Test combinations of different predicates * Add a predicate to check for links in messages * Remove a dumb TODO * Rewrite SearchPopup::performSearch to be cleaner * Ran clang-format on all files * Remove TODO I missed earlier * Forgot to run clang-format peepoSadDank * Re-use {}-initialization Was accidentally removed when fixing earlier merge conflict. * Does this fix line endings? No diffs are shown locally, hopefully Git doesn't lie to me. * Rename "predicates" directory to "search" Resolving one conversation in the review of #1237. * Use LinkParser in LinkPredicate Resolving a conversation in the review of #1237. * Predicates: Use unique_ptr instead of shared_ptr Resolves a conversation in the review of #1237. * Refactor of SearchPopup and AuthorPredicate Resolving some points from the review in #1237. * Moved parsing of comma-seperated values into AuthorPredicate constructor. * Rewrite SearchPopup::parsePredicates as suggested. * Deleted now redundant methods in SearchPopup. * MessagePredicate::appliesTo now takes a Message& ... instead of a MessagePtr. This resolves a conversation in the review of #1237. * Run clang-format on two files I missed * AuthorPredicate: Check for displayName & loginName Resolving conversation on #1237.
38 lines
1,022 B
C++
38 lines
1,022 B
C++
#pragma once
|
|
|
|
#include "messages/search/MessagePredicate.hpp"
|
|
|
|
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.
|
|
*
|
|
* @param authors a list of user names that a message should be sent from
|
|
*/
|
|
AuthorPredicate(const QStringList &authors);
|
|
|
|
/**
|
|
* @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
|
|
*/
|
|
bool appliesTo(const Message &message);
|
|
|
|
private:
|
|
/// Holds the user names that will be searched for
|
|
QStringList authors_;
|
|
};
|
|
|
|
} // namespace chatterino
|