Changed: #1302 Correct fill properties(ConstStringValue) with *both* contexts if the current context is not default and is valid.

This commit is contained in:
dnk-88 2012-06-10 16:56:45 +03:00
parent c2bd4fabd6
commit 5fb4de1a21

View file

@ -132,12 +132,12 @@ void PropertyEditorWidget::updateSelection(Node *node)
groupNode = m_groupManager->addProperty(QString("%1(%2)").arg(node->data(Qt::DisplayRole).toString()).arg(primClass->Name.c_str())); groupNode = m_groupManager->addProperty(QString("%1(%2)").arg(node->data(Qt::DisplayRole).toString()).arg(primClass->Name.c_str()));
m_ui.treePropertyBrowser->addProperty(groupNode); m_ui.treePropertyBrowser->addProperty(groupNode);
ite = parameterList.begin (); ite = parameterList.begin();
while (ite != parameterList.end ()) while (ite != parameterList.end())
{ {
NLLIGO::CPrimitiveClass::CParameter &parameter = (*ite); NLLIGO::CPrimitiveClass::CParameter &parameter = (*ite);
QtProperty *prop; QtProperty *prop;
NLLIGO::IProperty *ligoProperty; NLLIGO::IProperty *ligoProperty = 0;
primitive->getPropertyByName(parameter.Name.c_str(), ligoProperty); primitive->getPropertyByName(parameter.Name.c_str(), ligoProperty);
if (parameter.Type == NLLIGO::CPrimitiveClass::CParameter::ConstString) if (parameter.Type == NLLIGO::CPrimitiveClass::CParameter::ConstString)
@ -188,22 +188,39 @@ QtProperty *PropertyEditorWidget::addConstStringProperty(const NLLIGO::IProperty
const NLLIGO::CPrimitiveClass::CParameter &parameter, const NLLIGO::CPrimitiveClass::CParameter &parameter,
const NLLIGO::IPrimitive *primitive) const NLLIGO::IPrimitive *primitive)
{ {
std::string context("default"); // TODO: get context value from dialog
std::string context("jungle");
std::string defaultContext("default");
std::string value; std::string value;
std::string name = parameter.Name.c_str(); std::string name = parameter.Name.c_str();
// Get current value
primitive->getPropertyByName(name.c_str(), value); primitive->getPropertyByName(name.c_str(), value);
// Create qt property
QtProperty *prop = m_enumManager->addProperty(parameter.Name.c_str()); 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()); std::vector<std::string> listContext;
// TODO if (context != defaultContext)
//if (ite != parameter.ComboValues.end()) listContext.push_back(context);
listContext.push_back(defaultContext);
QStringList listEnums;
// Correct fill properties with *both* contexts if the current context is not default and is valid.
for (size_t j = 0; j < listContext.size(); j++)
{
std::map<std::string, NLLIGO::CPrimitiveClass::CParameter::CConstStringValue>::const_iterator ite = parameter.ComboValues.find(listContext[j].c_str());
if (ite != parameter.ComboValues.end())
{ {
std::vector<std::string> pathList; std::vector<std::string> pathList;
{ {
ite->second.appendFilePath(pathList); ite->second.appendFilePath(pathList);
// TODO: what is it?
/*std::vector<const NLLIGO::IPrimitive*> relativePrimPaths; /*std::vector<const NLLIGO::IPrimitive*> relativePrimPaths;
{ {
std::vector<const NLLIGO::IPrimitive*> startPrimPath; std::vector<const NLLIGO::IPrimitive*> startPrimPath;
@ -218,20 +235,34 @@ QtProperty *PropertyEditorWidget::addConstStringProperty(const NLLIGO::IProperty
if (parameter.SortEntries) if (parameter.SortEntries)
std::sort(pathList.begin(), pathList.end()); std::sort(pathList.begin(), pathList.end());
int currentValue = 0;
QStringList listEnums;
for (size_t i = 0; i < pathList.size(); ++i) for (size_t i = 0; i < pathList.size(); ++i)
{
listEnums.append(pathList[i].c_str()); listEnums.append(pathList[i].c_str());
if (value == pathList[i])
currentValue = i;
} }
if (!pathList.empty()) }
if (listEnums.isEmpty())
{ {
listEnums << tr("WRN: Check leveldesign!");
m_enumManager->setEnumNames(prop, listEnums); m_enumManager->setEnumNames(prop, listEnums);
m_enumManager->setValue(prop, currentValue); m_enumManager->setValue(prop, 0);
prop->setEnabled(false);
}
else
{
// Fill qt property
m_enumManager->setEnumNames(prop, listEnums);
// Find index of current value
for (int i = 0; i < listEnums.size(); i++)
{
if (value == listEnums[i].toStdString())
{
m_enumManager->setValue(prop, i);
break;
} }
} }
}
return prop; return prop;
} }
@ -263,11 +294,7 @@ QtProperty *PropertyEditorWidget::addStringArrayProperty(const NLLIGO::IProperty
if (propStringArray) if (propStringArray)
{ {
const std::vector<std::string> &vectString = propStringArray->StringArray; const std::vector<std::string> &vectString = propStringArray->StringArray;
if (vectString.empty()) if (!vectString.empty())
{
//m_stringArrayManager->setValue(prop, "StringArray");
}
else
{ {
std::string temp; std::string temp;
for (size_t i = 0; i < vectString.size(); i++) for (size_t i = 0; i < vectString.size(); i++)
@ -294,7 +321,8 @@ QtProperty *PropertyEditorWidget::addConstStringArrayProperty(const NLLIGO::IPro
{ {
std::string name = parameter.Name.c_str(); std::string name = parameter.Name.c_str();
QtVariantProperty *prop = m_variantManager->addProperty(QVariant::String, parameter.Name.c_str()); QtVariantProperty *prop = m_variantManager->addProperty(QVariant::String, parameter.Name.c_str());
prop->setValue("ConstStringArray"); prop->setValue("TODO: ConstStringArray");
prop->setEnabled(false);
return prop; return prop;
} }