File indexing completed on 2024-05-12 15:39:37

0001 /* This file is part of the KDE project
0002  *
0003  * Copyright (C) 2008 Bernhard Beschow <bbeschow AT cs DOT tu-berlin DOT de>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 #ifndef __khtml_findbar_h__
0021 #define __khtml_findbar_h__
0022 
0023 #include "khtmlviewbarwidget.h"
0024 #include "ui_khtmlfindbar_base.h"
0025 
0026 class QMenu;
0027 class QAction;
0028 
0029 class KHTMLFindBar : public KHTMLViewBarWidget, private Ui::KHTMLFindBarBase
0030 {
0031     Q_OBJECT
0032 public:
0033     KHTMLFindBar(QWidget *parent = nullptr);
0034 
0035     /**
0036      * Provide the list of @p strings to be displayed as the history
0037      * of find strings. @p strings might get truncated if it is
0038      * too long.
0039      *
0040      * @param history The find history.
0041      * @see findHistory
0042      */
0043     void setFindHistory(const QStringList &history);
0044 
0045     /**
0046      * Returns the list of history items.
0047      *
0048      * @see setFindHistory
0049      */
0050     QStringList findHistory() const;
0051 
0052     /*
0053      *  makes the current pattern be the first entry of the find history.
0054      *  Return false if the history was empty.
0055      *
0056      */
0057     bool restoreLastPatternFromHistory();
0058 
0059     /**
0060      * Enable/disable the 'search in selection' option, depending
0061      * on whether there actually is a selection.
0062      *
0063      * @param hasSelection true if a selection exists
0064      */
0065     void setHasSelection(bool hasSelection);
0066 
0067     /**
0068      * Hide/show the 'from cursor' option, depending
0069      * on whether the application implements a cursor.
0070      *
0071      * @param hasCursor true if the application features a cursor
0072      * This is assumed to be the case by default.
0073      */
0074     void setHasCursor(bool hasCursor);
0075 
0076     /**
0077      * Set the options which are checked.
0078      *
0079      * @param options The setting of the Options.
0080      *
0081      * @see options()
0082      * @see KFind::Options
0083      */
0084     void setOptions(long options);
0085 
0086     /**
0087      * Returns the state of the options. Disabled options may be returned in
0088      * an indeterminate state.
0089      *
0090      * @see setOptions()
0091      * @see KFind::Options
0092      */
0093     long options() const;
0094 
0095     /**
0096      * Returns the pattern to find.
0097      */
0098     QString pattern() const;
0099 
0100     void setFoundMatch(bool match);
0101     void setAtEnd(bool atEnd);
0102     void setVisible(bool visible) override;
0103 
0104 protected:
0105     bool event(QEvent *e) override;
0106 
0107 private Q_SLOTS:
0108     void slotSelectedTextToggled(bool selec);
0109     void slotSearchChanged();
0110     void slotAddPatternToHistory();
0111 
0112 Q_SIGNALS:
0113     void searchChanged();
0114     void findNextClicked();
0115     void findPreviousClicked();
0116 
0117 private:
0118     long m_enabled;
0119     QMenu *m_incMenu;
0120     QAction *m_caseSensitive;
0121     QAction *m_wholeWordsOnly;
0122     QAction *m_fromCursor;
0123     QAction *m_selectedText;
0124     QAction *m_regExp;
0125     QAction *m_findLinksOnly;
0126     QString m_prevPattern;
0127     bool m_atEnd;
0128 };
0129 
0130 #endif