From f4975287a196b321b0a6bfc9fc7bf364c2f1693f Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 21 Dec 2011 00:45:00 +0300 Subject: [PATCH] Changed: #1302 Added some stuff for weqt property editor. --- .../src/plugins/core/CMakeLists.txt | 1 - .../landscape_editor/list_zones_model.cpp | 4 +- .../world_editor/property_editor_widget.cpp | 111 +++++++++++++++++- .../world_editor/property_editor_widget.h | 7 +- .../world_editor/world_editor_window.cpp | 2 +- 5 files changed, 117 insertions(+), 8 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt index 3140f02fb..927e35eaa 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/CMakeLists.txt @@ -11,7 +11,6 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. SET(OVQT_CORE_PLUGIN_HDR icore.h icontext.h - imenu_manager.h icore_listener.h ioptions_page.h core_plugin.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp index 57e8683c0..103a43052 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/list_zones_model.cpp @@ -75,9 +75,7 @@ QVariant ListZonesModel::data(const QModelIndex &index, int role) const } } -QVariant ListZonesModel::headerData(int section, - Qt::Orientation /* orientation */, - int role) const +QVariant ListZonesModel::headerData(int section, Qt::Orientation, int role) const { return QVariant(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp index 7df0b6d1d..7b4224e04 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.cpp @@ -37,12 +37,16 @@ PropertyEditorWidget::PropertyEditorWidget(QWidget *parent) m_ui.setupUi(this); m_variantManager = new QtVariantPropertyManager(this); - + m_enumManager = new QtEnumPropertyManager(this); connect(m_variantManager, SIGNAL(valueChanged(QtProperty *, const QVariant &)), this, SLOT(valueChanged(QtProperty *, const QVariant &))); QtVariantEditorFactory *variantFactory = new QtVariantEditorFactory(this); + QtEnumEditorFactory *enumFactory = new QtEnumEditorFactory(this); m_ui.treePropertyBrowser->setFactoryForManager(m_variantManager, variantFactory); + m_ui.treePropertyBrowser->setFactoryForManager(m_enumManager, enumFactory); + + m_groupManager = new QtGroupPropertyManager(this); } PropertyEditorWidget::~PropertyEditorWidget() @@ -51,10 +55,113 @@ PropertyEditorWidget::~PropertyEditorWidget() void PropertyEditorWidget::clearProperties() { + m_ui.treePropertyBrowser->clear(); } -void PropertyEditorWidget::setCurrentPrimitive(PrimitiveNode *node) +void PropertyEditorWidget::updateSelection(const NodeList &selected, const NodeList &deselected) { + clearProperties(); + + // The parameter list + std::set parameterList; + + for (int i = 0; i < selected.size(); ++i) + { + if (selected.at(i)->type() == Node::RootPrimitiveNodeType) + { + /* + const_cast(_PropDlgLocators[i].Primitive)->removePropertyByName("name"); + const_cast(_PropDlgLocators[i].Primitive)->removePropertyByName("path"); + //TODO faire une fonction dans CWorldDoc pour recup m_strPathName + string name; + getDocument()->getPrimitiveDisplayName(name,_PropDlgLocators[i].getDatabaseIndex()); + string path; + getDocument()->getFilePath(_PropDlgLocators[i].getDatabaseIndex(),path); + + const_cast(_PropDlgLocators[i].Primitive)->addPropertyByName("name",new CPropertyString (name)); + const_cast(_PropDlgLocators[i].Primitive)->addPropertyByName("path",new CPropertyString (path)); + */ + } + + if (selected.at(i)->type() == Node::PrimitiveNodeType) + { + PrimitiveNode *node = static_cast(selected.at(i)); + const NLLIGO::IPrimitive *primitive = node->primitive(); + const NLLIGO::CPrimitiveClass *primClass = node->primitiveClass(); + + // Use the class or not ? + if (primClass) + { + QtProperty *groupNode; + groupNode = m_groupManager->addProperty(node->data(Qt::DisplayRole).toString()); + m_ui.treePropertyBrowser->addProperty(groupNode); + + // For each properties of the class + for (uint p = 0; p < primClass->Parameters.size(); p++) + { + // Is the parameter visible ? + if (primClass->Parameters[p].Visible) + { + QtProperty *param; + + if (primClass->Parameters[p].Type == NLLIGO::CPrimitiveClass::CParameter::Boolean) + param = m_variantManager->addProperty(QVariant::Bool, primClass->Parameters[p].Name.c_str()); + else if (primClass->Parameters[p].Type == NLLIGO::CPrimitiveClass::CParameter::ConstString) + { + param = m_enumManager->addProperty(primClass->Parameters[p].Name.c_str()); + } + else if (primClass->Parameters[p].Type == NLLIGO::CPrimitiveClass::CParameter::String) + param = m_variantManager->addProperty(QVariant::String, primClass->Parameters[p].Name.c_str()); + else + param = m_variantManager->addProperty(QVariant::String, primClass->Parameters[p].Name.c_str()); + + groupNode->addSubProperty(param); + + parameterList.insert(primClass->Parameters[p]); + } + } + } + else + { + // For each primitive property + uint numProp = primitive->getNumProperty(); + for (uint p = 0; p < numProp; p++) + { + // Get the property + std::string propertyName; + const NLLIGO::IProperty *prop; + nlverify(primitive->getProperty (p, propertyName, prop)); + + // Add a default property + NLLIGO::CPrimitiveClass::CParameter defProp(*prop, propertyName.c_str()); + parameterList.insert(defProp); + } + } + } + } + + // Remove property class + std::set::iterator ite = parameterList.begin (); + while (ite != parameterList.end ()) + { + // Next iterator + std::set::iterator next = ite; + next++; + + // Property name ? + if (ite->Name == "class") + { + // Remove it + parameterList.erase (ite); + } + + ite = next; + } + + // Add the default parameter + NLLIGO::CPrimitiveClass::CParameter defaultParameter; + defaultParameter.Visible = true; + defaultParameter.Filename = false; } } /* namespace WorldEditor */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h index 3ee73a293..3a2506def 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/property_editor_widget.h @@ -50,11 +50,16 @@ public: public Q_SLOTS: void clearProperties(); - void setCurrentPrimitive(PrimitiveNode *node); + + /// Update of selections + void updateSelection(const NodeList &selected, const NodeList &deselected); private: QtVariantPropertyManager *m_variantManager; + QtEnumPropertyManager *m_enumManager; + QtGroupPropertyManager *m_groupManager; + Ui::PropertyEditorWidget m_ui; }; /* PropertyEditorWidget */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp index 1e6d44ff6..30173b9d9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.cpp @@ -276,7 +276,7 @@ void WorldEditorWindow::updateSelection(const QItemSelection &selected, const QI } // TODO: update property editor - // ... + m_ui.propertyEditWidget->updateSelection(nodesSelected, nodesDeselected); QList itemSelected; Q_FOREACH(Node *node, nodesSelected)