summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-02-11 19:21:40 +0100
committerSean Harmer <sean.harmer@kdab.com>2015-02-13 13:18:50 +0000
commit664b73dd36de6205cc84a219f936dd744a2dc184 (patch)
treee20915fb559ee380d794da2cb5294f4b6c0a18dc /src/core
parent4ec502a7f8daf6560b0399106d0ceed91011e83c (diff)
Make mesh source url resolving compatible with Quick
The ideal way would be to call the function from QQmlFile but that would need a dependency on the qml module. So just copy the function in. Change-Id: If34d8a2356bbe87b2a011c1c25a79a3f24ebb1ab Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/io/io.pri6
-rw-r--r--src/core/io/qurlhelper.cpp64
-rw-r--r--src/core/io/qurlhelper_p.h57
3 files changed, 125 insertions, 2 deletions
diff --git a/src/core/io/io.pri b/src/core/io/io.pri
index 8513810dc..c56bdae2e 100644
--- a/src/core/io/io.pri
+++ b/src/core/io/io.pri
@@ -2,10 +2,12 @@ HEADERS += \
$$PWD/qabstractbuffer.h \
$$PWD/qabstractattribute.h \
$$PWD/qabstractattribute_p.h \
- $$PWD/qabstractbuffer_p.h
+ $$PWD/qabstractbuffer_p.h \
+ $$PWD/qurlhelper_p.h
SOURCES += \
$$PWD/qabstractbuffer.cpp \
- $$PWD/qabstractattribute.cpp
+ $$PWD/qabstractattribute.cpp \
+ $$PWD/qurlhelper.cpp
INCLUDEPATH += $$PWD
diff --git a/src/core/io/qurlhelper.cpp b/src/core/io/qurlhelper.cpp
new file mode 100644
index 000000000..6cc73ac94
--- /dev/null
+++ b/src/core/io/qurlhelper.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qurlhelper_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+QString QUrlHelper::urlToLocalFileOrQrc(const QUrl &url)
+{
+ if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) {
+ if (url.authority().isEmpty())
+ return QLatin1Char(':') + url.path();
+ return QString();
+ }
+
+#if defined(Q_OS_ANDROID)
+ else if (url.scheme().compare(QLatin1String("assets"), Qt::CaseInsensitive) == 0) {
+ if (url.authority().isEmpty())
+ return url.toString();
+ return QString();
+ }
+#endif
+
+ return url.toLocalFile();
+}
+
+} // Qt3D
+
+QT_END_NAMESPACE
diff --git a/src/core/io/qurlhelper_p.h b/src/core/io/qurlhelper_p.h
new file mode 100644
index 000000000..4fd298ccc
--- /dev/null
+++ b/src/core/io/qurlhelper_p.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_QURLHELPER_P_H
+#define QT3D_QURLHELPER_P_H
+
+#include <Qt3DCore/qt3dcore_global.h>
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QT3DCORESHARED_EXPORT QUrlHelper
+{
+public:
+ static QString urlToLocalFileOrQrc(const QUrl &url);
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_QURLHELPER_P_H