quicksearchline.h 2.17 KB
Newer Older
1
/*
Laurent Montel's avatar
Laurent Montel committed
2
  SPDX-FileCopyrightText: 2014-2021 Laurent Montel <montel@kde.org>
3

4
  SPDX-License-Identifier: LGPL-2.0-or-later
5
6
7

*/

Laurent Montel's avatar
Laurent Montel committed
8
#pragma once
9
10
11

#include "messagelist_export.h"
#include <Akonadi/KMime/MessageStatus>
Laurent Montel's avatar
Laurent Montel committed
12
#include <QWidget>
13

Laurent Montel's avatar
Laurent Montel committed
14
class QComboBox;
15
class QToolButton;
Laurent Montel's avatar
Laurent Montel committed
16
17
18
19
namespace MessageList
{
namespace Core
{
Laurent Montel's avatar
Laurent Montel committed
20
class SearchLineStatus;
Laurent Montel's avatar
Laurent Montel committed
21
class Filter;
22
23
24
25
/**
 * @brief The QuickSearchLine class
 * @author Laurent Montel <montel@kde.org>
 */
26
27
28
29
class MESSAGELIST_EXPORT QuickSearchLine : public QWidget
{
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
30
    explicit QuickSearchLine(QWidget *parent = nullptr);
31
    ~QuickSearchLine() override;
32
33
34
35
36
37
38
39
40
41

    enum SearchOption {
        SearchEveryWhere = 1,
        SearchAgainstBody = 2,
        SearchAgainstSubject = 4,
        SearchAgainstFrom = 8,
        SearchAgainstBcc = 16,
        SearchAgainstTo = 32
    };

Laurent Montel's avatar
Laurent Montel committed
42
    Q_ENUM(SearchOption)
43
44
    Q_DECLARE_FLAGS(SearchOptions, SearchOption)

Laurent Montel's avatar
Laurent Montel committed
45
    Q_REQUIRED_RESULT SearchOptions searchOptions() const;
46
47
48

    void focusQuickSearch(const QString &selectedText);

Laurent Montel's avatar
Laurent Montel committed
49
    Q_REQUIRED_RESULT QComboBox *tagFilterComboBox() const;
Laurent Montel's avatar
Laurent Montel committed
50
    Q_REQUIRED_RESULT SearchLineStatus *searchEdit() const;
51
    void resetFilter();
Laurent Montel's avatar
Laurent Montel committed
52
    Q_REQUIRED_RESULT QVector<Akonadi::MessageStatus> status() const;
53
54
55

    void updateComboboxVisibility();

Laurent Montel's avatar
Laurent Montel committed
56
    Q_REQUIRED_RESULT bool containsOutboundMessages() const;
57
58
59
    void setContainsOutboundMessages(bool containsOutboundMessages);

    void changeQuicksearchVisibility(bool show);
60
    void addCompletionItem(const QString &str);
61

Laurent Montel's avatar
Laurent Montel committed
62
    void setSearchOptions(QuickSearchLine::SearchOptions opts);
63
64
65
66
67
Q_SIGNALS:
    void clearButtonClicked();
    void searchEditTextEdited(const QString &);
    void searchOptionChanged();
    void statusButtonsClicked();
68
    void forceLostFocus();
Laurent Montel's avatar
Laurent Montel committed
69
    void saveFilter(const QString &filterName);
Laurent Montel's avatar
Laurent Montel committed
70
    void activateFilter(Filter *f);
71
72

protected:
73
    bool eventFilter(QObject *object, QEvent *e) override;
74
75
76
private Q_SLOTS:
    void slotSearchEditTextEdited(const QString &text);
    void slotClearButtonClicked();
Laurent Montel's avatar
Laurent Montel committed
77
    void slotFilterActionChanged(const QVector<Akonadi::MessageStatus> &lst);
Laurent Montel's avatar
Laurent Montel committed
78

79
private:
Laurent Montel's avatar
Laurent Montel committed
80
81
    SearchLineStatus *const mSearchEdit;
    QComboBox *const mTagFilterCombo;
Laurent Montel's avatar
Laurent Montel committed
82
    QVector<Akonadi::MessageStatus> mLstStatus;
83
84
85
};
}
}