2019-09-08 22:27:57 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ForwardDecl.hpp"
|
|
|
|
#include "messages/LimitedQueueSnapshot.hpp"
|
2019-09-09 15:21:49 +02:00
|
|
|
#include "messages/search/MessagePredicate.hpp"
|
2019-12-14 12:57:16 +01:00
|
|
|
#include "widgets/BasePopup.hpp"
|
2019-09-08 22:27:57 +02:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class QLineEdit;
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
2019-12-14 12:57:16 +01:00
|
|
|
class SearchPopup : public BasePopup
|
2019-09-08 22:27:57 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
SearchPopup();
|
|
|
|
|
|
|
|
virtual void setChannel(const ChannelPtr &channel);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void updateWindowTitle();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void initLayout();
|
|
|
|
void search();
|
|
|
|
|
2019-09-09 15:21:49 +02:00
|
|
|
/**
|
|
|
|
* @brief Only retains those message from a list of messages that satisfy a
|
|
|
|
* search query.
|
|
|
|
*
|
|
|
|
* @param text the search query -- will be parsed for MessagePredicates
|
|
|
|
* @param channelName name of the channel to be returned
|
|
|
|
* @param snapshot list of messages to filter
|
|
|
|
*
|
|
|
|
* @return a ChannelPtr with "channelName" and the filtered messages from
|
|
|
|
* "snapshot"
|
|
|
|
*/
|
|
|
|
static ChannelPtr filter(const QString &text, const QString &channelName,
|
|
|
|
const LimitedQueueSnapshot<MessagePtr> &snapshot);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Checks the input for tags and registers their corresponding
|
|
|
|
* predicates.
|
|
|
|
*
|
|
|
|
* @param input the string to check for tags
|
|
|
|
* @return a vector of MessagePredicates requested in the input
|
|
|
|
*/
|
|
|
|
static std::vector<std::unique_ptr<MessagePredicate>> parsePredicates(
|
|
|
|
const QString &input);
|
|
|
|
|
2019-09-08 22:27:57 +02:00
|
|
|
LimitedQueueSnapshot<MessagePtr> snapshot_;
|
|
|
|
QLineEdit *searchInput_{};
|
|
|
|
ChannelView *channelView_{};
|
|
|
|
QString channelName_{};
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace chatterino
|