BibleTime
btfindwidget.h
Go to the documentation of this file.
1 /*********
2 *
3 * In the name of the Father, and of the Son, and of the Holy Spirit.
4 *
5 * This file is part of BibleTime's source code, https://bibletime.info/
6 *
7 * Copyright 1999-2021 by the BibleTime developers.
8 * The BibleTime source code is licensed under the GNU General Public License
9 * version 2.0.
10 *
11 **********/
12 
13 #pragma once
14 
15 #include <QWidget>
16 
17 #include <QObject>
18 #include <QString>
19 
20 
21 class QCheckBox;
22 class QLineEdit;
23 class QToolButton;
24 
25 class BtFindWidget final: public QWidget {
26 
27  Q_OBJECT
28 
29 private: /* Types: */
30 
31  struct HighlightState {
32  QString text;
34 
35  friend bool operator==(HighlightState const & lhs,
36  HighlightState const & rhs) noexcept
37  {
38  return (lhs.text == rhs.text)
39  && (lhs.caseSensitive == rhs.caseSensitive);
40  }
41 
42  friend bool operator!=(HighlightState const & lhs,
43  HighlightState const & rhs) noexcept
44  {
45  return (lhs.text != rhs.text)
46  || (lhs.caseSensitive != rhs.caseSensitive);
47  }
48  };
49 
50 public: // methods:
51 
52  BtFindWidget(QWidget * parent = nullptr);
53 
54  void showAndSelect();
55 
56 protected: // Methods:
57 
58  void timerEvent(QTimerEvent * const event) final override;
59 
60 private: // methods:
61 
62  void queueHighlight();
63  void highlightImmediately();
64  void retranslateUi();
65 
66 Q_SIGNALS:
67 
68  void findPrevious();
69  void findNext();
70  void highlightText(QString const & text, bool caseSensitive);
71 
72 private: // fields:
73 
77  QCheckBox * m_caseCheckBox;
80 
81 };
HighlightState m_lastHighlightState
Definition: btfindwidget.h:78
void findPrevious()
void retranslateUi()
BtFindWidget(QWidget *parent=nullptr)
void highlightImmediately()
void showAndSelect()
QLineEdit * m_textEditor
Definition: btfindwidget.h:74
void findNext()
QToolButton * m_previousButton
Definition: btfindwidget.h:76
QToolButton * m_nextButton
Definition: btfindwidget.h:75
int m_throttleTimerId
Definition: btfindwidget.h:79
void highlightText(QString const &text, bool caseSensitive)
void timerEvent(QTimerEvent *const event) final override
QCheckBox * m_caseCheckBox
Definition: btfindwidget.h:77
void queueHighlight()
friend bool operator==(HighlightState const &lhs, HighlightState const &rhs) noexcept
Definition: btfindwidget.h:35
friend bool operator!=(HighlightState const &lhs, HighlightState const &rhs) noexcept
Definition: btfindwidget.h:42