File indexing completed on 2025-02-16 04:56:04

0001 /* SPDX-FileCopyrightText: 2010 Torgny Nyblom <nyblom@kde.org>
0002  * SPDX-FileCopyrightText: 2010-2024 Laurent Montel <montel@kde.org>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 #include "ksieveui_export.h"
0010 #include <QWidget>
0011 class QAction;
0012 class QPushButton;
0013 class QMenu;
0014 class QLabel;
0015 namespace PimCommon
0016 {
0017 class LineEditWithCompleterNg;
0018 }
0019 namespace KSieveUi
0020 {
0021 class KSIEVEUI_EXPORT FindBarBase : public QWidget
0022 {
0023     Q_OBJECT
0024 public:
0025     explicit FindBarBase(QWidget *parent = nullptr);
0026     ~FindBarBase() override;
0027 
0028     [[nodiscard]] QString text() const;
0029     void setText(const QString &text);
0030     void focusAndSetCursor();
0031 
0032 protected:
0033     bool event(QEvent *e) override;
0034     virtual void clearSelections();
0035     virtual void updateHighLight(bool);
0036     virtual void searchText(bool backward, bool isAutoSearch);
0037     virtual void updateSensitivity(bool);
0038 
0039     void setFoundMatch(bool match);
0040     QMenu *optionsMenu();
0041 
0042 public Q_SLOTS:
0043     void findNext();
0044     void findPrev();
0045     void autoSearch(const QString &str);
0046     void slotSearchText(bool backward = false, bool isAutoSearch = true);
0047     void closeBar();
0048 
0049 Q_SIGNALS:
0050     void hideFindBar();
0051 
0052 protected Q_SLOTS:
0053     void caseSensitivityChanged(bool);
0054     void slotHighlightAllChanged(bool);
0055 
0056 protected:
0057     QString mNotFoundString;
0058     QString mPositiveBackground;
0059     QString mNegativeBackground;
0060     QString mLastSearchStr;
0061     PimCommon::LineEditWithCompleterNg *mSearch = nullptr;
0062     QAction *mCaseSensitiveAct = nullptr;
0063 
0064     QPushButton *mFindPrevBtn = nullptr;
0065     QPushButton *mFindNextBtn = nullptr;
0066     QMenu *mOptionsMenu = nullptr;
0067     QLabel *mStatus = nullptr;
0068     void addToCompletion(const QString &text);
0069 };
0070 }