Changed: #1302 Used setData(QVariant) instead setGraphicsData().
--HG-- branch : gsoc2011-worldeditorqt
This commit is contained in:
parent
1b1bab4cd8
commit
a65eb22feb
4 changed files with 17 additions and 21 deletions
|
@ -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;
|
||||
|
|
|
@ -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<Node *> m_children;
|
||||
QHash<int, QVariant> m_data;
|
||||
QHash<int, void *> m_graphicsData;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -183,4 +175,6 @@ private:
|
|||
|
||||
} /* namespace WorldEditor */
|
||||
|
||||
Q_DECLARE_METATYPE(WorldEditor::Node *)
|
||||
|
||||
#endif // PRIMITIVE_ITEM_H
|
||||
|
|
|
@ -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 <QModelIndex>
|
||||
#include <QPersistentModelIndex>
|
||||
|
||||
namespace WorldEditor
|
||||
{
|
||||
|
@ -89,8 +91,13 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode
|
|||
break;
|
||||
}
|
||||
}
|
||||
QVariant variantNode;
|
||||
variantNode.setValue<Node *>(node);
|
||||
item->setData(Constants::WORLD_EDITOR_NODE, variantNode);
|
||||
|
||||
node->setGraphicsData(GRAPHICS_DATA_QT2D, item);
|
||||
QVariant graphicsData;
|
||||
graphicsData.setValue<QGraphicsItem *>(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<QGraphicsItem *>(node->graphicsData(GRAPHICS_DATA_QT2D));
|
||||
QGraphicsItem *item = qvariant_cast<QGraphicsItem *>(node->data(Constants::GRAPHICS_DATA_QT4_2D));
|
||||
if (item != 0)
|
||||
delete item;
|
||||
break;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// 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";
|
||||
|
|
Loading…
Reference in a new issue