summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2014-09-12 15:42:54 +0200
committerSean Harmer <sean.harmer@kdab.com>2014-09-29 13:52:50 +0200
commit8393ce4c692d259c9a9d13a22b85166f9fe48920 (patch)
tree0cf41679876885c9b5b631a6ece16d0546567c2c
parent4ac485397655503c3c0c7ac5b6d57f966d232037 (diff)
Quick3DSortMethod added
Change-Id: Iea81b62a0bfc424654764c68871a7120e8f888cd Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/quick3d/quick3drenderer/items/items.pri6
-rw-r--r--src/quick3d/quick3drenderer/items/quick3dsortmethod.cpp104
-rw-r--r--src/quick3d/quick3drenderer/items/quick3dsortmethod.h84
3 files changed, 192 insertions, 2 deletions
diff --git a/src/quick3d/quick3drenderer/items/items.pri b/src/quick3d/quick3drenderer/items/items.pri
index a1854559d..a22e3e0fe 100644
--- a/src/quick3d/quick3drenderer/items/items.pri
+++ b/src/quick3d/quick3drenderer/items/items.pri
@@ -10,7 +10,8 @@ HEADERS += \
$$PWD/shaderpropertyparser_p.h \
$$PWD/quick3dtexture.h \
$$PWD/quick3drenderpass.h \
- $$PWD/quick3dframegraphitem.h
+ $$PWD/quick3dframegraphitem.h \
+ $$PWD/quick3dsortmethod.h
SOURCES += \
$$PWD/quick3drenderpassfilter.cpp \
@@ -24,6 +25,7 @@ SOURCES += \
$$PWD/shaderpropertyparser.cpp \
$$PWD/quick3dtexture.cpp \
$$PWD/quick3drenderpass.cpp \
- $$PWD/quick3dframegraphitem.cpp
+ $$PWD/quick3dframegraphitem.cpp \
+ $$PWD/quick3dsortmethod.cpp
INCLUDEPATH += $$PWD
diff --git a/src/quick3d/quick3drenderer/items/quick3dsortmethod.cpp b/src/quick3d/quick3drenderer/items/quick3dsortmethod.cpp
new file mode 100644
index 000000000..5a19ecf1b
--- /dev/null
+++ b/src/quick3d/quick3drenderer/items/quick3dsortmethod.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "quick3dsortmethod.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+namespace Render {
+
+namespace Quick {
+
+Quick3DSortMethod::Quick3DSortMethod(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QQmlListProperty<QSortCriterion> Quick3DSortMethod::criteriaList()
+{
+ return QQmlListProperty<QSortCriterion>(this, 0,
+ &Quick3DSortMethod::appendCriterion,
+ &Quick3DSortMethod::criteriaCount,
+ &Quick3DSortMethod::criterionAt,
+ &Quick3DSortMethod::clearCriteria);
+}
+
+void Quick3DSortMethod::appendCriterion(QQmlListProperty<QSortCriterion> *list, QSortCriterion *criterion)
+{
+ Quick3DSortMethod *sM = qobject_cast<Quick3DSortMethod *>(list->object);
+ if (sM != Q_NULLPTR)
+ sM->parentSortMethod()->addCriterion(criterion);
+}
+
+QSortCriterion *Quick3DSortMethod::criterionAt(QQmlListProperty<QSortCriterion> *list, int index)
+{
+ Quick3DSortMethod *sM = qobject_cast<Quick3DSortMethod *>(list->object);
+ if (sM != Q_NULLPTR)
+ return sM->parentSortMethod()->criteria().at(index);
+ return Q_NULLPTR;
+}
+
+int Quick3DSortMethod::criteriaCount(QQmlListProperty<QSortCriterion> *list)
+{
+ Quick3DSortMethod *sM = qobject_cast<Quick3DSortMethod *>(list->object);
+ if (sM != Q_NULLPTR)
+ return sM->parentSortMethod()->criteria().count();
+ return -1;
+}
+
+void Quick3DSortMethod::clearCriteria(QQmlListProperty<QSortCriterion> *list)
+{
+ Quick3DSortMethod *sM = qobject_cast<Quick3DSortMethod *>(list->object);
+ if (sM != Q_NULLPTR) {
+ Q_FOREACH (QSortCriterion *c, sM->parentSortMethod()->criteria())
+ sM->parentSortMethod()->removeCriterion(c);
+ }
+}
+
+} // Quick
+
+} // Render
+
+} // Qt3D
+
+QT_END_NAMESPACE
diff --git a/src/quick3d/quick3drenderer/items/quick3dsortmethod.h b/src/quick3d/quick3drenderer/items/quick3dsortmethod.h
new file mode 100644
index 000000000..99032b009
--- /dev/null
+++ b/src/quick3d/quick3drenderer/items/quick3dsortmethod.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_RENDER_QUICK_QUICK3DSORTMETHOD_H
+#define QT3D_RENDER_QUICK_QUICK3DSORTMETHOD_H
+
+#include <Qt3DQuickRenderer/qt3dquickrenderer_global.h>
+#include <Qt3DRenderer/qsortmethod.h>
+#include <Qt3DRenderer/qsortcriterion.h>
+#include <QQmlListProperty>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+namespace Render {
+
+namespace Quick {
+
+class QT3DQUICKRENDERERSHARED_EXPORT Quick3DSortMethod : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<Qt3D::QSortCriterion> criteria READ criteriaList)
+public:
+ explicit Quick3DSortMethod(QObject *parent = 0);
+
+ inline QSortMethod *parentSortMethod() const { return qobject_cast<QSortMethod *>(parent()); }
+
+ QQmlListProperty<Qt3D::QSortCriterion> criteriaList();
+
+private:
+ static void appendCriterion(QQmlListProperty<QSortCriterion> *list, QSortCriterion *criterion);
+ static QSortCriterion *criterionAt(QQmlListProperty<QSortCriterion> *list, int index);
+ static int criteriaCount(QQmlListProperty<QSortCriterion> *list);
+ static void clearCriteria(QQmlListProperty<QSortCriterion> *list);
+};
+
+} // Quick
+
+} // Render
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QUICK3DSORTMETHOD_H