pqTextEdit.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqTextEdit_h
5 #define pqTextEdit_h
6 
7 #include "pqWidgetsModule.h"
8 
9 #include <QTextEdit>
10 
11 class pqTextEditPrivate;
12 class pqWidgetCompleter;
13 
37 class PQWIDGETS_EXPORT pqTextEdit : public QTextEdit
38 {
39  Q_OBJECT
40  typedef QTextEdit Superclass;
41 
42 public:
43  pqTextEdit(QWidget* parent = nullptr);
44  pqTextEdit(const QString& contents, QWidget* parent = nullptr);
45 
46  void setCompleter(pqWidgetCompleter* completer);
47  pqWidgetCompleter* getCompleter() { return this->Completer; }
48 
49  ~pqTextEdit() override;
50 
51 Q_SIGNALS:
58  void textChangedAndEditingFinished();
59 
64  void editingFinished();
65 
66 private Q_SLOTS:
67  void onEditingFinished();
68  void onTextEdited();
69  void insertCompletion(const QString& completion);
70 
71 protected:
72  void keyPressEvent(QKeyEvent* e) override;
73  void focusOutEvent(QFocusEvent* e) override;
74  void focusInEvent(QFocusEvent* e) override;
75 
79  QString textUnderCursor() const;
80 
84  void updateCompleter();
85 
90  void updateCompleterIfVisible();
91 
95  void selectCompletion();
96 
97  QScopedPointer<pqTextEditPrivate> d_ptr;
98 
99 private:
100  Q_DECLARE_PRIVATE(pqTextEdit);
101  Q_DISABLE_COPY(pqTextEdit);
102 
103  pqWidgetCompleter* Completer = nullptr;
104 };
105 
106 #endif
Abstact class for widget completers.
QScopedPointer< pqTextEditPrivate > d_ptr
Definition: pqTextEdit.h:97
#define PQWIDGETS_EXPORT
pqWidgetCompleter * getCompleter()
Definition: pqTextEdit.h:47
pqTextEdit is a specialization of QTextEdit which provide editingFinished() and textChangedAndEditing...
Definition: pqTextEdit.h:37