Port mimetypes away from QStringRef
Task-number: QTBUG-84319 Change-Id: I2bed1149df7f11495fd9dc3577828c0790b17dab Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
This commit is contained in:
parent
ecacb3c62f
commit
82a0f4a193
@ -250,7 +250,7 @@ void QMimeDatabasePrivate::loadIcon(QMimeTypePrivate &mimePrivate)
|
|||||||
|
|
||||||
static QString fallbackParent(const QString &mimeTypeName)
|
static QString fallbackParent(const QString &mimeTypeName)
|
||||||
{
|
{
|
||||||
const QStringRef myGroup = mimeTypeName.leftRef(mimeTypeName.indexOf(QLatin1Char('/')));
|
const QStringView myGroup = QStringView{mimeTypeName}.left(mimeTypeName.indexOf(QLatin1Char('/')));
|
||||||
// All text/* types are subclasses of text/plain.
|
// All text/* types are subclasses of text/plain.
|
||||||
if (myGroup == QLatin1String("text") && mimeTypeName != QLatin1String("text/plain"))
|
if (myGroup == QLatin1String("text") && mimeTypeName != QLatin1String("text/plain"))
|
||||||
return QLatin1String("text/plain");
|
return QLatin1String("text/plain");
|
||||||
|
@ -128,7 +128,7 @@ bool QMimeGlobPattern::matchFileName(const QString &inputFilename) const
|
|||||||
if (starCount == 1 && m_pattern.at(pattern_len - 1) == QLatin1Char('*')) {
|
if (starCount == 1 && m_pattern.at(pattern_len - 1) == QLatin1Char('*')) {
|
||||||
if (len + 1 < pattern_len) return false;
|
if (len + 1 < pattern_len) return false;
|
||||||
if (m_pattern.at(0) == QLatin1Char('*'))
|
if (m_pattern.at(0) == QLatin1Char('*'))
|
||||||
return filename.indexOf(m_pattern.midRef(1, pattern_len - 2)) != -1;
|
return filename.indexOf(QStringView{m_pattern}.mid(1, pattern_len - 2)) != -1;
|
||||||
|
|
||||||
const QChar *c1 = m_pattern.unicode();
|
const QChar *c1 = m_pattern.unicode();
|
||||||
const QChar *c2 = filename.unicode();
|
const QChar *c2 = filename.unicode();
|
||||||
|
@ -236,8 +236,8 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
|
|||||||
|
|
||||||
// Parse for offset as "1" or "1:10"
|
// Parse for offset as "1" or "1:10"
|
||||||
const int colonIndex = offsets.indexOf(QLatin1Char(':'));
|
const int colonIndex = offsets.indexOf(QLatin1Char(':'));
|
||||||
const QStringRef startPosStr = offsets.midRef(0, colonIndex); // \ These decay to returning 'offsets'
|
const QStringView startPosStr = QStringView{offsets}.mid(0, colonIndex); // \ These decay to returning 'offsets'
|
||||||
const QStringRef endPosStr = offsets.midRef(colonIndex + 1);// / unchanged when colonIndex == -1
|
const QStringView endPosStr = QStringView{offsets}.mid(colonIndex + 1);// / unchanged when colonIndex == -1
|
||||||
if (Q_UNLIKELY(!QMimeTypeParserBase::parseNumber(startPosStr, &m_startPos, errorString)) ||
|
if (Q_UNLIKELY(!QMimeTypeParserBase::parseNumber(startPosStr, &m_startPos, errorString)) ||
|
||||||
Q_UNLIKELY(!QMimeTypeParserBase::parseNumber(endPosStr, &m_endPos, errorString))) {
|
Q_UNLIKELY(!QMimeTypeParserBase::parseNumber(endPosStr, &m_endPos, errorString))) {
|
||||||
m_type = Invalid;
|
m_type = Invalid;
|
||||||
|
@ -306,7 +306,7 @@ bool QMimeBinaryProvider::matchSuffixTree(QMimeGlobMatchResult &result, QMimeBin
|
|||||||
const bool caseSensitive = flagsAndWeight & 0x100;
|
const bool caseSensitive = flagsAndWeight & 0x100;
|
||||||
if (caseSensitiveCheck || !caseSensitive) {
|
if (caseSensitiveCheck || !caseSensitive) {
|
||||||
result.addMatch(QLatin1String(mimeType), weight,
|
result.addMatch(QLatin1String(mimeType), weight,
|
||||||
QLatin1Char('*') + fileName.midRef(charPos + 1), fileName.size() - charPos - 2);
|
QLatin1Char('*') + QStringView{fileName}.mid(charPos + 1), fileName.size() - charPos - 2);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ QString QMimeType::genericIconName() const
|
|||||||
// media type (e.g. "video" in "video/ogg") and appending "-x-generic"
|
// media type (e.g. "video" in "video/ogg") and appending "-x-generic"
|
||||||
// (i.e. "video-x-generic" in the previous example).
|
// (i.e. "video-x-generic" in the previous example).
|
||||||
const QString group = name();
|
const QString group = name();
|
||||||
QStringRef groupRef(&group);
|
QStringView groupRef(group);
|
||||||
const int slashindex = groupRef.indexOf(QLatin1Char('/'));
|
const int slashindex = groupRef.indexOf(QLatin1Char('/'));
|
||||||
if (slashindex != -1)
|
if (slashindex != -1)
|
||||||
groupRef = groupRef.left(slashindex);
|
groupRef = groupRef.left(slashindex);
|
||||||
|
@ -157,7 +157,7 @@ QMimeTypeParserBase::ParseState QMimeTypeParserBase::nextState(ParseState curren
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse int number from an (attribute) string
|
// Parse int number from an (attribute) string
|
||||||
bool QMimeTypeParserBase::parseNumber(const QStringRef &n, int *target, QString *errorMessage)
|
bool QMimeTypeParserBase::parseNumber(QStringView n, int *target, QString *errorMessage)
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
*target = n.toInt(&ok);
|
*target = n.toInt(&ok);
|
||||||
|
@ -72,7 +72,7 @@ public:
|
|||||||
|
|
||||||
bool parse(QIODevice *dev, const QString &fileName, QString *errorMessage);
|
bool parse(QIODevice *dev, const QString &fileName, QString *errorMessage);
|
||||||
|
|
||||||
static bool parseNumber(const QStringRef &n, int *target, QString *errorMessage);
|
static bool parseNumber(QStringView n, int *target, QString *errorMessage);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool process(const QMimeType &t, QString *errorMessage) = 0;
|
virtual bool process(const QMimeType &t, QString *errorMessage) = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user