2019-09-08 22:27:57 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ForwardDecl.hpp"
|
2020-10-18 15:16:56 +02:00
|
|
|
#include "controllers/filters/FilterSet.hpp"
|
2019-09-08 22:27:57 +02:00
|
|
|
#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:
|
2020-11-15 11:07:20 +01:00
|
|
|
SearchPopup(QWidget *parent);
|
2019-09-08 22:27:57 +02:00
|
|
|
|
|
|
|
virtual void setChannel(const ChannelPtr &channel);
|
2020-10-18 15:16:56 +02:00
|
|
|
virtual void setChannelFilters(FilterSetPtr filters);
|
2019-09-08 22:27:57 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void updateWindowTitle();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void initLayout();
|
|
|
|
void search();
|
2021-11-21 18:46:21 +01:00
|
|
|
void addShortcuts() override;
|
2019-09-08 22:27:57 +02:00
|
|
|
|
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
|
2020-10-18 15:16:56 +02:00
|
|
|
* @param filterSet channel filter to apply
|
2019-09-09 15:21:49 +02:00
|
|
|
*
|
|
|
|
* @return a ChannelPtr with "channelName" and the filtered messages from
|
|
|
|
* "snapshot"
|
|
|
|
*/
|
|
|
|
static ChannelPtr filter(const QString &text, const QString &channelName,
|
2020-10-18 15:16:56 +02:00
|
|
|
const LimitedQueueSnapshot<MessagePtr> &snapshot,
|
|
|
|
FilterSetPtr filterSet);
|
2019-09-09 15:21:49 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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_{};
|
2020-10-18 15:16:56 +02:00
|
|
|
FilterSetPtr channelFilters_;
|
2019-09-08 22:27:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace chatterino
|