[gegl-qt/qt5] TEMP: QtQuickItem for NodeView



commit 37bdf7c21cdaa8fbb3375dfff40f9c53779c3f3a
Author: Jon Nordby <jononor gmail com>
Date:   Thu Apr 12 21:27:01 2012 +0200

    TEMP: QtQuickItem for NodeView

 config.pri                                  |    1 +
 gegl-qt/gegl-qt.pro                         |   13 ++++-
 gegl-qt/internal/nodeviewchilditem.h        |    6 +-
 gegl-qt/internal/nodeviewquickchilditem.cpp |   57 ++++++++++++++++++++
 gegl-qt/internal/nodeviewquickchilditem.h   |   33 +++++++++++
 gegl-qt/nodeviewquickitem.cpp               |   77 +++++++++++++++++++++++++++
 gegl-qt/nodeviewquickitem.h                 |   18 ++++++
 7 files changed, 200 insertions(+), 5 deletions(-)
---
diff --git a/config.pri b/config.pri
index f06e6bf..e9c200e 100644
--- a/config.pri
+++ b/config.pri
@@ -108,6 +108,7 @@ contains(QT_MAJOR_VERSION, 5) {
     !system(pkg-config QtWidgets) {
         HAVE_QT_WIDGETS = no
     }
+
 } else {
     # Qt4 always has QtWidgets
 }
diff --git a/gegl-qt/gegl-qt.pro b/gegl-qt/gegl-qt.pro
index 39717cc..7779aae 100644
--- a/gegl-qt/gegl-qt.pro
+++ b/gegl-qt/gegl-qt.pro
@@ -58,8 +58,17 @@ contains(HAVE_QT_WIDGETS, yes) {
 contains(HAVE_QT_DECLARATIVE, yes) {
 
     contains(QT_MAJOR_VERSION, 5) {
-        #PUBLIC_HEADERS +=
-        #PUBLIC_SOURCES +=
+
+        contains(HAVE_QT_WIDGETS, yes) {
+            PUBLIC_HEADERS += nodeviewquickitem.h
+            PUBLIC_SOURCES += nodeviewquickitem.cpp
+
+            PRIVATE_HEADERS += internal/nodeviewquickchilditem.h
+            PRIVATE_SOURCES += internal/nodeviewquickchilditem.cpp
+        } else {
+            error("Need QtWidgets for Qt5")
+        }
+
     }
 
     contains(HAVE_QTQUICK1, yes) {
diff --git a/gegl-qt/internal/nodeviewchilditem.h b/gegl-qt/internal/nodeviewchilditem.h
index 5341c3e..8cc2508 100644
--- a/gegl-qt/internal/nodeviewchilditem.h
+++ b/gegl-qt/internal/nodeviewchilditem.h
@@ -1,6 +1,3 @@
-#ifndef NODEVIEWCHILDITEM_H
-#define NODEVIEWCHILDITEM_H
-
 /* This file is part of GEGL-QT
  *
  * GEGL-QT is free software; you can redistribute it and/or
@@ -19,6 +16,9 @@
  * Copyright (C) 2011 Jon Nordby <jononor gmail com>
  */
 
+#ifndef NODEVIEWCHILDITEM_H
+#define NODEVIEWCHILDITEM_H
+
 #include <QGraphicsItem>
 
 namespace GeglQt {
diff --git a/gegl-qt/internal/nodeviewquickchilditem.cpp b/gegl-qt/internal/nodeviewquickchilditem.cpp
new file mode 100644
index 0000000..45f56bf
--- /dev/null
+++ b/gegl-qt/internal/nodeviewquickchilditem.cpp
@@ -0,0 +1,57 @@
+/* This file is part of GEGL-QT
+ *
+ * GEGL-QT is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL-QT is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL-QT; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (C) 2011 Jon Nordby <jononor gmail com>
+ */
+
+#include "nodeviewquickchilditem.h"
+
+NodeViewQuickChildItem::NodeViewQuickChildItem(QObject *parent) :
+    QSGPaintedItem(parent)
+  , mHelper(helper)
+  , mItemSize(0.0, 0.0)
+{
+  Q_UNUSED(parent);
+}
+
+NodeViewQuickChildItem::~NodeViewChildItem()
+{
+}
+
+void
+NodeViewQuickChildItem::updateSize(QSizeF newSize)
+{
+  if (!newSize.isValid()) {
+      return;
+  }
+
+  // Must be called before changing the return value of boundingRect()
+  prepareGeometryChange();
+  mItemSize = newSize;
+}
+
+QRectF
+NodeViewQuickChildItem::boundingRect() const
+{
+  return QRectF(0.0, 0.0, mItemSize.width(), mItemSize.height());
+}
+
+void
+NodeViewQuickChildItem::paint(QPainter *painter)
+{
+  Q_UNUSED(widget);
+
+  mHelper->paint(painter, option->exposedRect);
+}
diff --git a/gegl-qt/internal/nodeviewquickchilditem.h b/gegl-qt/internal/nodeviewquickchilditem.h
new file mode 100644
index 0000000..cc68c37
--- /dev/null
+++ b/gegl-qt/internal/nodeviewquickchilditem.h
@@ -0,0 +1,33 @@
+/* This file is part of GEGL-QT
+ *
+ * GEGL-QT is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL-QT is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL-QT; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (C) 2011 Jon Nordby <jononor gmail com>
+ */
+
+#ifndef NODEVIEWQUICKCHILDITEM_H
+#define NODEVIEWQUICKCHILDITEM_H
+
+#include <QSGPaintedItem>
+
+class NodeViewQuickChildItem : public QSGPaintedItem
+{
+    Q_OBJECT
+public:
+    explicit NodeViewQuickChildItem(QObject *parent = 0);
+    
+
+};
+
+#endif // NODEVIEWQUICKCHILDITEM_H
diff --git a/gegl-qt/nodeviewquickitem.cpp b/gegl-qt/nodeviewquickitem.cpp
new file mode 100644
index 0000000..119ea07
--- /dev/null
+++ b/gegl-qt/nodeviewquickitem.cpp
@@ -0,0 +1,77 @@
+#include "nodeviewquickitem.h"
+
+NodeViewQuickItem::NodeViewQuickItem(QObject *parent) :
+    QQuickItem(parent)
+    , priv(new NodeViewImplementation(NodeViewImplementation::DrawModeChildGraphicsItem))
+{
+    priv->childItem()->setParentItem(static_cast<QGraphicsItem *>(this));
+
+    connect(priv, SIGNAL(viewportSizeRequest(QSizeF)),
+            this, SLOT(viewportSizeChangeRequested(QSizeF)));
+}
+
+NodeViewQuickItem::~NodeViewQuickItem()
+{
+    delete priv;
+}
+
+void
+NodeViewQuickItem::setInputNode(GeglNode *node)
+{
+    if (node != inputNode()) {
+        priv->setInputNode(node);
+        Q_EMIT inputNodeChanged();
+    }
+}
+
+GeglNode *
+NodeViewQuickItem::inputNode()
+{
+    return priv->inputNode();
+}
+
+void
+NodeViewQuickItem::setInputNodeVariant(QVariant node)
+{
+    if (node.isValid()) {
+        GeglNode *gegl_node = static_cast<GeglNode*>(node.value<void*>());
+        setInputNode(gegl_node);
+    }
+}
+
+QVariant
+NodeViewQuickItem::inputNodeVariant()
+{
+    return qVariantFromValue(static_cast<void*>(inputNode()));
+}
+
+void
+NodeViewQuickItem::setOptions(GeglQt::NodeViewOptions* newOptions)
+{
+    if (newOptions != options()) {
+        priv->setOptions(newOptions);
+        Q_EMIT optionsChanged();
+    }
+}
+
+NodeViewOptions *
+NodeViewQuickItem::options() const
+{
+    return priv->options();
+}
+
+void
+NodeViewQuickItem::viewportSizeChangeRequested(QSizeF requestedSize)
+{
+    setImplicitHeight(requestedSize.height());
+    setImplicitWidth(requestedSize.width());
+}
+
+void
+NodeViewQuickItem::geometryChanged(const QRectF & newGeometry,
+                                   const QRectF & oldGeometry)
+{
+    QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+
+    priv->viewportSizeChanged(newGeometry.size());
+}
diff --git a/gegl-qt/nodeviewquickitem.h b/gegl-qt/nodeviewquickitem.h
new file mode 100644
index 0000000..d8cea3a
--- /dev/null
+++ b/gegl-qt/nodeviewquickitem.h
@@ -0,0 +1,18 @@
+#ifndef NODEVIEWQUICKITEM_H
+#define NODEVIEWQUICKITEM_H
+
+#include <QQuickItem>
+
+class NodeViewQuickItem : public QQuickItem
+{
+    Q_OBJECT
+public:
+    explicit NodeViewQuickItem(QObject *parent = 0);
+    
+signals:
+    
+public slots:
+    
+};
+
+#endif // NODEVIEWQUICKITEM_H



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]