diff options
Diffstat (limited to 'src/quick/items/qquicktextinput.cpp')
-rw-r--r-- | src/quick/items/qquicktextinput.cpp | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index b3c7da1e3e..27f3dcecfa 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -1994,7 +1994,7 @@ bool QQuickTextInput::isRightToLeft(int start, int end) qmlInfo(this) << "isRightToLeft(start, end) called with the end property being smaller than the start."; return false; } else { - return text().mid(start, end - start).isRightToLeft(); + return text().midRef(start, end - start).isRightToLeft(); } } @@ -2846,7 +2846,7 @@ void QQuickTextInputPrivate::updateDisplayText(bool forceUpdate) // drawing boxes when using fonts that don't have glyphs for such // characters) QChar* uc = str.data(); - for (int i = 0; i < (int)str.length(); ++i) { + for (int i = 0; i < str.length(); ++i) { if ((uc[i].unicode() < 0x20 && uc[i] != QChar::Tabulation) || uc[i] == QChar::LineSeparator || uc[i] == QChar::ParagraphSeparator @@ -3232,7 +3232,7 @@ void QQuickTextInputPrivate::setSelection(int start, int length) commitPreedit(); #endif - if (start < 0 || start > (int)m_text.length()){ + if (start < 0 || start > m_text.length()) { qWarning("QQuickTextInputPrivate::setSelection: Invalid start position"); return; } @@ -3241,7 +3241,7 @@ void QQuickTextInputPrivate::setSelection(int start, int length) if (start == m_selstart && start + length == m_selend && m_cursor == m_selend) return; m_selstart = start; - m_selend = qMin(start + length, (int)m_text.length()); + m_selend = qMin(start + length, m_text.length()); m_cursor = m_selend; } else if (length < 0){ if (start == m_selend && start + length == m_selstart && m_cursor == m_selstart) @@ -3679,7 +3679,7 @@ void QQuickTextInputPrivate::internalInsert(const QString &s) Q_ASSERT(!hasSelectedText()); // insert(), processInputMethodEvent() call removeSelectedText() first. if (m_maskData) { QString ms = maskString(m_cursor, s); - for (int i = 0; i < (int) ms.length(); ++i) { + for (int i = 0; i < ms.length(); ++i) { addCommand (Command(DeleteSelection, m_cursor + i, m_text.at(m_cursor + i), -1, -1)); addCommand(Command(Insert, m_cursor + i, ms.at(i), -1, -1)); } @@ -3690,9 +3690,10 @@ void QQuickTextInputPrivate::internalInsert(const QString &s) } else { int remaining = m_maxLength - m_text.length(); if (remaining != 0) { - m_text.insert(m_cursor, s.left(remaining)); - for (int i = 0; i < (int) s.leftRef(remaining).length(); ++i) - addCommand(Command(Insert, m_cursor++, s.at(i), -1, -1)); + const QStringRef remainingStr = s.leftRef(remaining); + m_text.insert(m_cursor, remainingStr); + for (auto e : remainingStr) + addCommand(Command(Insert, m_cursor++, e, -1, -1)); m_textDirty = true; } } @@ -3711,7 +3712,7 @@ void QQuickTextInputPrivate::internalInsert(const QString &s) */ void QQuickTextInputPrivate::internalDelete(bool wasBackspace) { - if (m_cursor < (int) m_text.length()) { + if (m_cursor < m_text.length()) { cancelPasswordEchoTimer(); Q_ASSERT(!hasSelectedText()); // del(), backspace() call removeSelectedText() first. addCommand(Command((CommandType)((m_maskData ? 2 : 0) + (wasBackspace ? Remove : Delete)), @@ -3737,7 +3738,7 @@ void QQuickTextInputPrivate::internalDelete(bool wasBackspace) */ void QQuickTextInputPrivate::removeSelectedText() { - if (m_selstart < m_selend && m_selend <= (int) m_text.length()) { + if (m_selstart < m_selend && m_selend <= m_text.length()) { cancelPasswordEchoTimer(); int i ; if (m_selstart <= m_cursor && m_cursor < m_selend) { @@ -4023,44 +4024,44 @@ QString QQuickTextInputPrivate::maskString(uint pos, const QString &str, bool cl if (strIndex < str.length()) { if (m_maskData[i].separator) { s += m_maskData[i].maskChar; - if (str[(int)strIndex] == m_maskData[i].maskChar) + if (str[strIndex] == m_maskData[i].maskChar) strIndex++; ++i; } else { - if (isValidInput(str[(int)strIndex], m_maskData[i].maskChar)) { + if (isValidInput(str[strIndex], m_maskData[i].maskChar)) { switch (m_maskData[i].caseMode) { case MaskInputData::Upper: - s += str[(int)strIndex].toUpper(); + s += str[strIndex].toUpper(); break; case MaskInputData::Lower: - s += str[(int)strIndex].toLower(); + s += str[strIndex].toLower(); break; default: - s += str[(int)strIndex]; + s += str[strIndex]; } ++i; } else { // search for separator first - int n = findInMask(i, true, true, str[(int)strIndex]); + int n = findInMask(i, true, true, str[strIndex]); if (n != -1) { - if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[(int)strIndex]))) { + if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[strIndex]))) { s += fill.midRef(i, n-i+1); i = n + 1; // update i to find + 1 } } else { // search for valid m_blank if not - n = findInMask(i, true, false, str[(int)strIndex]); + n = findInMask(i, true, false, str[strIndex]); if (n != -1) { s += fill.midRef(i, n-i); switch (m_maskData[n].caseMode) { case MaskInputData::Upper: - s += str[(int)strIndex].toUpper(); + s += str[strIndex].toUpper(); break; case MaskInputData::Lower: - s += str[(int)strIndex].toLower(); + s += str[strIndex].toLower(); break; default: - s += str[(int)strIndex]; + s += str[strIndex]; } i = n + 1; // updates i to find + 1 } @@ -4111,7 +4112,7 @@ QString QQuickTextInputPrivate::stripString(const QString &str) const return str; QString s; - int end = qMin(m_maxLength, (int)str.length()); + int end = qMin(m_maxLength, str.length()); for (int i = 0; i < end; ++i) { if (m_maskData[i].separator) s += m_maskData[i].maskChar; @@ -4201,7 +4202,7 @@ void QQuickTextInputPrivate::internalRedo() if (!isRedoAvailable()) return; internalDeselect(); - while (m_undoState < (int)m_history.size()) { + while (m_undoState < m_history.size()) { Command& cmd = m_history[m_undoState++]; switch (cmd.type) { case Insert: @@ -4228,7 +4229,7 @@ void QQuickTextInputPrivate::internalRedo() m_cursor = cmd.pos; break; } - if (m_undoState < (int)m_history.size()) { + if (m_undoState < m_history.size()) { Command& next = m_history[m_undoState]; if (next.type != cmd.type && cmd.type < RemoveSelection |