[gegl-qt] Widgets: Add GeglNode* inputNode API to the DeclarativeItem



commit e141e7640fe08bc99a1b8eb6ae5ed939dcf744b2
Author: Jon Nordby <jononor gmail com>
Date:   Tue Aug 30 18:27:10 2011 +0200

    Widgets: Add GeglNode* inputNode API to the DeclarativeItem
    
    Make the QVariant case secondary in the C++ API, so that
    all widgets have the same API in this respect.
    
    The property (mainly for QML) is still a QVariant, and called inputNode.

 gegl-qt/nodeviewdeclarativeitem.cpp |   24 +++++++++++++++++++-----
 gegl-qt/nodeviewdeclarativeitem.h   |   10 +++++++---
 2 files changed, 26 insertions(+), 8 deletions(-)
---
diff --git a/gegl-qt/nodeviewdeclarativeitem.cpp b/gegl-qt/nodeviewdeclarativeitem.cpp
index 9f7fc9e..6e858bb 100644
--- a/gegl-qt/nodeviewdeclarativeitem.cpp
+++ b/gegl-qt/nodeviewdeclarativeitem.cpp
@@ -39,19 +39,33 @@ NodeViewDeclarativeItem::~NodeViewDeclarativeItem()
 }
 
 void
-NodeViewDeclarativeItem::setInputNode(QVariant node)
+NodeViewDeclarativeItem::setInputNode(GeglNode *node)
+{
+    if (node != inputNode()) {
+        priv->setInputNode(node);
+        Q_EMIT inputNodeChanged();
+    }
+}
+
+GeglNode *
+NodeViewDeclarativeItem::inputNode()
+{
+    return priv->inputNode();
+}
+
+void
+NodeViewDeclarativeItem::setInputNodeVariant(QVariant node)
 {
     if (node.isValid()) {
         GeglNode *gegl_node = static_cast<GeglNode*>(node.value<void*>());
-        priv->setInputNode(gegl_node);
-        Q_EMIT inputNodeChanged();
+        setInputNode(gegl_node);
     }
 }
 
 QVariant
-NodeViewDeclarativeItem::inputNode()
+NodeViewDeclarativeItem::inputNodeVariant()
 {
-    return qVariantFromValue(static_cast<void*>(priv->inputNode()));
+    return qVariantFromValue(static_cast<void*>(inputNode()));
 }
 
 NodeViewOptions *
diff --git a/gegl-qt/nodeviewdeclarativeitem.h b/gegl-qt/nodeviewdeclarativeitem.h
index 8857b9c..fa32248 100644
--- a/gegl-qt/nodeviewdeclarativeitem.h
+++ b/gegl-qt/nodeviewdeclarativeitem.h
@@ -37,9 +37,13 @@ public:
     ~NodeViewDeclarativeItem();
 
     // QVariant is used so that GeglNode* can be passed through QML
-    void setInputNode(QVariant node);
-    QVariant inputNode();
-    Q_PROPERTY(QVariant inputNode READ inputNode WRITE setInputNode NOTIFY inputNodeChanged)
+    void setInputNodeVariant(QVariant node);
+    QVariant inputNodeVariant();
+
+    void setInputNode(GeglNode *node);
+    GeglNode *inputNode();
+
+    Q_PROPERTY(QVariant inputNode READ inputNodeVariant WRITE setInputNodeVariant NOTIFY inputNodeChanged)
 
     Q_INVOKABLE GeglQt::NodeViewOptions *options() const;
 



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