From 52c6cc98a2eea6243c7db9e586297b2caa9f9fa9 Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 10 Aug 2011 17:13:06 +0300 Subject: [PATCH] Changed: #1302 Used setData(QVariant) instead setGraphicsData(). --- .../src/plugins/world_editor/primitive_item.cpp | 10 ---------- .../src/plugins/world_editor/primitive_item.h | 10 ++-------- .../src/plugins/world_editor/world_editor_actions.cpp | 11 +++++++++-- .../src/plugins/world_editor/world_editor_constants.h | 7 ++++++- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp index 672bd2954..e948f8b0f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.cpp @@ -132,16 +132,6 @@ void Node::setData(int key, const QVariant &data) m_data[key] = data; } -void Node::setGraphicsData(int key, void *pointerToData) -{ - m_graphicsData[key] = pointerToData; -} - -void *Node::graphicsData(int key) const -{ - return m_graphicsData[key]; -} - Node *Node::parent() { return m_parent; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h index 01c96c9d2..4940a622b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/primitive_item.h @@ -35,9 +35,6 @@ class RootPrimitiveNode; class LandscapeNode; class PrimitiveNode; -const int GRAPHICS_DATA_QT2D = 0; -const int GRAPHICS_DATA_NEL3D = 1; - /* @class Node @brief @@ -93,10 +90,6 @@ public: /// Return this node's custom data for the key key as a QVariant. QVariant data(int key) const; - void setGraphicsData(int key, void *pointerToData); - - void *graphicsData(int key) const; - /// Return a type this node. virtual NodeType type() const; @@ -106,7 +99,6 @@ private: Node *m_parent; QList m_children; QHash m_data; - QHash m_graphicsData; }; /* @@ -183,4 +175,6 @@ private: } /* namespace WorldEditor */ +Q_DECLARE_METATYPE(WorldEditor::Node *) + #endif // PRIMITIVE_ITEM_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index a654e8f31..4f69181c8 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -16,6 +16,7 @@ // Project includes #include "world_editor_actions.h" +#include "world_editor_constants.h" #include "world_editor_misc.h" #include "primitive_item.h" #include "world_editor_scene.h" @@ -37,6 +38,7 @@ // Qt includes #include +#include namespace WorldEditor { @@ -89,8 +91,13 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode break; } } + QVariant variantNode; + variantNode.setValue(node); + item->setData(Constants::WORLD_EDITOR_NODE, variantNode); - node->setGraphicsData(GRAPHICS_DATA_QT2D, item); + QVariant graphicsData; + graphicsData.setValue(item); + node->setData(Constants::GRAPHICS_DATA_QT4_2D, graphicsData); } int count = model->rowCount(primIndex); @@ -112,7 +119,7 @@ void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode case NLLIGO::CPrimitiveClass::Path: case NLLIGO::CPrimitiveClass::Zone: { - QGraphicsItem *item = static_cast(node->graphicsData(GRAPHICS_DATA_QT2D)); + QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); if (item != 0) delete item; break; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h index 5c1d32908..e0bdc4705 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_constants.h @@ -1,5 +1,4 @@ // Object Viewer Qt - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2011 Dzmitry Kamiahin // // This program is free software: you can redistribute it and/or modify @@ -24,6 +23,12 @@ namespace Constants { const char *const WORLD_EDITOR_PLUGIN = "WorldEditor"; +const int USER_TYPE = 65536; +const int NODE_PERISTENT_INDEX = USER_TYPE + 1; +const int WORLD_EDITOR_NODE = USER_TYPE + 2; +const int GRAPHICS_DATA_QT4_2D = USER_TYPE + 3; +const int GRAPHICS_DATA_NEL3D = USER_TYPE + 4; + //settings const char *const WORLD_EDITOR_SECTION = "WorldEditor"; const char *const WORLD_WINDOW_STATE = "WorldWindowState";