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:
parent
fed4d6d78d
commit
cb8eb0f86c
@ -53,7 +53,6 @@
|
|||||||
#include <QtGui/private/qcoregraphics_p.h>
|
#include <QtGui/private/qcoregraphics_p.h>
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QRegExp>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
@ -47,7 +47,13 @@
|
|||||||
#include <qpa/qplatformscreen.h>
|
#include <qpa/qplatformscreen.h>
|
||||||
#include <qpa/qwindowsysteminterface.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)
|
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
|
// 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.
|
// 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
|
- (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
|
// 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.
|
// 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
|
@end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user