From e91c41239166beb4b68a3f5523351e8dc3796857 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Wed, 6 Jul 2016 17:58:13 +0300 Subject: QStringRef: add chop() chop() was missing in the API. Change-Id: I15af86c8f218cf159b8ce19bbeb2ffa6201f98cf Reviewed-by: Edward Welbourne --- src/corelib/tools/qstring.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/corelib/tools/qstring.h') diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 0c0f3355a9..ec959b50a0 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1438,6 +1438,12 @@ public: QStringRef mid(int pos, int n = -1) const Q_REQUIRED_RESULT; void truncate(int pos) Q_DECL_NOTHROW { m_size = qBound(0, pos, m_size); } + void chop(int n) Q_DECL_NOTHROW { + if (n >= m_size) + m_size = 0; + else if (n > 0) + m_size -= n; + } bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; -- cgit v1.2.3