| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquicktextinput_p_p.h |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||
| 2 | ** | - | ||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
| 5 | ** | - | ||||||
| 6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||
| 7 | ** | - | ||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
| 9 | ** Commercial License Usage | - | ||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
| 16 | ** | - | ||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
| 24 | ** | - | ||||||
| 25 | ** GNU General Public License Usage | - | ||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
| 35 | ** | - | ||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||
| 37 | ** | - | ||||||
| 38 | ****************************************************************************/ | - | ||||||
| 39 | - | |||||||
| 40 | #ifndef QQUICKTEXTINPUT_P_P_H | - | ||||||
| 41 | #define QQUICKTEXTINPUT_P_P_H | - | ||||||
| 42 | - | |||||||
| 43 | #include "qquicktextinput_p.h" | - | ||||||
| 44 | #include "qquicktext_p.h" | - | ||||||
| 45 | #include "qquickimplicitsizeitem_p_p.h" | - | ||||||
| 46 | #include "qquicktextutil_p.h" | - | ||||||
| 47 | - | |||||||
| 48 | #include <QtQml/qqml.h> | - | ||||||
| 49 | #include <QtCore/qelapsedtimer.h> | - | ||||||
| 50 | #include <QtCore/qpointer.h> | - | ||||||
| 51 | #include <QtCore/qbasictimer.h> | - | ||||||
| 52 | #include <QtGui/qclipboard.h> | - | ||||||
| 53 | #include <QtGui/qguiapplication.h> | - | ||||||
| 54 | #include <QtGui/qpalette.h> | - | ||||||
| 55 | #include <QtGui/qtextlayout.h> | - | ||||||
| 56 | #include <QtGui/qstylehints.h> | - | ||||||
| 57 | #include <private/qlazilyallocated_p.h> | - | ||||||
| 58 | - | |||||||
| 59 | #include "qplatformdefs.h" | - | ||||||
| 60 | - | |||||||
| 61 | // | - | ||||||
| 62 | // W A R N I N G | - | ||||||
| 63 | // ------------- | - | ||||||
| 64 | // | - | ||||||
| 65 | // This file is not part of the Qt API. It exists purely as an | - | ||||||
| 66 | // implementation detail. This header file may change from version to | - | ||||||
| 67 | // version without notice, or even be removed. | - | ||||||
| 68 | // | - | ||||||
| 69 | // We mean it. | - | ||||||
| 70 | - | |||||||
| 71 | QT_BEGIN_NAMESPACE | - | ||||||
| 72 | - | |||||||
| 73 | class QQuickTextNode; | - | ||||||
| 74 | class QInputControl; | - | ||||||
| 75 | - | |||||||
| 76 | class Q_QUICK_PRIVATE_EXPORT QQuickTextInputPrivate : public QQuickImplicitSizeItemPrivate | - | ||||||
| 77 | { | - | ||||||
| 78 | public: | - | ||||||
| 79 | Q_DECLARE_PUBLIC(QQuickTextInput) | - | ||||||
| 80 | - | |||||||
| 81 | typedef QQuickTextInput Public; | - | ||||||
| 82 | - | |||||||
| 83 | struct ExtraData { | - | ||||||
| 84 | ExtraData(); | - | ||||||
| 85 | - | |||||||
| 86 | qreal padding; | - | ||||||
| 87 | qreal topPadding; | - | ||||||
| 88 | qreal leftPadding; | - | ||||||
| 89 | qreal rightPadding; | - | ||||||
| 90 | qreal bottomPadding; | - | ||||||
| 91 | bool explicitTopPadding : 1; | - | ||||||
| 92 | bool explicitLeftPadding : 1; | - | ||||||
| 93 | bool explicitRightPadding : 1; | - | ||||||
| 94 | bool explicitBottomPadding : 1; | - | ||||||
| 95 | bool implicitResize : 1; | - | ||||||
| 96 | }; | - | ||||||
| 97 | QLazilyAllocated<ExtraData> extra; | - | ||||||
| 98 | - | |||||||
| 99 | QQuickTextInputPrivate() | - | ||||||
| 100 | : hscroll(0) | - | ||||||
| 101 | , vscroll(0) | - | ||||||
| 102 | , cursorItem(nullptr) | - | ||||||
| 103 | , textNode(nullptr) | - | ||||||
| 104 | , m_maskData(nullptr) | - | ||||||
| 105 | , color(QRgb(0xFF000000)) | - | ||||||
| 106 | , selectionColor(QRgb(0xFF000080)) | - | ||||||
| 107 | , selectedTextColor(QRgb(0xFFFFFFFF)) | - | ||||||
| 108 | , m_cursor(0) | - | ||||||
| 109 | #if QT_CONFIG(im) | - | ||||||
| 110 | , m_preeditCursor(0) | - | ||||||
| 111 | #endif | - | ||||||
| 112 | , m_blinkEnabled(false) | - | ||||||
| 113 | , m_blinkTimer(0) | - | ||||||
| 114 | , m_maxLength(32767) | - | ||||||
| 115 | , m_lastCursorPos(-1) | - | ||||||
| 116 | , m_undoState(0) | - | ||||||
| 117 | , m_selstart(0) | - | ||||||
| 118 | , m_selend(0) | - | ||||||
| 119 | #if QT_CONFIG(im) | - | ||||||
| 120 | , inputMethodHints(Qt::ImhNone) | - | ||||||
| 121 | #endif | - | ||||||
| 122 | , hAlign(QQuickTextInput::AlignLeft) | - | ||||||
| 123 | , vAlign(QQuickTextInput::AlignTop) | - | ||||||
| 124 | , wrapMode(QQuickTextInput::NoWrap) | - | ||||||
| 125 | , m_echoMode(QQuickTextInput::Normal) | - | ||||||
| 126 | , renderType(QQuickTextUtil::textRenderType<QQuickTextInput>()) | - | ||||||
| 127 | , updateType(UpdatePaintNode) | - | ||||||
| 128 | , mouseSelectionMode(QQuickTextInput::SelectCharacters) | - | ||||||
| 129 | , m_layoutDirection(Qt::LayoutDirectionAuto) | - | ||||||
| 130 | , m_passwordCharacter(QGuiApplication::styleHints()->passwordMaskCharacter()) | - | ||||||
| 131 | , m_passwordMaskDelay(QGuiApplication::styleHints()->passwordMaskDelay()) | - | ||||||
| 132 | , focusOnPress(true) | - | ||||||
| 133 | , cursorVisible(false) | - | ||||||
| 134 | , cursorPending(false) | - | ||||||
| 135 | , autoScroll(true) | - | ||||||
| 136 | , selectByMouse(false) | - | ||||||
| 137 | , canPaste(false) | - | ||||||
| 138 | , canPasteValid(false) | - | ||||||
| 139 | , canUndo(false) | - | ||||||
| 140 | , canRedo(false) | - | ||||||
| 141 | , hAlignImplicit(true) | - | ||||||
| 142 | , selectPressed(false) | - | ||||||
| 143 | , textLayoutDirty(true) | - | ||||||
| 144 | , persistentSelection(false) | - | ||||||
| 145 | , hasImState(false) | - | ||||||
| 146 | , m_separator(0) | - | ||||||
| 147 | , m_readOnly(0) | - | ||||||
| 148 | , m_textDirty(0) | - | ||||||
| 149 | #if QT_CONFIG(im) | - | ||||||
| 150 | , m_preeditDirty(0) | - | ||||||
| 151 | #endif | - | ||||||
| 152 | , m_selDirty(0) | - | ||||||
| 153 | , m_validInput(1) | - | ||||||
| 154 | , m_acceptableInput(1) | - | ||||||
| 155 | , m_blinkStatus(0) | - | ||||||
| 156 | , m_passwordEchoEditing(false) | - | ||||||
| 157 | , inLayout(false) | - | ||||||
| 158 | , requireImplicitWidth(false) | - | ||||||
| 159 | , overwriteMode(false) | - | ||||||
| 160 | { | - | ||||||
| 161 | } executed 1042 times by 5 tests: end of blockExecuted by:
| 1042 | ||||||
| 162 | - | |||||||
| 163 | ~QQuickTextInputPrivate() | - | ||||||
| 164 | { | - | ||||||
| 165 | } | - | ||||||
| 166 | - | |||||||
| 167 | void init(); | - | ||||||
| 168 | void resetInputMethod(); | - | ||||||
| 169 | void startCreatingCursor(); | - | ||||||
| 170 | void ensureVisible(int position, int preeditCursor = 0, int preeditLength = 0); | - | ||||||
| 171 | void updateHorizontalScroll(); | - | ||||||
| 172 | void updateVerticalScroll(); | - | ||||||
| 173 | bool determineHorizontalAlignment(); | - | ||||||
| 174 | bool setHAlign(QQuickTextInput::HAlignment, bool forceAlign = false); | - | ||||||
| 175 | void mirrorChange() override; | - | ||||||
| 176 | bool sendMouseEventToInputContext(QMouseEvent *event); | - | ||||||
| 177 | #if QT_CONFIG(im) | - | ||||||
| 178 | Qt::InputMethodHints effectiveInputMethodHints() const; | - | ||||||
| 179 | #endif | - | ||||||
| 180 | void handleFocusEvent(QFocusEvent *event); | - | ||||||
| 181 | - | |||||||
| 182 | struct MaskInputData { | - | ||||||
| 183 | enum Casemode { NoCaseMode, Upper, Lower }; | - | ||||||
| 184 | QChar maskChar; // either the separator char or the inputmask | - | ||||||
| 185 | bool separator; | - | ||||||
| 186 | Casemode caseMode; | - | ||||||
| 187 | }; | - | ||||||
| 188 | - | |||||||
| 189 | // undo/redo handling | - | ||||||
| 190 | enum CommandType { Separator, Insert, Remove, Delete, RemoveSelection, DeleteSelection, SetSelection }; | - | ||||||
| 191 | struct Command { | - | ||||||
| 192 | inline Command() {} | - | ||||||
| 193 | inline Command(CommandType t, int p, QChar c, int ss, int se) : type(t),uc(c),pos(p),selStart(ss),selEnd(se) {} executed 5182 times by 1 test: end of blockExecuted by:
| 5182 | ||||||
| 194 | uint type : 4; | - | ||||||
| 195 | QChar uc; | - | ||||||
| 196 | int pos, selStart, selEnd; | - | ||||||
| 197 | }; | - | ||||||
| 198 | - | |||||||
| 199 | enum DrawFlags { | - | ||||||
| 200 | DrawText = 0x01, | - | ||||||
| 201 | DrawSelections = 0x02, | - | ||||||
| 202 | DrawCursor = 0x04, | - | ||||||
| 203 | DrawAll = DrawText | DrawSelections | DrawCursor | - | ||||||
| 204 | }; | - | ||||||
| 205 | - | |||||||
| 206 | QElapsedTimer tripleClickTimer; | - | ||||||
| 207 | QSizeF contentSize; | - | ||||||
| 208 | QPointF pressPos; | - | ||||||
| 209 | QPointF tripleClickStartPoint; | - | ||||||
| 210 | - | |||||||
| 211 | QPointer<QQmlComponent> cursorComponent; | - | ||||||
| 212 | #if QT_CONFIG(validator) | - | ||||||
| 213 | QPointer<QValidator> m_validator; | - | ||||||
| 214 | #endif | - | ||||||
| 215 | - | |||||||
| 216 | qreal hscroll; | - | ||||||
| 217 | qreal vscroll; | - | ||||||
| 218 | - | |||||||
| 219 | QTextLayout m_textLayout; | - | ||||||
| 220 | QString m_text; | - | ||||||
| 221 | QString m_inputMask; | - | ||||||
| 222 | QString m_cancelText; | - | ||||||
| 223 | QFont font; | - | ||||||
| 224 | QFont sourceFont; | - | ||||||
| 225 | - | |||||||
| 226 | QQuickItem *cursorItem; | - | ||||||
| 227 | QQuickTextNode *textNode; | - | ||||||
| 228 | MaskInputData *m_maskData; | - | ||||||
| 229 | QInputControl *m_inputControl; | - | ||||||
| 230 | - | |||||||
| 231 | QList<int> m_transactions; | - | ||||||
| 232 | QVector<Command> m_history; | - | ||||||
| 233 | - | |||||||
| 234 | QColor color; | - | ||||||
| 235 | QColor selectionColor; | - | ||||||
| 236 | QColor selectedTextColor; | - | ||||||
| 237 | - | |||||||
| 238 | QBasicTimer m_passwordEchoTimer; | - | ||||||
| 239 | int lastSelectionStart; | - | ||||||
| 240 | int lastSelectionEnd; | - | ||||||
| 241 | int m_cursor; | - | ||||||
| 242 | #if QT_CONFIG(im) | - | ||||||
| 243 | int m_preeditCursor; | - | ||||||
| 244 | #endif | - | ||||||
| 245 | bool m_blinkEnabled; | - | ||||||
| 246 | int m_blinkTimer; | - | ||||||
| 247 | int m_maxLength; | - | ||||||
| 248 | int m_lastCursorPos; | - | ||||||
| 249 | int m_undoState; | - | ||||||
| 250 | int m_selstart; | - | ||||||
| 251 | int m_selend; | - | ||||||
| 252 | - | |||||||
| 253 | enum UpdateType { | - | ||||||
| 254 | UpdateNone, | - | ||||||
| 255 | UpdateOnlyPreprocess, | - | ||||||
| 256 | UpdatePaintNode | - | ||||||
| 257 | }; | - | ||||||
| 258 | - | |||||||
| 259 | #if QT_CONFIG(im) | - | ||||||
| 260 | Qt::InputMethodHints inputMethodHints; | - | ||||||
| 261 | #endif | - | ||||||
| 262 | QQuickTextInput::HAlignment hAlign; | - | ||||||
| 263 | QQuickTextInput::VAlignment vAlign; | - | ||||||
| 264 | QQuickTextInput::WrapMode wrapMode; | - | ||||||
| 265 | QQuickTextInput::EchoMode m_echoMode; | - | ||||||
| 266 | QQuickTextInput::RenderType renderType; | - | ||||||
| 267 | UpdateType updateType; | - | ||||||
| 268 | QQuickTextInput::SelectionMode mouseSelectionMode; | - | ||||||
| 269 | Qt::LayoutDirection m_layoutDirection; | - | ||||||
| 270 | - | |||||||
| 271 | QChar m_blank; | - | ||||||
| 272 | QChar m_passwordCharacter; | - | ||||||
| 273 | int m_passwordMaskDelay; | - | ||||||
| 274 | - | |||||||
| 275 | bool focusOnPress:1; | - | ||||||
| 276 | bool cursorVisible:1; | - | ||||||
| 277 | bool cursorPending:1; | - | ||||||
| 278 | bool autoScroll:1; | - | ||||||
| 279 | bool selectByMouse:1; | - | ||||||
| 280 | bool canPaste:1; | - | ||||||
| 281 | bool canPasteValid:1; | - | ||||||
| 282 | bool canUndo:1; | - | ||||||
| 283 | bool canRedo:1; | - | ||||||
| 284 | bool hAlignImplicit:1; | - | ||||||
| 285 | bool selectPressed:1; | - | ||||||
| 286 | bool textLayoutDirty:1; | - | ||||||
| 287 | bool persistentSelection:1; | - | ||||||
| 288 | bool hasImState : 1; | - | ||||||
| 289 | bool m_separator : 1; | - | ||||||
| 290 | bool m_readOnly : 1; | - | ||||||
| 291 | bool m_textDirty : 1; | - | ||||||
| 292 | #if QT_CONFIG(im) | - | ||||||
| 293 | bool m_preeditDirty : 1; | - | ||||||
| 294 | #endif | - | ||||||
| 295 | bool m_selDirty : 1; | - | ||||||
| 296 | bool m_validInput : 1; | - | ||||||
| 297 | bool m_acceptableInput : 1; | - | ||||||
| 298 | bool m_blinkStatus : 1; | - | ||||||
| 299 | bool m_passwordEchoEditing : 1; | - | ||||||
| 300 | bool inLayout:1; | - | ||||||
| 301 | bool requireImplicitWidth:1; | - | ||||||
| 302 | bool overwriteMode:1; | - | ||||||
| 303 | - | |||||||
| 304 | static inline QQuickTextInputPrivate *get(QQuickTextInput *t) { | - | ||||||
| 305 | return t->d_func(); executed 6 times by 1 test: return t->d_func();Executed by:
| 6 | ||||||
| 306 | } | - | ||||||
| 307 | bool hasPendingTripleClick() const { | - | ||||||
| 308 | return !tripleClickTimer.hasExpired(QGuiApplication::styleHints()->mouseDoubleClickInterval()); executed 74 times by 1 test: return !tripleClickTimer.hasExpired(QGuiApplication::styleHints()->mouseDoubleClickInterval());Executed by:
| 74 | ||||||
| 309 | } | - | ||||||
| 310 | - | |||||||
| 311 | void setNativeCursorEnabled(bool) { | - | ||||||
| 312 | updateCursorBlinking(); | - | ||||||
| 313 | } executed 26 times by 1 test: end of blockExecuted by:
| 26 | ||||||
| 314 | - | |||||||
| 315 | int nextMaskBlank(int pos) | - | ||||||
| 316 | { | - | ||||||
| 317 | int c = findInMask(pos, true, false); | - | ||||||
| 318 | m_separator |= (c != pos); | - | ||||||
| 319 | return (c != -1 ? c : m_maxLength); executed 764 times by 1 test: return (c != -1 ? c : m_maxLength);Executed by:
| 764 | ||||||
| 320 | } | - | ||||||
| 321 | - | |||||||
| 322 | int prevMaskBlank(int pos) | - | ||||||
| 323 | { | - | ||||||
| 324 | int c = findInMask(pos, false, false); | - | ||||||
| 325 | m_separator |= (c != pos); | - | ||||||
| 326 | return (c != -1 ? c : 0); executed 276 times by 1 test: return (c != -1 ? c : 0);Executed by:
| 276 | ||||||
| 327 | } | - | ||||||
| 328 | - | |||||||
| 329 | bool isUndoAvailable() const { return !m_readOnly && m_undoState; } executed 3900 times by 4 tests: return !m_readOnly && m_undoState;Executed by:
| 3900 | ||||||
| 330 | bool isRedoAvailable() const { return !m_readOnly && m_undoState < (int)m_history.size(); } executed 3732 times by 4 tests: return !m_readOnly && m_undoState < (int)m_history.size();Executed by:
| 3732 | ||||||
| 331 | void clearUndo() { m_history.clear(); m_undoState = 0; } never executed: end of block | 0 | ||||||
| 332 | - | |||||||
| 333 | bool allSelected() const { return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.length(); } never executed: return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.length(); | 0 | ||||||
| 334 | bool hasSelectedText() const { return !m_text.isEmpty() && m_selend > m_selstart; } executed 13754 times by 4 tests: return !m_text.isEmpty() && m_selend > m_selstart;Executed by:
| 13754 | ||||||
| 335 | - | |||||||
| 336 | void setSelection(int start, int length); | - | ||||||
| 337 | - | |||||||
| 338 | inline QString selectedText() const { return hasSelectedText() ? m_text.mid(m_selstart, m_selend - m_selstart) : QString(); } executed 1010 times by 1 test: return hasSelectedText() ? m_text.mid(m_selstart, m_selend - m_selstart) : QString();Executed by:
| 1010 | ||||||
| 339 | QString textBeforeSelection() const { return hasSelectedText() ? m_text.left(m_selstart) : QString(); } never executed: return hasSelectedText() ? m_text.left(m_selstart) : QString(); | 0 | ||||||
| 340 | QString textAfterSelection() const { return hasSelectedText() ? m_text.mid(m_selend) : QString(); } never executed: return hasSelectedText() ? m_text.mid(m_selend) : QString(); | 0 | ||||||
| 341 | - | |||||||
| 342 | int selectionStart() const { return hasSelectedText() ? m_selstart : -1; } executed 1975 times by 4 tests: return hasSelectedText() ? m_selstart : -1;Executed by:
| 1975 | ||||||
| 343 | int selectionEnd() const { return hasSelectedText() ? m_selend : -1; } executed 1963 times by 4 tests: return hasSelectedText() ? m_selend : -1;Executed by:
| 1963 | ||||||
| 344 | - | |||||||
| 345 | QRectF anchorRectangle() const; | - | ||||||
| 346 | - | |||||||
| 347 | int positionAt(qreal x, qreal y, QTextLine::CursorPosition position) const; | - | ||||||
| 348 | int positionAt(const QPointF &point, QTextLine::CursorPosition position = QTextLine::CursorBetweenCharacters) const { | - | ||||||
| 349 | return positionAt(point.x(), point.y(), position); executed 120 times by 1 test: return positionAt(point.x(), point.y(), position);Executed by:
| 120 | ||||||
| 350 | } | - | ||||||
| 351 | - | |||||||
| 352 | void removeSelection() | - | ||||||
| 353 | { | - | ||||||
| 354 | int priorState = m_undoState; | - | ||||||
| 355 | removeSelectedText(); | - | ||||||
| 356 | finishChange(priorState); | - | ||||||
| 357 | } never executed: end of block | 0 | ||||||
| 358 | - | |||||||
| 359 | int start() const { return 0; } never executed: return 0; | 0 | ||||||
| 360 | int end() const { return m_text.length(); } executed 52 times by 2 tests: return m_text.length();Executed by:
| 52 | ||||||
| 361 | - | |||||||
| 362 | QString realText() const; | - | ||||||
| 363 | - | |||||||
| 364 | #if QT_CONFIG(clipboard) | - | ||||||
| 365 | void copy(QClipboard::Mode mode = QClipboard::Clipboard) const; | - | ||||||
| 366 | void paste(QClipboard::Mode mode = QClipboard::Clipboard); | - | ||||||
| 367 | #endif | - | ||||||
| 368 | - | |||||||
| 369 | #if QT_CONFIG(im) | - | ||||||
| 370 | void commitPreedit(); | - | ||||||
| 371 | void cancelPreedit(); | - | ||||||
| 372 | #endif | - | ||||||
| 373 | - | |||||||
| 374 | Qt::CursorMoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); } executed 2024 times by 2 tests: return m_textLayout.cursorMoveStyle();Executed by:
| 2024 | ||||||
| 375 | void setCursorMoveStyle(Qt::CursorMoveStyle style) { m_textLayout.setCursorMoveStyle(style); } never executed: end of block | 0 | ||||||
| 376 | - | |||||||
| 377 | void moveCursor(int pos, bool mark = false); | - | ||||||
| 378 | void cursorForward(bool mark, int steps) | - | ||||||
| 379 | { | - | ||||||
| 380 | int c = m_cursor; | - | ||||||
| 381 | if (steps > 0) {
| 30 | ||||||
| 382 | while (steps--)
| 30 | ||||||
| 383 | c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.rightCursorPosition(c) executed 30 times by 1 test: c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.rightCursorPosition(c) : m_textLayout.nextCursorPosition(c);Executed by:
| 0-30 | ||||||
| 384 | : m_textLayout.nextCursorPosition(c); executed 30 times by 1 test: c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.rightCursorPosition(c) : m_textLayout.nextCursorPosition(c);Executed by:
| 30 | ||||||
| 385 | } else if (steps < 0) { executed 30 times by 1 test: end of blockExecuted by:
| 0-30 | ||||||
| 386 | while (steps++)
| 30 | ||||||
| 387 | c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.leftCursorPosition(c) executed 30 times by 1 test: c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.leftCursorPosition(c) : m_textLayout.previousCursorPosition(c);Executed by:
| 0-30 | ||||||
| 388 | : m_textLayout.previousCursorPosition(c); executed 30 times by 1 test: c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.leftCursorPosition(c) : m_textLayout.previousCursorPosition(c);Executed by:
| 30 | ||||||
| 389 | } executed 30 times by 1 test: end of blockExecuted by:
| 30 | ||||||
| 390 | moveCursor(c, mark); | - | ||||||
| 391 | } executed 60 times by 1 test: end of blockExecuted by:
| 60 | ||||||
| 392 | - | |||||||
| 393 | void cursorWordForward(bool mark) { moveCursor(m_textLayout.nextCursorPosition(m_cursor, QTextLayout::SkipWords), mark); } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||
| 394 | void cursorWordBackward(bool mark) { moveCursor(m_textLayout.previousCursorPosition(m_cursor, QTextLayout::SkipWords), mark); } executed 18 times by 1 test: end of blockExecuted by:
| 18 | ||||||
| 395 | - | |||||||
| 396 | void home(bool mark) { moveCursor(0, mark); } executed 102 times by 1 test: end of blockExecuted by:
| 102 | ||||||
| 397 | void end(bool mark) { moveCursor(q_func()->text().length(), mark); } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||
| 398 | - | |||||||
| 399 | void backspace(); | - | ||||||
| 400 | void del(); | - | ||||||
| 401 | void deselect() { internalDeselect(); finishChange(); } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||
| 402 | void selectAll() { m_selstart = m_selend = m_cursor = 0; moveCursor(m_text.length(), true); } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||
| 403 | - | |||||||
| 404 | void insert(const QString &); | - | ||||||
| 405 | void clear(); | - | ||||||
| 406 | void selectWordAtPos(int); | - | ||||||
| 407 | - | |||||||
| 408 | void setCursorPosition(int pos) { if (pos <= m_text.length()) moveCursor(qMax(0, pos)); } executed 38 times by 2 tests: end of blockExecuted by:
executed 38 times by 2 tests: moveCursor(qMax(0, pos));Executed by:
| 0-38 | ||||||
| 409 | - | |||||||
| 410 | bool fixup(); | - | ||||||
| 411 | - | |||||||
| 412 | QString inputMask() const { return m_maskData ? m_inputMask + QLatin1Char(';') + m_blank : QString(); } executed 622 times by 1 test: return m_maskData ? m_inputMask + QLatin1Char(';') + m_blank : QString();Executed by:
| 622 | ||||||
| 413 | void setInputMask(const QString &mask) | - | ||||||
| 414 | { | - | ||||||
| 415 | parseInputMask(mask); | - | ||||||
| 416 | if (m_maskData)
| 2-254 | ||||||
| 417 | moveCursor(nextMaskBlank(0)); executed 254 times by 1 test: moveCursor(nextMaskBlank(0));Executed by:
| 254 | ||||||
| 418 | } executed 256 times by 1 test: end of blockExecuted by:
| 256 | ||||||
| 419 | - | |||||||
| 420 | // input methods | - | ||||||
| 421 | #if QT_CONFIG(im) | - | ||||||
| 422 | bool composeMode() const { return !m_textLayout.preeditAreaText().isEmpty(); } executed 208 times by 1 test: return !m_textLayout.preeditAreaText().isEmpty();Executed by:
| 208 | ||||||
| 423 | - | |||||||
| 424 | QString preeditAreaText() const { return m_textLayout.preeditAreaText(); } executed 588 times by 1 test: return m_textLayout.preeditAreaText();Executed by:
| 588 | ||||||
| 425 | #endif | - | ||||||
| 426 | - | |||||||
| 427 | void updatePasswordEchoEditing(bool editing); | - | ||||||
| 428 | - | |||||||
| 429 | void cancelPasswordEchoTimer() { | - | ||||||
| 430 | m_passwordEchoTimer.stop(); | - | ||||||
| 431 | } executed 486 times by 1 test: end of blockExecuted by:
| 486 | ||||||
| 432 | - | |||||||
| 433 | Qt::LayoutDirection textDirection() const; | - | ||||||
| 434 | Qt::LayoutDirection layoutDirection() const; | - | ||||||
| 435 | void setLayoutDirection(Qt::LayoutDirection direction) | - | ||||||
| 436 | { | - | ||||||
| 437 | if (direction != m_layoutDirection) {
| 0-58 | ||||||
| 438 | m_layoutDirection = direction; | - | ||||||
| 439 | updateDisplayText(); | - | ||||||
| 440 | } executed 58 times by 1 test: end of blockExecuted by:
| 58 | ||||||
| 441 | } executed 58 times by 1 test: end of blockExecuted by:
| 58 | ||||||
| 442 | - | |||||||
| 443 | #if QT_CONFIG(im) | - | ||||||
| 444 | void processInputMethodEvent(QInputMethodEvent *event); | - | ||||||
| 445 | #endif | - | ||||||
| 446 | void processKeyEvent(QKeyEvent* ev); | - | ||||||
| 447 | - | |||||||
| 448 | void setBlinkingCursorEnabled(bool enable); | - | ||||||
| 449 | void updateCursorBlinking(); | - | ||||||
| 450 | - | |||||||
| 451 | void updateLayout(); | - | ||||||
| 452 | void updateBaselineOffset(); | - | ||||||
| 453 | - | |||||||
| 454 | qreal getImplicitWidth() const override; | - | ||||||
| 455 | - | |||||||
| 456 | inline qreal padding() const { return extra.isAllocated() ? extra->padding : 0.0; } executed 71678 times by 5 tests: return extra.isAllocated() ? extra->padding : 0.0;Executed by:
| 71678 | ||||||
| 457 | void setTopPadding(qreal value, bool reset = false); | - | ||||||
| 458 | void setLeftPadding(qreal value, bool reset = false); | - | ||||||
| 459 | void setRightPadding(qreal value, bool reset = false); | - | ||||||
| 460 | void setBottomPadding(qreal value, bool reset = false); | - | ||||||
| 461 | - | |||||||
| 462 | bool isImplicitResizeEnabled() const; | - | ||||||
| 463 | void setImplicitResizeEnabled(bool enabled); | - | ||||||
| 464 | - | |||||||
| 465 | private: | - | ||||||
| 466 | void removeSelectedText(); | - | ||||||
| 467 | void internalSetText(const QString &txt, int pos = -1, bool edited = true); | - | ||||||
| 468 | void updateDisplayText(bool forceUpdate = false); | - | ||||||
| 469 | - | |||||||
| 470 | void internalInsert(const QString &s); | - | ||||||
| 471 | void internalDelete(bool wasBackspace = false); | - | ||||||
| 472 | void internalRemove(int pos); | - | ||||||
| 473 | - | |||||||
| 474 | inline void internalDeselect() | - | ||||||
| 475 | { | - | ||||||
| 476 | m_selDirty |= (m_selend > m_selstart); | - | ||||||
| 477 | m_selstart = m_selend = 0; | - | ||||||
| 478 | } executed 3312 times by 4 tests: end of blockExecuted by:
| 3312 | ||||||
| 479 | - | |||||||
| 480 | void internalUndo(int until = -1); | - | ||||||
| 481 | void internalRedo(); | - | ||||||
| 482 | void emitUndoRedoChanged(); | - | ||||||
| 483 | - | |||||||
| 484 | bool emitCursorPositionChanged(); | - | ||||||
| 485 | - | |||||||
| 486 | bool finishChange(int validateFromState = -1, bool update = false, bool edited = true); | - | ||||||
| 487 | - | |||||||
| 488 | void addCommand(const Command& cmd); | - | ||||||
| 489 | - | |||||||
| 490 | inline void separate() { m_separator = true; } executed 1626 times by 1 test: end of blockExecuted by:
| 1626 | ||||||
| 491 | - | |||||||
| 492 | bool separateSelection(); | - | ||||||
| 493 | void deleteStartOfWord(); | - | ||||||
| 494 | void deleteEndOfWord(); | - | ||||||
| 495 | void deleteEndOfLine(); | - | ||||||
| 496 | - | |||||||
| 497 | enum ValidatorState { | - | ||||||
| 498 | #if QT_CONFIG(validator) | - | ||||||
| 499 | InvalidInput = QValidator::Invalid, | - | ||||||
| 500 | IntermediateInput = QValidator::Intermediate, | - | ||||||
| 501 | AcceptableInput = QValidator::Acceptable | - | ||||||
| 502 | #else | - | ||||||
| 503 | InvalidInput, | - | ||||||
| 504 | IntermediateInput, | - | ||||||
| 505 | AcceptableInput | - | ||||||
| 506 | #endif | - | ||||||
| 507 | }; | - | ||||||
| 508 | - | |||||||
| 509 | // masking | - | ||||||
| 510 | void parseInputMask(const QString &maskFields); | - | ||||||
| 511 | bool isValidInput(QChar key, QChar mask) const; | - | ||||||
| 512 | ValidatorState hasAcceptableInput(const QString &text) const; | - | ||||||
| 513 | void checkIsValid(); | - | ||||||
| 514 | QString maskString(uint pos, const QString &str, bool clear = false) const; | - | ||||||
| 515 | QString clearString(uint pos, uint len) const; | - | ||||||
| 516 | QString stripString(const QString &str) const; | - | ||||||
| 517 | int findInMask(int pos, bool forward, bool findSeparator, QChar searchChar = QChar()) const; | - | ||||||
| 518 | }; | - | ||||||
| 519 | - | |||||||
| 520 | QT_END_NAMESPACE | - | ||||||
| 521 | - | |||||||
| 522 | #endif // QQUICKTEXTINPUT_P_P_H | - | ||||||
| Source code | Switch to Preprocessed file |