|
|
|
@ -17,6 +17,7 @@
|
|
|
|
|
|
|
|
|
|
// Project includes
|
|
|
|
|
#include "property_editor_widget.h"
|
|
|
|
|
#include "world_editor_misc.h"
|
|
|
|
|
|
|
|
|
|
// NeL includes
|
|
|
|
|
#include <nel/misc/debug.h>
|
|
|
|
@ -38,13 +39,18 @@ PropertyEditorWidget::PropertyEditorWidget(QWidget *parent)
|
|
|
|
|
|
|
|
|
|
m_variantManager = new QtVariantPropertyManager(this);
|
|
|
|
|
m_enumManager = new QtEnumPropertyManager(this);
|
|
|
|
|
m_stringArrayManager = new QtTextPropertyManager(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);
|
|
|
|
|
QtTextEditorFactory *textFactory = new QtTextEditorFactory(this);
|
|
|
|
|
|
|
|
|
|
m_ui.treePropertyBrowser->setFactoryForManager(m_variantManager, variantFactory);
|
|
|
|
|
m_ui.treePropertyBrowser->setFactoryForManager(m_enumManager, enumFactory);
|
|
|
|
|
m_ui.treePropertyBrowser->setFactoryForManager(m_stringArrayManager, textFactory);
|
|
|
|
|
|
|
|
|
|
m_groupManager = new QtGroupPropertyManager(this);
|
|
|
|
|
}
|
|
|
|
@ -58,66 +64,33 @@ void PropertyEditorWidget::clearProperties()
|
|
|
|
|
m_ui.treePropertyBrowser->clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PropertyEditorWidget::updateSelection(const NodeList &selected, const NodeList &deselected)
|
|
|
|
|
void PropertyEditorWidget::updateSelection(Node *node)
|
|
|
|
|
{
|
|
|
|
|
clearProperties();
|
|
|
|
|
|
|
|
|
|
if ((node == 0) || (node->type() != Node::PrimitiveNodeType))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// The parameter list
|
|
|
|
|
std::set<NLLIGO::CPrimitiveClass::CParameter> parameterList;
|
|
|
|
|
std::list<NLLIGO::CPrimitiveClass::CParameter> parameterList;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < selected.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (selected.at(i)->type() == Node::RootPrimitiveNodeType)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
const_cast<IPrimitive*>(_PropDlgLocators[i].Primitive)->removePropertyByName("name");
|
|
|
|
|
const_cast<IPrimitive*>(_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<IPrimitive*>(_PropDlgLocators[i].Primitive)->addPropertyByName("name",new CPropertyString (name));
|
|
|
|
|
const_cast<IPrimitive*>(_PropDlgLocators[i].Primitive)->addPropertyByName("path",new CPropertyString (path));
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (selected.at(i)->type() == Node::PrimitiveNodeType)
|
|
|
|
|
{
|
|
|
|
|
PrimitiveNode *node = static_cast<PrimitiveNode *>(selected.at(i));
|
|
|
|
|
const NLLIGO::IPrimitive *primitive = node->primitive();
|
|
|
|
|
const NLLIGO::CPrimitiveClass *primClass = node->primitiveClass();
|
|
|
|
|
PrimitiveNode *primNode = static_cast<PrimitiveNode *>(node);
|
|
|
|
|
const NLLIGO::IPrimitive *primitive = primNode->primitive();
|
|
|
|
|
const NLLIGO::CPrimitiveClass *primClass = primNode->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());
|
|
|
|
|
if (primClass->Parameters[p].Name == "name")
|
|
|
|
|
parameterList.push_front(primClass->Parameters[p]);
|
|
|
|
|
else
|
|
|
|
|
param = m_variantManager->addProperty(QVariant::String, primClass->Parameters[p].Name.c_str());
|
|
|
|
|
|
|
|
|
|
groupNode->addSubProperty(param);
|
|
|
|
|
|
|
|
|
|
parameterList.insert(primClass->Parameters[p]);
|
|
|
|
|
parameterList.push_back(primClass->Parameters[p]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -130,38 +103,199 @@ void PropertyEditorWidget::updateSelection(const NodeList &selected, const NodeL
|
|
|
|
|
// Get the property
|
|
|
|
|
std::string propertyName;
|
|
|
|
|
const NLLIGO::IProperty *prop;
|
|
|
|
|
nlverify(primitive->getProperty (p, propertyName, prop));
|
|
|
|
|
nlverify(primitive->getProperty(p, propertyName, prop));
|
|
|
|
|
|
|
|
|
|
// Add a default property
|
|
|
|
|
NLLIGO::CPrimitiveClass::CParameter defProp(*prop, propertyName.c_str());
|
|
|
|
|
parameterList.insert(defProp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (defProp.Name == "name")
|
|
|
|
|
parameterList.push_front(defProp);
|
|
|
|
|
else
|
|
|
|
|
parameterList.push_back(defProp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove property class
|
|
|
|
|
std::set<NLLIGO::CPrimitiveClass::CParameter>::iterator ite = parameterList.begin ();
|
|
|
|
|
std::list<NLLIGO::CPrimitiveClass::CParameter>::iterator ite = parameterList.begin ();
|
|
|
|
|
while (ite != parameterList.end ())
|
|
|
|
|
{
|
|
|
|
|
// Next iterator
|
|
|
|
|
std::set<NLLIGO::CPrimitiveClass::CParameter>::iterator next = ite;
|
|
|
|
|
std::list<NLLIGO::CPrimitiveClass::CParameter>::iterator next = ite;
|
|
|
|
|
next++;
|
|
|
|
|
|
|
|
|
|
// Property name ?
|
|
|
|
|
if (ite->Name == "class")
|
|
|
|
|
{
|
|
|
|
|
// Remove it
|
|
|
|
|
parameterList.erase (ite);
|
|
|
|
|
parameterList.erase(ite);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ite = next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add the default parameter
|
|
|
|
|
NLLIGO::CPrimitiveClass::CParameter defaultParameter;
|
|
|
|
|
defaultParameter.Visible = true;
|
|
|
|
|
defaultParameter.Filename = false;
|
|
|
|
|
QtProperty *groupNode;
|
|
|
|
|
groupNode = m_groupManager->addProperty(QString("%1(%2)").arg(node->data(Qt::DisplayRole).toString()).arg(primClass->Name.c_str()));
|
|
|
|
|
m_ui.treePropertyBrowser->addProperty(groupNode);
|
|
|
|
|
|
|
|
|
|
ite = parameterList.begin ();
|
|
|
|
|
while (ite != parameterList.end ())
|
|
|
|
|
{
|
|
|
|
|
NLLIGO::CPrimitiveClass::CParameter ¶meter = (*ite);
|
|
|
|
|
QtProperty *prop;
|
|
|
|
|
NLLIGO::IProperty *ligoProperty;
|
|
|
|
|
primitive->getPropertyByName(parameter.Name.c_str(), ligoProperty);
|
|
|
|
|
|
|
|
|
|
if (parameter.Type == NLLIGO::CPrimitiveClass::CParameter::ConstString)
|
|
|
|
|
prop = addConstStringProperty(ligoProperty, parameter, primitive);
|
|
|
|
|
else if (parameter.Type == NLLIGO::CPrimitiveClass::CParameter::String)
|
|
|
|
|
prop = addStringProperty(ligoProperty, parameter, primitive);
|
|
|
|
|
else if (parameter.Type == NLLIGO::CPrimitiveClass::CParameter::StringArray)
|
|
|
|
|
prop = addStringArrayProperty(ligoProperty, parameter, primitive);
|
|
|
|
|
else if (parameter.Type == NLLIGO::CPrimitiveClass::CParameter::ConstStringArray)
|
|
|
|
|
prop = addConstStringArrayProperty(ligoProperty, parameter, primitive);
|
|
|
|
|
else
|
|
|
|
|
// hmn?
|
|
|
|
|
prop = addBoolProperty(parameter, primitive);
|
|
|
|
|
|
|
|
|
|
// Default value ?
|
|
|
|
|
if ((ligoProperty == NULL) || (ligoProperty->Default))
|
|
|
|
|
prop->setModified(false);
|
|
|
|
|
else
|
|
|
|
|
prop->setModified(true);
|
|
|
|
|
|
|
|
|
|
bool staticChildSelected = Utils::ligoConfig()->isStaticChild(*primitive);
|
|
|
|
|
if (parameter.ReadOnly || (staticChildSelected && (parameter.Name == "name")))
|
|
|
|
|
prop->setEnabled(false);
|
|
|
|
|
|
|
|
|
|
groupNode->addSubProperty(prop);
|
|
|
|
|
|
|
|
|
|
ite++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QtProperty *PropertyEditorWidget::addBoolProperty(const NLLIGO::IProperty *property,
|
|
|
|
|
const NLLIGO::CPrimitiveClass::CParameter ¶meter,
|
|
|
|
|
const NLLIGO::IPrimitive *primitive)
|
|
|
|
|
{
|
|
|
|
|
std::string value;
|
|
|
|
|
std::string name = parameter.Name.c_str();
|
|
|
|
|
primitive->getPropertyByName(name.c_str(), value);
|
|
|
|
|
QtVariantProperty *prop = m_variantManager->addProperty(QVariant::Bool, name.c_str());
|
|
|
|
|
// if (Default)
|
|
|
|
|
{
|
|
|
|
|
//DialogProperties->setDefaultValue (this, value);
|
|
|
|
|
prop->setValue(bool((value=="true")?1:0));
|
|
|
|
|
}
|
|
|
|
|
return prop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QtProperty *PropertyEditorWidget::addConstStringProperty(const NLLIGO::IProperty *property,
|
|
|
|
|
const NLLIGO::CPrimitiveClass::CParameter ¶meter,
|
|
|
|
|
const NLLIGO::IPrimitive *primitive)
|
|
|
|
|
{
|
|
|
|
|
std::string context("default");
|
|
|
|
|
|
|
|
|
|
std::string value;
|
|
|
|
|
std::string name = parameter.Name.c_str();
|
|
|
|
|
primitive->getPropertyByName(name.c_str(), value);
|
|
|
|
|
QtProperty *prop = m_enumManager->addProperty(parameter.Name.c_str());
|
|
|
|
|
|
|
|
|
|
std::map<std::string, NLLIGO::CPrimitiveClass::CParameter::CConstStringValue>::const_iterator ite = parameter.ComboValues.find(context.c_str());
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
//if (ite != parameter.ComboValues.end())
|
|
|
|
|
{
|
|
|
|
|
std::vector<std::string> pathList;
|
|
|
|
|
{
|
|
|
|
|
ite->second.appendFilePath(pathList);
|
|
|
|
|
|
|
|
|
|
/*std::vector<const NLLIGO::IPrimitive*> relativePrimPaths;
|
|
|
|
|
{
|
|
|
|
|
std::vector<const NLLIGO::IPrimitive*> startPrimPath;
|
|
|
|
|
for (uint locIndex = 0; locIndex<_PropDlgLocators.size(); locIndex++)
|
|
|
|
|
startPrimPath.push_back(_PropDlgLocators[locIndex].Primitive);
|
|
|
|
|
|
|
|
|
|
ite->second.getPrimitivesForPrimPath(relativePrimPaths, startPrimPath);
|
|
|
|
|
}
|
|
|
|
|
ite->second.appendPrimPath(pathList, relativePrimPaths);*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (parameter.SortEntries)
|
|
|
|
|
std::sort(pathList.begin(), pathList.end());
|
|
|
|
|
|
|
|
|
|
int currentValue = 0;
|
|
|
|
|
QStringList listEnums;
|
|
|
|
|
for (size_t i = 0; i < pathList.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
listEnums.append(pathList[i].c_str());
|
|
|
|
|
if (value == pathList[i])
|
|
|
|
|
currentValue = i;
|
|
|
|
|
}
|
|
|
|
|
if (!pathList.empty())
|
|
|
|
|
{
|
|
|
|
|
m_enumManager->setEnumNames(prop, listEnums);
|
|
|
|
|
m_enumManager->setValue(prop, currentValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return prop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QtProperty *PropertyEditorWidget::addStringProperty(const NLLIGO::IProperty *property,
|
|
|
|
|
const NLLIGO::CPrimitiveClass::CParameter ¶meter,
|
|
|
|
|
const NLLIGO::IPrimitive *primitive)
|
|
|
|
|
{
|
|
|
|
|
std::string value;
|
|
|
|
|
std::string name = parameter.Name.c_str();
|
|
|
|
|
primitive->getPropertyByName(name.c_str(), value);
|
|
|
|
|
QtVariantProperty *prop = m_variantManager->addProperty(QVariant::String, parameter.Name.c_str());
|
|
|
|
|
prop->setValue(QString(value.c_str()));
|
|
|
|
|
return prop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QtProperty *PropertyEditorWidget::addStringArrayProperty(const NLLIGO::IProperty *property,
|
|
|
|
|
const NLLIGO::CPrimitiveClass::CParameter ¶meter,
|
|
|
|
|
const NLLIGO::IPrimitive *primitive)
|
|
|
|
|
{
|
|
|
|
|
std::string name = parameter.Name.c_str();
|
|
|
|
|
QtProperty *prop = m_stringArrayManager->addProperty(parameter.Name.c_str());
|
|
|
|
|
|
|
|
|
|
const NLLIGO::IProperty *ligoProperty;
|
|
|
|
|
std::vector<std::string> vectString;
|
|
|
|
|
|
|
|
|
|
if (primitive->getPropertyByName (parameter.Name.c_str (), ligoProperty))
|
|
|
|
|
{
|
|
|
|
|
const NLLIGO::CPropertyStringArray *const propStringArray = dynamic_cast<const NLLIGO::CPropertyStringArray *> (ligoProperty);
|
|
|
|
|
if (propStringArray)
|
|
|
|
|
{
|
|
|
|
|
const std::vector<std::string> &vectString = propStringArray->StringArray;
|
|
|
|
|
if (vectString.empty())
|
|
|
|
|
{
|
|
|
|
|
//m_stringArrayManager->setValue(prop, "StringArray");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
std::string temp;
|
|
|
|
|
for (size_t i = 0; i < vectString.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
temp += vectString[i];
|
|
|
|
|
if (i != (vectString.size() - 1))
|
|
|
|
|
temp += '\n';
|
|
|
|
|
}
|
|
|
|
|
m_stringArrayManager->setValue(prop, temp.c_str());
|
|
|
|
|
prop->setToolTip(temp.c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_stringArrayManager->setValue(prop, "StringArray :(");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return prop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QtProperty *PropertyEditorWidget::addConstStringArrayProperty(const NLLIGO::IProperty *property,
|
|
|
|
|
const NLLIGO::CPrimitiveClass::CParameter ¶meter,
|
|
|
|
|
const NLLIGO::IPrimitive *primitive)
|
|
|
|
|
{
|
|
|
|
|
std::string name = parameter.Name.c_str();
|
|
|
|
|
QtVariantProperty *prop = m_variantManager->addProperty(QVariant::String, parameter.Name.c_str());
|
|
|
|
|
prop->setValue("ConstStringArray");
|
|
|
|
|
return prop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} /* namespace WorldEditor */
|
|
|
|
|