File indexing completed on 2024-04-28 15:51:57

0001 /*
0002     SPDX-FileCopyrightText: 2004 Enrico Ros <eros.kde@email.it>
0003     SPDX-FileCopyrightText: 2007, 2009-2010 Pino Toscano <pino@kde.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef _OKULAR_SEARCHLINEEDIT_H_
0009 #define _OKULAR_SEARCHLINEEDIT_H_
0010 
0011 #include "core/document.h"
0012 
0013 #include <KLineEdit>
0014 
0015 #include <kwidgetsaddons_version.h>
0016 class KBusyIndicatorWidget;
0017 class QTimer;
0018 
0019 /**
0020  * @short A line edit for find-as-you-type search. Outputs to the Document.
0021  */
0022 class SearchLineEdit : public KLineEdit
0023 {
0024     Q_OBJECT
0025 public:
0026     SearchLineEdit(QWidget *parent, Okular::Document *document);
0027 
0028     void clearText();
0029 
0030     void setSearchCaseSensitivity(Qt::CaseSensitivity cs);
0031     void setSearchMinimumLength(int length);
0032     void setSearchType(Okular::Document::SearchType type);
0033     void setSearchId(int id);
0034     void setSearchColor(const QColor &color);
0035     void setSearchMoveViewport(bool move);
0036     void setSearchFromStart(bool fromStart);
0037     void setFindAsYouType(bool findAsYouType);
0038     void resetSearch();
0039 
0040     bool isSearchRunning() const;
0041 
0042 Q_SIGNALS:
0043     void searchStarted();
0044     void searchStopped();
0045 
0046 public Q_SLOTS:
0047     void restartSearch();
0048     void stopSearch();
0049     void findNext();
0050     void findPrev();
0051 
0052 private:
0053     void prepareLineEditForSearch();
0054 
0055     Okular::Document *m_document;
0056     QTimer *m_inputDelayTimer;
0057     int m_minLength;
0058     Qt::CaseSensitivity m_caseSensitivity;
0059     Okular::Document::SearchType m_searchType;
0060     int m_id;
0061     QColor m_color;
0062     bool m_moveViewport;
0063     bool m_changed;
0064     bool m_fromStart;
0065     bool m_findAsYouType;
0066     bool m_searchRunning;
0067 
0068 private Q_SLOTS:
0069     void slotTextChanged(const QString &text);
0070     void slotReturnPressed(const QString &text);
0071     void startSearch();
0072     void searchFinished(int id, Okular::Document::SearchStatus endStatus);
0073 };
0074 
0075 class SearchLineWidget : public QWidget
0076 {
0077     Q_OBJECT
0078 public:
0079     SearchLineWidget(QWidget *parent, Okular::Document *document);
0080 
0081     SearchLineEdit *lineEdit() const;
0082 
0083 private Q_SLOTS:
0084     void slotSearchStarted();
0085     void slotSearchStopped();
0086     void slotTimedout();
0087 
0088 private:
0089     SearchLineEdit *m_edit;
0090     KBusyIndicatorWidget *m_anim;
0091     QTimer *m_timer;
0092 };
0093 
0094 #endif