summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/sceneformats/assimp/ai_plugin.cpp (renamed from src/plugins/sceneformats/assimp/main.cpp)50
-rw-r--r--src/plugins/sceneformats/assimp/ai_plugin.h62
-rw-r--r--src/plugins/sceneformats/assimp/ai_scene_plugin.json53
-rw-r--r--src/plugins/sceneformats/assimp/assimp.pro17
-rw-r--r--src/plugins/sceneformats/bezier/bezier.pro15
-rw-r--r--src/plugins/sceneformats/bezier/bezier_plugin.cpp (renamed from src/plugins/sceneformats/bezier/main.cpp)20
-rw-r--r--src/plugins/sceneformats/bezier/bezier_plugin.h62
-rw-r--r--src/plugins/sceneformats/bezier/bezier_scene_plugin.json6
-rw-r--r--src/plugins/sceneformats/obj/obj.pro15
-rw-r--r--src/plugins/sceneformats/obj/obj_plugin.cpp (renamed from src/plugins/sceneformats/obj/main.cpp)26
-rw-r--r--src/plugins/sceneformats/obj/obj_plugin.h62
-rw-r--r--src/plugins/sceneformats/obj/obj_scene_plugin.json5
-rw-r--r--src/plugins/sceneformats/obj/qglobjscenehandler.cpp1
-rw-r--r--src/plugins/sceneformats/obj/qglobjscenehandler.h2
-rw-r--r--src/threed/scene/qglabstractscene.cpp71
-rw-r--r--src/threed/scene/qglabstractscene.h5
-rw-r--r--src/threed/scene/qglsceneformatplugin.cpp54
-rw-r--r--src/threed/scene/qglsceneformatplugin.h19
18 files changed, 337 insertions, 208 deletions
diff --git a/src/plugins/sceneformats/assimp/main.cpp b/src/plugins/sceneformats/assimp/ai_plugin.cpp
index e9724a6da..9e1dbd6be 100644
--- a/src/plugins/sceneformats/assimp/main.cpp
+++ b/src/plugins/sceneformats/assimp/ai_plugin.cpp
@@ -39,52 +39,13 @@
**
****************************************************************************/
-#include "qglsceneformatplugin.h"
+#include "ai_plugin.h"
#include "qaiscenehandler.h"
-#include "assimp.hpp"
-
-#include <QtCore/qmap.h>
-#include <QtCore/qdebug.h>
-
QT_BEGIN_NAMESPACE
-class QAiScenePlugin : public QGLSceneFormatPlugin
-{
-public:
- QStringList keys() const;
- virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const;
-};
-
-QStringList QAiScenePlugin::keys() const
-{
- static QMultiMap<QString, QString> mimetypes;
- if (mimetypes.size() == 0)
- {
- mimetypes.insertMulti("3ds", "application/x-3ds");
- mimetypes.insertMulti("3ds", "image/x-3ds");
- mimetypes.insertMulti("dae", "model/x3d+binary");
- mimetypes.insertMulti("dxf", "application/x-dxf");
- }
- QStringList result;
- Assimp::Importer importer;
- aiString extns;
- importer.GetExtensionList(extns);
- QString qextns = QString::fromUtf8(extns.data, extns.length);
- QStringList extnList = qextns.split(';');
- for (int i = 0; i < extnList.size(); ++i)
- {
- QString xt = extnList.at(i);
- xt = xt.simplified();
- if (xt.startsWith(QLatin1String("*.")))
- xt = xt.mid(2);
- result << xt;
- QMap<QString, QString>::const_iterator it = mimetypes.constFind(xt);
- for ( ; it != mimetypes.constEnd(); ++it)
- result << it.value();
- }
- return result;
-}
+QAiScenePlugin::QAiScenePlugin() {}
+QAiScenePlugin::~QAiScenePlugin() {}
QGLSceneFormatHandler *QAiScenePlugin::create(QIODevice *device, const QUrl& url, const QString &format) const
{
@@ -94,7 +55,6 @@ QGLSceneFormatHandler *QAiScenePlugin::create(QIODevice *device, const QUrl& url
return new QAiSceneHandler;
}
-Q_EXPORT_STATIC_PLUGIN(QAiScenePlugin)
-Q_EXPORT_PLUGIN2(qsceneai, QAiScenePlugin)
-
QT_END_NAMESPACE
+
+
diff --git a/src/plugins/sceneformats/assimp/ai_plugin.h b/src/plugins/sceneformats/assimp/ai_plugin.h
new file mode 100644
index 000000000..ea0696785
--- /dev/null
+++ b/src/plugins/sceneformats/assimp/ai_plugin.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 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 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef AI_PLUGIN_H
+#define AI_PLUGIN_H
+
+#include "qglsceneformatplugin.h"
+
+QT_BEGIN_NAMESPACE
+
+class QAiScenePlugin : public QObject, public QGLSceneFormatFactoryInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QGLSceneFormatFactoryInterface)
+ Q_PLUGIN_METADATA(IID "com.trolltech.Qt.QGLSceneFormatFactoryInterface" FILE "ai_scene_plugin.json")
+public:
+ QAiScenePlugin();
+ ~QAiScenePlugin();
+ virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const;
+};
+
+QT_END_NAMESPACE
+
+#endif // AI_PLUGIN_H
diff --git a/src/plugins/sceneformats/assimp/ai_scene_plugin.json b/src/plugins/sceneformats/assimp/ai_scene_plugin.json
new file mode 100644
index 000000000..a0c272e2b
--- /dev/null
+++ b/src/plugins/sceneformats/assimp/ai_scene_plugin.json
@@ -0,0 +1,53 @@
+{
+ "Keys": [
+ "3d",
+ "3ds",
+ "ac",
+ "ac3d",
+ "acc",
+ "ase",
+ "ask",
+ "b3d",
+ "blend",
+ "bvh",
+ "cob",
+ "csm",
+ "dae",
+ "dxf",
+ "enff",
+ "hmp",
+ "irr",
+ "irrmesh",
+ "lwo",
+ "lws",
+ "lxo",
+ "md2",
+ "md3",
+ "md5anim",
+ "md5camera",
+ "md5mesh",
+ "mdc",
+ "mdl",
+ "mesh.xml",
+ "mot",
+ "ms3d",
+ "ndo",
+ "nff",
+ "obj",
+ "off",
+ "pk3",
+ "ply",
+ "prj",
+ "q3o",
+ "q3s",
+ "raw",
+ "scn",
+ "smd",
+ "stl",
+ "ter",
+ "uc",
+ "vta",
+ "x",
+ "xml"
+ ]
+}
diff --git a/src/plugins/sceneformats/assimp/assimp.pro b/src/plugins/sceneformats/assimp/assimp.pro
index 39fbb5454..5a0fca51d 100644
--- a/src/plugins/sceneformats/assimp/assimp.pro
+++ b/src/plugins/sceneformats/assimp/assimp.pro
@@ -1,20 +1,29 @@
TARGET = qsceneai
+QT += 3d
+
+load(qt_plugin)
+
include(../../qpluginbase.pri)
HEADERS += qailoader.h \
qaiscene.h \
qaiscenehandler.h \
qaimesh.h \
ailoaderiostream.h \
- ailoaderiosystem.h
-SOURCES += main.cpp \
+ ailoaderiosystem.h \
+ ai_plugin.h
+SOURCES += \
qailoader.cpp \
qaiscene.cpp \
qaiscenehandler.cpp \
qaimesh.cpp \
ailoaderiostream.cpp \
- ailoaderiosystem.cpp
+ ailoaderiosystem.cpp \
+ ai_plugin.cpp
+
+OTHER_FILES += \
+ ai_scene_plugin.json
+
-QT += 3d
DESTDIR = $$QT.3d.plugins/sceneformats
target.path = $$[QT_INSTALL_PLUGINS]/sceneformats
diff --git a/src/plugins/sceneformats/bezier/bezier.pro b/src/plugins/sceneformats/bezier/bezier.pro
index 911dc60ef..870d6970c 100644
--- a/src/plugins/sceneformats/bezier/bezier.pro
+++ b/src/plugins/sceneformats/bezier/bezier.pro
@@ -1,13 +1,20 @@
TARGET = qscenebezier
+QT += 3d
+
+load(qt_plugin)
+
include(../../qpluginbase.pri)
HEADERS += qglbezierscene.h \
- qglbezierscenehandler.h
-SOURCES += main.cpp \
+ qglbezierscenehandler.h \
+ bezier_plugin.h
+SOURCES += \
qglbezierscene.cpp \
- qglbezierscenehandler.cpp
+ qglbezierscenehandler.cpp \
+ bezier_plugin.cpp
-QT += 3d
+OTHER_FILES += \
+ bezier_scene_plugin.json
DESTDIR = $$QT.3d.plugins/sceneformats
target.path = $$[QT_INSTALL_PLUGINS]/sceneformats
diff --git a/src/plugins/sceneformats/bezier/main.cpp b/src/plugins/sceneformats/bezier/bezier_plugin.cpp
index a56bc8653..91a81afe6 100644
--- a/src/plugins/sceneformats/bezier/main.cpp
+++ b/src/plugins/sceneformats/bezier/bezier_plugin.cpp
@@ -39,22 +39,13 @@
**
****************************************************************************/
-#include "qglsceneformatplugin.h"
+#include "bezier_plugin.h"
#include "qglbezierscenehandler.h"
QT_BEGIN_NAMESPACE
-class QGLBezierScenePlugin : public QGLSceneFormatPlugin
-{
-public:
- QStringList keys() const;
- virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const;
-};
-
-QStringList QGLBezierScenePlugin::keys() const
-{
- return QStringList() << QLatin1String("bezier") << QLatin1String("bez");
-}
+QGLBezierScenePlugin::QGLBezierScenePlugin() {}
+QGLBezierScenePlugin::~QGLBezierScenePlugin() {}
QGLSceneFormatHandler *QGLBezierScenePlugin::create(QIODevice *device, const QUrl& url, const QString &format) const
{
@@ -64,7 +55,6 @@ QGLSceneFormatHandler *QGLBezierScenePlugin::create(QIODevice *device, const QUr
return new QGLBezierSceneHandler;
}
-Q_EXPORT_STATIC_PLUGIN(QGLBezierScenePlugin)
-Q_EXPORT_PLUGIN2(qscenebezier, QGLBezierScenePlugin)
-
QT_END_NAMESPACE
+
+
diff --git a/src/plugins/sceneformats/bezier/bezier_plugin.h b/src/plugins/sceneformats/bezier/bezier_plugin.h
new file mode 100644
index 000000000..83b40b726
--- /dev/null
+++ b/src/plugins/sceneformats/bezier/bezier_plugin.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 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 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BEZIER_PLUGIN_H
+#define BEZIER_PLUGIN_H
+
+#include "qglsceneformatplugin.h"
+
+QT_BEGIN_NAMESPACE
+
+class QGLBezierScenePlugin : public QObject, public QGLSceneFormatFactoryInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QGLSceneFormatFactoryInterface)
+ Q_PLUGIN_METADATA(IID "com.trolltech.Qt.QGLSceneFormatFactoryInterface" FILE "bezier_scene_plugin.json")
+public:
+ QGLBezierScenePlugin();
+ ~QGLBezierScenePlugin();
+ virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const;
+};
+
+QT_END_NAMESPACE
+
+#endif // BEZIER_PLUGIN_H
diff --git a/src/plugins/sceneformats/bezier/bezier_scene_plugin.json b/src/plugins/sceneformats/bezier/bezier_scene_plugin.json
new file mode 100644
index 000000000..d91418547
--- /dev/null
+++ b/src/plugins/sceneformats/bezier/bezier_scene_plugin.json
@@ -0,0 +1,6 @@
+{
+ "Keys": [
+ "bezier",
+ "bez"
+ ]
+}
diff --git a/src/plugins/sceneformats/obj/obj.pro b/src/plugins/sceneformats/obj/obj.pro
index c20cc91f3..73bd0e8ec 100644
--- a/src/plugins/sceneformats/obj/obj.pro
+++ b/src/plugins/sceneformats/obj/obj.pro
@@ -1,13 +1,20 @@
TARGET = qsceneobj
+QT += 3d
+
+load(qt_plugin)
+
include(../../qpluginbase.pri)
HEADERS += qglobjscene.h \
- qglobjscenehandler.h
-SOURCES += main.cpp \
+ qglobjscenehandler.h \
+ obj_plugin.h
+SOURCES += \
qglobjscene.cpp \
- qglobjscenehandler.cpp
+ qglobjscenehandler.cpp \
+ obj_plugin.cpp
-QT += 3d
+OTHER_FILES += \
+ obj_scene_plugin.json
DESTDIR = $$QT.3d.plugins/sceneformats
target.path = $$[QT_INSTALL_PLUGINS]/sceneformats
diff --git a/src/plugins/sceneformats/obj/main.cpp b/src/plugins/sceneformats/obj/obj_plugin.cpp
index 46ed0b3f2..ae88ae374 100644
--- a/src/plugins/sceneformats/obj/main.cpp
+++ b/src/plugins/sceneformats/obj/obj_plugin.cpp
@@ -39,28 +39,14 @@
**
****************************************************************************/
-#include "qglsceneformatplugin.h"
+#include "obj_plugin.h"
#include "qglobjscenehandler.h"
QT_BEGIN_NAMESPACE
-//! [1]
-class QGLObjScenePlugin : public QGLSceneFormatPlugin
-{
-public:
- QStringList keys() const;
- virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const;
-};
-//! [1]
+QGLObjScenePlugin::QGLObjScenePlugin() {}
+QGLObjScenePlugin::~QGLObjScenePlugin() {}
-//! [2]
-QStringList QGLObjScenePlugin::keys() const
-{
- return QStringList() << QLatin1String("obj") << QLatin1String("model/obj");
-}
-//! [2]
-
-//! [3]
QGLSceneFormatHandler *QGLObjScenePlugin::create(QIODevice *device, const QUrl& url, const QString &format) const
{
Q_UNUSED(device);
@@ -68,11 +54,5 @@ QGLSceneFormatHandler *QGLObjScenePlugin::create(QIODevice *device, const QUrl&
Q_UNUSED(format);
return new QGLObjSceneHandler;
}
-//! [3]
-
-//! [4]
-Q_EXPORT_STATIC_PLUGIN(QGLObjScenePlugin)
-Q_EXPORT_PLUGIN2(qsceneobj, QGLObjScenePlugin)
-//! [4]
QT_END_NAMESPACE
diff --git a/src/plugins/sceneformats/obj/obj_plugin.h b/src/plugins/sceneformats/obj/obj_plugin.h
new file mode 100644
index 000000000..de9283a23
--- /dev/null
+++ b/src/plugins/sceneformats/obj/obj_plugin.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 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 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OBJ_PLUGIN_H
+#define OBJ_PLUGIN_H
+
+#include "qglsceneformatplugin.h"
+
+QT_BEGIN_NAMESPACE
+
+class QGLObjScenePlugin : public QObject, public QGLSceneFormatFactoryInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QGLSceneFormatFactoryInterface)
+ Q_PLUGIN_METADATA(IID "com.trolltech.Qt.QGLSceneFormatFactoryInterface" FILE "obj_scene_plugin.json")
+public:
+ QGLObjScenePlugin();
+ ~QGLObjScenePlugin();
+ virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format) const;
+};
+
+QT_END_NAMESPACE
+
+#endif // OBJ_PLUGIN_H
diff --git a/src/plugins/sceneformats/obj/obj_scene_plugin.json b/src/plugins/sceneformats/obj/obj_scene_plugin.json
new file mode 100644
index 000000000..b33d38205
--- /dev/null
+++ b/src/plugins/sceneformats/obj/obj_scene_plugin.json
@@ -0,0 +1,5 @@
+{
+ "Keys": [
+ "obj"
+ ]
+}
diff --git a/src/plugins/sceneformats/obj/qglobjscenehandler.cpp b/src/plugins/sceneformats/obj/qglobjscenehandler.cpp
index 9568be6d3..6ae0b7872 100644
--- a/src/plugins/sceneformats/obj/qglobjscenehandler.cpp
+++ b/src/plugins/sceneformats/obj/qglobjscenehandler.cpp
@@ -53,7 +53,6 @@ QT_BEGIN_NAMESPACE
QGLObjSceneHandler::QGLObjSceneHandler()
: QGLSceneFormatHandler()
- , palette(0)
, smoothing(QGL::Faceted)
, smoothingForced(false)
{
diff --git a/src/plugins/sceneformats/obj/qglobjscenehandler.h b/src/plugins/sceneformats/obj/qglobjscenehandler.h
index b55d29d1b..1cfd5551f 100644
--- a/src/plugins/sceneformats/obj/qglobjscenehandler.h
+++ b/src/plugins/sceneformats/obj/qglobjscenehandler.h
@@ -63,7 +63,7 @@ private:
void loadMaterials(QIODevice *device);
QGLTexture2D *loadTexture(const QString& name);
- QGLMaterialCollection *palette;
+ QSharedPointer<QGLMaterialCollection> palette;
QGL::Smoothing smoothing;
bool smoothingForced;
//! [2]
diff --git a/src/threed/scene/qglabstractscene.cpp b/src/threed/scene/qglabstractscene.cpp
index cba0aaced..9cf3bc943 100644
--- a/src/threed/scene/qglabstractscene.cpp
+++ b/src/threed/scene/qglabstractscene.cpp
@@ -136,6 +136,10 @@ public:
bool pickNodesDirty;
};
+bool QGLAbstractScene::m_bFormatListReady = false;
+QStringList QGLAbstractScene::m_Formats;
+QStringList QGLAbstractScene::m_FormatsFilter;
+
/*!
Constructs a 3D scene and attaches it to \a parent.
*/
@@ -328,7 +332,8 @@ QList<QGLSceneAnimation *> QGLAbstractScene::animations() const
#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QGLSceneFormatFactoryInterface_iid, QLatin1String("/sceneformats")))
+ ("com.trolltech.Qt.QGLSceneFormatFactoryInterface",
+ QLatin1String("/sceneformats")))
#endif
/*!
@@ -377,8 +382,10 @@ QGLAbstractScene *QGLAbstractScene::loadScene
if (!device)
return 0;
+ checkSupportedFormats();
+ QStringList keys = m_Formats;
+
QFactoryLoader *l = loader();
- QStringList keys = l->keys();
// If the format is not specified, then use the filename/url extension.
QString fmt = format;
@@ -495,48 +502,28 @@ QGLAbstractScene *QGLAbstractScene::loadScene
*/
QStringList QGLAbstractScene::supportedFormats(QGLAbstractScene::FormatListType t)
{
- QStringList formats;
- QSet<QString> formatSet;
- QSet<QString> dirSet;
- QStringList pluginPaths = QCoreApplication::libraryPaths();
- QStringList::const_iterator it = pluginPaths.constBegin();
- for ( ; it != pluginPaths.constEnd(); ++it)
- {
- QString path = *it;
- QDir sceneformatDir(path + QLatin1String("/sceneformats"));
- path = sceneformatDir.absolutePath();
- if (!sceneformatDir.exists() || dirSet.contains(path))
- continue;
- dirSet.insert(path);
- sceneformatDir.setFilter(QDir::Files);
- QStringList entries = sceneformatDir.entryList();
- QStringList::const_iterator fit = entries.constBegin();
- for ( ; fit != entries.constEnd(); ++fit)
- {
- QString fi = *fit;
- QPluginLoader loader(sceneformatDir.absoluteFilePath(fi));
- QObject *inst = loader.instance();
- QGLSceneFormatFactoryInterface *iface = qobject_cast<QGLSceneFormatFactoryInterface*>(inst);
- if (iface)
- {
- QStringList formatKeys = iface->keys();
- QStringList::const_iterator kit = formatKeys.constBegin();
- for ( ; kit != formatKeys.constEnd(); ++kit)
- {
- QString k = *kit;
- if (!formatSet.contains(k) && !k.contains(QLatin1Char('/'))) // dont add mime-type keys
- {
- if (t == AsFilter)
- k.prepend(QLatin1String("*."));
- formatSet.insert(k);
- formats.append(k);
- }
- }
- }
+ checkSupportedFormats();
+ if (t == AsFilter)
+ return m_FormatsFilter;
+ else
+ return m_Formats;
+}
+
+/*!
+ \internal
+*/
+
+void QGLAbstractScene::checkSupportedFormats()
+{
+ if (!m_bFormatListReady) {
+ QFactoryLoader *l = loader();
+ m_Formats = l->keys();
+ m_FormatsFilter.clear();
+ foreach (QString f, m_Formats) {
+ m_FormatsFilter.append(f.prepend("*."));
}
+ m_bFormatListReady = true;
}
- return formats;
}
-
QT_END_NAMESPACE
diff --git a/src/threed/scene/qglabstractscene.h b/src/threed/scene/qglabstractscene.h
index 9836a249a..7d6a7ee7d 100644
--- a/src/threed/scene/qglabstractscene.h
+++ b/src/threed/scene/qglabstractscene.h
@@ -100,6 +100,11 @@ protected:
private:
QScopedPointer<QGLAbstractScenePrivate> d_ptr;
+ static void checkSupportedFormats();
+ static bool m_bFormatListReady;
+ static QStringList m_Formats;
+ static QStringList m_FormatsFilter;
+
Q_DISABLE_COPY(QGLAbstractScene)
Q_DECLARE_PRIVATE(QGLAbstractScene)
};
diff --git a/src/threed/scene/qglsceneformatplugin.cpp b/src/threed/scene/qglsceneformatplugin.cpp
index 6bba64b5f..7c1c91bef 100644
--- a/src/threed/scene/qglsceneformatplugin.cpp
+++ b/src/threed/scene/qglsceneformatplugin.cpp
@@ -52,8 +52,6 @@ QT_BEGIN_NAMESPACE
This interface will be deprecated in an upcoming release. For more details see the
\l{sceneformats-obj.html}{plug-in tutorial documentation}.
-
- \sa QGLSceneFormatPlugin
*/
class QGLSceneFormatHandlerPrivate
@@ -177,58 +175,8 @@ void QGLSceneFormatHandler::decodeOptions(const QString &options)
/*!
\class QGLSceneFormatFactoryInterface
- \brief The QGLSceneFormatFactoryInterface class provides the factory interface for QGLSceneFormatPlugin.
+ \brief The QGLSceneFormatFactoryInterface class provides the factory interface for scene plugins.
\internal
*/
-/*!
- \class QGLSceneFormatPlugin
- \brief The QGLSceneFormatPlugin class defines an interface for loading 3D object and scene formats.
- \ingroup qt3d
- \ingroup qt3d::scene
-
- This class will be deprecated in an upcoming release. For more details see the
- \l{sceneformats-obj.html}{plug-in tutorial documentation}.
-
- \sa QGLSceneFormatHandler
-*/
-
-/*!
- Constructs a 3D scene format plugin with the given \a parent. This is
- invoked automatically by the Q_EXPORT_PLUGIN2() macro.
-*/
-QGLSceneFormatPlugin::QGLSceneFormatPlugin(QObject *parent)
- : QObject(parent)
-{
-}
-
-/*!
- Destroys this 3D scene format plugin. This is invoked automatically
- when the plugin is unloaded.
-*/
-QGLSceneFormatPlugin::~QGLSceneFormatPlugin()
-{
-}
-
-/*!
- \fn QStringList QGLSceneFormatPlugin::keys() const
-
- Returns the list of format keys this plugin supports. These keys
- are usually the names of the 3D scene formats that are implemented in
- the plugin (e.g., "3ds", "obj", etc). The returned elements must
- be in lower case.
-
- \sa create()
-*/
-
-/*!
- \fn QGLSceneFormatHandler *QGLSceneFormatPlugin::create(QIODevice *device, const QUrl& url, const QString &format) const
-
- Creates and returns a QGLSceneFormatHandler for handling the data in
- \a device according to \a format. The \a url specifies the original
- location of the data for resolving relative resource references.
-
- \sa keys()
-*/
-
QT_END_NAMESPACE
diff --git a/src/threed/scene/qglsceneformatplugin.h b/src/threed/scene/qglsceneformatplugin.h
index 422cf780b..5f1ec5791 100644
--- a/src/threed/scene/qglsceneformatplugin.h
+++ b/src/threed/scene/qglsceneformatplugin.h
@@ -79,27 +79,14 @@ private:
QGLSceneFormatHandlerPrivate *d_ptr;
};
-struct Q_QT3D_EXPORT QGLSceneFormatFactoryInterface : public QFactoryInterface
+class Q_QT3D_EXPORT QGLSceneFormatFactoryInterface
{
- virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format = QString()) const = 0;
-};
-
-#define QGLSceneFormatFactoryInterface_iid \
- "com.trolltech.Qt.QGLSceneFormatFactoryInterface"
-Q_DECLARE_INTERFACE(QGLSceneFormatFactoryInterface, QGLSceneFormatFactoryInterface_iid)
-
-class Q_QT3D_EXPORT QGLSceneFormatPlugin : public QObject, public QGLSceneFormatFactoryInterface
-{
- Q_OBJECT
- Q_INTERFACES(QGLSceneFormatFactoryInterface:QFactoryInterface)
public:
- explicit QGLSceneFormatPlugin(QObject *parent = 0);
- virtual ~QGLSceneFormatPlugin();
-
- virtual QStringList keys() const = 0;
virtual QGLSceneFormatHandler *create(QIODevice *device, const QUrl& url, const QString &format = QString()) const = 0;
};
+Q_DECLARE_INTERFACE(QGLSceneFormatFactoryInterface, "com.trolltech.Qt.QGLSceneFormatFactoryInterface")
+
QT_END_NAMESPACE
QT_END_HEADER