[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [gluon] creator/lib/models: Expose the scene root so it is possible to attach scripts to it.
From:       Arjen Hiemstra <ahiemstra () heimr ! nl>
Date:       2012-12-01 15:03:32
Message-ID: 20121201150332.DD74AA6091 () git ! kde ! org
[Download RAW message or body]

Git commit 394e43a42bbc573a871cc1be2f21a1fd86ea340c by Arjen Hiemstra.
Committed on 01/12/2012 at 15:34.
Pushed by ahiemstra into branch 'master'.

Expose the scene root so it is possible to attach scripts to it.

Still need to see if we want to add a filter to determine what kind of
components can be added, but this way we at least have a central place
to assign controller scripts.

REVIEW: 104273

M  +14   -10   creator/lib/models/scenemodel.cpp

http://commits.kde.org/gluon/394e43a42bbc573a871cc1be2f21a1fd86ea340c

diff --git a/creator/lib/models/scenemodel.cpp b/creator/lib/models/scenemodel.cpp
index cbbefe0..cc15ca1 100644
--- a/creator/lib/models/scenemodel.cpp
+++ b/creator/lib/models/scenemodel.cpp
@@ -145,9 +145,9 @@ int SceneModel::rowCount( const QModelIndex& parent ) const
         return 0;
 
     if( !parent.isValid() )
-        parentItem = d->root;
-    else
-        parentItem = static_cast<GluonEngine::GameObject*>( parent.internalPointer() \
); +        return 1;
+
+    parentItem = static_cast<GluonEngine::GameObject*>( parent.internalPointer() );
 
     if( parentItem )
         return parentItem->childCount();
@@ -164,11 +164,11 @@ QModelIndex SceneModel::parent( const QModelIndex& child ) \
const  if( !childItem )
         return QModelIndex();
 
-    GluonEngine::GameObject* parentItem = childItem->parentGameObject();
-
-    if( parentItem == d->root )
+    if( childItem == d->root )
         return QModelIndex();
 
+    GluonEngine::GameObject* parentItem = childItem->parentGameObject();
+
     return createIndex( d->rowIndex( parentItem ), 0, parentItem );
 }
 
@@ -177,14 +177,18 @@ QModelIndex SceneModel::index( int row, int column, const \
QModelIndex& parent )  if( !hasIndex( row, column, parent ) )
         return QModelIndex();
 
-    GluonEngine::GameObject* parentItem;
+    GluonEngine::GameObject* childItem;
 
     if( !parent.isValid() )
-        parentItem = d->root;
+    {
+        childItem = d->root;
+    }
     else
-        parentItem = static_cast<GluonEngine::GameObject*>( parent.internalPointer() \
); +    {
+        GluonEngine::GameObject* parentItem = static_cast<GluonEngine::GameObject*>( \
parent.internalPointer() ); +        childItem = parentItem->childGameObject( row );
+    }
 
-    GluonEngine::GameObject* childItem = parentItem->childGameObject( row );
     if( childItem )
         return createIndex( row, column, childItem );
     else


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic