Get rid of QRegExp usage in the cocoa plugin

Change-Id: I9789e1637a17809082458e946fa7c49ab9269537
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Lars Knoll 2020-03-15 14:35:41 +01:00
parent fed4d6d78d
commit cb8eb0f86c
2 changed files with 9 additions and 4 deletions

View File

@ -53,7 +53,6 @@
#include <QtGui/private/qcoregraphics_p.h>
#include <QtCore/QDebug>
#include <QtCore/QRegExp>
QT_BEGIN_NAMESPACE

View File

@ -47,7 +47,13 @@
#include <qpa/qplatformscreen.h>
#include <qpa/qwindowsysteminterface.h>
static QRegExp whitespaceRegex = QRegExp(QStringLiteral("\\s*"));
static inline bool isWhiteSpace(const QString &s)
{
for (int i = 0; i < s.size(); ++i)
if (!s.at(i).isSpace())
return false;
return true;
}
static QCocoaWindow *toPlatformWindow(NSWindow *window)
{
@ -113,7 +119,7 @@ static QCocoaWindow *toPlatformWindow(NSWindow *window)
// Only pop up document path if the filename is non-empty. We allow whitespace, to
// allow faking a window icon by setting the file path to a single space character.
return !whitespaceRegex.exactMatch(platformWindow->window()->filePath());
return !isWhiteSpace(platformWindow->window()->filePath());
}
- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard
@ -127,6 +133,6 @@ static QCocoaWindow *toPlatformWindow(NSWindow *window)
// Only allow drag if the filename is non-empty. We allow whitespace, to
// allow faking a window icon by setting the file path to a single space.
return !whitespaceRegex.exactMatch(platformWindow->window()->filePath());
return !isWhiteSpace(platformWindow->window()->filePath());
}
@end