Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
messageeditorwidgets.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef MESSAGEEDITORWIDGETS_H
5#define MESSAGEEDITORWIDGETS_H
6
7#include <QAbstractButton>
8#include <QIcon>
9#include <QImage>
10#include <QLabel>
11#include <QMap>
12#include <QTextEdit>
13#include <QUrl>
14#include <QWidget>
15
17
18class QAction;
19class QContextMenuEvent;
20class QKeyEvent;
21class QMenu;
22class QSizeF;
23class QString;
24class QVariant;
25
27
28/*
29 Automatically adapt height to document contents
30 */
32{
34
35public:
37 QSize sizeHint() const override;
38 QSize minimumSizeHint() const override;
39
40private slots:
41 void updateHeight(const QSizeF &documentSize);
42 void reallyEnsureCursorVisible();
43
44private:
45 int m_minimumHeight;
46};
47
48/*
49 Format markup & control characters
50*/
52{
54public:
57 void setEditable(bool editable);
58
61
62public slots:
63 void setPlainText(const QString & text, bool userAction);
64 void setVisualizeWhitespace(bool value);
65
66private:
67 MessageHighlighter *m_highlighter;
68};
69
70/*
71 Displays text field & associated label
72*/
73class FormWidget : public QWidget
74{
76public:
77 FormWidget(const QString &label, bool isEditable, QWidget *parent = 0);
78 void setLabel(const QString &label) { m_label->setText(label); }
79 void setTranslation(const QString &text, bool userAction = false);
80 void clearTranslation() { setTranslation(QString(), false); }
81 QString getTranslation() { return m_editor->toPlainText(); }
82 void setEditingEnabled(bool enable);
83 void setHideWhenEmpty(bool optional) { m_hideWhenEmpty = optional; }
84 FormatTextEdit *getEditor() { return m_editor; }
85
88 void selectionChanged(QTextEdit *);
90
91private slots:
93 void slotTextChanged();
94
95private:
96 QLabel *m_label;
97 FormatTextEdit *m_editor;
98 bool m_hideWhenEmpty;
99};
100
101/*
102 Displays text fields & associated label
103*/
105{
107public:
109 void setLabel(const QString &label) { m_label->setText(label); }
110 void setTranslation(const QString &text, bool userAction = false);
111 void clearTranslation() { setTranslation(QString(), false); }
112 QString getTranslation() const;
113 void setEditingEnabled(bool enable);
114 void setMultiEnabled(bool enable);
115 void setHideWhenEmpty(bool optional) { m_hideWhenEmpty = optional; }
116 const QList<FormatTextEdit *> &getEditors() const { return m_editors; }
117
118signals:
120 void textChanged(QTextEdit *);
121 void selectionChanged(QTextEdit *);
123
124protected:
125 bool eventFilter(QObject *watched, QEvent *event) override;
126
127private slots:
128 void slotTextChanged();
129 void slotSelectionChanged();
130 void minusButtonClicked();
131 void plusButtonClicked();
132
133private:
134 void addEditor(int idx);
135 void updateLayout();
136
137 template<typename Func>
138 QAbstractButton *makeButton(const QIcon &icon, Func slot)
139 {
140 auto *button = makeButton(icon);
141 connect(button, &QAbstractButton::clicked,
142 this, slot);
143 return button;
144 }
145 QAbstractButton *makeButton(const QIcon &icon);
146 void insertEditor(int idx);
147 void deleteEditor(int idx);
148
149 QLabel *m_label;
150 QList<FormatTextEdit *> m_editors;
151 QList<QWidget *> m_plusButtons;
152 QList<QAbstractButton *> m_minusButtons;
153 bool m_hideWhenEmpty;
154 bool m_multiEnabled;
155 QIcon m_plusIcon, m_minusIcon;
156};
157
158QT_END_NAMESPACE
159
160#endif // MESSAGEEDITORWIDGETS_H
QSize minimumSizeHint() const override
QSize sizeHint() const override
void setLabel(const QString &label)
void setHideWhenEmpty(bool optional)
void setTranslation(const QString &text, bool userAction=false)
QString getTranslation() const
bool eventFilter(QObject *watched, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
void setMultiEnabled(bool enable)
void setEditingEnabled(bool enable)
void cursorPositionChanged()
const QList< FormatTextEdit * > & getEditors() const
void setLabel(const QString &label)
void setTranslation(const QString &text, bool userAction=false)
QString getTranslation()
void setEditingEnabled(bool enable)
void cursorPositionChanged()
FormatTextEdit * getEditor()
void setHideWhenEmpty(bool optional)
void setVisualizeWhitespace(bool value)
void setEditable(bool editable)
void setLengthVariants(bool on)
void setVisualizeWhitespace(bool value)
void setEditorFocusForModel(int model)
void setFontSize(const float fontSize)
void setUnfinishedEditorFocus()
bool focusNextUnfinished()
void showMessage(const MultiDataIndex &index)
bool eventFilter(QObject *, QEvent *) override
const TranslatorMessage & message() const
TranslatorMessage::Type type() const
MessageItem * messageItem(const MultiDataIndex &index, int model) const
DataModel * model(int i)
bool isModelWritable(int model) const
The QScrollArea class provides a scrolling view onto another widget.
Definition qscrollarea.h:17
static void clearSelection(QTextEdit *t)
Combined button and popup list for selecting options.
FormWidget * transCommentText