42 #ifndef QLINECONTROL_P_H 43 #define QLINECONTROL_P_H 56 #include "QtCore/qglobal.h" 58 #ifndef QT_NO_LINEEDIT 59 #include "private/qwidget_p.h" 60 #include "QtGui/qlineedit.h" 61 #include "QtGui/qtextlayout.h" 62 #include "QtGui/qstyleoption.h" 63 #include "QtCore/qpointer.h" 64 #include "QtGui/qclipboard.h" 65 #include "QtCore/qpoint.h" 66 #include "QtGui/qcompleter.h" 67 #include "QtGui/qaccessible.h" 69 #include "qplatformdefs.h" 84 m_hideCursor(false), m_separator(0), m_readOnly(0),
85 m_dragEnabled(0), m_echoMode(0), m_textDirty(0), m_selDirty(0),
86 m_validInput(1), m_blinkStatus(0), m_blinkPeriod(0), m_blinkTimer(0), m_deleteAllTimer(0),
87 m_ascent(0), m_maxLength(32767), m_lastCursorPos(-1),
88 m_tripleClickTimer(0), m_maskData(0), m_modifiedState(0), m_undoState(0),
89 m_selstart(0), m_selend(0), m_passwordEchoEditing(false)
90 #ifdef QT_GUI_PASSWORD_ECHO_DELAY
91 , m_passwordEchoTimer(0)
104 int c = findInMask(pos,
true,
false);
105 m_separator |= (c != pos);
106 return (c != -1 ? c : m_maxLength);
111 int c = findInMask(pos,
false,
false);
112 m_separator |= (c != pos);
113 return (c != -1 ? c : 0);
116 bool isUndoAvailable()
const;
117 bool isRedoAvailable()
const;
118 void clearUndo() { m_history.clear(); m_modifiedState = m_undoState = 0; }
120 bool isModified()
const {
return m_modifiedState != m_undoState; }
121 void setModified(
bool modified) { m_modifiedState = modified ? -1 : m_undoState; }
123 bool allSelected()
const {
return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.length(); }
126 int width()
const {
return qRound(m_textLayout.lineAt(0).width()) + 1; }
127 int height()
const {
return qRound(m_textLayout.lineAt(0).height()) + 1; }
131 void setSelection(
int start,
int length);
141 if (m_selstart >= m_selend)
144 return pos >= m_selstart && pos < m_selend;
149 int priorState = m_undoState;
150 removeSelectedText();
151 finishChange(priorState);
155 int end()
const {
return m_text.length(); }
157 #ifndef QT_NO_CLIPBOARD 178 : m_textLayout.nextCursorPosition(c);
179 }
else if (steps < 0) {
182 : m_textLayout.previousCursorPosition(c);
194 QRect cursorRect()
const;
196 qreal cursorToX(
int cursor)
const {
return m_textLayout.lineAt(0).cursorToX(cursor); }
199 int cursor = m_cursor;
200 if (m_preeditCursor != -1)
201 cursor += m_preeditCursor;
202 return cursorToX(cursor);
210 QString res = m_maskData ? stripString(m_text) : m_text;
218 void deselect() { internalDeselect(); finishChange(); }
223 void undo() { internalUndo(); finishChange(-1,
true); }
224 void redo() { internalRedo(); finishChange(); }
225 void selectWordAtPos(
int);
230 cancelPasswordEchoTimer();
232 m_passwordEchoEditing =
false;
241 m_maxLength = maxLength;
245 #ifndef QT_NO_VALIDATOR 250 #ifndef QT_NO_COMPLETER 254 void complete(
int key);
266 parseInputMask(mask);
273 bool composeMode()
const {
return !m_textLayout.preeditAreaText().isEmpty(); }
279 void updatePasswordEchoEditing(
bool editing);
281 #ifdef QT_GUI_PASSWORD_ECHO_DELAY 282 if (m_passwordEchoTimer != 0)
285 return m_passwordEchoEditing ;
293 if (m_text.isEmpty())
297 return m_layoutDirection;
301 if (direction != m_layoutDirection) {
307 void setFont(
const QFont &font) { m_textLayout.setFont(font); updateDisplayText(); }
314 void setCursorBlinkPeriod(
int msec);
315 void resetCursorBlinkTimer();
325 DrawSelections = 0x02,
327 DrawAll = DrawText | DrawSelections | DrawCursor
331 bool processEvent(
QEvent *ev);
335 void removeSelectedText();
336 void internalSetText(
const QString &txt,
int pos = -1,
bool edited =
true);
337 void updateDisplayText(
bool forceUpdate =
false);
339 void internalInsert(
const QString &s);
340 void internalDelete(
bool wasBackspace =
false);
341 void internalRemove(
int pos);
345 m_selDirty |= (m_selend > m_selstart);
346 m_selstart = m_selend = 0;
349 void internalUndo(
int until = -1);
378 void emitCursorPositionChanged();
380 bool finishChange(
int validateFromState = -1,
bool update =
false,
bool edited =
true);
382 #ifndef QT_NO_VALIDATOR 386 #ifndef QT_NO_COMPLETER 387 bool advanceToEnabledItem(
int dir);
401 enum CommandType { Separator, Insert, Remove, Delete, RemoveSelection, DeleteSelection, SetSelection };
412 void addCommand(
const Command& cmd);
421 void parseInputMask(
const QString &maskFields);
422 bool isValidInput(
QChar key,
QChar mask)
const;
423 bool hasAcceptableInput(
const QString &
text)
const;
427 int findInMask(
int pos,
bool forward,
bool findSeparator,
QChar searchChar =
QChar())
const;
434 #ifdef QT_GUI_PASSWORD_ECHO_DELAY 435 int m_passwordEchoTimer;
439 #ifdef QT_GUI_PASSWORD_ECHO_DELAY 440 if (m_passwordEchoTimer != 0) {
441 killTimer(m_passwordEchoTimer);
442 m_passwordEchoTimer = 0;
448 void cursorPositionChanged(
int,
int);
449 void selectionChanged();
451 void displayTextChanged(
const QString &);
452 void textChanged(
const QString &);
453 void textEdited(
const QString &);
455 void resetInputContext();
456 void updateMicroFocus();
459 void editingFinished();
460 void updateNeeded(
const QRect &);
462 #ifdef QT_KEYPAD_NAVIGATION 463 void editFocusChange(
bool);
469 void _q_clipboardChanged();
470 void _q_deleteSelected();
478 #endif // QT_NO_LINEEDIT 480 #endif // QLINECONTROL_P_H
Mode
This enum type is used to control which part of the system clipboard is used by QClipboard::mimeData(...
The QPainter class performs low-level painting on widgets and other paint devices.
QChar m_passwordCharacter
The QKeyEvent class describes a key event.
QString cancelText() const
Qt::CursorMoveStyle cursorMoveStyle() const
int selectionStart() const
#define QT_END_NAMESPACE
This macro expands to.
QString textAfterSelection() const
void cursorWordForward(bool mark)
void cancelPasswordEchoTimer()
Qt::LayoutDirection m_layoutDirection
void setEchoMode(uint mode)
void setText(const QString &txt)
QCompleter * completer() const
static void clear(QVariant::Private *d)
The QCompleter class provides completions based on an item model.
void setModified(bool modified)
QVector< Command > m_history
The QString class provides a Unicode character string.
void setCursorMoveStyle(Qt::CursorMoveStyle style)
The QVector class is a template class that provides a dynamic array.
The QObject class is the base class of all Qt objects.
const QValidator * validator() const
int preeditCursor() const
The QChar class provides a 16-bit Unicode character.
void setPreeditArea(int cursor, const QString &text)
QString preeditAreaText() const
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
void setValidator(const QValidator *v)
static QCursor * moveCursor
int cursorPosition() const
QString textBeforeSelection() const
QChar passwordCharacter() const
void setCursorPosition(int pos)
bool hasAcceptableInput() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QValidator class provides validation of input text.
bool passwordEchoEditing() const
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
QList< int > m_transactions
const QPalette & palette() const
QLineControl(const QString &txt=QString())
qreal cursorToX(int cursor) const
void setCancelText(const QString &text)
int nextMaskBlank(int pos)
QPointer< QCompleter > m_completer
The QMouseEvent class contains parameters that describe a mouse event.
QString inputMask() const
bool isNull() const
Returns true if this string is null; otherwise returns false.
void setCompleter(const QCompleter *c)
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
QPointer< QValidator > m_validator
QString displayText() const
void cursorWordBackward(bool mark)
The QTextLayout class is used to lay out and render text.
QString selectedText() const
The QTimerEvent class contains parameters that describe a timer event.
CursorMoveStyle
This enum describes the movement style available to text cursors.
The QFont class specifies a font used for drawing text.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
void setMaxLength(int maxLength)
int prevMaskBlank(int pos)
MaskInputData * m_maskData
void setFont(const QFont &font)
The QPoint class defines a point in the plane using integer precision.
Qt::LayoutDirection layoutDirection() const
void setPasswordCharacter(const QChar &character)
qreal naturalTextWidth() const
void setPalette(const QPalette &p)
The QRect class defines a rectangle in the plane using integer precision.
Command(CommandType t, int p, QChar c, int ss, int se)
void cursorForward(bool mark, int steps)
void setLayoutDirection(Qt::LayoutDirection direction)
void setCursorWidth(int value)
void setInputMask(const QString &mask)
void setReadOnly(bool enable)
bool hasSelectedText() const
static Qt::LayoutDirection keyboardInputDirection()
Returns the current keyboard input direction.
int cursorBlinkPeriod() const
The QEvent class is the base class of all event classes.
bool inSelection(int x) const
bool m_passwordEchoEditing
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Q_DECL_CONSTEXPR int qRound(qreal d)
Qt::LayoutDirection direction
The QPalette class contains color groups for each widget state.