File indexing completed on 2024-05-19 05:11:51

0001 /*
0002   SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 #include <QRegularExpression>
0009 #include <QSyntaxHighlighter>
0010 namespace Akonadi
0011 {
0012 namespace Search
0013 {
0014 class Rule
0015 {
0016 public:
0017     Rule() = default;
0018     Rule(const QRegularExpression &r, const QTextCharFormat &f)
0019         : pattern(r)
0020         , format(f)
0021     {
0022     }
0023     QRegularExpression pattern;
0024     QTextCharFormat format;
0025 };
0026 
0027 class AkonadiSearchSyntaxHighlighter : public QSyntaxHighlighter
0028 {
0029     Q_OBJECT
0030 public:
0031     explicit AkonadiSearchSyntaxHighlighter(QTextDocument *doc);
0032     ~AkonadiSearchSyntaxHighlighter() override;
0033 
0034     void highlightBlock(const QString &text) override;
0035 
0036 protected:
0037     void init();
0038     QList<Rule> m_rules;
0039 };
0040 }
0041 }