4#ifndef QWIDGETLINECONTROL_P_H
5#define QWIDGETLINECONTROL_P_H
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
20#include "private/qwidget_p.h"
21#include "QtWidgets/qlineedit.h"
22#include "QtGui/qtextlayout.h"
23#include "QtWidgets/qstyleoption.h"
24#include "QtCore/qpointer.h"
25#include "QtGui/qclipboard.h"
26#include "QtGui/qinputmethod.h"
27#include "QtCore/qpoint.h"
28#if QT_CONFIG(completer)
29#include "QtWidgets/qcompleter.h"
31#include "QtCore/qthread.h"
32#include "QtGui/private/qinputcontrol_p.h"
34#include "qplatformdefs.h"
57 , m_cursor(0), m_preeditCursor(0), m_cursorWidth(0), m_layoutDirection(
Qt::LayoutDirectionAuto),
58 m_hideCursor(
false), m_separator(0), m_readOnly(0),
59 m_dragEnabled(0), m_echoMode(0), m_textDirty(0), m_selDirty(0),
60 m_validInput(1), m_blinkStatus(0), m_blinkEnabled(
false), m_blinkTimer(0), m_deleteAllTimer(0),
61 m_ascent(0), m_maxLength(32767), m_lastCursorPos(-1),
62 m_tripleClickTimer(0), m_maskData(
nullptr), m_modifiedState(0), m_undoState(0),
63 m_selstart(0), m_selend(0), m_passwordEchoEditing(
false)
64 , m_passwordEchoTimer(0)
65 , m_passwordMaskDelay(-1)
66#
if defined(QT_BUILD_INTERNAL)
67 , m_passwordMaskDelayOverride(-1)
87 m_accessibleObject =
object;
92 if (m_accessibleObject)
93 return m_accessibleObject;
99 int c = findInMask(
pos,
true,
false);
100 m_separator |= (
c !=
pos);
101 return (
c != -1 ?
c : m_maxLength);
106 int c = findInMask(
pos,
false,
false);
107 m_separator |= (
c !=
pos);
108 return (
c != -1 ?
c : 0);
111 bool isUndoAvailable()
const;
112 bool isRedoAvailable()
const;
113 void clearUndo() { m_history.clear(); m_modifiedState = m_undoState = 0; }
115 bool isModified()
const {
return m_modifiedState != m_undoState; }
116 void setModified(
bool modified) { m_modifiedState = modified ? -1 : m_undoState; }
121 int width()
const {
return qRound(m_textLayout.lineAt(0).width()) + 1; }
122 int height()
const {
return qRound(m_textLayout.lineAt(0).height()) + 1; }
134#if defined (Q_OS_ANDROID)
135 bool isSelectableByMouse()
const {
return true; }
139 if (m_selstart >= m_selend)
142 return pos >= m_selstart &&
pos < m_selend;
147 int priorState = m_undoState;
148 removeSelectedText();
149 finishChange(priorState);
155#ifndef QT_NO_CLIPBOARD
169 void moveCursor(
int pos,
bool mark =
false);
176 : m_textLayout.nextCursorPosition(
c);
177 }
else if (steps < 0) {
180 : m_textLayout.previousCursorPosition(
c);
188 void home(
bool mark) { moveCursor(0, mark); }
189 void end(
bool mark) { moveCursor(m_text.
size(), mark); }
193 QRect cursorRect()
const;
194 QRect anchorRect()
const;
200 if (m_preeditCursor != -1)
201 cursor += m_preeditCursor;
206 void setReadOnly(
bool enable);
211 QString res = m_maskData ? stripString(content) : content;
220 internalSetText(
txt, -1,
false);
222 void commitPreedit();
233 void deselect() { internalDeselect(); finishChange(); }
234 void selectAll() { m_selstart = m_selend = m_cursor = 0; moveCursor(m_text.
size(),
true); }
239 void redo() { internalRedo(); finishChange(); }
240 void selectWordAtPos(
int);
245 cancelPasswordEchoTimer();
247 m_passwordEchoEditing =
false;
267#ifndef QT_NO_VALIDATOR
272#if QT_CONFIG(completer)
276 void complete(
int key);
290 if (m_blank != u
' ') {
299 parseInputMask(
mask);
301 moveCursor(nextMaskBlank(0));
306 bool composeMode()
const {
return !m_textLayout.preeditAreaText().isEmpty(); }
312 void updatePasswordEchoEditing(
bool editing);
314 if (m_passwordEchoTimer != 0)
316 return m_passwordEchoEditing ;
328 return m_layoutDirection;
343 void setBlinkingCursorEnabled(
bool enable);
344 void updateCursorBlinking();
345 void resetCursorBlinkTimer();
357 DrawSelections = 0x02,
359 DrawAll = DrawText | DrawSelections | DrawCursor
363#ifndef QT_NO_SHORTCUT
364 void processShortcutOverrideEvent(
QKeyEvent *ke);
369 return &m_textLayout;
374 void removeSelectedText();
375 void internalSetText(
const QString &
txt,
int pos = -1,
bool edited =
true);
378 void internalInsert(
const QString &
s);
379 void internalDelete(
bool wasBackspace =
false);
380 void internalRemove(
int pos);
382 inline void internalDeselect()
384 m_selDirty |= (m_selend > m_selstart);
385 m_selstart = m_selend = 0;
388 void internalUndo(
int until = -1);
397 uint m_hideCursor : 1;
398 uint m_separator : 1;
400 uint m_dragEnabled : 1;
402 uint m_textDirty : 1;
404 uint m_validInput : 1;
405 uint m_blinkStatus : 1;
406 uint m_blinkEnabled : 1;
408 int m_deleteAllTimer;
414 int m_tripleClickTimer;
417 void emitCursorPositionChanged();
419 bool finishChange(
int validateFromState = -1,
bool update =
false,
bool edited =
true);
421#ifndef QT_NO_VALIDATOR
425#if QT_CONFIG(completer)
426 bool advanceToEnabledItem(
int dir);
429 struct MaskInputData {
437 std::unique_ptr<MaskInputData[]> m_maskData;
440 enum CommandType { Separator, Insert, Remove, Delete, RemoveSelection, DeleteSelection, SetSelection };
445 int pos, selStart, selEnd;
449 std::vector<Command> m_history;
450 void addCommand(
const Command& cmd);
452 inline void separate() { m_separator =
true; }
459 void parseInputMask(
const QString &maskFields);
461 bool hasAcceptableInput(
const QString &
text)
const;
465 int findInMask(
int pos,
bool forward,
bool findSeparator,
QChar searchChar =
QChar())
const;
470 bool m_passwordEchoEditing;
471 QChar m_passwordCharacter;
472 int m_passwordEchoTimer;
473 int m_passwordMaskDelay;
474 void cancelPasswordEchoTimer()
476 if (m_passwordEchoTimer != 0) {
478 m_passwordEchoTimer = 0;
482 int redoTextLayout()
const;
485#if defined(QT_BUILD_INTERNAL)
486 int m_passwordMaskDelayOverride;
505#ifdef QT_KEYPAD_NAVIGATION
506 void editFocusChange(
bool);
512 void _q_deleteSelected();
515 int m_keyboardScheme;
Mode
\keyword clipboard mode
The QCompleter class provides completions based on an item model.
static QInputMethod * inputMethod()
returns the input method.
The QKeyEvent class describes a key event.
QObject * parent() const
Returns a pointer to the parent object.
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
void killTimer(int id)
Kills the timer with timer identifier, id.
The QPainter class performs low-level painting on widgets and other paint devices.
The QPalette class contains color groups for each widget state.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString & fill(QChar c, qsizetype size=-1)
Sets every character in the string to character ch.
void reserve(qsizetype size)
Ensures the string has space for at least size characters.
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isNull() const
Returns true if this string is null; otherwise returns false.
qsizetype size() const
Returns the number of characters in this string.
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
bool isRightToLeft() const
Returns true if the string is read right to left.
CursorPosition
\value CursorBetweenCharacters \value CursorOnCharacter
@ CursorBetweenCharacters
The QValidator class provides validation of input text.
cache insert(employee->id(), employee)
Combined button and popup list for selecting options.
static jboolean copy(JNIEnv *, jobject)
static jboolean paste(JNIEnv *, jobject)
static jboolean setSelection(JNIEnv *, jobject, jint start, jint end)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
int qRound(qfloat16 d) noexcept
constexpr const T & qMax(const T &a, const T &b)
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLenum GLsizei length
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
void forceUpdate(QQuickItem *item)
#define QT_REQUIRE_CONFIG(feature)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
if(qFloatDistance(a, b)<(1<< 7))
[0]
myFilter draw(painter, QPoint(0, 0), originalPixmap)
lineEdit setCompleter(completer)
QCompleter * completer
[0]
insertRed setText("insert red text")