File indexing completed on 2024-12-15 04:54:36

0001 /*
0002   SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "messagelist_private_export.h"
0010 #include "quicksearchline.h"
0011 #include <Akonadi/MessageStatus>
0012 #include <QIcon>
0013 #include <QLineEdit>
0014 class QStringListModel;
0015 class QAction;
0016 namespace MessageList
0017 {
0018 namespace Core
0019 {
0020 class FilterSavedMenu;
0021 class Filter;
0022 class MESSAGELIST_TESTS_EXPORT SearchLineStatus : public QLineEdit
0023 {
0024     Q_OBJECT
0025 public:
0026     explicit SearchLineStatus(QWidget *parent = nullptr);
0027     ~SearchLineStatus() override;
0028 
0029     void setLocked(bool b);
0030     [[nodiscard]] bool locked() const;
0031 
0032     void setContainsOutboundMessages(bool containsOutboundMessages);
0033     [[nodiscard]] bool containsOutboundMessages() const;
0034     [[nodiscard]] QuickSearchLine::SearchOptions searchOptions() const;
0035     void setSearchOptions(QuickSearchLine::SearchOptions opts);
0036     void setFilterMessageStatus(const QList<Akonadi::MessageStatus> &newLstStatus);
0037     void addCompletionItem(const QString &str);
0038     void slotClearHistory();
0039     void clearFilterButtonClicked();
0040 Q_SIGNALS:
0041     void filterActionChanged(const QList<Akonadi::MessageStatus> &lst);
0042     void searchOptionChanged();
0043     void clearButtonClicked();
0044     void forceLostFocus();
0045     void saveFilter();
0046     void activateFilter(MessageList::Core::Filter *f);
0047 
0048 protected:
0049     void contextMenuEvent(QContextMenuEvent *e) override;
0050     void keyPressEvent(QKeyEvent *e) override;
0051 
0052 private:
0053     void slotToggledLockAction();
0054     void showMenu();
0055     void slotFilterActionClicked(QAction *act);
0056     void clearFilterAction();
0057     void createFilterAction(const QIcon &icon, const QString &text, int value);
0058     void createMenuSearch();
0059     void updateLockAction();
0060     void initializeActions();
0061     void updateFilterActionIcon();
0062     void updateFilters();
0063     void createFilterByAction();
0064     void clearFilterByAction();
0065     void changeSearchAgainstFromOrToText();
0066     void slotClear();
0067     void showSavedFiltersMenu();
0068     void slotConfigureFilters();
0069     void slotActivateFilter(const QString &identifier);
0070 
0071     bool mLocked = false;
0072     bool mHasFilter = false;
0073     QIcon mWithoutFilter;
0074     QIcon mWithFilter;
0075     QAction *mLockAction = nullptr;
0076     QAction *mFiltersAction = nullptr;
0077     QAction *mSaveFilterAction = nullptr;
0078     QMenu *mFilterMenu = nullptr;
0079     QCompleter *const mCompleter;
0080     QList<QAction *> mFilterListActions;
0081     QAction *mSearchEveryWhereAction = nullptr;
0082     QAction *mSearchAgainstBodyAction = nullptr;
0083     QAction *mSearchAgainstSubjectAction = nullptr;
0084     QAction *mSearchAgainstFromOrToAction = nullptr;
0085     QAction *mSearchAgainstBccAction = nullptr;
0086     QStringListModel *const mCompleterListModel;
0087     FilterSavedMenu *mFilterSavedMenu = nullptr;
0088     QStringList mListCompetion;
0089     QString mColorName;
0090     bool mContainsOutboundMessages = false;
0091 };
0092 }
0093 }