File indexing completed on 2024-12-15 04:54:36
0001 /* 0002 SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 0006 */ 0007 0008 #pragma once 0009 0010 #include "messagelist_export.h" 0011 #include <Akonadi/MessageStatus> 0012 #include <QWidget> 0013 0014 class QComboBox; 0015 namespace MessageList 0016 { 0017 namespace Core 0018 { 0019 class SearchLineStatus; 0020 class Filter; 0021 /** 0022 * @brief The QuickSearchLine class 0023 * @author Laurent Montel <montel@kde.org> 0024 */ 0025 class MESSAGELIST_EXPORT QuickSearchLine : public QWidget 0026 { 0027 Q_OBJECT 0028 public: 0029 explicit QuickSearchLine(QWidget *parent = nullptr); 0030 ~QuickSearchLine() override; 0031 0032 enum SearchOption { 0033 SearchEveryWhere = 1, 0034 SearchAgainstBody = 2, 0035 SearchAgainstSubject = 4, 0036 SearchAgainstFrom = 8, 0037 SearchAgainstBcc = 16, 0038 SearchAgainstTo = 32 0039 }; 0040 0041 Q_ENUM(SearchOption) 0042 Q_DECLARE_FLAGS(SearchOptions, SearchOption) 0043 0044 [[nodiscard]] SearchOptions searchOptions() const; 0045 0046 void focusQuickSearch(const QString &selectedText); 0047 0048 [[nodiscard]] QComboBox *tagFilterComboBox() const; 0049 [[nodiscard]] SearchLineStatus *searchEdit() const; 0050 void resetFilter(); 0051 [[nodiscard]] QList<Akonadi::MessageStatus> status() const; 0052 0053 void updateComboboxVisibility(); 0054 0055 [[nodiscard]] bool containsOutboundMessages() const; 0056 void setContainsOutboundMessages(bool containsOutboundMessages); 0057 0058 void changeQuicksearchVisibility(bool show); 0059 void addCompletionItem(const QString &str); 0060 0061 void setSearchOptions(QuickSearchLine::SearchOptions opts); 0062 void setFilterMessageStatus(const QList<Akonadi::MessageStatus> &newLstStatus); 0063 0064 Q_SIGNALS: 0065 void clearButtonClicked(); 0066 void searchEditTextEdited(const QString &); 0067 void searchOptionChanged(); 0068 void statusButtonsClicked(); 0069 void forceLostFocus(); 0070 void saveFilter(); 0071 void activateFilter(MessageList::Core::Filter *f); 0072 0073 protected: 0074 bool eventFilter(QObject *object, QEvent *e) override; 0075 private Q_SLOTS: 0076 MESSAGELIST_NO_EXPORT void slotSearchEditTextEdited(const QString &text); 0077 MESSAGELIST_NO_EXPORT void slotClearButtonClicked(); 0078 MESSAGELIST_NO_EXPORT void slotFilterActionChanged(const QList<Akonadi::MessageStatus> &lst); 0079 0080 private: 0081 SearchLineStatus *const mSearchEdit; 0082 QComboBox *const mTagFilterCombo; 0083 QList<Akonadi::MessageStatus> mLstStatus; 0084 }; 0085 } 0086 }