| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qwidgetlinecontrol.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||||||||
| 11 | int QWidgetLineControl::redoTextLayout() const | - | ||||||||||||||||||||||||||||||
| 12 | { | - | ||||||||||||||||||||||||||||||
| 13 | m_textLayout.clearLayout(); | - | ||||||||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||||||||
| 15 | m_textLayout.beginLayout(); | - | ||||||||||||||||||||||||||||||
| 16 | QTextLine l = m_textLayout.createLine(); | - | ||||||||||||||||||||||||||||||
| 17 | m_textLayout.endLayout(); | - | ||||||||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||||||||
| 19 | - | |||||||||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||||||||
| 21 | - | |||||||||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||||||||
| 24 | return qRound(l.ascent()); | - | ||||||||||||||||||||||||||||||
| 25 | } | - | ||||||||||||||||||||||||||||||
| 26 | - | |||||||||||||||||||||||||||||||
| 27 | - | |||||||||||||||||||||||||||||||
| 28 | - | |||||||||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||||||||
| 30 | - | |||||||||||||||||||||||||||||||
| 31 | - | |||||||||||||||||||||||||||||||
| 32 | - | |||||||||||||||||||||||||||||||
| 33 | void QWidgetLineControl::updateDisplayText(bool forceUpdate) | - | ||||||||||||||||||||||||||||||
| 34 | { | - | ||||||||||||||||||||||||||||||
| 35 | QString orig = m_textLayout.text(); | - | ||||||||||||||||||||||||||||||
| 36 | QString str; | - | ||||||||||||||||||||||||||||||
| 37 | if (m_echoMode == QLineEdit::NoEcho) | - | ||||||||||||||||||||||||||||||
| 38 | str = QString::fromLatin1(""); | - | ||||||||||||||||||||||||||||||
| 39 | else | - | ||||||||||||||||||||||||||||||
| 40 | str = m_text; | - | ||||||||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||||||||
| 42 | if (m_echoMode == QLineEdit::Password) { | - | ||||||||||||||||||||||||||||||
| 43 | str.fill(m_passwordCharacter); | - | ||||||||||||||||||||||||||||||
| 44 | if (m_passwordEchoTimer != 0 && m_cursor > 0 && m_cursor <= m_text.length()) { | - | ||||||||||||||||||||||||||||||
| 45 | int cursor = m_cursor - 1; | - | ||||||||||||||||||||||||||||||
| 46 | QChar uc = m_text.at(cursor); | - | ||||||||||||||||||||||||||||||
| 47 | str[cursor] = uc; | - | ||||||||||||||||||||||||||||||
| 48 | if (cursor > 0 && uc.isLowSurrogate()) { | - | ||||||||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||||||||
| 51 | uc = m_text.at(cursor - 1); | - | ||||||||||||||||||||||||||||||
| 52 | if (uc.isHighSurrogate()) | - | ||||||||||||||||||||||||||||||
| 53 | str[cursor - 1] = uc; | - | ||||||||||||||||||||||||||||||
| 54 | } | - | ||||||||||||||||||||||||||||||
| 55 | } | - | ||||||||||||||||||||||||||||||
| 56 | } else if (m_echoMode == QLineEdit::PasswordEchoOnEdit && !m_passwordEchoEditing) { | - | ||||||||||||||||||||||||||||||
| 57 | str.fill(m_passwordCharacter); | - | ||||||||||||||||||||||||||||||
| 58 | } | - | ||||||||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||||||||
| 62 | - | |||||||||||||||||||||||||||||||
| 63 | QChar* uc = str.data(); | - | ||||||||||||||||||||||||||||||
| 64 | for (int i = 0; i < (int)str.length(); ++i) { | - | ||||||||||||||||||||||||||||||
| 65 | if ((uc[i].unicode() < 0x20 && uc[i].unicode() != 0x09) | - | ||||||||||||||||||||||||||||||
| 66 | || uc[i] == QChar::LineSeparator | - | ||||||||||||||||||||||||||||||
| 67 | || uc[i] == QChar::ParagraphSeparator | - | ||||||||||||||||||||||||||||||
| 68 | || uc[i] == QChar::ObjectReplacementCharacter) | - | ||||||||||||||||||||||||||||||
| 69 | uc[i] = QChar(0x0020); | - | ||||||||||||||||||||||||||||||
| 70 | } | - | ||||||||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||||||||
| 72 | m_textLayout.setText(str); | - | ||||||||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||||||||
| 74 | QTextOption option = m_textLayout.textOption(); | - | ||||||||||||||||||||||||||||||
| 75 | option.setTextDirection(m_layoutDirection); | - | ||||||||||||||||||||||||||||||
| 76 | option.setFlags(QTextOption::IncludeTrailingSpaces); | - | ||||||||||||||||||||||||||||||
| 77 | m_textLayout.setTextOption(option); | - | ||||||||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||||||||
| 79 | m_ascent = redoTextLayout(); | - | ||||||||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||||||||
| 81 | if (str != orig || forceUpdate) | - | ||||||||||||||||||||||||||||||
| 82 | displayTextChanged(str); | - | ||||||||||||||||||||||||||||||
| 83 | } | - | ||||||||||||||||||||||||||||||
| 84 | void QWidgetLineControl::copy(QClipboard::Mode mode) const | - | ||||||||||||||||||||||||||||||
| 85 | { | - | ||||||||||||||||||||||||||||||
| 86 | QString t = selectedText(); | - | ||||||||||||||||||||||||||||||
| 87 | if (!t.isEmpty()
| 0 | ||||||||||||||||||||||||||||||
| 88 | disconnect(QApplication::clipboard(), qFlagLocation("2""selectionChanged()" "\0" __FILE__ ":" "150"), this, 0);QApplication::clipboard()->setText(t, mode); | - | ||||||||||||||||||||||||||||||
| 89 | connect(QApplication::clipboard(), qFlagLocation("2""selectionChanged()" "\0" __FILE__ ":" "152"), | 0 | ||||||||||||||||||||||||||||||
| this, qFlagLocation("1""_q_clipboardChanged()" "\0" __FILE__ ":" "153"));} never executed: end of block | ||||||||||||||||||||||||||||||||
| 90 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 91 | void QWidgetLineControl::paste(QClipboard::Mode clipboardMode) | - | ||||||||||||||||||||||||||||||
| 92 | { | - | ||||||||||||||||||||||||||||||
| 93 | QString clip = QApplication::clipboard()->text(clipboardMode); | - | ||||||||||||||||||||||||||||||
| 94 | if (!clip.isEmpty() || hasSelectedText()) { | - | ||||||||||||||||||||||||||||||
| 95 | separate(); | - | ||||||||||||||||||||||||||||||
| 96 | insert(clip); | - | ||||||||||||||||||||||||||||||
| 97 | separate(); | - | ||||||||||||||||||||||||||||||
| 98 | } | - | ||||||||||||||||||||||||||||||
| 99 | } | - | ||||||||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||||||||
| 101 | - | |||||||||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||||||||
| 105 | - | |||||||||||||||||||||||||||||||
| 106 | void QWidgetLineControl::commitPreedit() | - | ||||||||||||||||||||||||||||||
| 107 | { | - | ||||||||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||||||||
| 109 | if (!composeMode()) | - | ||||||||||||||||||||||||||||||
| 110 | return; | - | ||||||||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||||||||
| 112 | QGuiApplication::inputMethod()->commit(); | - | ||||||||||||||||||||||||||||||
| 113 | if (!composeMode()) | - | ||||||||||||||||||||||||||||||
| 114 | return; | - | ||||||||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||||||||
| 116 | m_preeditCursor = 0; | - | ||||||||||||||||||||||||||||||
| 117 | setPreeditArea(-1, QString()); | - | ||||||||||||||||||||||||||||||
| 118 | m_textLayout.clearFormats(); | - | ||||||||||||||||||||||||||||||
| 119 | updateDisplayText( true); | - | ||||||||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||||||||
| 121 | } | - | ||||||||||||||||||||||||||||||
| 122 | void QWidgetLineControl::backspace() | - | ||||||||||||||||||||||||||||||
| 123 | { | - | ||||||||||||||||||||||||||||||
| 124 | int priorState = m_undoState; | - | ||||||||||||||||||||||||||||||
| 125 | if (hasSelectedText()) { | - | ||||||||||||||||||||||||||||||
| 126 | removeSelectedText(); | - | ||||||||||||||||||||||||||||||
| 127 | } else if (m_cursor) { | - | ||||||||||||||||||||||||||||||
| 128 | --m_cursor; | - | ||||||||||||||||||||||||||||||
| 129 | if (m_maskData) | - | ||||||||||||||||||||||||||||||
| 130 | m_cursor = prevMaskBlank(m_cursor); | - | ||||||||||||||||||||||||||||||
| 131 | QChar uc = m_text.at(m_cursor); | - | ||||||||||||||||||||||||||||||
| 132 | if (m_cursor > 0 && uc.isLowSurrogate()) { | - | ||||||||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||||||||
| 135 | uc = m_text.at(m_cursor - 1); | - | ||||||||||||||||||||||||||||||
| 136 | if (uc.isHighSurrogate()) { | - | ||||||||||||||||||||||||||||||
| 137 | internalDelete(true); | - | ||||||||||||||||||||||||||||||
| 138 | --m_cursor; | - | ||||||||||||||||||||||||||||||
| 139 | } | - | ||||||||||||||||||||||||||||||
| 140 | } | - | ||||||||||||||||||||||||||||||
| 141 | internalDelete(true); | - | ||||||||||||||||||||||||||||||
| 142 | } | - | ||||||||||||||||||||||||||||||
| 143 | finishChange(priorState); | - | ||||||||||||||||||||||||||||||
| 144 | } | - | ||||||||||||||||||||||||||||||
| 145 | void QWidgetLineControl::del() | - | ||||||||||||||||||||||||||||||
| 146 | { | - | ||||||||||||||||||||||||||||||
| 147 | int priorState = m_undoState; | - | ||||||||||||||||||||||||||||||
| 148 | if (hasSelectedText()) { | - | ||||||||||||||||||||||||||||||
| 149 | removeSelectedText(); | - | ||||||||||||||||||||||||||||||
| 150 | } else { | - | ||||||||||||||||||||||||||||||
| 151 | int n = textLayout()->nextCursorPosition(m_cursor) - m_cursor; | - | ||||||||||||||||||||||||||||||
| 152 | while (n--) | - | ||||||||||||||||||||||||||||||
| 153 | internalDelete(); | - | ||||||||||||||||||||||||||||||
| 154 | } | - | ||||||||||||||||||||||||||||||
| 155 | finishChange(priorState); | - | ||||||||||||||||||||||||||||||
| 156 | } | - | ||||||||||||||||||||||||||||||
| 157 | void QWidgetLineControl::insert(const QString &newText) | - | ||||||||||||||||||||||||||||||
| 158 | { | - | ||||||||||||||||||||||||||||||
| 159 | int priorState = m_undoState; | - | ||||||||||||||||||||||||||||||
| 160 | removeSelectedText(); | - | ||||||||||||||||||||||||||||||
| 161 | internalInsert(newText); | - | ||||||||||||||||||||||||||||||
| 162 | finishChange(priorState); | - | ||||||||||||||||||||||||||||||
| 163 | } | - | ||||||||||||||||||||||||||||||
| 164 | - | |||||||||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||||||||
| 166 | - | |||||||||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||||||||
| 168 | - | |||||||||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||||||||
| 170 | void QWidgetLineControl::clear() | - | ||||||||||||||||||||||||||||||
| 171 | { | - | ||||||||||||||||||||||||||||||
| 172 | int priorState = m_undoState; | - | ||||||||||||||||||||||||||||||
| 173 | m_selstart = 0; | - | ||||||||||||||||||||||||||||||
| 174 | m_selend = m_text.length(); | - | ||||||||||||||||||||||||||||||
| 175 | removeSelectedText(); | - | ||||||||||||||||||||||||||||||
| 176 | separate(); | - | ||||||||||||||||||||||||||||||
| 177 | finishChange(priorState, false, false); | - | ||||||||||||||||||||||||||||||
| 178 | } | - | ||||||||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||||||||
| 180 | - | |||||||||||||||||||||||||||||||
| 181 | - | |||||||||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||||||||
| 183 | - | |||||||||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||||||||
| 185 | void QWidgetLineControl::undo() | - | ||||||||||||||||||||||||||||||
| 186 | { | - | ||||||||||||||||||||||||||||||
| 187 | - | |||||||||||||||||||||||||||||||
| 188 | if (m_echoMode == QLineEdit::Normal) { | - | ||||||||||||||||||||||||||||||
| 189 | internalUndo(); | - | ||||||||||||||||||||||||||||||
| 190 | finishChange(-1, true); | - | ||||||||||||||||||||||||||||||
| 191 | } else { | - | ||||||||||||||||||||||||||||||
| 192 | cancelPasswordEchoTimer(); | - | ||||||||||||||||||||||||||||||
| 193 | clear(); | - | ||||||||||||||||||||||||||||||
| 194 | } | - | ||||||||||||||||||||||||||||||
| 195 | } | - | ||||||||||||||||||||||||||||||
| 196 | void QWidgetLineControl::setSelection(int start, int length) | - | ||||||||||||||||||||||||||||||
| 197 | { | - | ||||||||||||||||||||||||||||||
| 198 | commitPreedit(); | - | ||||||||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||||||||
| 200 | if (__builtin_expect(!!(
| 0 | ||||||||||||||||||||||||||||||
| 201 | QMessageLogger(__FILE__, 313316, __PRETTY_FUNCTION__).warning("QWidgetLineControl::setSelection: Invalid start position"); | - | ||||||||||||||||||||||||||||||
| 202 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 203 | } | - | ||||||||||||||||||||||||||||||
| 204 | - | |||||||||||||||||||||||||||||||
| 205 | if (length > 0
| 0 | ||||||||||||||||||||||||||||||
| 206 | if (start == m_selstart
| 0 | ||||||||||||||||||||||||||||||
| 207 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 208 | m_selstart = start; | - | ||||||||||||||||||||||||||||||
| 209 | m_selend = qMin(start + length, (int)m_text.length()); | - | ||||||||||||||||||||||||||||||
| 210 | m_cursor = m_selend; | - | ||||||||||||||||||||||||||||||
| 211 | } never executed: else if (length < 0end of block
| 0 | ||||||||||||||||||||||||||||||
| 212 | if (start == m_selend
| 0 | ||||||||||||||||||||||||||||||
| 213 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 214 | m_selstart = qMax(start + length, 0); | - | ||||||||||||||||||||||||||||||
| 215 | m_selend = start; | - | ||||||||||||||||||||||||||||||
| 216 | m_cursor = m_selstart; | - | ||||||||||||||||||||||||||||||
| 217 | } never executed: else if (m_selstart != m_selendend of block
| 0 | ||||||||||||||||||||||||||||||
| 218 | m_selstart = 0; | - | ||||||||||||||||||||||||||||||
| 219 | m_selend = 0; | - | ||||||||||||||||||||||||||||||
| 220 | m_cursor = start; | - | ||||||||||||||||||||||||||||||
| 221 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 222 | m_cursor = start; | - | ||||||||||||||||||||||||||||||
| 223 | emitCursorPositionChanged(); | - | ||||||||||||||||||||||||||||||
| 224 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 225 | } | - | ||||||||||||||||||||||||||||||
| 226 | selectionChanged(); | - | ||||||||||||||||||||||||||||||
| 227 | emitCursorPositionChanged(); | - | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| void QWidgetLineControl::_q_clipboardChanged() | ||||||||||||||||||||||||||||||||
| {} never executed: end of block | ||||||||||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||||||||
| 230 | void QWidgetLineControl::_q_deleteSelected() | - | ||||||||||||||||||||||||||||||
| 231 | { | - | ||||||||||||||||||||||||||||||
| 232 | if (!hasSelectedText()) | - | ||||||||||||||||||||||||||||||
| 233 | return; | - | ||||||||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||||||||
| 235 | int priorState = m_undoState; | - | ||||||||||||||||||||||||||||||
| 236 | resetInputContext(); | - | ||||||||||||||||||||||||||||||
| 237 | removeSelectedText(); | - | ||||||||||||||||||||||||||||||
| 238 | separate(); | - | ||||||||||||||||||||||||||||||
| 239 | finishChange(priorState); | - | ||||||||||||||||||||||||||||||
| 240 | } | - | ||||||||||||||||||||||||||||||
| 241 | - | |||||||||||||||||||||||||||||||
| 242 | - | |||||||||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||||||||
| 244 | - | |||||||||||||||||||||||||||||||
| 245 | - | |||||||||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||||||||
| 247 | void QWidgetLineControl::init(const QString &txt) | - | ||||||||||||||||||||||||||||||
| 248 | { | - | ||||||||||||||||||||||||||||||
| 249 | m_textLayout.setCacheEnabled(true); | - | ||||||||||||||||||||||||||||||
| 250 | m_text = txt; | - | ||||||||||||||||||||||||||||||
| 251 | updateDisplayText(); | - | ||||||||||||||||||||||||||||||
| 252 | m_cursor = m_text.length(); | - | ||||||||||||||||||||||||||||||
| 253 | if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { | - | ||||||||||||||||||||||||||||||
| 254 | m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); | - | ||||||||||||||||||||||||||||||
| 255 | m_passwordMaskDelay = theme->themeHint(QPlatformTheme::PasswordMaskDelay).toInt(); | - | ||||||||||||||||||||||||||||||
| 256 | } | - | ||||||||||||||||||||||||||||||
| 257 | - | |||||||||||||||||||||||||||||||
| 258 | if (m_keyboardScheme == QPlatformTheme::KdeKeyboardScheme | - | ||||||||||||||||||||||||||||||
| 259 | || m_keyboardScheme == QPlatformTheme::GnomeKeyboardScheme | - | ||||||||||||||||||||||||||||||
| 260 | || m_keyboardScheme == QPlatformTheme::CdeKeyboardScheme) { | - | ||||||||||||||||||||||||||||||
| 261 | m_keyboardScheme = QPlatformTheme::X11KeyboardScheme; | - | ||||||||||||||||||||||||||||||
| 262 | } | - | ||||||||||||||||||||||||||||||
| 263 | } | - | ||||||||||||||||||||||||||||||
| 264 | void QWidgetLineControl::updatePasswordEchoEditing(bool editing) | - | ||||||||||||||||||||||||||||||
| 265 | { | - | ||||||||||||||||||||||||||||||
| 266 | cancelPasswordEchoTimer(); | - | ||||||||||||||||||||||||||||||
| 267 | m_passwordEchoEditing = editing; | - | ||||||||||||||||||||||||||||||
| 268 | updateDisplayText(); | - | ||||||||||||||||||||||||||||||
| 269 | } | - | ||||||||||||||||||||||||||||||
| 270 | int QWidgetLineControl::xToPos(int x, QTextLine::CursorPosition betweenOrOn) const | - | ||||||||||||||||||||||||||||||
| 271 | { | - | ||||||||||||||||||||||||||||||
| 272 | return textLayout()->lineAt(0).xToCursor(x, betweenOrOn); | - | ||||||||||||||||||||||||||||||
| 273 | } | - | ||||||||||||||||||||||||||||||
| 274 | - | |||||||||||||||||||||||||||||||
| 275 | - | |||||||||||||||||||||||||||||||
| 276 | - | |||||||||||||||||||||||||||||||
| 277 | - | |||||||||||||||||||||||||||||||
| 278 | - | |||||||||||||||||||||||||||||||
| 279 | - | |||||||||||||||||||||||||||||||
| 280 | QRect QWidgetLineControl::cursorRect()rectForPos(int pos) const | - | ||||||||||||||||||||||||||||||
| 281 | { | - | ||||||||||||||||||||||||||||||
| 282 | QTextLine l = textLayout()->lineAt(0); | - | ||||||||||||||||||||||||||||||
| 283 | int c = m_cursor;if (m_preeditCursor != -1
| 0 | ||||||||||||||||||||||||||||||
| 284 | cpos never executed: += m_preeditCursor;pos += m_preeditCursor;never executed: pos += m_preeditCursor; | 0 | ||||||||||||||||||||||||||||||
| 285 | int cix = qRound(l.cursorToX(cpos)); | - | ||||||||||||||||||||||||||||||
| 286 | int w = m_cursorWidth; | - | ||||||||||||||||||||||||||||||
| 287 | int ch = l.height() + 1; | - | ||||||||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||||||||
| 289 | return never executed: QRect(cix-5, 0, w+9, ch);return QRect(cix-5, 0, w+9, ch);never executed: return QRect(cix-5, 0, w+9, ch); | 0 | ||||||||||||||||||||||||||||||
| 290 | } | - | ||||||||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||||||||
| 294 | - | |||||||||||||||||||||||||||||||
| 295 | - | |||||||||||||||||||||||||||||||
| 296 | - | |||||||||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||||||||
| 298 | QRect QWidgetLineControl::cursorRect() const | - | ||||||||||||||||||||||||||||||
| 299 | { | - | ||||||||||||||||||||||||||||||
| 300 | return never executed: rectForPos(m_cursor);return rectForPos(m_cursor);never executed: return rectForPos(m_cursor); | 0 | ||||||||||||||||||||||||||||||
| 301 | } | - | ||||||||||||||||||||||||||||||
| 302 | - | |||||||||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||||||||
| 305 | - | |||||||||||||||||||||||||||||||
| 306 | - | |||||||||||||||||||||||||||||||
| 307 | - | |||||||||||||||||||||||||||||||
| 308 | QRect QWidgetLineControl::anchorRect() const | - | ||||||||||||||||||||||||||||||
| 309 | { | - | ||||||||||||||||||||||||||||||
| 310 | if (!hasSelectedText()
| 0 | ||||||||||||||||||||||||||||||
| 311 | return never executed: cursorRect();return cursorRect();never executed: return cursorRect(); | 0 | ||||||||||||||||||||||||||||||
| 312 | return never executed: rectForPos(m_selstart < m_selend ? m_selstart : m_selendreturn rectForPos(m_selstart < m_selend ? m_selstart : m_selend);never executed: return rectForPos(m_selstart < m_selend ? m_selstart : m_selend);never executed: );return rectForPos(m_selstart < m_selend ? m_selstart : m_selend);never executed: return rectForPos(m_selstart < m_selend ? m_selstart : m_selend); | 0 | ||||||||||||||||||||||||||||||
| 313 | } | - | ||||||||||||||||||||||||||||||
| 314 | bool QWidgetLineControl::fixup() | - | ||||||||||||||||||||||||||||||
| 315 | { | - | ||||||||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||||||||
| 317 | if (m_validator) { | - | ||||||||||||||||||||||||||||||
| 318 | QString textCopy = m_text; | - | ||||||||||||||||||||||||||||||
| 319 | int cursorCopy = m_cursor; | - | ||||||||||||||||||||||||||||||
| 320 | m_validator->fixup(textCopy); | - | ||||||||||||||||||||||||||||||
| 321 | if (m_validator->validate(textCopy, cursorCopy) == QValidator::Acceptable) { | - | ||||||||||||||||||||||||||||||
| 322 | if (textCopy != m_text || cursorCopy != m_cursor) | - | ||||||||||||||||||||||||||||||
| 323 | internalSetText(textCopy, cursorCopy, false); | - | ||||||||||||||||||||||||||||||
| 324 | return true; | - | ||||||||||||||||||||||||||||||
| 325 | } | - | ||||||||||||||||||||||||||||||
| 326 | } | - | ||||||||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||||||||
| 328 | return false; | - | ||||||||||||||||||||||||||||||
| 329 | } | - | ||||||||||||||||||||||||||||||
| 330 | - | |||||||||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||||||||
| 337 | void QWidgetLineControl::moveCursor(int pos, bool mark) | - | ||||||||||||||||||||||||||||||
| 338 | { | - | ||||||||||||||||||||||||||||||
| 339 | commitPreedit(); | - | ||||||||||||||||||||||||||||||
| 340 | - | |||||||||||||||||||||||||||||||
| 341 | if (pos != m_cursor) { | - | ||||||||||||||||||||||||||||||
| 342 | separate(); | - | ||||||||||||||||||||||||||||||
| 343 | if (m_maskData) | - | ||||||||||||||||||||||||||||||
| 344 | pos = pos > m_cursor ? nextMaskBlank(pos) : prevMaskBlank(pos); | - | ||||||||||||||||||||||||||||||
| 345 | } | - | ||||||||||||||||||||||||||||||
| 346 | if (mark) { | - | ||||||||||||||||||||||||||||||
| 347 | int anchor; | - | ||||||||||||||||||||||||||||||
| 348 | if (m_selend > m_selstart && m_cursor == m_selstart) | - | ||||||||||||||||||||||||||||||
| 349 | anchor = m_selend; | - | ||||||||||||||||||||||||||||||
| 350 | else if (m_selend > m_selstart && m_cursor == m_selend) | - | ||||||||||||||||||||||||||||||
| 351 | anchor = m_selstart; | - | ||||||||||||||||||||||||||||||
| 352 | else | - | ||||||||||||||||||||||||||||||
| 353 | anchor = m_cursor; | - | ||||||||||||||||||||||||||||||
| 354 | m_selstart = qMin(anchor, pos); | - | ||||||||||||||||||||||||||||||
| 355 | m_selend = qMax(anchor, pos); | - | ||||||||||||||||||||||||||||||
| 356 | updateDisplayText(); | - | ||||||||||||||||||||||||||||||
| 357 | } else { | - | ||||||||||||||||||||||||||||||
| 358 | internalDeselect(); | - | ||||||||||||||||||||||||||||||
| 359 | } | - | ||||||||||||||||||||||||||||||
| 360 | m_cursor = pos; | - | ||||||||||||||||||||||||||||||
| 361 | if (mark || m_selDirty) { | - | ||||||||||||||||||||||||||||||
| 362 | m_selDirty = false; | - | ||||||||||||||||||||||||||||||
| 363 | selectionChanged(); | - | ||||||||||||||||||||||||||||||
| 364 | } | - | ||||||||||||||||||||||||||||||
| 365 | emitCursorPositionChanged(); | - | ||||||||||||||||||||||||||||||
| 366 | } | - | ||||||||||||||||||||||||||||||
| 367 | - | |||||||||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||||||||
| 370 | - | |||||||||||||||||||||||||||||||
| 371 | - | |||||||||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||||||||
| 374 | void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event) | - | ||||||||||||||||||||||||||||||
| 375 | { | - | ||||||||||||||||||||||||||||||
| 376 | int priorState = -1; | - | ||||||||||||||||||||||||||||||
| 377 | bool isGettingInput = !event->commitString().isEmpty() | - | ||||||||||||||||||||||||||||||
| 378 | || event->preeditString() != preeditAreaText() | - | ||||||||||||||||||||||||||||||
| 379 | || event->replacementLength() > 0; | - | ||||||||||||||||||||||||||||||
| 380 | bool cursorPositionChanged = false; | - | ||||||||||||||||||||||||||||||
| 381 | bool selectionChange = false; | - | ||||||||||||||||||||||||||||||
| 382 | - | |||||||||||||||||||||||||||||||
| 383 | if (isGettingInput) { | - | ||||||||||||||||||||||||||||||
| 384 | - | |||||||||||||||||||||||||||||||
| 385 | priorState = m_undoState; | - | ||||||||||||||||||||||||||||||
| 386 | if (echoMode() == QLineEdit::PasswordEchoOnEdit && !passwordEchoEditing()) { | - | ||||||||||||||||||||||||||||||
| 387 | updatePasswordEchoEditing(true); | - | ||||||||||||||||||||||||||||||
| 388 | m_selstart = 0; | - | ||||||||||||||||||||||||||||||
| 389 | m_selend = m_text.length(); | - | ||||||||||||||||||||||||||||||
| 390 | } | - | ||||||||||||||||||||||||||||||
| 391 | removeSelectedText(); | - | ||||||||||||||||||||||||||||||
| 392 | } | - | ||||||||||||||||||||||||||||||
| 393 | - | |||||||||||||||||||||||||||||||
| 394 | int c = m_cursor; | - | ||||||||||||||||||||||||||||||
| 395 | if (event->replacementStart() <= 0) | - | ||||||||||||||||||||||||||||||
| 396 | c += event->commitString().length() - qMin(-event->replacementStart(), event->replacementLength()); | - | ||||||||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||||||||
| 398 | m_cursor += event->replacementStart(); | - | ||||||||||||||||||||||||||||||
| 399 | if (m_cursor < 0) | - | ||||||||||||||||||||||||||||||
| 400 | m_cursor = 0; | - | ||||||||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||||||||
| 402 | - | |||||||||||||||||||||||||||||||
| 403 | if (event->replacementLength()) { | - | ||||||||||||||||||||||||||||||
| 404 | m_selstart = m_cursor; | - | ||||||||||||||||||||||||||||||
| 405 | m_selend = m_selstart + event->replacementLength(); | - | ||||||||||||||||||||||||||||||
| 406 | removeSelectedText(); | - | ||||||||||||||||||||||||||||||
| 407 | } | - | ||||||||||||||||||||||||||||||
| 408 | if (!event->commitString().isEmpty()) { | - | ||||||||||||||||||||||||||||||
| 409 | internalInsert(event->commitString()); | - | ||||||||||||||||||||||||||||||
| 410 | cursorPositionChanged = true; | - | ||||||||||||||||||||||||||||||
| 411 | } | - | ||||||||||||||||||||||||||||||
| 412 | - | |||||||||||||||||||||||||||||||
| 413 | m_cursor = qBound(0, c, m_text.length()); | - | ||||||||||||||||||||||||||||||
| 414 | - | |||||||||||||||||||||||||||||||
| 415 | for (int i = 0; i < event->attributes().size(); ++i) { | - | ||||||||||||||||||||||||||||||
| 416 | const QInputMethodEvent::Attribute &a = event->attributes().at(i); | - | ||||||||||||||||||||||||||||||
| 417 | if (a.type == QInputMethodEvent::Selection) { | - | ||||||||||||||||||||||||||||||
| 418 | m_cursor = qBound(0, a.start + a.length, m_text.length()); | - | ||||||||||||||||||||||||||||||
| 419 | if (a.length) { | - | ||||||||||||||||||||||||||||||
| 420 | m_selstart = qMax(0, qMin(a.start, m_text.length())); | - | ||||||||||||||||||||||||||||||
| 421 | m_selend = m_cursor; | - | ||||||||||||||||||||||||||||||
| 422 | if (m_selend < m_selstart) { | - | ||||||||||||||||||||||||||||||
| 423 | qSwap(m_selstart, m_selend); | - | ||||||||||||||||||||||||||||||
| 424 | } | - | ||||||||||||||||||||||||||||||
| 425 | selectionChange = true; | - | ||||||||||||||||||||||||||||||
| 426 | } else { | - | ||||||||||||||||||||||||||||||
| 427 | if (m_selstart != m_selend) | - | ||||||||||||||||||||||||||||||
| 428 | selectionChange = true; | - | ||||||||||||||||||||||||||||||
| 429 | m_selstart = m_selend = 0; | - | ||||||||||||||||||||||||||||||
| 430 | } | - | ||||||||||||||||||||||||||||||
| 431 | cursorPositionChanged = true; | - | ||||||||||||||||||||||||||||||
| 432 | } | - | ||||||||||||||||||||||||||||||
| 433 | } | - | ||||||||||||||||||||||||||||||
| 434 | - | |||||||||||||||||||||||||||||||
| 435 | setPreeditArea(m_cursor, event->preeditString()); | - | ||||||||||||||||||||||||||||||
| 436 | - | |||||||||||||||||||||||||||||||
| 437 | const int oldPreeditCursor = m_preeditCursor; | - | ||||||||||||||||||||||||||||||
| 438 | m_preeditCursor = event->preeditString().length(); | - | ||||||||||||||||||||||||||||||
| 439 | m_hideCursor = false; | - | ||||||||||||||||||||||||||||||
| 440 | QVector<QTextLayout::FormatRange> formats; | - | ||||||||||||||||||||||||||||||
| 441 | formats.reserve(event->attributes().size()); | - | ||||||||||||||||||||||||||||||
| 442 | for (int i = 0; i < event->attributes().size(); ++i) { | - | ||||||||||||||||||||||||||||||
| 443 | const QInputMethodEvent::Attribute &a = event->attributes().at(i); | - | ||||||||||||||||||||||||||||||
| 444 | if (a.type == QInputMethodEvent::Cursor) { | - | ||||||||||||||||||||||||||||||
| 445 | m_preeditCursor = a.start; | - | ||||||||||||||||||||||||||||||
| 446 | m_hideCursor = !a.length; | - | ||||||||||||||||||||||||||||||
| 447 | } else if (a.type == QInputMethodEvent::TextFormat) { | - | ||||||||||||||||||||||||||||||
| 448 | QTextCharFormat f = qvariant_cast<QTextFormat>(a.value).toCharFormat(); | - | ||||||||||||||||||||||||||||||
| 449 | if (f.isValid()) { | - | ||||||||||||||||||||||||||||||
| 450 | QTextLayout::FormatRange o; | - | ||||||||||||||||||||||||||||||
| 451 | o.start = a.start + m_cursor; | - | ||||||||||||||||||||||||||||||
| 452 | o.length = a.length; | - | ||||||||||||||||||||||||||||||
| 453 | o.format = f; | - | ||||||||||||||||||||||||||||||
| 454 | formats.append(o); | - | ||||||||||||||||||||||||||||||
| 455 | } | - | ||||||||||||||||||||||||||||||
| 456 | } | - | ||||||||||||||||||||||||||||||
| 457 | } | - | ||||||||||||||||||||||||||||||
| 458 | m_textLayout.setFormats(formats); | - | ||||||||||||||||||||||||||||||
| 459 | updateDisplayText( true); | - | ||||||||||||||||||||||||||||||
| 460 | if (cursorPositionChanged) | - | ||||||||||||||||||||||||||||||
| 461 | emitCursorPositionChanged(); | - | ||||||||||||||||||||||||||||||
| 462 | else if (m_preeditCursor != oldPreeditCursor) | - | ||||||||||||||||||||||||||||||
| 463 | updateMicroFocus(); | - | ||||||||||||||||||||||||||||||
| 464 | - | |||||||||||||||||||||||||||||||
| 465 | if (isGettingInput) | - | ||||||||||||||||||||||||||||||
| 466 | finishChange(priorState); | - | ||||||||||||||||||||||||||||||
| 467 | - | |||||||||||||||||||||||||||||||
| 468 | if (selectionChange) | - | ||||||||||||||||||||||||||||||
| 469 | selectionChanged(); | - | ||||||||||||||||||||||||||||||
| 470 | } | - | ||||||||||||||||||||||||||||||
| 471 | void QWidgetLineControl::draw(QPainter *painter, const QPoint &offset, const QRect &clip, int flags) | - | ||||||||||||||||||||||||||||||
| 472 | { | - | ||||||||||||||||||||||||||||||
| 473 | QVector<QTextLayout::FormatRange> selections; | - | ||||||||||||||||||||||||||||||
| 474 | if (flags & DrawSelections
| 0 | ||||||||||||||||||||||||||||||
| 475 | QTextLayout::FormatRange o; | - | ||||||||||||||||||||||||||||||
| 476 | if (m_selstart < m_selend
| 0 | ||||||||||||||||||||||||||||||
| 477 | o.start = m_selstart; | - | ||||||||||||||||||||||||||||||
| 478 | o.length = m_selend - m_selstart; | - | ||||||||||||||||||||||||||||||
| 479 | o.format.setBackground(m_palette.brush(QPalette::Highlight)); | - | ||||||||||||||||||||||||||||||
| 480 | o.format.setForeground(m_palette.brush(QPalette::HighlightedText)); | - | ||||||||||||||||||||||||||||||
| 481 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 482 | - | |||||||||||||||||||||||||||||||
| 483 | if (!m_blinkPeriod ||(m_blinkStatus
| 0 | ||||||||||||||||||||||||||||||
| 484 | o.start = m_cursor; | - | ||||||||||||||||||||||||||||||
| 485 | o.length = 1; | - | ||||||||||||||||||||||||||||||
| 486 | o.format.setBackground(m_palette.brush(QPalette::Text)); | - | ||||||||||||||||||||||||||||||
| 487 | o.format.setForeground(m_palette.brush(QPalette::Window)); | - | ||||||||||||||||||||||||||||||
| 488 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 489 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 490 | selections.append(o); | - | ||||||||||||||||||||||||||||||
| 491 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 492 | - | |||||||||||||||||||||||||||||||
| 493 | if (flags & DrawText
| 0 | ||||||||||||||||||||||||||||||
| 494 | textLayout()->draw(painter, offset, selections, clip); never executed: textLayout()->draw(painter, offset, selections, clip); | 0 | ||||||||||||||||||||||||||||||
| 495 | - | |||||||||||||||||||||||||||||||
| 496 | if (flags & DrawCursor
| 0 | ||||||||||||||||||||||||||||||
| 497 | int cursor = m_cursor; | - | ||||||||||||||||||||||||||||||
| 498 | if (m_preeditCursor != -1
| 0 | ||||||||||||||||||||||||||||||
| 499 | cursor += m_preeditCursor; never executed: cursor += m_preeditCursor; | 0 | ||||||||||||||||||||||||||||||
| 500 | if (!m_hideCursor
| 0 | ||||||||||||||||||||||||||||||
| 501 | textLayout()->drawCursor(painter, offset, cursor, m_cursorWidth); never executed: textLayout()->drawCursor(painter, offset, cursor, m_cursorWidth); | 0 | ||||||||||||||||||||||||||||||
| 502 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 503 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 504 | void QWidgetLineControl::selectWordAtPos(int cursor) | - | ||||||||||||||||||||||||||||||
| 505 | { | - | ||||||||||||||||||||||||||||||
| 506 | int next = cursor + 1; | - | ||||||||||||||||||||||||||||||
| 507 | if(next > end()) | - | ||||||||||||||||||||||||||||||
| 508 | --next; | - | ||||||||||||||||||||||||||||||
| 509 | int c = textLayout()->previousCursorPosition(next, QTextLayout::SkipWords); | - | ||||||||||||||||||||||||||||||
| 510 | moveCursor(c, false); | - | ||||||||||||||||||||||||||||||
| 511 | - | |||||||||||||||||||||||||||||||
| 512 | int end = textLayout()->nextCursorPosition(c, QTextLayout::SkipWords); | - | ||||||||||||||||||||||||||||||
| 513 | while (end > cursor && m_text[end-1].isSpace()) | - | ||||||||||||||||||||||||||||||
| 514 | --end; | - | ||||||||||||||||||||||||||||||
| 515 | moveCursor(end, true); | - | ||||||||||||||||||||||||||||||
| 516 | } | - | ||||||||||||||||||||||||||||||
| 517 | bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool edited) | - | ||||||||||||||||||||||||||||||
| 518 | { | - | ||||||||||||||||||||||||||||||
| 519 | (void)update; | - | ||||||||||||||||||||||||||||||
| 520 | - | |||||||||||||||||||||||||||||||
| 521 | if (m_textDirty) { | - | ||||||||||||||||||||||||||||||
| 522 | - | |||||||||||||||||||||||||||||||
| 523 | bool wasValidInput = m_validInput; | - | ||||||||||||||||||||||||||||||
| 524 | m_validInput = true; | - | ||||||||||||||||||||||||||||||
| 525 | - | |||||||||||||||||||||||||||||||
| 526 | if (m_validator) { | - | ||||||||||||||||||||||||||||||
| 527 | QString textCopy = m_text; | - | ||||||||||||||||||||||||||||||
| 528 | int cursorCopy = m_cursor; | - | ||||||||||||||||||||||||||||||
| 529 | m_validInput = (m_validator->validate(textCopy, cursorCopy) != QValidator::Invalid); | - | ||||||||||||||||||||||||||||||
| 530 | if (m_validInput) { | - | ||||||||||||||||||||||||||||||
| 531 | if (m_text != textCopy) { | - | ||||||||||||||||||||||||||||||
| 532 | internalSetText(textCopy, cursorCopy, false); | - | ||||||||||||||||||||||||||||||
| 533 | return true; | - | ||||||||||||||||||||||||||||||
| 534 | } | - | ||||||||||||||||||||||||||||||
| 535 | m_cursor = cursorCopy; | - | ||||||||||||||||||||||||||||||
| 536 | } | - | ||||||||||||||||||||||||||||||
| 537 | } | - | ||||||||||||||||||||||||||||||
| 538 | - | |||||||||||||||||||||||||||||||
| 539 | if (validateFromState >= 0 && wasValidInput && !m_validInput) { | - | ||||||||||||||||||||||||||||||
| 540 | if (m_transactions.count()) | - | ||||||||||||||||||||||||||||||
| 541 | return false; | - | ||||||||||||||||||||||||||||||
| 542 | internalUndo(validateFromState); | - | ||||||||||||||||||||||||||||||
| 543 | m_history.erase(m_history.begin() + m_undoState, m_history.end()); | - | ||||||||||||||||||||||||||||||
| 544 | if (m_modifiedState > m_undoState) | - | ||||||||||||||||||||||||||||||
| 545 | m_modifiedState = -1; | - | ||||||||||||||||||||||||||||||
| 546 | m_validInput = true; | - | ||||||||||||||||||||||||||||||
| 547 | m_textDirty = false; | - | ||||||||||||||||||||||||||||||
| 548 | } | - | ||||||||||||||||||||||||||||||
| 549 | updateDisplayText(); | - | ||||||||||||||||||||||||||||||
| 550 | - | |||||||||||||||||||||||||||||||
| 551 | if (m_textDirty) { | - | ||||||||||||||||||||||||||||||
| 552 | m_textDirty = false; | - | ||||||||||||||||||||||||||||||
| 553 | QString actualText = text(); | - | ||||||||||||||||||||||||||||||
| 554 | if (edited) | - | ||||||||||||||||||||||||||||||
| 555 | textEdited(actualText); | - | ||||||||||||||||||||||||||||||
| 556 | textChanged(actualText); | - | ||||||||||||||||||||||||||||||
| 557 | } | - | ||||||||||||||||||||||||||||||
| 558 | } | - | ||||||||||||||||||||||||||||||
| 559 | if (m_selDirty) { | - | ||||||||||||||||||||||||||||||
| 560 | m_selDirty = false; | - | ||||||||||||||||||||||||||||||
| 561 | selectionChanged(); | - | ||||||||||||||||||||||||||||||
| 562 | } | - | ||||||||||||||||||||||||||||||
| 563 | if (m_cursor == m_lastCursorPos) | - | ||||||||||||||||||||||||||||||
| 564 | updateMicroFocus(); | - | ||||||||||||||||||||||||||||||
| 565 | emitCursorPositionChanged(); | - | ||||||||||||||||||||||||||||||
| 566 | return true; | - | ||||||||||||||||||||||||||||||
| 567 | } | - | ||||||||||||||||||||||||||||||
| 568 | - | |||||||||||||||||||||||||||||||
| 569 | - | |||||||||||||||||||||||||||||||
| 570 | - | |||||||||||||||||||||||||||||||
| 571 | - | |||||||||||||||||||||||||||||||
| 572 | - | |||||||||||||||||||||||||||||||
| 573 | - | |||||||||||||||||||||||||||||||
| 574 | void QWidgetLineControl::internalSetText(const QString &txt, int pos, bool edited) | - | ||||||||||||||||||||||||||||||
| 575 | { | - | ||||||||||||||||||||||||||||||
| 576 | cancelPasswordEchoTimer(); | - | ||||||||||||||||||||||||||||||
| 577 | internalDeselect(); | - | ||||||||||||||||||||||||||||||
| 578 | resetInputContext(); | - | ||||||||||||||||||||||||||||||
| 579 | QString oldText = m_text; | - | ||||||||||||||||||||||||||||||
| 580 | if (m_maskData) { | - | ||||||||||||||||||||||||||||||
| 581 | m_text = maskString(0, txt, true); | - | ||||||||||||||||||||||||||||||
| 582 | m_text += clearString(m_text.length(), m_maxLength - m_text.length()); | - | ||||||||||||||||||||||||||||||
| 583 | } else { | - | ||||||||||||||||||||||||||||||
| 584 | m_text = txt.isEmpty() ? txt : txt.left(m_maxLength); | - | ||||||||||||||||||||||||||||||
| 585 | } | - | ||||||||||||||||||||||||||||||
| 586 | m_history.clear(); | - | ||||||||||||||||||||||||||||||
| 587 | m_modifiedState = m_undoState = 0; | - | ||||||||||||||||||||||||||||||
| 588 | m_cursor = (pos < 0 || pos > m_text.length()) ? m_text.length() : pos; | - | ||||||||||||||||||||||||||||||
| 589 | m_textDirty = (oldText != m_text); | - | ||||||||||||||||||||||||||||||
| 590 | const bool changed = finishChange(-1, true, edited); | - | ||||||||||||||||||||||||||||||
| 591 | - | |||||||||||||||||||||||||||||||
| 592 | - | |||||||||||||||||||||||||||||||
| 593 | if (changed) { | - | ||||||||||||||||||||||||||||||
| 594 | if (oldText.isEmpty()) { | - | ||||||||||||||||||||||||||||||
| 595 | QAccessibleTextInsertEvent event(accessibleObject(), 0, txt); | - | ||||||||||||||||||||||||||||||
| 596 | event.setCursorPosition(m_cursor); | - | ||||||||||||||||||||||||||||||
| 597 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||
| 598 | } else if (txt.isEmpty()) { | - | ||||||||||||||||||||||||||||||
| 599 | QAccessibleTextRemoveEvent event(accessibleObject(), 0, oldText); | - | ||||||||||||||||||||||||||||||
| 600 | event.setCursorPosition(m_cursor); | - | ||||||||||||||||||||||||||||||
| 601 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||
| 602 | } else { | - | ||||||||||||||||||||||||||||||
| 603 | QAccessibleTextUpdateEvent event(accessibleObject(), 0, oldText, txt); | - | ||||||||||||||||||||||||||||||
| 604 | event.setCursorPosition(m_cursor); | - | ||||||||||||||||||||||||||||||
| 605 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||
| 606 | } | - | ||||||||||||||||||||||||||||||
| 607 | } | - | ||||||||||||||||||||||||||||||
| 608 | - | |||||||||||||||||||||||||||||||
| 609 | - | |||||||||||||||||||||||||||||||
| 610 | - | |||||||||||||||||||||||||||||||
| 611 | } | - | ||||||||||||||||||||||||||||||
| 612 | void QWidgetLineControl::addCommand(const Command &cmd) | - | ||||||||||||||||||||||||||||||
| 613 | { | - | ||||||||||||||||||||||||||||||
| 614 | m_history.erase(m_history.begin() + m_undoState, m_history.end()); | - | ||||||||||||||||||||||||||||||
| 615 | - | |||||||||||||||||||||||||||||||
| 616 | if (m_separator && m_undoState && m_history[m_undoState - 1].type != Separator) | - | ||||||||||||||||||||||||||||||
| 617 | m_history.push_back(Command(Separator, m_cursor, 0, m_selstart, m_selend)); | - | ||||||||||||||||||||||||||||||
| 618 | - | |||||||||||||||||||||||||||||||
| 619 | m_separator = false; | - | ||||||||||||||||||||||||||||||
| 620 | m_history.push_back(cmd); | - | ||||||||||||||||||||||||||||||
| 621 | m_undoState = int(m_history.size()); | - | ||||||||||||||||||||||||||||||
| 622 | } | - | ||||||||||||||||||||||||||||||
| 623 | void QWidgetLineControl::internalInsert(const QString &s) | - | ||||||||||||||||||||||||||||||
| 624 | { | - | ||||||||||||||||||||||||||||||
| 625 | if (m_echoMode == QLineEdit::Password) { | - | ||||||||||||||||||||||||||||||
| 626 | if (m_passwordEchoTimer != 0) | - | ||||||||||||||||||||||||||||||
| 627 | killTimer(m_passwordEchoTimer); | - | ||||||||||||||||||||||||||||||
| 628 | int delay = m_passwordMaskDelay; | - | ||||||||||||||||||||||||||||||
| 629 | - | |||||||||||||||||||||||||||||||
| 630 | if (m_passwordMaskDelayOverride >= 0) | - | ||||||||||||||||||||||||||||||
| 631 | delay = m_passwordMaskDelayOverride; | - | ||||||||||||||||||||||||||||||
| 632 | - | |||||||||||||||||||||||||||||||
| 633 | - | |||||||||||||||||||||||||||||||
| 634 | if (delay > 0) | - | ||||||||||||||||||||||||||||||
| 635 | m_passwordEchoTimer = startTimer(delay); | - | ||||||||||||||||||||||||||||||
| 636 | } | - | ||||||||||||||||||||||||||||||
| 637 | if (hasSelectedText()) | - | ||||||||||||||||||||||||||||||
| 638 | addCommand(Command(SetSelection, m_cursor, 0, m_selstart, m_selend)); | - | ||||||||||||||||||||||||||||||
| 639 | if (m_maskData) { | - | ||||||||||||||||||||||||||||||
| 640 | QString ms = maskString(m_cursor, s); | - | ||||||||||||||||||||||||||||||
| 641 | - | |||||||||||||||||||||||||||||||
| 642 | QAccessibleTextInsertEvent insertEvent(accessibleObject(), m_cursor, ms); | - | ||||||||||||||||||||||||||||||
| 643 | QAccessible::updateAccessibility(&insertEvent); | - | ||||||||||||||||||||||||||||||
| 644 | - | |||||||||||||||||||||||||||||||
| 645 | for (int i = 0; i < (int) ms.length(); ++i) { | - | ||||||||||||||||||||||||||||||
| 646 | addCommand (Command(DeleteSelection, m_cursor + i, m_text.at(m_cursor + i), -1, -1)); | - | ||||||||||||||||||||||||||||||
| 647 | addCommand(Command(Insert, m_cursor + i, ms.at(i), -1, -1)); | - | ||||||||||||||||||||||||||||||
| 648 | } | - | ||||||||||||||||||||||||||||||
| 649 | m_text.replace(m_cursor, ms.length(), ms); | - | ||||||||||||||||||||||||||||||
| 650 | m_cursor += ms.length(); | - | ||||||||||||||||||||||||||||||
| 651 | m_cursor = nextMaskBlank(m_cursor); | - | ||||||||||||||||||||||||||||||
| 652 | m_textDirty = true; | - | ||||||||||||||||||||||||||||||
| 653 | - | |||||||||||||||||||||||||||||||
| 654 | QAccessibleTextCursorEvent event(accessibleObject(), m_cursor); | - | ||||||||||||||||||||||||||||||
| 655 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||
| 656 | - | |||||||||||||||||||||||||||||||
| 657 | } else { | - | ||||||||||||||||||||||||||||||
| 658 | int remaining = m_maxLength - m_text.length(); | - | ||||||||||||||||||||||||||||||
| 659 | if (remaining != 0) { | - | ||||||||||||||||||||||||||||||
| 660 | - | |||||||||||||||||||||||||||||||
| 661 | QAccessibleTextInsertEvent insertEvent(accessibleObject(), m_cursor, s); | - | ||||||||||||||||||||||||||||||
| 662 | QAccessible::updateAccessibility(&insertEvent); | - | ||||||||||||||||||||||||||||||
| 663 | - | |||||||||||||||||||||||||||||||
| 664 | m_text.insert(m_cursor, s.left(remaining)); | - | ||||||||||||||||||||||||||||||
| 665 | for (int i = 0; i < (int) s.left(remaining).length(); ++i) | - | ||||||||||||||||||||||||||||||
| 666 | addCommand(Command(Insert, m_cursor++, s.at(i), -1, -1)); | - | ||||||||||||||||||||||||||||||
| 667 | m_textDirty = true; | - | ||||||||||||||||||||||||||||||
| 668 | } | - | ||||||||||||||||||||||||||||||
| 669 | } | - | ||||||||||||||||||||||||||||||
| 670 | } | - | ||||||||||||||||||||||||||||||
| 671 | void QWidgetLineControl::internalDelete(bool wasBackspace) | - | ||||||||||||||||||||||||||||||
| 672 | { | - | ||||||||||||||||||||||||||||||
| 673 | if (m_cursor < (int) m_text.length()) { | - | ||||||||||||||||||||||||||||||
| 674 | cancelPasswordEchoTimer(); | - | ||||||||||||||||||||||||||||||
| 675 | if (hasSelectedText()) | - | ||||||||||||||||||||||||||||||
| 676 | addCommand(Command(SetSelection, m_cursor, 0, m_selstart, m_selend)); | - | ||||||||||||||||||||||||||||||
| 677 | addCommand(Command((CommandType)((m_maskData ? 2 : 0) + (wasBackspace ? Remove : Delete)), | - | ||||||||||||||||||||||||||||||
| 678 | m_cursor, m_text.at(m_cursor), -1, -1)); | - | ||||||||||||||||||||||||||||||
| 679 | - | |||||||||||||||||||||||||||||||
| 680 | QAccessibleTextRemoveEvent event(accessibleObject(), m_cursor, m_text.at(m_cursor)); | - | ||||||||||||||||||||||||||||||
| 681 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||
| 682 | - | |||||||||||||||||||||||||||||||
| 683 | if (m_maskData) { | - | ||||||||||||||||||||||||||||||
| 684 | m_text.replace(m_cursor, 1, clearString(m_cursor, 1)); | - | ||||||||||||||||||||||||||||||
| 685 | addCommand(Command(Insert, m_cursor, m_text.at(m_cursor), -1, -1)); | - | ||||||||||||||||||||||||||||||
| 686 | } else { | - | ||||||||||||||||||||||||||||||
| 687 | m_text.remove(m_cursor, 1); | - | ||||||||||||||||||||||||||||||
| 688 | } | - | ||||||||||||||||||||||||||||||
| 689 | m_textDirty = true; | - | ||||||||||||||||||||||||||||||
| 690 | } | - | ||||||||||||||||||||||||||||||
| 691 | } | - | ||||||||||||||||||||||||||||||
| 692 | void QWidgetLineControl::removeSelectedText() | - | ||||||||||||||||||||||||||||||
| 693 | { | - | ||||||||||||||||||||||||||||||
| 694 | if (m_selstart < m_selend && m_selend <= (int) m_text.length()) { | - | ||||||||||||||||||||||||||||||
| 695 | cancelPasswordEchoTimer(); | - | ||||||||||||||||||||||||||||||
| 696 | separate(); | - | ||||||||||||||||||||||||||||||
| 697 | int i ; | - | ||||||||||||||||||||||||||||||
| 698 | addCommand(Command(SetSelection, m_cursor, 0, m_selstart, m_selend)); | - | ||||||||||||||||||||||||||||||
| 699 | if (m_selstart <= m_cursor && m_cursor < m_selend) { | - | ||||||||||||||||||||||||||||||
| 700 | - | |||||||||||||||||||||||||||||||
| 701 | - | |||||||||||||||||||||||||||||||
| 702 | for (i = m_cursor; i >= m_selstart; --i) | - | ||||||||||||||||||||||||||||||
| 703 | addCommand (Command(DeleteSelection, i, m_text.at(i), -1, 1)); | - | ||||||||||||||||||||||||||||||
| 704 | for (i = m_selend - 1; i > m_cursor; --i) | - | ||||||||||||||||||||||||||||||
| 705 | addCommand (Command(DeleteSelection, i - m_cursor + m_selstart - 1, m_text.at(i), -1, -1)); | - | ||||||||||||||||||||||||||||||
| 706 | } else { | - | ||||||||||||||||||||||||||||||
| 707 | for (i = m_selend-1; i >= m_selstart; --i) | - | ||||||||||||||||||||||||||||||
| 708 | addCommand (Command(RemoveSelection, i, m_text.at(i), -1, -1)); | - | ||||||||||||||||||||||||||||||
| 709 | } | - | ||||||||||||||||||||||||||||||
| 710 | - | |||||||||||||||||||||||||||||||
| 711 | QAccessibleTextRemoveEvent event(accessibleObject(), m_selstart, m_text.mid(m_selstart, m_selend - m_selstart)); | - | ||||||||||||||||||||||||||||||
| 712 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||
| 713 | - | |||||||||||||||||||||||||||||||
| 714 | if (m_maskData) { | - | ||||||||||||||||||||||||||||||
| 715 | m_text.replace(m_selstart, m_selend - m_selstart, clearString(m_selstart, m_selend - m_selstart)); | - | ||||||||||||||||||||||||||||||
| 716 | for (int i = 0; i < m_selend - m_selstart; ++i) | - | ||||||||||||||||||||||||||||||
| 717 | addCommand(Command(Insert, m_selstart + i, m_text.at(m_selstart + i), -1, -1)); | - | ||||||||||||||||||||||||||||||
| 718 | } else { | - | ||||||||||||||||||||||||||||||
| 719 | m_text.remove(m_selstart, m_selend - m_selstart); | - | ||||||||||||||||||||||||||||||
| 720 | } | - | ||||||||||||||||||||||||||||||
| 721 | if (m_cursor > m_selstart) | - | ||||||||||||||||||||||||||||||
| 722 | m_cursor -= qMin(m_cursor, m_selend) - m_selstart; | - | ||||||||||||||||||||||||||||||
| 723 | internalDeselect(); | - | ||||||||||||||||||||||||||||||
| 724 | m_textDirty = true; | - | ||||||||||||||||||||||||||||||
| 725 | } | - | ||||||||||||||||||||||||||||||
| 726 | } | - | ||||||||||||||||||||||||||||||
| 727 | - | |||||||||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||||||||
| 729 | - | |||||||||||||||||||||||||||||||
| 730 | - | |||||||||||||||||||||||||||||||
| 731 | - | |||||||||||||||||||||||||||||||
| 732 | - | |||||||||||||||||||||||||||||||
| 733 | - | |||||||||||||||||||||||||||||||
| 734 | void QWidgetLineControl::parseInputMask(const QString &maskFields) | - | ||||||||||||||||||||||||||||||
| 735 | { | - | ||||||||||||||||||||||||||||||
| 736 | int delimiter = maskFields.indexOf(QLatin1Char(';')); | - | ||||||||||||||||||||||||||||||
| 737 | if (maskFields.isEmpty() || delimiter == 0) { | - | ||||||||||||||||||||||||||||||
| 738 | if (m_maskData) { | - | ||||||||||||||||||||||||||||||
| 739 | delete [] m_maskData; | - | ||||||||||||||||||||||||||||||
| 740 | m_maskData = 0; | - | ||||||||||||||||||||||||||||||
| 741 | m_maxLength = 32767; | - | ||||||||||||||||||||||||||||||
| 742 | internalSetText(QString(), -1, false); | - | ||||||||||||||||||||||||||||||
| 743 | } | - | ||||||||||||||||||||||||||||||
| 744 | return; | - | ||||||||||||||||||||||||||||||
| 745 | } | - | ||||||||||||||||||||||||||||||
| 746 | - | |||||||||||||||||||||||||||||||
| 747 | if (delimiter == -1) { | - | ||||||||||||||||||||||||||||||
| 748 | m_blank = QLatin1Char(' '); | - | ||||||||||||||||||||||||||||||
| 749 | m_inputMask = maskFields; | - | ||||||||||||||||||||||||||||||
| 750 | } else { | - | ||||||||||||||||||||||||||||||
| 751 | m_inputMask = maskFields.left(delimiter); | - | ||||||||||||||||||||||||||||||
| 752 | m_blank = (delimiter + 1 < maskFields.length()) ? maskFields[delimiter + 1] : QLatin1Char(' '); | - | ||||||||||||||||||||||||||||||
| 753 | } | - | ||||||||||||||||||||||||||||||
| 754 | - | |||||||||||||||||||||||||||||||
| 755 | - | |||||||||||||||||||||||||||||||
| 756 | m_maxLength = 0; | - | ||||||||||||||||||||||||||||||
| 757 | QChar c = 0; | - | ||||||||||||||||||||||||||||||
| 758 | for (int i=0; i<m_inputMask.length(); i++) { | - | ||||||||||||||||||||||||||||||
| 759 | c = m_inputMask.at(i); | - | ||||||||||||||||||||||||||||||
| 760 | if (i > 0 && m_inputMask.at(i-1) == QLatin1Char('\\')) { | - | ||||||||||||||||||||||||||||||
| 761 | m_maxLength++; | - | ||||||||||||||||||||||||||||||
| 762 | continue; | - | ||||||||||||||||||||||||||||||
| 763 | } | - | ||||||||||||||||||||||||||||||
| 764 | if (c != QLatin1Char('\\') && c != QLatin1Char('!') && | - | ||||||||||||||||||||||||||||||
| 765 | c != QLatin1Char('<') && c != QLatin1Char('>') && | - | ||||||||||||||||||||||||||||||
| 766 | c != QLatin1Char('{') && c != QLatin1Char('}') && | - | ||||||||||||||||||||||||||||||
| 767 | c != QLatin1Char('[') && c != QLatin1Char(']')) | - | ||||||||||||||||||||||||||||||
| 768 | m_maxLength++; | - | ||||||||||||||||||||||||||||||
| 769 | } | - | ||||||||||||||||||||||||||||||
| 770 | - | |||||||||||||||||||||||||||||||
| 771 | delete [] m_maskData; | - | ||||||||||||||||||||||||||||||
| 772 | m_maskData = new MaskInputData[m_maxLength]; | - | ||||||||||||||||||||||||||||||
| 773 | - | |||||||||||||||||||||||||||||||
| 774 | MaskInputData::Casemode m = MaskInputData::NoCaseMode; | - | ||||||||||||||||||||||||||||||
| 775 | c = 0; | - | ||||||||||||||||||||||||||||||
| 776 | bool s; | - | ||||||||||||||||||||||||||||||
| 777 | bool escape = false; | - | ||||||||||||||||||||||||||||||
| 778 | int index = 0; | - | ||||||||||||||||||||||||||||||
| 779 | for (int i = 0; i < m_inputMask.length(); i++) { | - | ||||||||||||||||||||||||||||||
| 780 | c = m_inputMask.at(i); | - | ||||||||||||||||||||||||||||||
| 781 | if (escape) { | - | ||||||||||||||||||||||||||||||
| 782 | s = true; | - | ||||||||||||||||||||||||||||||
| 783 | m_maskData[index].maskChar = c; | - | ||||||||||||||||||||||||||||||
| 784 | m_maskData[index].separator = s; | - | ||||||||||||||||||||||||||||||
| 785 | m_maskData[index].caseMode = m; | - | ||||||||||||||||||||||||||||||
| 786 | index++; | - | ||||||||||||||||||||||||||||||
| 787 | escape = false; | - | ||||||||||||||||||||||||||||||
| 788 | } else if (c == QLatin1Char('<')) { | - | ||||||||||||||||||||||||||||||
| 789 | m = MaskInputData::Lower; | - | ||||||||||||||||||||||||||||||
| 790 | } else if (c == QLatin1Char('>')) { | - | ||||||||||||||||||||||||||||||
| 791 | m = MaskInputData::Upper; | - | ||||||||||||||||||||||||||||||
| 792 | } else if (c == QLatin1Char('!')) { | - | ||||||||||||||||||||||||||||||
| 793 | m = MaskInputData::NoCaseMode; | - | ||||||||||||||||||||||||||||||
| 794 | } else if (c != QLatin1Char('{') && c != QLatin1Char('}') && c != QLatin1Char('[') && c != QLatin1Char(']')) { | - | ||||||||||||||||||||||||||||||
| 795 | switch (c.unicode()) { | - | ||||||||||||||||||||||||||||||
| 796 | case 'A': | - | ||||||||||||||||||||||||||||||
| 797 | case 'a': | - | ||||||||||||||||||||||||||||||
| 798 | case 'N': | - | ||||||||||||||||||||||||||||||
| 799 | case 'n': | - | ||||||||||||||||||||||||||||||
| 800 | case 'X': | - | ||||||||||||||||||||||||||||||
| 801 | case 'x': | - | ||||||||||||||||||||||||||||||
| 802 | case '9': | - | ||||||||||||||||||||||||||||||
| 803 | case '0': | - | ||||||||||||||||||||||||||||||
| 804 | case 'D': | - | ||||||||||||||||||||||||||||||
| 805 | case 'd': | - | ||||||||||||||||||||||||||||||
| 806 | case '#': | - | ||||||||||||||||||||||||||||||
| 807 | case 'H': | - | ||||||||||||||||||||||||||||||
| 808 | case 'h': | - | ||||||||||||||||||||||||||||||
| 809 | case 'B': | - | ||||||||||||||||||||||||||||||
| 810 | case 'b': | - | ||||||||||||||||||||||||||||||
| 811 | s = false; | - | ||||||||||||||||||||||||||||||
| 812 | break; | - | ||||||||||||||||||||||||||||||
| 813 | case '\\': | - | ||||||||||||||||||||||||||||||
| 814 | escape = true; | - | ||||||||||||||||||||||||||||||
| 815 | default: | - | ||||||||||||||||||||||||||||||
| 816 | s = true; | - | ||||||||||||||||||||||||||||||
| 817 | break; | - | ||||||||||||||||||||||||||||||
| 818 | } | - | ||||||||||||||||||||||||||||||
| 819 | - | |||||||||||||||||||||||||||||||
| 820 | if (!escape) { | - | ||||||||||||||||||||||||||||||
| 821 | m_maskData[index].maskChar = c; | - | ||||||||||||||||||||||||||||||
| 822 | m_maskData[index].separator = s; | - | ||||||||||||||||||||||||||||||
| 823 | m_maskData[index].caseMode = m; | - | ||||||||||||||||||||||||||||||
| 824 | index++; | - | ||||||||||||||||||||||||||||||
| 825 | } | - | ||||||||||||||||||||||||||||||
| 826 | } | - | ||||||||||||||||||||||||||||||
| 827 | } | - | ||||||||||||||||||||||||||||||
| 828 | internalSetText(m_text, -1, false); | - | ||||||||||||||||||||||||||||||
| 829 | } | - | ||||||||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||||||||
| 831 | - | |||||||||||||||||||||||||||||||
| 832 | - | |||||||||||||||||||||||||||||||
| 833 | - | |||||||||||||||||||||||||||||||
| 834 | - | |||||||||||||||||||||||||||||||
| 835 | - | |||||||||||||||||||||||||||||||
| 836 | - | |||||||||||||||||||||||||||||||
| 837 | bool QWidgetLineControl::isValidInput(QChar key, QChar mask) const | - | ||||||||||||||||||||||||||||||
| 838 | { | - | ||||||||||||||||||||||||||||||
| 839 | switch (mask.unicode()) { | - | ||||||||||||||||||||||||||||||
| 840 | case 'A': | - | ||||||||||||||||||||||||||||||
| 841 | if (key.isLetter()) | - | ||||||||||||||||||||||||||||||
| 842 | return true; | - | ||||||||||||||||||||||||||||||
| 843 | break; | - | ||||||||||||||||||||||||||||||
| 844 | case 'a': | - | ||||||||||||||||||||||||||||||
| 845 | if (key.isLetter() || key == m_blank) | - | ||||||||||||||||||||||||||||||
| 846 | return true; | - | ||||||||||||||||||||||||||||||
| 847 | break; | - | ||||||||||||||||||||||||||||||
| 848 | case 'N': | - | ||||||||||||||||||||||||||||||
| 849 | if (key.isLetterOrNumber()) | - | ||||||||||||||||||||||||||||||
| 850 | return true; | - | ||||||||||||||||||||||||||||||
| 851 | break; | - | ||||||||||||||||||||||||||||||
| 852 | case 'n': | - | ||||||||||||||||||||||||||||||
| 853 | if (key.isLetterOrNumber() || key == m_blank) | - | ||||||||||||||||||||||||||||||
| 854 | return true; | - | ||||||||||||||||||||||||||||||
| 855 | break; | - | ||||||||||||||||||||||||||||||
| 856 | case 'X': | - | ||||||||||||||||||||||||||||||
| 857 | if (key.isPrint()) | - | ||||||||||||||||||||||||||||||
| 858 | return true; | - | ||||||||||||||||||||||||||||||
| 859 | break; | - | ||||||||||||||||||||||||||||||
| 860 | case 'x': | - | ||||||||||||||||||||||||||||||
| 861 | if (key.isPrint() || key == m_blank) | - | ||||||||||||||||||||||||||||||
| 862 | return true; | - | ||||||||||||||||||||||||||||||
| 863 | break; | - | ||||||||||||||||||||||||||||||
| 864 | case '9': | - | ||||||||||||||||||||||||||||||
| 865 | if (key.isNumber()) | - | ||||||||||||||||||||||||||||||
| 866 | return true; | - | ||||||||||||||||||||||||||||||
| 867 | break; | - | ||||||||||||||||||||||||||||||
| 868 | case '0': | - | ||||||||||||||||||||||||||||||
| 869 | if (key.isNumber() || key == m_blank) | - | ||||||||||||||||||||||||||||||
| 870 | return true; | - | ||||||||||||||||||||||||||||||
| 871 | break; | - | ||||||||||||||||||||||||||||||
| 872 | case 'D': | - | ||||||||||||||||||||||||||||||
| 873 | if (key.isNumber() && key.digitValue() > 0) | - | ||||||||||||||||||||||||||||||
| 874 | return true; | - | ||||||||||||||||||||||||||||||
| 875 | break; | - | ||||||||||||||||||||||||||||||
| 876 | case 'd': | - | ||||||||||||||||||||||||||||||
| 877 | if ((key.isNumber() && key.digitValue() > 0) || key == m_blank) | - | ||||||||||||||||||||||||||||||
| 878 | return true; | - | ||||||||||||||||||||||||||||||
| 879 | break; | - | ||||||||||||||||||||||||||||||
| 880 | case '#': | - | ||||||||||||||||||||||||||||||
| 881 | if (key.isNumber() || key == QLatin1Char('+') || key == QLatin1Char('-') || key == m_blank) | - | ||||||||||||||||||||||||||||||
| 882 | return true; | - | ||||||||||||||||||||||||||||||
| 883 | break; | - | ||||||||||||||||||||||||||||||
| 884 | case 'B': | - | ||||||||||||||||||||||||||||||
| 885 | if (key == QLatin1Char('0') || key == QLatin1Char('1')) | - | ||||||||||||||||||||||||||||||
| 886 | return true; | - | ||||||||||||||||||||||||||||||
| 887 | break; | - | ||||||||||||||||||||||||||||||
| 888 | case 'b': | - | ||||||||||||||||||||||||||||||
| 889 | if (key == QLatin1Char('0') || key == QLatin1Char('1') || key == m_blank) | - | ||||||||||||||||||||||||||||||
| 890 | return true; | - | ||||||||||||||||||||||||||||||
| 891 | break; | - | ||||||||||||||||||||||||||||||
| 892 | case 'H': | - | ||||||||||||||||||||||||||||||
| 893 | if (key.isNumber() || (key >= QLatin1Char('a') && key <= QLatin1Char('f')) || (key >= QLatin1Char('A') && key <= QLatin1Char('F'))) | - | ||||||||||||||||||||||||||||||
| 894 | return true; | - | ||||||||||||||||||||||||||||||
| 895 | break; | - | ||||||||||||||||||||||||||||||
| 896 | case 'h': | - | ||||||||||||||||||||||||||||||
| 897 | if (key.isNumber() || (key >= QLatin1Char('a') && key <= QLatin1Char('f')) || (key >= QLatin1Char('A') && key <= QLatin1Char('F')) || key == m_blank) | - | ||||||||||||||||||||||||||||||
| 898 | return true; | - | ||||||||||||||||||||||||||||||
| 899 | break; | - | ||||||||||||||||||||||||||||||
| 900 | default: | - | ||||||||||||||||||||||||||||||
| 901 | break; | - | ||||||||||||||||||||||||||||||
| 902 | } | - | ||||||||||||||||||||||||||||||
| 903 | return false; | - | ||||||||||||||||||||||||||||||
| 904 | } | - | ||||||||||||||||||||||||||||||
| 905 | bool QWidgetLineControl::hasAcceptableInput(const QString &str) const | - | ||||||||||||||||||||||||||||||
| 906 | { | - | ||||||||||||||||||||||||||||||
| 907 | - | |||||||||||||||||||||||||||||||
| 908 | QString textCopy = str; | - | ||||||||||||||||||||||||||||||
| 909 | int cursorCopy = m_cursor; | - | ||||||||||||||||||||||||||||||
| 910 | if (m_validator && m_validator->validate(textCopy, cursorCopy) | - | ||||||||||||||||||||||||||||||
| 911 | != QValidator::Acceptable) | - | ||||||||||||||||||||||||||||||
| 912 | return false; | - | ||||||||||||||||||||||||||||||
| 913 | - | |||||||||||||||||||||||||||||||
| 914 | - | |||||||||||||||||||||||||||||||
| 915 | if (!m_maskData) | - | ||||||||||||||||||||||||||||||
| 916 | return true; | - | ||||||||||||||||||||||||||||||
| 917 | - | |||||||||||||||||||||||||||||||
| 918 | if (str.length() != m_maxLength) | - | ||||||||||||||||||||||||||||||
| 919 | return false; | - | ||||||||||||||||||||||||||||||
| 920 | - | |||||||||||||||||||||||||||||||
| 921 | for (int i=0; i < m_maxLength; ++i) { | - | ||||||||||||||||||||||||||||||
| 922 | if (m_maskData[i].separator) { | - | ||||||||||||||||||||||||||||||
| 923 | if (str.at(i) != m_maskData[i].maskChar) | - | ||||||||||||||||||||||||||||||
| 924 | return false; | - | ||||||||||||||||||||||||||||||
| 925 | } else { | - | ||||||||||||||||||||||||||||||
| 926 | if (!isValidInput(str.at(i), m_maskData[i].maskChar)) | - | ||||||||||||||||||||||||||||||
| 927 | return false; | - | ||||||||||||||||||||||||||||||
| 928 | } | - | ||||||||||||||||||||||||||||||
| 929 | } | - | ||||||||||||||||||||||||||||||
| 930 | return true; | - | ||||||||||||||||||||||||||||||
| 931 | } | - | ||||||||||||||||||||||||||||||
| 932 | QString QWidgetLineControl::maskString(uint pos, const QString &str, bool clear) const | - | ||||||||||||||||||||||||||||||
| 933 | { | - | ||||||||||||||||||||||||||||||
| 934 | if (pos >= (uint)m_maxLength
| 0 | ||||||||||||||||||||||||||||||
| 935 | return never executed: QString::fromLatin1("");return QString::fromLatin1("");never executed: return QString::fromLatin1(""); | 0 | ||||||||||||||||||||||||||||||
| 936 | - | |||||||||||||||||||||||||||||||
| 937 | QString fill; | - | ||||||||||||||||||||||||||||||
| 938 | fill = clear
| 0 | ||||||||||||||||||||||||||||||
| 939 | - | |||||||||||||||||||||||||||||||
| 940 | int strIndex = 0; | - | ||||||||||||||||||||||||||||||
| 941 | QString s = QString::fromLatin1(""); | - | ||||||||||||||||||||||||||||||
| 942 | int i = pos; | - | ||||||||||||||||||||||||||||||
| 943 | while (i < m_maxLength
| 0 | ||||||||||||||||||||||||||||||
| 944 | if (strIndex < str.length()
| 0 | ||||||||||||||||||||||||||||||
| 945 | if (m_maskData[i].separator
| 0 | ||||||||||||||||||||||||||||||
| 946 | s += m_maskData[i].maskChar; | - | ||||||||||||||||||||||||||||||
| 947 | if (str[(int)strIndex] == m_maskData[i].maskChar
| 0 | ||||||||||||||||||||||||||||||
| 948 | strIndex++; never executed: strIndex++; | 0 | ||||||||||||||||||||||||||||||
| 949 | ++i; | - | ||||||||||||||||||||||||||||||
| 950 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 951 | if (isValidInput(str[(int)strIndex], m_maskData[i].maskChar)
| 0 | ||||||||||||||||||||||||||||||
| 952 | switch (m_maskData[i].caseMode) { | - | ||||||||||||||||||||||||||||||
| 953 | case never executed: MaskInputData::Upper:case MaskInputData::Upper:never executed: case MaskInputData::Upper: | 0 | ||||||||||||||||||||||||||||||
| 954 | s += str[(int)strIndex].toUpper(); | - | ||||||||||||||||||||||||||||||
| 955 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 956 | case never executed: MaskInputData::Lower:case MaskInputData::Lower:never executed: case MaskInputData::Lower: | 0 | ||||||||||||||||||||||||||||||
| 957 | s += str[(int)strIndex].toLower(); | - | ||||||||||||||||||||||||||||||
| 958 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 959 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 960 | s += str[(int)strIndex]; | - | ||||||||||||||||||||||||||||||
| 961 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 962 | ++i; | - | ||||||||||||||||||||||||||||||
| 963 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 964 | - | |||||||||||||||||||||||||||||||
| 965 | int n = findInMask(i, true, true, str[(int)strIndex]); | - | ||||||||||||||||||||||||||||||
| 966 | if (n != -1
| 0 | ||||||||||||||||||||||||||||||
| 967 | if (str.length() != 1
| 0 | ||||||||||||||||||||||||||||||
| 968 | s += fill.midmidRef(i, n - i + 1); | - | ||||||||||||||||||||||||||||||
| 969 | i = n + 1; | - | ||||||||||||||||||||||||||||||
| 970 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 971 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 972 | - | |||||||||||||||||||||||||||||||
| 973 | n = findInMask(i, true, false, str[(int)strIndex]); | - | ||||||||||||||||||||||||||||||
| 974 | if (n != -1
| 0 | ||||||||||||||||||||||||||||||
| 975 | s += fill.midmidRef(i, n - i); | - | ||||||||||||||||||||||||||||||
| 976 | switch (m_maskData[n].caseMode) { | - | ||||||||||||||||||||||||||||||
| 977 | case never executed: MaskInputData::Upper:case MaskInputData::Upper:never executed: case MaskInputData::Upper: | 0 | ||||||||||||||||||||||||||||||
| 978 | s += str[(int)strIndex].toUpper(); | - | ||||||||||||||||||||||||||||||
| 979 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 980 | case never executed: MaskInputData::Lower:case MaskInputData::Lower:never executed: case MaskInputData::Lower: | 0 | ||||||||||||||||||||||||||||||
| 981 | s += str[(int)strIndex].toLower(); | - | ||||||||||||||||||||||||||||||
| 982 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 983 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 984 | s += str[(int)strIndex]; | - | ||||||||||||||||||||||||||||||
| 985 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 986 | i = n + 1; | - | ||||||||||||||||||||||||||||||
| 987 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 988 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 989 | } | - | ||||||||||||||||||||||||||||||
| 990 | ++strIndex; | - | ||||||||||||||||||||||||||||||
| 991 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 992 | } else | - | ||||||||||||||||||||||||||||||
| 993 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 994 | } | - | ||||||||||||||||||||||||||||||
| 995 | - | |||||||||||||||||||||||||||||||
| 996 | return never executed: s;return s;never executed: return s; | 0 | ||||||||||||||||||||||||||||||
| 997 | } | - | ||||||||||||||||||||||||||||||
| 998 | QString QWidgetLineControl::clearString(uint pos, uint len) const | - | ||||||||||||||||||||||||||||||
| 999 | { | - | ||||||||||||||||||||||||||||||
| 1000 | if (pos >= (uint)m_maxLength) | - | ||||||||||||||||||||||||||||||
| 1001 | return QString(); | - | ||||||||||||||||||||||||||||||
| 1002 | - | |||||||||||||||||||||||||||||||
| 1003 | QString s; | - | ||||||||||||||||||||||||||||||
| 1004 | int end = qMin((uint)m_maxLength, pos + len); | - | ||||||||||||||||||||||||||||||
| 1005 | for (int i = pos; i < end; ++i) | - | ||||||||||||||||||||||||||||||
| 1006 | if (m_maskData[i].separator) | - | ||||||||||||||||||||||||||||||
| 1007 | s += m_maskData[i].maskChar; | - | ||||||||||||||||||||||||||||||
| 1008 | else | - | ||||||||||||||||||||||||||||||
| 1009 | s += m_blank; | - | ||||||||||||||||||||||||||||||
| 1010 | - | |||||||||||||||||||||||||||||||
| 1011 | return s; | - | ||||||||||||||||||||||||||||||
| 1012 | } | - | ||||||||||||||||||||||||||||||
| 1013 | - | |||||||||||||||||||||||||||||||
| 1014 | - | |||||||||||||||||||||||||||||||
| 1015 | - | |||||||||||||||||||||||||||||||
| 1016 | - | |||||||||||||||||||||||||||||||
| 1017 | - | |||||||||||||||||||||||||||||||
| 1018 | - | |||||||||||||||||||||||||||||||
| 1019 | - | |||||||||||||||||||||||||||||||
| 1020 | QString QWidgetLineControl::stripString(const QString &str) const | - | ||||||||||||||||||||||||||||||
| 1021 | { | - | ||||||||||||||||||||||||||||||
| 1022 | if (!m_maskData) | - | ||||||||||||||||||||||||||||||
| 1023 | return str; | - | ||||||||||||||||||||||||||||||
| 1024 | - | |||||||||||||||||||||||||||||||
| 1025 | QString s; | - | ||||||||||||||||||||||||||||||
| 1026 | int end = qMin(m_maxLength, (int)str.length()); | - | ||||||||||||||||||||||||||||||
| 1027 | for (int i = 0; i < end; ++i) | - | ||||||||||||||||||||||||||||||
| 1028 | if (m_maskData[i].separator) | - | ||||||||||||||||||||||||||||||
| 1029 | s += m_maskData[i].maskChar; | - | ||||||||||||||||||||||||||||||
| 1030 | else | - | ||||||||||||||||||||||||||||||
| 1031 | if (str[i] != m_blank) | - | ||||||||||||||||||||||||||||||
| 1032 | s += str[i]; | - | ||||||||||||||||||||||||||||||
| 1033 | - | |||||||||||||||||||||||||||||||
| 1034 | return s; | - | ||||||||||||||||||||||||||||||
| 1035 | } | - | ||||||||||||||||||||||||||||||
| 1036 | - | |||||||||||||||||||||||||||||||
| 1037 | - | |||||||||||||||||||||||||||||||
| 1038 | - | |||||||||||||||||||||||||||||||
| 1039 | - | |||||||||||||||||||||||||||||||
| 1040 | - | |||||||||||||||||||||||||||||||
| 1041 | int QWidgetLineControl::findInMask(int pos, bool forward, bool findSeparator, QChar searchChar) const | - | ||||||||||||||||||||||||||||||
| 1042 | { | - | ||||||||||||||||||||||||||||||
| 1043 | if (pos >= m_maxLength || pos < 0) | - | ||||||||||||||||||||||||||||||
| 1044 | return -1; | - | ||||||||||||||||||||||||||||||
| 1045 | - | |||||||||||||||||||||||||||||||
| 1046 | int end = forward ? m_maxLength : -1; | - | ||||||||||||||||||||||||||||||
| 1047 | int step = forward ? 1 : -1; | - | ||||||||||||||||||||||||||||||
| 1048 | int i = pos; | - | ||||||||||||||||||||||||||||||
| 1049 | - | |||||||||||||||||||||||||||||||
| 1050 | while (i != end) { | - | ||||||||||||||||||||||||||||||
| 1051 | if (findSeparator) { | - | ||||||||||||||||||||||||||||||
| 1052 | if (m_maskData[i].separator && m_maskData[i].maskChar == searchChar) | - | ||||||||||||||||||||||||||||||
| 1053 | return i; | - | ||||||||||||||||||||||||||||||
| 1054 | } else { | - | ||||||||||||||||||||||||||||||
| 1055 | if (!m_maskData[i].separator) { | - | ||||||||||||||||||||||||||||||
| 1056 | if (searchChar.isNull()) | - | ||||||||||||||||||||||||||||||
| 1057 | return i; | - | ||||||||||||||||||||||||||||||
| 1058 | else if (isValidInput(searchChar, m_maskData[i].maskChar)) | - | ||||||||||||||||||||||||||||||
| 1059 | return i; | - | ||||||||||||||||||||||||||||||
| 1060 | } | - | ||||||||||||||||||||||||||||||
| 1061 | } | - | ||||||||||||||||||||||||||||||
| 1062 | i += step; | - | ||||||||||||||||||||||||||||||
| 1063 | } | - | ||||||||||||||||||||||||||||||
| 1064 | return -1; | - | ||||||||||||||||||||||||||||||
| 1065 | } | - | ||||||||||||||||||||||||||||||
| 1066 | - | |||||||||||||||||||||||||||||||
| 1067 | void QWidgetLineControl::internalUndo(int until) | - | ||||||||||||||||||||||||||||||
| 1068 | { | - | ||||||||||||||||||||||||||||||
| 1069 | if (!isUndoAvailable()) | - | ||||||||||||||||||||||||||||||
| 1070 | return; | - | ||||||||||||||||||||||||||||||
| 1071 | cancelPasswordEchoTimer(); | - | ||||||||||||||||||||||||||||||
| 1072 | internalDeselect(); | - | ||||||||||||||||||||||||||||||
| 1073 | - | |||||||||||||||||||||||||||||||
| 1074 | while (m_undoState && m_undoState > until) { | - | ||||||||||||||||||||||||||||||
| 1075 | Command& cmd = m_history[--m_undoState]; | - | ||||||||||||||||||||||||||||||
| 1076 | switch (cmd.type) { | - | ||||||||||||||||||||||||||||||
| 1077 | case Insert: | - | ||||||||||||||||||||||||||||||
| 1078 | m_text.remove(cmd.pos, 1); | - | ||||||||||||||||||||||||||||||
| 1079 | m_cursor = cmd.pos; | - | ||||||||||||||||||||||||||||||
| 1080 | break; | - | ||||||||||||||||||||||||||||||
| 1081 | case SetSelection: | - | ||||||||||||||||||||||||||||||
| 1082 | m_selstart = cmd.selStart; | - | ||||||||||||||||||||||||||||||
| 1083 | m_selend = cmd.selEnd; | - | ||||||||||||||||||||||||||||||
| 1084 | m_cursor = cmd.pos; | - | ||||||||||||||||||||||||||||||
| 1085 | break; | - | ||||||||||||||||||||||||||||||
| 1086 | case Remove: | - | ||||||||||||||||||||||||||||||
| 1087 | case RemoveSelection: | - | ||||||||||||||||||||||||||||||
| 1088 | m_text.insert(cmd.pos, cmd.uc); | - | ||||||||||||||||||||||||||||||
| 1089 | m_cursor = cmd.pos + 1; | - | ||||||||||||||||||||||||||||||
| 1090 | break; | - | ||||||||||||||||||||||||||||||
| 1091 | case Delete: | - | ||||||||||||||||||||||||||||||
| 1092 | case DeleteSelection: | - | ||||||||||||||||||||||||||||||
| 1093 | m_text.insert(cmd.pos, cmd.uc); | - | ||||||||||||||||||||||||||||||
| 1094 | m_cursor = cmd.pos; | - | ||||||||||||||||||||||||||||||
| 1095 | break; | - | ||||||||||||||||||||||||||||||
| 1096 | case Separator: | - | ||||||||||||||||||||||||||||||
| 1097 | continue; | - | ||||||||||||||||||||||||||||||
| 1098 | } | - | ||||||||||||||||||||||||||||||
| 1099 | if (until < 0 && m_undoState) { | - | ||||||||||||||||||||||||||||||
| 1100 | Command& next = m_history[m_undoState-1]; | - | ||||||||||||||||||||||||||||||
| 1101 | if (next.type != cmd.type && next.type < RemoveSelection | - | ||||||||||||||||||||||||||||||
| 1102 | && (cmd.type < RemoveSelection || next.type == Separator)) | - | ||||||||||||||||||||||||||||||
| 1103 | break; | - | ||||||||||||||||||||||||||||||
| 1104 | } | - | ||||||||||||||||||||||||||||||
| 1105 | } | - | ||||||||||||||||||||||||||||||
| 1106 | m_textDirty = true; | - | ||||||||||||||||||||||||||||||
| 1107 | emitCursorPositionChanged(); | - | ||||||||||||||||||||||||||||||
| 1108 | } | - | ||||||||||||||||||||||||||||||
| 1109 | - | |||||||||||||||||||||||||||||||
| 1110 | void QWidgetLineControl::internalRedo() | - | ||||||||||||||||||||||||||||||
| 1111 | { | - | ||||||||||||||||||||||||||||||
| 1112 | if (!isRedoAvailable()) | - | ||||||||||||||||||||||||||||||
| 1113 | return; | - | ||||||||||||||||||||||||||||||
| 1114 | internalDeselect(); | - | ||||||||||||||||||||||||||||||
| 1115 | while (m_undoState < (int)m_history.size()) { | - | ||||||||||||||||||||||||||||||
| 1116 | Command& cmd = m_history[m_undoState++]; | - | ||||||||||||||||||||||||||||||
| 1117 | switch (cmd.type) { | - | ||||||||||||||||||||||||||||||
| 1118 | case Insert: | - | ||||||||||||||||||||||||||||||
| 1119 | m_text.insert(cmd.pos, cmd.uc); | - | ||||||||||||||||||||||||||||||
| 1120 | m_cursor = cmd.pos + 1; | - | ||||||||||||||||||||||||||||||
| 1121 | break; | - | ||||||||||||||||||||||||||||||
| 1122 | case SetSelection: | - | ||||||||||||||||||||||||||||||
| 1123 | m_selstart = cmd.selStart; | - | ||||||||||||||||||||||||||||||
| 1124 | m_selend = cmd.selEnd; | - | ||||||||||||||||||||||||||||||
| 1125 | m_cursor = cmd.pos; | - | ||||||||||||||||||||||||||||||
| 1126 | break; | - | ||||||||||||||||||||||||||||||
| 1127 | case Remove: | - | ||||||||||||||||||||||||||||||
| 1128 | case Delete: | - | ||||||||||||||||||||||||||||||
| 1129 | case RemoveSelection: | - | ||||||||||||||||||||||||||||||
| 1130 | case DeleteSelection: | - | ||||||||||||||||||||||||||||||
| 1131 | m_text.remove(cmd.pos, 1); | - | ||||||||||||||||||||||||||||||
| 1132 | m_selstart = cmd.selStart; | - | ||||||||||||||||||||||||||||||
| 1133 | m_selend = cmd.selEnd; | - | ||||||||||||||||||||||||||||||
| 1134 | m_cursor = cmd.pos; | - | ||||||||||||||||||||||||||||||
| 1135 | break; | - | ||||||||||||||||||||||||||||||
| 1136 | case Separator: | - | ||||||||||||||||||||||||||||||
| 1137 | m_selstart = cmd.selStart; | - | ||||||||||||||||||||||||||||||
| 1138 | m_selend = cmd.selEnd; | - | ||||||||||||||||||||||||||||||
| 1139 | m_cursor = cmd.pos; | - | ||||||||||||||||||||||||||||||
| 1140 | break; | - | ||||||||||||||||||||||||||||||
| 1141 | } | - | ||||||||||||||||||||||||||||||
| 1142 | if (m_undoState < (int)m_history.size()) { | - | ||||||||||||||||||||||||||||||
| 1143 | Command& next = m_history[m_undoState]; | - | ||||||||||||||||||||||||||||||
| 1144 | if (next.type != cmd.type && cmd.type < RemoveSelection && next.type != Separator | - | ||||||||||||||||||||||||||||||
| 1145 | && (next.type < RemoveSelection || cmd.type == Separator)) | - | ||||||||||||||||||||||||||||||
| 1146 | break; | - | ||||||||||||||||||||||||||||||
| 1147 | } | - | ||||||||||||||||||||||||||||||
| 1148 | } | - | ||||||||||||||||||||||||||||||
| 1149 | m_textDirty = true; | - | ||||||||||||||||||||||||||||||
| 1150 | emitCursorPositionChanged(); | - | ||||||||||||||||||||||||||||||
| 1151 | } | - | ||||||||||||||||||||||||||||||
| 1152 | - | |||||||||||||||||||||||||||||||
| 1153 | - | |||||||||||||||||||||||||||||||
| 1154 | - | |||||||||||||||||||||||||||||||
| 1155 | - | |||||||||||||||||||||||||||||||
| 1156 | - | |||||||||||||||||||||||||||||||
| 1157 | - | |||||||||||||||||||||||||||||||
| 1158 | - | |||||||||||||||||||||||||||||||
| 1159 | void QWidgetLineControl::emitCursorPositionChanged() | - | ||||||||||||||||||||||||||||||
| 1160 | { | - | ||||||||||||||||||||||||||||||
| 1161 | if (m_cursor != m_lastCursorPos) { | - | ||||||||||||||||||||||||||||||
| 1162 | const int oldLast = m_lastCursorPos; | - | ||||||||||||||||||||||||||||||
| 1163 | m_lastCursorPos = m_cursor; | - | ||||||||||||||||||||||||||||||
| 1164 | cursorPositionChanged(oldLast, m_cursor); | - | ||||||||||||||||||||||||||||||
| 1165 | - | |||||||||||||||||||||||||||||||
| 1166 | - | |||||||||||||||||||||||||||||||
| 1167 | if (!hasSelectedText()) { | - | ||||||||||||||||||||||||||||||
| 1168 | QAccessibleTextCursorEvent event(accessibleObject(), m_cursor); | - | ||||||||||||||||||||||||||||||
| 1169 | QAccessible::updateAccessibility(&event); | - | ||||||||||||||||||||||||||||||
| 1170 | } | - | ||||||||||||||||||||||||||||||
| 1171 | - | |||||||||||||||||||||||||||||||
| 1172 | } | - | ||||||||||||||||||||||||||||||
| 1173 | } | - | ||||||||||||||||||||||||||||||
| 1174 | - | |||||||||||||||||||||||||||||||
| 1175 | - | |||||||||||||||||||||||||||||||
| 1176 | - | |||||||||||||||||||||||||||||||
| 1177 | - | |||||||||||||||||||||||||||||||
| 1178 | bool QWidgetLineControl::advanceToEnabledItem(int dir) | - | ||||||||||||||||||||||||||||||
| 1179 | { | - | ||||||||||||||||||||||||||||||
| 1180 | int start = m_completer->currentRow(); | - | ||||||||||||||||||||||||||||||
| 1181 | if (start == -1) | - | ||||||||||||||||||||||||||||||
| 1182 | return false; | - | ||||||||||||||||||||||||||||||
| 1183 | int i = start + dir; | - | ||||||||||||||||||||||||||||||
| 1184 | if (dir == 0) dir = 1; | - | ||||||||||||||||||||||||||||||
| 1185 | do { | - | ||||||||||||||||||||||||||||||
| 1186 | if (!m_completer->setCurrentRow(i)) { | - | ||||||||||||||||||||||||||||||
| 1187 | if (!m_completer->wrapAround()) | - | ||||||||||||||||||||||||||||||
| 1188 | break; | - | ||||||||||||||||||||||||||||||
| 1189 | i = i > 0 ? 0 : m_completer->completionCount() - 1; | - | ||||||||||||||||||||||||||||||
| 1190 | } else { | - | ||||||||||||||||||||||||||||||
| 1191 | QModelIndex currentIndex = m_completer->currentIndex(); | - | ||||||||||||||||||||||||||||||
| 1192 | if (m_completer->completionModel()->flags(currentIndex) & Qt::ItemIsEnabled) | - | ||||||||||||||||||||||||||||||
| 1193 | return true; | - | ||||||||||||||||||||||||||||||
| 1194 | i += dir; | - | ||||||||||||||||||||||||||||||
| 1195 | } | - | ||||||||||||||||||||||||||||||
| 1196 | } while (i != start); | - | ||||||||||||||||||||||||||||||
| 1197 | - | |||||||||||||||||||||||||||||||
| 1198 | m_completer->setCurrentRow(start); | - | ||||||||||||||||||||||||||||||
| 1199 | return false; | - | ||||||||||||||||||||||||||||||
| 1200 | } | - | ||||||||||||||||||||||||||||||
| 1201 | - | |||||||||||||||||||||||||||||||
| 1202 | void QWidgetLineControl::complete(int key) | - | ||||||||||||||||||||||||||||||
| 1203 | { | - | ||||||||||||||||||||||||||||||
| 1204 | if (!m_completer || isReadOnly() || echoMode() != QLineEdit::Normal) | - | ||||||||||||||||||||||||||||||
| 1205 | return; | - | ||||||||||||||||||||||||||||||
| 1206 | - | |||||||||||||||||||||||||||||||
| 1207 | QString text = this->text(); | - | ||||||||||||||||||||||||||||||
| 1208 | if (m_completer->completionMode() == QCompleter::InlineCompletion) { | - | ||||||||||||||||||||||||||||||
| 1209 | if (key == Qt::Key_Backspace) | - | ||||||||||||||||||||||||||||||
| 1210 | return; | - | ||||||||||||||||||||||||||||||
| 1211 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 1212 | if (key == Qt::Key_Up || key == Qt::Key_Down) { | - | ||||||||||||||||||||||||||||||
| 1213 | if (textAfterSelection().length()) | - | ||||||||||||||||||||||||||||||
| 1214 | return; | - | ||||||||||||||||||||||||||||||
| 1215 | QString prefix = hasSelectedText() ? textBeforeSelection() | - | ||||||||||||||||||||||||||||||
| 1216 | : text; | - | ||||||||||||||||||||||||||||||
| 1217 | if (text.compare(m_completer->currentCompletion(), m_completer->caseSensitivity()) != 0 | - | ||||||||||||||||||||||||||||||
| 1218 | || prefix.compare(m_completer->completionPrefix(), m_completer->caseSensitivity()) != 0) { | - | ||||||||||||||||||||||||||||||
| 1219 | m_completer->setCompletionPrefix(prefix); | - | ||||||||||||||||||||||||||||||
| 1220 | } else { | - | ||||||||||||||||||||||||||||||
| 1221 | n = (key == Qt::Key_Up) ? -1 : +1; | - | ||||||||||||||||||||||||||||||
| 1222 | } | - | ||||||||||||||||||||||||||||||
| 1223 | } else { | - | ||||||||||||||||||||||||||||||
| 1224 | m_completer->setCompletionPrefix(text); | - | ||||||||||||||||||||||||||||||
| 1225 | } | - | ||||||||||||||||||||||||||||||
| 1226 | if (!advanceToEnabledItem(n)) | - | ||||||||||||||||||||||||||||||
| 1227 | return; | - | ||||||||||||||||||||||||||||||
| 1228 | } else { | - | ||||||||||||||||||||||||||||||
| 1229 | - | |||||||||||||||||||||||||||||||
| 1230 | if (text.isEmpty()) { | - | ||||||||||||||||||||||||||||||
| 1231 | m_completer->popup()->hide(); | - | ||||||||||||||||||||||||||||||
| 1232 | return; | - | ||||||||||||||||||||||||||||||
| 1233 | } | - | ||||||||||||||||||||||||||||||
| 1234 | - | |||||||||||||||||||||||||||||||
| 1235 | m_completer->setCompletionPrefix(text); | - | ||||||||||||||||||||||||||||||
| 1236 | } | - | ||||||||||||||||||||||||||||||
| 1237 | - | |||||||||||||||||||||||||||||||
| 1238 | m_completer->complete(); | - | ||||||||||||||||||||||||||||||
| 1239 | } | - | ||||||||||||||||||||||||||||||
| 1240 | - | |||||||||||||||||||||||||||||||
| 1241 | - | |||||||||||||||||||||||||||||||
| 1242 | void QWidgetLineControl::setReadOnly(bool enable) | - | ||||||||||||||||||||||||||||||
| 1243 | { | - | ||||||||||||||||||||||||||||||
| 1244 | if (m_readOnly == enable
| 0 | ||||||||||||||||||||||||||||||
| 1245 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1246 | - | |||||||||||||||||||||||||||||||
| 1247 | m_readOnly = enable; | - | ||||||||||||||||||||||||||||||
| 1248 | updateCursorBlinking(); | - | ||||||||||||||||||||||||||||||
| 1249 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1250 | - | |||||||||||||||||||||||||||||||
| 1251 | void QWidgetLineControl::setBlinkingCursorEnabled(bool enable) | - | ||||||||||||||||||||||||||||||
| 1252 | { | - | ||||||||||||||||||||||||||||||
| 1253 | if (m_blinkEnabled ==
| 0 | ||||||||||||||||||||||||||||||
| 1254 | setCursorBlinkPeriodreturn; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1255 | - | |||||||||||||||||||||||||||||||
| 1256 | m_blinkEnabled = enable; | - | ||||||||||||||||||||||||||||||
| 1257 | - | |||||||||||||||||||||||||||||||
| 1258 | if (0enable
| 0 | ||||||||||||||||||||||||||||||
| 1259 | connect((static_cast<QApplication *>(QCoreApplication::instance()))->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking never executed: connect((static_cast<QApplication *>(QCoreApplication::instance()))->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking);never executed: );connect((static_cast<QApplication *>(QCoreApplication::instance()))->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking);never executed: connect((static_cast<QApplication *>(QCoreApplication::instance()))->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking); | 0 | ||||||||||||||||||||||||||||||
| 1260 | else | - | ||||||||||||||||||||||||||||||
| 1261 | setCursorBlinkPeriod(disconnect((static_cast< never executed: QApplication *>(QCoreApplication::cursorFlashTime());instance()))->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking);disconnect((static_cast<QApplication *>(QCoreApplication::instance()))->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking);never executed: disconnect((static_cast<QApplication *>(QCoreApplication::instance()))->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking); | 0 | ||||||||||||||||||||||||||||||
| 1262 | - | |||||||||||||||||||||||||||||||
| 1263 | updateCursorBlinking(); | - | ||||||||||||||||||||||||||||||
| 1264 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1265 | - | |||||||||||||||||||||||||||||||
| 1266 | void QWidgetLineControl::setCursorBlinkPeriod(int msec)updateCursorBlinking() | - | ||||||||||||||||||||||||||||||
| 1267 | { | - | ||||||||||||||||||||||||||||||
| 1268 | if (msec == m_blinkPeriod) | 0 | ||||||||||||||||||||||||||||||
return;if (m_blinkTimer
| ||||||||||||||||||||||||||||||||
| 1269 | killTimer(m_blinkTimer); | - | ||||||||||||||||||||||||||||||
| 1270 | m_blinkTimer = 0; | - | ||||||||||||||||||||||||||||||
| 1271 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1272 | - | |||||||||||||||||||||||||||||||
| 1273 | if (msec > 0m_blinkEnabled
| 0 | ||||||||||||||||||||||||||||||
| 1274 | int flashTime = QGuiApplication::styleHints()->cursorFlashTime(); | - | ||||||||||||||||||||||||||||||
| 1275 | if (flashTime >= 2
| 0 | ||||||||||||||||||||||||||||||
| 1276 | m_blinkTimer = startTimer(msecflashTime / 2); never executed: m_blinkTimer = startTimer(flashTime / 2); | 0 | ||||||||||||||||||||||||||||||
| 1277 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1278 | - | |||||||||||||||||||||||||||||||
| 1279 | m_blinkStatus = 1; | - | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||
| m_blinkTimer = 0; | ||||||||||||||||||||||||||||||||
| 1280 | if (m_blinkStatus == 1)updateNeeded(inputMask().isEmpty() ? cursorRect() : QRect()); | - | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| m_blinkPeriod = msec;} never executed: end of block | ||||||||||||||||||||||||||||||||
| 1282 | - | |||||||||||||||||||||||||||||||
| 1283 | - | |||||||||||||||||||||||||||||||
| 1284 | void QWidgetLineControl::resetCursorBlinkTimer() | - | ||||||||||||||||||||||||||||||
| 1285 | { | - | ||||||||||||||||||||||||||||||
| 1286 | if (m_blinkPeriod == 0(!m_blinkEnabled
| 0 | ||||||||||||||||||||||||||||||
| 1287 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1288 | killTimer(m_blinkTimer); | - | ||||||||||||||||||||||||||||||
| 1289 | m_blinkTimer = 0; | - | ||||||||||||||||||||||||||||||
| 1290 | int flashTime = QGuiApplication::styleHints()->cursorFlashTime(); | - | ||||||||||||||||||||||||||||||
| 1291 | if (flashTime >= 2
| 0 | ||||||||||||||||||||||||||||||
| 1292 | m_blinkTimer = startTimer(m_blinkPeriodflashTime / 2); never executed: m_blinkTimer = startTimer(flashTime / 2); | 0 | ||||||||||||||||||||||||||||||
| 1293 | m_blinkStatus = 1; | - | ||||||||||||||||||||||||||||||
| 1294 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1295 | - | |||||||||||||||||||||||||||||||
| 1296 | void QWidgetLineControl::timerEvent(QTimerEvent *event) | - | ||||||||||||||||||||||||||||||
| 1297 | { | - | ||||||||||||||||||||||||||||||
| 1298 | if (event->timerId() == m_blinkTimer) { | - | ||||||||||||||||||||||||||||||
| 1299 | m_blinkStatus = !m_blinkStatus; | - | ||||||||||||||||||||||||||||||
| 1300 | updateNeeded(inputMask().isEmpty() ? cursorRect() : QRect()); | - | ||||||||||||||||||||||||||||||
| 1301 | } else if (event->timerId() == m_deleteAllTimer) { | - | ||||||||||||||||||||||||||||||
| 1302 | killTimer(m_deleteAllTimer); | - | ||||||||||||||||||||||||||||||
| 1303 | m_deleteAllTimer = 0; | - | ||||||||||||||||||||||||||||||
| 1304 | clear(); | - | ||||||||||||||||||||||||||||||
| 1305 | } else if (event->timerId() == m_tripleClickTimer) { | - | ||||||||||||||||||||||||||||||
| 1306 | killTimer(m_tripleClickTimer); | - | ||||||||||||||||||||||||||||||
| 1307 | m_tripleClickTimer = 0; | - | ||||||||||||||||||||||||||||||
| 1308 | } else if (event->timerId() == m_passwordEchoTimer) { | - | ||||||||||||||||||||||||||||||
| 1309 | killTimer(m_passwordEchoTimer); | - | ||||||||||||||||||||||||||||||
| 1310 | m_passwordEchoTimer = 0; | - | ||||||||||||||||||||||||||||||
| 1311 | updateDisplayText(); | - | ||||||||||||||||||||||||||||||
| 1312 | } | - | ||||||||||||||||||||||||||||||
| 1313 | } | - | ||||||||||||||||||||||||||||||
| 1314 | - | |||||||||||||||||||||||||||||||
| 1315 | - | |||||||||||||||||||||||||||||||
| 1316 | void QWidgetLineControl::processShortcutOverrideEvent(QKeyEvent *ke) | - | ||||||||||||||||||||||||||||||
| 1317 | { | - | ||||||||||||||||||||||||||||||
| 1318 | if (isReadOnly()) | 0 | ||||||||||||||||||||||||||||||
return;if (ke == QKeySequence::Copy
| ||||||||||||||||||||||||||||||||
| 1319 | || ke == QKeySequence::PasteMoveToNextWord
| 0 | ||||||||||||||||||||||||||||||
| 1320 | || ke == QKeySequence::CutMoveToPreviousWord
| 0 | ||||||||||||||||||||||||||||||
| 1321 | || ke == QKeySequence::RedoMoveToStartOfLine
| 0 | ||||||||||||||||||||||||||||||
| 1322 | || ke == QKeySequence::UndoMoveToEndOfLine
| 0 | ||||||||||||||||||||||||||||||
| 1323 | || ke == QKeySequence::MoveToNextWordMoveToStartOfDocument
| 0 | ||||||||||||||||||||||||||||||
| 1324 | || ke == QKeySequence::MoveToPreviousWordMoveToEndOfDocument
| 0 | ||||||||||||||||||||||||||||||
| 1325 | || ke == QKeySequence::MoveToStartOfLineSelectNextWord
| 0 | ||||||||||||||||||||||||||||||
| 1326 | || ke == QKeySequence::MoveToEndOfLineSelectPreviousWord
| 0 | ||||||||||||||||||||||||||||||
| 1327 | || ke == QKeySequence::MoveToStartOfDocumentSelectStartOfLine
| 0 | ||||||||||||||||||||||||||||||
| 1328 | || ke == QKeySequence::MoveToEndOfDocumentSelectEndOfLine
| 0 | ||||||||||||||||||||||||||||||
| 1329 | || ke == QKeySequence::SelectNextWordSelectStartOfBlock
| 0 | ||||||||||||||||||||||||||||||
| 1330 | || ke == QKeySequence::SelectPreviousWordSelectEndOfBlock
| 0 | ||||||||||||||||||||||||||||||
| 1331 | || ke == QKeySequence::SelectStartOfLineSelectStartOfDocument
| 0 | ||||||||||||||||||||||||||||||
| 1332 | || ke == QKeySequence::SelectEndOfLineSelectAll
| 0 | ||||||||||||||||||||||||||||||
| 1333 | || ke == QKeySequence::SelectStartOfBlock
| 0 | ||||||||||||||||||||||||||||||
||
| ||||||||||||||||||||||||||||||||
| 1334 | ke->accept(); | - | ||||||||||||||||||||||||||||||
| 1335 | } never executed: else if (ke == QKeySequence::SelectEndOfBlockPasteend of block
| 0 | ||||||||||||||||||||||||||||||
| 1336 | || ke == QKeySequence::SelectStartOfDocumentCut
| 0 | ||||||||||||||||||||||||||||||
| 1337 | || ke == QKeySequence::SelectAllRedo
| 0 | ||||||||||||||||||||||||||||||
| 1338 | || ke == QKeySequence::SelectEndOfDocumentUndo
| 0 | ||||||||||||||||||||||||||||||
| 1339 | || ke == QKeySequence::DeleteCompleteLine
| 0 | ||||||||||||||||||||||||||||||
| 1340 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1341 | ke->accept(); never executed: ke->accept(); | 0 | ||||||||||||||||||||||||||||||
| 1342 | } never executed: else if (ke->modifiers() == Qt::NoModifierend of block
| 0 | ||||||||||||||||||||||||||||||
| 1343 | || ke->modifiers() == Qt::KeypadModifier
| 0 | ||||||||||||||||||||||||||||||
| 1344 | if (ke->key() < Qt::Key_Escape
| 0 | ||||||||||||||||||||||||||||||
| 1345 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1346 | ke->accept(); never executed: ke->accept(); | 0 | ||||||||||||||||||||||||||||||
| 1347 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1348 | switch (ke->key()) { | - | ||||||||||||||||||||||||||||||
| 1349 | case never executed: Qt::Key_Delete:case Qt::Key_Delete:never executed: case Qt::Key_Delete: | 0 | ||||||||||||||||||||||||||||||
| 1350 | case never executed: Qt::Key_HomeKey_Backspace:case Qt::Key_Backspace:never executed: case Qt::Key_Backspace: | 0 | ||||||||||||||||||||||||||||||
| 1351 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1352 | ke->accept(); never executed: ke->accept(); | 0 | ||||||||||||||||||||||||||||||
| 1353 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1354 | - | |||||||||||||||||||||||||||||||
| 1355 | case never executed: Qt::Key_EndKey_Home:case Qt::Key_Home:never executed: case Qt::Key_Home: | 0 | ||||||||||||||||||||||||||||||
| 1356 | case never executed: Qt::Key_BackspaceKey_End:case Qt::Key_End:never executed: case Qt::Key_End: | 0 | ||||||||||||||||||||||||||||||
| 1357 | case never executed: Qt::Key_Left:case Qt::Key_Left:never executed: case Qt::Key_Left: | 0 | ||||||||||||||||||||||||||||||
| 1358 | case never executed: Qt::Key_Right:case Qt::Key_Right:never executed: case Qt::Key_Right: | 0 | ||||||||||||||||||||||||||||||
| 1359 | ke->accept(); | - | ||||||||||||||||||||||||||||||
| 1360 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1361 | - | |||||||||||||||||||||||||||||||
| 1362 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 1363 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1364 | } | - | ||||||||||||||||||||||||||||||
| 1365 | } | - | ||||||||||||||||||||||||||||||
| 1366 | } | - | ||||||||||||||||||||||||||||||
| 1367 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1368 | - | |||||||||||||||||||||||||||||||
| 1369 | - | |||||||||||||||||||||||||||||||
| 1370 | void QWidgetLineControl::processKeyEvent(QKeyEvent* event) | - | ||||||||||||||||||||||||||||||
| 1371 | { | - | ||||||||||||||||||||||||||||||
| 1372 | bool inlineCompletionAccepted = false; | - | ||||||||||||||||||||||||||||||
| 1373 | - | |||||||||||||||||||||||||||||||
| 1374 | - | |||||||||||||||||||||||||||||||
| 1375 | if (m_completer
| 0 | ||||||||||||||||||||||||||||||
| 1376 | QCompleter::CompletionMode completionMode = m_completer->completionMode(); | - | ||||||||||||||||||||||||||||||
| 1377 | if ((completionMode == QCompleter::PopupCompletion
| 0 | ||||||||||||||||||||||||||||||
| 1378 | || completionMode == QCompleter::UnfilteredPopupCompletion
| 0 | ||||||||||||||||||||||||||||||
| 1379 | && m_completer->popup()
| 0 | ||||||||||||||||||||||||||||||
| 1380 | && m_completer->popup()->isVisible()
| 0 | ||||||||||||||||||||||||||||||
| 1381 | - | |||||||||||||||||||||||||||||||
| 1382 | - | |||||||||||||||||||||||||||||||
| 1383 | switch (event->key()) { | - | ||||||||||||||||||||||||||||||
| 1384 | case never executed: Qt::Key_Escape:case Qt::Key_Escape:never executed: case Qt::Key_Escape: | 0 | ||||||||||||||||||||||||||||||
| 1385 | event->ignore(); | - | ||||||||||||||||||||||||||||||
| 1386 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1387 | case never executed: Qt::Key_Enter:case Qt::Key_Enter:never executed: case Qt::Key_Enter: | 0 | ||||||||||||||||||||||||||||||
| 1388 | case never executed: Qt::Key_Return:case Qt::Key_Return:never executed: case Qt::Key_Return: | 0 | ||||||||||||||||||||||||||||||
| 1389 | case never executed: Qt::Key_F4:case Qt::Key_F4:never executed: case Qt::Key_F4: | 0 | ||||||||||||||||||||||||||||||
| 1390 | - | |||||||||||||||||||||||||||||||
| 1391 | - | |||||||||||||||||||||||||||||||
| 1392 | - | |||||||||||||||||||||||||||||||
| 1393 | - | |||||||||||||||||||||||||||||||
| 1394 | - | |||||||||||||||||||||||||||||||
| 1395 | m_completer->popup()->hide(); | - | ||||||||||||||||||||||||||||||
| 1396 | default never executed: :default:never executed: default:code before this statement never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 1397 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1398 | } | - | ||||||||||||||||||||||||||||||
| 1399 | } else if (completionMode == QCompleter::InlineCompletion
| 0 | ||||||||||||||||||||||||||||||
| 1400 | switch (event->key()) { | - | ||||||||||||||||||||||||||||||
| 1401 | case never executed: Qt::Key_Enter:case Qt::Key_Enter:never executed: case Qt::Key_Enter: | 0 | ||||||||||||||||||||||||||||||
| 1402 | case never executed: Qt::Key_Return:case Qt::Key_Return:never executed: case Qt::Key_Return: | 0 | ||||||||||||||||||||||||||||||
| 1403 | case never executed: Qt::Key_F4:case Qt::Key_F4:never executed: case Qt::Key_F4: | 0 | ||||||||||||||||||||||||||||||
| 1404 | - | |||||||||||||||||||||||||||||||
| 1405 | - | |||||||||||||||||||||||||||||||
| 1406 | - | |||||||||||||||||||||||||||||||
| 1407 | - | |||||||||||||||||||||||||||||||
| 1408 | - | |||||||||||||||||||||||||||||||
| 1409 | if (!m_completer->currentCompletion().isEmpty()
| 0 | ||||||||||||||||||||||||||||||
| 1410 | && textAfterSelection().isEmpty()
| 0 | ||||||||||||||||||||||||||||||
| 1411 | setText(m_completer->currentCompletion()); | - | ||||||||||||||||||||||||||||||
| 1412 | inlineCompletionAccepted = true; | - | ||||||||||||||||||||||||||||||
| 1413 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1414 | default never executed: :default:never executed: default:code before this statement never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 1415 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1416 | } | - | ||||||||||||||||||||||||||||||
| 1417 | } | - | ||||||||||||||||||||||||||||||
| 1418 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1419 | - | |||||||||||||||||||||||||||||||
| 1420 | - | |||||||||||||||||||||||||||||||
| 1421 | if (event->key() == Qt::Key_Enter
| 0 | ||||||||||||||||||||||||||||||
| 1422 | if (hasAcceptableInput()
| 0 | ||||||||||||||||||||||||||||||
| 1423 | - | |||||||||||||||||||||||||||||||
| 1424 | QInputMethod *inputMethod = QApplication::inputMethod(); | - | ||||||||||||||||||||||||||||||
| 1425 | inputMethod->commit(); | - | ||||||||||||||||||||||||||||||
| 1426 | QWidget *lineEdit = qobject_cast<QWidget *>(parent()); | - | ||||||||||||||||||||||||||||||
| 1427 | if (!(lineEdit
| 0 | ||||||||||||||||||||||||||||||
| 1428 | inputMethod->hide(); never executed: inputMethod->hide(); | 0 | ||||||||||||||||||||||||||||||
| 1429 | - | |||||||||||||||||||||||||||||||
| 1430 | accepted(); | - | ||||||||||||||||||||||||||||||
| 1431 | editingFinished(); | - | ||||||||||||||||||||||||||||||
| 1432 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1433 | if (inlineCompletionAccepted
| 0 | ||||||||||||||||||||||||||||||
| 1434 | event->accept(); never executed: event->accept(); | 0 | ||||||||||||||||||||||||||||||
| 1435 | else | - | ||||||||||||||||||||||||||||||
| 1436 | event->ignore(); never executed: event->ignore(); | 0 | ||||||||||||||||||||||||||||||
| 1437 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1438 | } | - | ||||||||||||||||||||||||||||||
| 1439 | - | |||||||||||||||||||||||||||||||
| 1440 | if (echoMode() == QLineEdit::PasswordEchoOnEdit
| 0 | ||||||||||||||||||||||||||||||
| 1441 | && !passwordEchoEditing()
| 0 | ||||||||||||||||||||||||||||||
| 1442 | && !isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1443 | && !event->text().isEmpty()
| 0 | ||||||||||||||||||||||||||||||
| 1444 | - | |||||||||||||||||||||||||||||||
| 1445 | - | |||||||||||||||||||||||||||||||
| 1446 | - | |||||||||||||||||||||||||||||||
| 1447 | - | |||||||||||||||||||||||||||||||
| 1448 | - | |||||||||||||||||||||||||||||||
| 1449 | - | |||||||||||||||||||||||||||||||
| 1450 | && !(event->modifiers() & Qt::ControlModifier)
| 0 | ||||||||||||||||||||||||||||||
| 1451 | - | |||||||||||||||||||||||||||||||
| 1452 | - | |||||||||||||||||||||||||||||||
| 1453 | - | |||||||||||||||||||||||||||||||
| 1454 | - | |||||||||||||||||||||||||||||||
| 1455 | - | |||||||||||||||||||||||||||||||
| 1456 | updatePasswordEchoEditing(true); | - | ||||||||||||||||||||||||||||||
| 1457 | clear(); | - | ||||||||||||||||||||||||||||||
| 1458 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1459 | - | |||||||||||||||||||||||||||||||
| 1460 | bool unknown = false; | - | ||||||||||||||||||||||||||||||
| 1461 | bool visual = cursorMoveStyle() == Qt::VisualMoveStyle; | - | ||||||||||||||||||||||||||||||
| 1462 | - | |||||||||||||||||||||||||||||||
| 1463 | if (false) { dead code: { } | - | ||||||||||||||||||||||||||||||
| 1464 | } dead code: { } | - | ||||||||||||||||||||||||||||||
| 1465 | - | |||||||||||||||||||||||||||||||
| 1466 | else if (event == QKeySequence::Undo
| 0 | ||||||||||||||||||||||||||||||
| 1467 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1468 | undo(); never executed: undo(); | 0 | ||||||||||||||||||||||||||||||
| 1469 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1470 | else if (event == QKeySequence::Redo
| 0 | ||||||||||||||||||||||||||||||
| 1471 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1472 | redo(); never executed: redo(); | 0 | ||||||||||||||||||||||||||||||
| 1473 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1474 | else if (event == QKeySequence::SelectAll
| 0 | ||||||||||||||||||||||||||||||
| 1475 | selectAll(); | - | ||||||||||||||||||||||||||||||
| 1476 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1477 | - | |||||||||||||||||||||||||||||||
| 1478 | else if (event == QKeySequence::Copy
| 0 | ||||||||||||||||||||||||||||||
| 1479 | copy(); | - | ||||||||||||||||||||||||||||||
| 1480 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1481 | else if (event == QKeySequence::Paste
| 0 | ||||||||||||||||||||||||||||||
| 1482 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1483 | QClipboard::Mode mode = QClipboard::Clipboard; | - | ||||||||||||||||||||||||||||||
| 1484 | if (m_keyboardScheme == QPlatformTheme::X11KeyboardScheme
| 0 | ||||||||||||||||||||||||||||||
| 1485 | && event->modifiers() == (Qt::CTRL | Qt::SHIFT)
| 0 | ||||||||||||||||||||||||||||||
| 1486 | && event->key() == Qt::Key_Insert
| 0 | ||||||||||||||||||||||||||||||
| 1487 | mode = QClipboard::Selection; | - | ||||||||||||||||||||||||||||||
| 1488 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1489 | paste(mode); | - | ||||||||||||||||||||||||||||||
| 1490 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1491 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1492 | else if (event == QKeySequence::Cut
| 0 | ||||||||||||||||||||||||||||||
| 1493 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1494 | copy(); | - | ||||||||||||||||||||||||||||||
| 1495 | del(); | - | ||||||||||||||||||||||||||||||
| 1496 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1497 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1498 | else if (event == QKeySequence::DeleteEndOfLine
| 0 | ||||||||||||||||||||||||||||||
| 1499 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1500 | setSelection(cursor(), end()); | - | ||||||||||||||||||||||||||||||
| 1501 | copy(); | - | ||||||||||||||||||||||||||||||
| 1502 | del(); | - | ||||||||||||||||||||||||||||||
| 1503 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1504 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1505 | - | |||||||||||||||||||||||||||||||
| 1506 | else if (event == QKeySequence::MoveToStartOfLine
| 0 | ||||||||||||||||||||||||||||||
| 1507 | home(0); | - | ||||||||||||||||||||||||||||||
| 1508 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1509 | else if (event == QKeySequence::MoveToEndOfLine
| 0 | ||||||||||||||||||||||||||||||
| 1510 | end(0); | - | ||||||||||||||||||||||||||||||
| 1511 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1512 | else if (event == QKeySequence::SelectStartOfLine
| 0 | ||||||||||||||||||||||||||||||
| 1513 | home(1); | - | ||||||||||||||||||||||||||||||
| 1514 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1515 | else if (event == QKeySequence::SelectEndOfLine
| 0 | ||||||||||||||||||||||||||||||
| 1516 | end(1); | - | ||||||||||||||||||||||||||||||
| 1517 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1518 | else if (event == QKeySequence::MoveToNextChar
| 0 | ||||||||||||||||||||||||||||||
| 1519 | - | |||||||||||||||||||||||||||||||
| 1520 | - | |||||||||||||||||||||||||||||||
| 1521 | - | |||||||||||||||||||||||||||||||
| 1522 | const bool inlineCompletion = m_completer
| 0 | ||||||||||||||||||||||||||||||
| 1523 | - | |||||||||||||||||||||||||||||||
| 1524 | if (hasSelectedText()
| 0 | ||||||||||||||||||||||||||||||
| 1525 | && (m_keyboardScheme != QPlatformTheme::WindowsKeyboardScheme
| 0 | ||||||||||||||||||||||||||||||
| 1526 | || inlineCompletion
| 0 | ||||||||||||||||||||||||||||||
| 1527 | moveCursor(selectionEnd(), false); | - | ||||||||||||||||||||||||||||||
| 1528 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1529 | cursorForward(0, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1)); | - | ||||||||||||||||||||||||||||||
| 1530 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1531 | } | - | ||||||||||||||||||||||||||||||
| 1532 | else if (event == QKeySequence::SelectNextChar
| 0 | ||||||||||||||||||||||||||||||
| 1533 | cursorForward(1, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1)); | - | ||||||||||||||||||||||||||||||
| 1534 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1535 | else if (event == QKeySequence::MoveToPreviousChar
| 0 | ||||||||||||||||||||||||||||||
| 1536 | - | |||||||||||||||||||||||||||||||
| 1537 | - | |||||||||||||||||||||||||||||||
| 1538 | - | |||||||||||||||||||||||||||||||
| 1539 | const bool inlineCompletion = m_completer
| 0 | ||||||||||||||||||||||||||||||
| 1540 | - | |||||||||||||||||||||||||||||||
| 1541 | if (hasSelectedText()
| 0 | ||||||||||||||||||||||||||||||
| 1542 | && (m_keyboardScheme != QPlatformTheme::WindowsKeyboardScheme
| 0 | ||||||||||||||||||||||||||||||
| 1543 | || inlineCompletion
| 0 | ||||||||||||||||||||||||||||||
| 1544 | moveCursor(selectionStart(), false); | - | ||||||||||||||||||||||||||||||
| 1545 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1546 | cursorForward(0, visual ? -1 : (layoutDirection() == Qt::LeftToRight ? -1 : 1)); | - | ||||||||||||||||||||||||||||||
| 1547 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1548 | } | - | ||||||||||||||||||||||||||||||
| 1549 | else if (event == QKeySequence::SelectPreviousChar
| 0 | ||||||||||||||||||||||||||||||
| 1550 | cursorForward(1, visual ? -1 : (layoutDirection() == Qt::LeftToRight ? -1 : 1)); | - | ||||||||||||||||||||||||||||||
| 1551 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1552 | else if (event == QKeySequence::MoveToNextWord
| 0 | ||||||||||||||||||||||||||||||
| 1553 | if (echoMode() == QLineEdit::Normal
| 0 | ||||||||||||||||||||||||||||||
| 1554 | layoutDirection() == Qt::LeftToRight ? cursorWordForward(0) : cursorWordBackward(0); never executed: layoutDirection() == Qt::LeftToRight ? cursorWordForward(0) : cursorWordBackward(0); | 0 | ||||||||||||||||||||||||||||||
| 1555 | else | - | ||||||||||||||||||||||||||||||
| 1556 | layoutDirection() == Qt::LeftToRight ? end(0) : home(0); never executed: layoutDirection() == Qt::LeftToRight ? end(0) : home(0); | 0 | ||||||||||||||||||||||||||||||
| 1557 | } | - | ||||||||||||||||||||||||||||||
| 1558 | else if (event == QKeySequence::MoveToPreviousWord
| 0 | ||||||||||||||||||||||||||||||
| 1559 | if (echoMode() == QLineEdit::Normal
| 0 | ||||||||||||||||||||||||||||||
| 1560 | layoutDirection() == Qt::LeftToRight ? cursorWordBackward(0) : cursorWordForward(0); never executed: layoutDirection() == Qt::LeftToRight ? cursorWordBackward(0) : cursorWordForward(0); | 0 | ||||||||||||||||||||||||||||||
| 1561 | else if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1562 | layoutDirection() == Qt::LeftToRight ? home(0) : end(0); | - | ||||||||||||||||||||||||||||||
| 1563 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1564 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1565 | else if (event == QKeySequence::SelectNextWord
| 0 | ||||||||||||||||||||||||||||||
| 1566 | if (echoMode() == QLineEdit::Normal
| 0 | ||||||||||||||||||||||||||||||
| 1567 | layoutDirection() == Qt::LeftToRight ? cursorWordForward(1) : cursorWordBackward(1); never executed: layoutDirection() == Qt::LeftToRight ? cursorWordForward(1) : cursorWordBackward(1); | 0 | ||||||||||||||||||||||||||||||
| 1568 | else | - | ||||||||||||||||||||||||||||||
| 1569 | layoutDirection() == Qt::LeftToRight ? end(1) : home(1); never executed: layoutDirection() == Qt::LeftToRight ? end(1) : home(1); | 0 | ||||||||||||||||||||||||||||||
| 1570 | } | - | ||||||||||||||||||||||||||||||
| 1571 | else if (event == QKeySequence::SelectPreviousWord
| 0 | ||||||||||||||||||||||||||||||
| 1572 | if (echoMode() == QLineEdit::Normal
| 0 | ||||||||||||||||||||||||||||||
| 1573 | layoutDirection() == Qt::LeftToRight ? cursorWordBackward(1) : cursorWordForward(1); never executed: layoutDirection() == Qt::LeftToRight ? cursorWordBackward(1) : cursorWordForward(1); | 0 | ||||||||||||||||||||||||||||||
| 1574 | else | - | ||||||||||||||||||||||||||||||
| 1575 | layoutDirection() == Qt::LeftToRight ? home(1) : end(1); never executed: layoutDirection() == Qt::LeftToRight ? home(1) : end(1); | 0 | ||||||||||||||||||||||||||||||
| 1576 | } | - | ||||||||||||||||||||||||||||||
| 1577 | else if (event == QKeySequence::Delete
| 0 | ||||||||||||||||||||||||||||||
| 1578 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1579 | del(); never executed: del(); | 0 | ||||||||||||||||||||||||||||||
| 1580 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1581 | else if (event == QKeySequence::DeleteEndOfWord
| 0 | ||||||||||||||||||||||||||||||
| 1582 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1583 | cursorWordForward(true); | - | ||||||||||||||||||||||||||||||
| 1584 | del(); | - | ||||||||||||||||||||||||||||||
| 1585 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1586 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1587 | else if (event == QKeySequence::DeleteStartOfWord
| 0 | ||||||||||||||||||||||||||||||
| 1588 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1589 | cursorWordBackward(true); | - | ||||||||||||||||||||||||||||||
| 1590 | del(); | - | ||||||||||||||||||||||||||||||
| 1591 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1592 | } never executed: else if (event == QKeySequence::DeleteCompleteLineend of block
| 0 | ||||||||||||||||||||||||||||||
| 1593 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1594 | setSelection(0, text().size()); | - | ||||||||||||||||||||||||||||||
| 1595 | - | |||||||||||||||||||||||||||||||
| 1596 | copy(); | - | ||||||||||||||||||||||||||||||
| 1597 | - | |||||||||||||||||||||||||||||||
| 1598 | del(); | - | ||||||||||||||||||||||||||||||
| 1599 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1600 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1601 | - | |||||||||||||||||||||||||||||||
| 1602 | else { | - | ||||||||||||||||||||||||||||||
| 1603 | bool handled = false; | - | ||||||||||||||||||||||||||||||
| 1604 | if (m_keyboardScheme == QPlatformTheme::MacKeyboardScheme
| 0 | ||||||||||||||||||||||||||||||
| 1605 | && (event->key() == Qt::Key_Up
| 0 | ||||||||||||||||||||||||||||||
| 1606 | Qt::KeyboardModifiers myModifiers = (event->modifiers() & ~Qt::KeypadModifier); | - | ||||||||||||||||||||||||||||||
| 1607 | if (myModifiers & Qt::ShiftModifier
| 0 | ||||||||||||||||||||||||||||||
| 1608 | if (myModifiers == (Qt::ControlModifier|Qt::ShiftModifier)
| 0 | ||||||||||||||||||||||||||||||
| 1609 | || myModifiers == (Qt::AltModifier|Qt::ShiftModifier)
| 0 | ||||||||||||||||||||||||||||||
| 1610 | || myModifiers == Qt::ShiftModifier
| 0 | ||||||||||||||||||||||||||||||
| 1611 | - | |||||||||||||||||||||||||||||||
| 1612 | event->key() == Qt::Key_Up ? home(1) : end(1); | - | ||||||||||||||||||||||||||||||
| 1613 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1614 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1615 | if ((myModifiers == Qt::ControlModifier
| 0 | ||||||||||||||||||||||||||||||
| 1616 | || myModifiers == Qt::AltModifier
| 0 | ||||||||||||||||||||||||||||||
| 1617 | || myModifiers == Qt::NoModifier
| 0 | ||||||||||||||||||||||||||||||
| 1618 | event->key() == Qt::Key_Up ? home(0) : end(0); | - | ||||||||||||||||||||||||||||||
| 1619 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1620 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1621 | handled = true; | - | ||||||||||||||||||||||||||||||
| 1622 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1623 | if (event->modifiers() & Qt::ControlModifier
| 0 | ||||||||||||||||||||||||||||||
| 1624 | switch (event->key()) { | - | ||||||||||||||||||||||||||||||
| 1625 | case never executed: Qt::Key_Backspace:case Qt::Key_Backspace:never executed: case Qt::Key_Backspace: | 0 | ||||||||||||||||||||||||||||||
| 1626 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1627 | cursorWordBackward(true); | - | ||||||||||||||||||||||||||||||
| 1628 | del(); | - | ||||||||||||||||||||||||||||||
| 1629 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1630 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1631 | - | |||||||||||||||||||||||||||||||
| 1632 | case never executed: Qt::Key_Up:case Qt::Key_Up:never executed: case Qt::Key_Up: | 0 | ||||||||||||||||||||||||||||||
| 1633 | case never executed: Qt::Key_Down:case Qt::Key_Down:never executed: case Qt::Key_Down: | 0 | ||||||||||||||||||||||||||||||
| 1634 | complete(event->key()); | - | ||||||||||||||||||||||||||||||
| 1635 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1636 | - | |||||||||||||||||||||||||||||||
| 1637 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 1638 | if (!handled
| 0 | ||||||||||||||||||||||||||||||
| 1639 | unknown = true; never executed: unknown = true; | 0 | ||||||||||||||||||||||||||||||
| 1640 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1641 | } else { | - | ||||||||||||||||||||||||||||||
| 1642 | switch (event->key()) { | - | ||||||||||||||||||||||||||||||
| 1643 | case never executed: Qt::Key_Backspace:case Qt::Key_Backspace:never executed: case Qt::Key_Backspace: | 0 | ||||||||||||||||||||||||||||||
| 1644 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||||||||
| 1645 | backspace(); | - | ||||||||||||||||||||||||||||||
| 1646 | - | |||||||||||||||||||||||||||||||
| 1647 | complete(Qt::Key_Backspace); | - | ||||||||||||||||||||||||||||||
| 1648 | - | |||||||||||||||||||||||||||||||
| 1649 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1650 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1651 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 1652 | if (!handled
| 0 | ||||||||||||||||||||||||||||||
| 1653 | unknown = true; never executed: unknown = true; | 0 | ||||||||||||||||||||||||||||||
| 1654 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1655 | } | - | ||||||||||||||||||||||||||||||
| 1656 | } | - | ||||||||||||||||||||||||||||||
| 1657 | - | |||||||||||||||||||||||||||||||
| 1658 | if (event->key() == Qt::Key_Direction_L
| 0 | ||||||||||||||||||||||||||||||
| 1659 | setLayoutDirection((event->key() == Qt::Key_Direction_L) ? Qt::LeftToRight : Qt::RightToLeft); | - | ||||||||||||||||||||||||||||||
| 1660 | unknown = false; | - | ||||||||||||||||||||||||||||||
| 1661 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1662 | - | |||||||||||||||||||||||||||||||
| 1663 | - | |||||||||||||||||||||||||||||||
| 1664 | if (unknown
| 0 | ||||||||||||||||||||||||||||||
| 1665 | && isAcceptableInput(event->modifiers() != Qt::ControlModifier
| 0 | ||||||||||||||||||||||||||||||
| 1666 | && event->modifiers() != (Qt::ControlModifier | Qt::ShiftModifier)
| 0 | ||||||||||||||||||||||||||||||
| 1667 | insert(QString t = event->text());(); | - | ||||||||||||||||||||||||||||||
| 1668 | if (!t.isEmpty()
| 0 | ||||||||||||||||||||||||||||||
| 1669 | insert(t); | - | ||||||||||||||||||||||||||||||
| 1670 | - | |||||||||||||||||||||||||||||||
| 1671 | complete(event->key()); | - | ||||||||||||||||||||||||||||||
| 1672 | - | |||||||||||||||||||||||||||||||
| 1673 | event->accept(); | - | ||||||||||||||||||||||||||||||
| 1674 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1675 | } | - | ||||||||||||||||||||||||||||||
| 1676 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1677 | - | |||||||||||||||||||||||||||||||
| 1678 | if (unknown
| 0 | ||||||||||||||||||||||||||||||
| 1679 | event->ignore(); never executed: event->ignore(); | 0 | ||||||||||||||||||||||||||||||
| 1680 | else | - | ||||||||||||||||||||||||||||||
| 1681 | event->accept(); never executed: event->accept(); | 0 | ||||||||||||||||||||||||||||||
| 1682 | } | - | ||||||||||||||||||||||||||||||
| 1683 | - | |||||||||||||||||||||||||||||||
| 1684 | bool QWidgetLineControl::isUndoAvailable() const | - | ||||||||||||||||||||||||||||||
| 1685 | { | - | ||||||||||||||||||||||||||||||
| 1686 | - | |||||||||||||||||||||||||||||||
| 1687 | - | |||||||||||||||||||||||||||||||
| 1688 | return !m_readOnly && m_undoState | - | ||||||||||||||||||||||||||||||
| 1689 | && (m_echoMode == QLineEdit::Normal || m_history[m_undoState - 1].type == QWidgetLineControl::Insert); | - | ||||||||||||||||||||||||||||||
| 1690 | } | - | ||||||||||||||||||||||||||||||
| 1691 | - | |||||||||||||||||||||||||||||||
| 1692 | bool QWidgetLineControl::isRedoAvailable() const | - | ||||||||||||||||||||||||||||||
| 1693 | { | - | ||||||||||||||||||||||||||||||
| 1694 | - | |||||||||||||||||||||||||||||||
| 1695 | return !m_readOnly | - | ||||||||||||||||||||||||||||||
| 1696 | && m_echoMode == QLineEdit::Normal | - | ||||||||||||||||||||||||||||||
| 1697 | && m_undoState < int(m_history.size()); | - | ||||||||||||||||||||||||||||||
| 1698 | } | - | ||||||||||||||||||||||||||||||
| 1699 | - | |||||||||||||||||||||||||||||||
| 1700 | - | |||||||||||||||||||||||||||||||
| 1701 | - | |||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |