Index: trunk/demos/boxes/qtbox.cpp
===================================================================
--- trunk/demos/boxes/qtbox.cpp	(revision 5)
+++ trunk/demos/boxes/qtbox.cpp	(revision 561)
@@ -2,5 +2,6 @@
 **
 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
 **
 ** This file is part of the demonstration applications of the Qt Toolkit.
@@ -21,8 +22,7 @@
 ** 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.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** 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
@@ -34,6 +34,6 @@
 ** met: http://www.gnu.org/copyleft/gpl.html.
 **
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
 ** $QT_END_LICENSE$
 **
@@ -123,5 +123,5 @@
 
     foreach (QGraphicsItem *item, selected) {
-        ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+        ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
         if (itemBase)
             scene->addItem(itemBase->createNew(itemBase->m_size, itemBase->pos().x() + itemBase->m_size, itemBase->pos().y()));
@@ -138,5 +138,5 @@
 
     foreach (QGraphicsItem *item, selected) {
-        ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+        ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
         if (itemBase)
             delete itemBase;
@@ -153,5 +153,5 @@
 
     foreach (QGraphicsItem *item, selected) {
-        ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+        ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
         if (itemBase) {
             itemBase->prepareGeometryChange();
@@ -172,5 +172,5 @@
 
     foreach (QGraphicsItem *item, selected) {
-        ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+        ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
         if (itemBase) {
             itemBase->prepareGeometryChange();
@@ -258,4 +258,10 @@
 }
 
+int ItemBase::type() const
+{
+    return Type;
+}
+
+
 bool ItemBase::isInResizeArea(const QPointF &pos)
 {
@@ -270,17 +276,18 @@
 {
     for (int i = 0; i < 8; ++i) {
-        m_vertices[i][0] = (i & 1 ? 0.5f : -0.5f);
-        m_vertices[i][1] = (i & 2 ? 0.5f : -0.5f);
-        m_vertices[i][2] = (i & 4 ? 0.5f : -0.5f);
+        m_vertices[i].setX(i & 1 ? 0.5f : -0.5f);
+        m_vertices[i].setY(i & 2 ? 0.5f : -0.5f);
+        m_vertices[i].setZ(i & 4 ? 0.5f : -0.5f);
     }
     for (int i = 0; i < 4; ++i) {
-        m_texCoords[i][0] = (i & 1 ? 1.0f : 0.0f);
-        m_texCoords[i][1] = (i & 2 ? 1.0f : 0.0f);
-    }
-    memset(m_normals, 0, sizeof(m_normals));
-    for (int i = 0; i < 3; ++i) {
-        m_normals[2 * i + 0][i] = -1.0f;
-        m_normals[2 * i + 1][i] = 1.0f;
-    }
+        m_texCoords[i].setX(i & 1 ? 1.0f : 0.0f);
+        m_texCoords[i].setY(i & 2 ? 1.0f : 0.0f);
+    }
+    m_normals[0] = QVector3D(-1.0f, 0.0f, 0.0f);
+    m_normals[1] = QVector3D(1.0f, 0.0f, 0.0f);
+    m_normals[2] = QVector3D(0.0f, -1.0f, 0.0f);
+    m_normals[3] = QVector3D(0.0f, 1.0f, 0.0f);
+    m_normals[4] = QVector3D(0.0f, 0.0f, -1.0f);
+    m_normals[5] = QVector3D(0.0f, 0.0f, 1.0f);
 }
 
@@ -313,4 +320,6 @@
     };
 
+    painter->beginNativePainting();
+
     glMatrixMode(GL_PROJECTION);
     glPushMatrix();
@@ -352,9 +361,9 @@
 
         glBegin(GL_TRIANGLE_STRIP);
-        glNormal3fv(m_normals[2 * dir + 0].bits());
+        glNormal3fv(reinterpret_cast<float *>(&m_normals[2 * dir + 0]));
         for (int i = 0; i < 2; ++i) {
             for (int j = 0; j < 2; ++j) {
-                glTexCoord2fv(m_texCoords[(j << 1) | i].bits());
-                glVertex3fv(m_vertices[(i << ((dir + 2) % 3)) | (j << ((dir + 1) % 3))].bits());
+                glTexCoord2fv(reinterpret_cast<float *>(&m_texCoords[(j << 1) | i]));
+                glVertex3fv(reinterpret_cast<float *>(&m_vertices[(i << ((dir + 2) % 3)) | (j << ((dir + 1) % 3))]));
             }
         }
@@ -362,9 +371,9 @@
 
         glBegin(GL_TRIANGLE_STRIP);
-        glNormal3fv(m_normals[2 * dir + 1].bits());
+        glNormal3fv(reinterpret_cast<float *>(&m_normals[2 * dir + 1]));
         for (int i = 0; i < 2; ++i) {
             for (int j = 0; j < 2; ++j) {
-                glTexCoord2fv(m_texCoords[(j << 1) | i].bits());
-                glVertex3fv(m_vertices[(1 << dir) | (i << ((dir + 1) % 3)) | (j << ((dir + 2) % 3))].bits());
+                glTexCoord2fv(reinterpret_cast<float *>(&m_texCoords[(j << 1) | i]));
+                glVertex3fv(reinterpret_cast<float *>(&m_vertices[(1 << dir) | (i << ((dir + 1) % 3)) | (j << ((dir + 2) % 3))]));
             }
         }
@@ -385,4 +394,6 @@
     glMatrixMode(GL_PROJECTION);
     glPopMatrix();
+
+    painter->endNativePainting();
 
     ItemBase::paint(painter, option, widget);
