From 9887f32df91c579f5e891d16d9be9d9e3b8c4e17 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 2 May 2021 01:10:13 +0200 Subject: QAbstractItemModel::match: code tidies Remove a magic number from the code, by adding it (as a private value) to the right enumeration. Use toInt() to convert to integer. Change-Id: Id1b00dde900619684b5a3df247d46938439150ca Reviewed-by: Thiago Macieira --- src/corelib/global/qnamespace.h | 1 + src/corelib/global/qnamespace.qdoc | 1 + src/corelib/itemmodels/qabstractitemmodel.cpp | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index f678c81c6b..6555e7c4f4 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1547,6 +1547,7 @@ namespace Qt { MatchRegularExpression = 4, MatchWildcard = 5, MatchFixedString = 8, + MatchTypeMask = 0x0F, MatchCaseSensitive = 16, MatchWrap = 32, MatchRecursive = 64 diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 411ee30424..1452c8eea8 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2838,6 +2838,7 @@ the search reaches the last item in the model, it begins again at the first item and continues until all items have been examined. \value MatchRecursive Searches the entire hierarchy. + \omitvalue MatchTypeMask \sa QString::compare(), QRegularExpression */ diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 8da33e0c4e..ca04eb6a31 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -2533,7 +2533,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, Qt::MatchFlags flags) const { QModelIndexList result; - uint matchType = flags & 0x0F; + uint matchType = (flags & Qt::MatchTypeMask).toInt(); Qt::CaseSensitivity cs = flags & Qt::MatchCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive; bool recurse = flags & Qt::MatchRecursive; bool wrap = flags & Qt::MatchWrap; -- cgit v1.2.3