From 664b73dd36de6205cc84a219f936dd744a2dc184 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 11 Feb 2015 19:21:40 +0100 Subject: 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 --- src/core/io/io.pri | 6 +++-- src/core/io/qurlhelper.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++ src/core/io/qurlhelper_p.h | 57 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 src/core/io/qurlhelper.cpp create mode 100644 src/core/io/qurlhelper_p.h (limited to 'src/core') 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 +#include + +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 -- cgit v1.2.3