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