mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-10 17:29:06 +00:00
Changed: #1302 Replaced VariantPropertyManager
This commit is contained in:
parent
25ed79ef55
commit
7977b787f3
2 changed files with 51 additions and 15 deletions
|
@ -37,22 +37,32 @@ PropertyEditorWidget::PropertyEditorWidget(QWidget *parent)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
m_variantManager = new QtVariantPropertyManager(this);
|
m_stringManager = new QtStringPropertyManager(this);
|
||||||
|
m_boolManager = new QtBoolPropertyManager(this);
|
||||||
m_enumManager = new QtEnumPropertyManager(this);
|
m_enumManager = new QtEnumPropertyManager(this);
|
||||||
m_stringArrayManager = new QtTextPropertyManager(this);
|
m_stringArrayManager = new QtTextPropertyManager(this);
|
||||||
|
|
||||||
connect(m_variantManager, SIGNAL(valueChanged(QtProperty *, const QVariant &)),
|
QtLineEditFactory *lineEditFactory = new QtLineEditFactory(this);
|
||||||
this, SLOT(valueChanged(QtProperty *, const QVariant &)));
|
QtCheckBoxFactory *boolFactory = new QtCheckBoxFactory(this);
|
||||||
|
|
||||||
QtVariantEditorFactory *variantFactory = new QtVariantEditorFactory(this);
|
|
||||||
QtEnumEditorFactory *enumFactory = new QtEnumEditorFactory(this);
|
QtEnumEditorFactory *enumFactory = new QtEnumEditorFactory(this);
|
||||||
QtTextEditorFactory *textFactory = new QtTextEditorFactory(this);
|
QtTextEditorFactory *textFactory = new QtTextEditorFactory(this);
|
||||||
|
|
||||||
m_ui.treePropertyBrowser->setFactoryForManager(m_variantManager, variantFactory);
|
m_ui.treePropertyBrowser->setFactoryForManager(m_stringManager, lineEditFactory);
|
||||||
|
m_ui.treePropertyBrowser->setFactoryForManager(m_boolManager, boolFactory);
|
||||||
m_ui.treePropertyBrowser->setFactoryForManager(m_enumManager, enumFactory);
|
m_ui.treePropertyBrowser->setFactoryForManager(m_enumManager, enumFactory);
|
||||||
m_ui.treePropertyBrowser->setFactoryForManager(m_stringArrayManager, textFactory);
|
m_ui.treePropertyBrowser->setFactoryForManager(m_stringArrayManager, textFactory);
|
||||||
|
|
||||||
m_groupManager = new QtGroupPropertyManager(this);
|
m_groupManager = new QtGroupPropertyManager(this);
|
||||||
|
|
||||||
|
connect(m_stringManager, SIGNAL(propertyChanged(QtProperty *)), this, SLOT(propertyChanged(QtProperty *)));
|
||||||
|
connect(m_boolManager, SIGNAL(propertyChanged(QtProperty *)), this, SLOT(propertyChanged(QtProperty *)));
|
||||||
|
connect(m_enumManager, SIGNAL(propertyChanged(QtProperty *)), this, SLOT(propertyChanged(QtProperty *)));
|
||||||
|
connect(m_stringArrayManager, SIGNAL(propertyChanged(QtProperty *)), this, SLOT(propertyChanged(QtProperty *)));
|
||||||
|
|
||||||
|
connect(m_boolManager, SIGNAL(resetProperty(QtProperty *)), this, SLOT(resetProperty(QtProperty *)));
|
||||||
|
connect(m_stringManager, SIGNAL(resetProperty(QtProperty *)), this, SLOT(resetProperty(QtProperty *)));
|
||||||
|
connect(m_enumManager, SIGNAL(resetProperty(QtProperty *)), this, SLOT(resetProperty(QtProperty *)));
|
||||||
|
connect(m_stringArrayManager, SIGNAL(resetProperty(QtProperty *)), this, SLOT(resetProperty(QtProperty *)));
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyEditorWidget::~PropertyEditorWidget()
|
PropertyEditorWidget::~PropertyEditorWidget()
|
||||||
|
@ -71,6 +81,8 @@ void PropertyEditorWidget::updateSelection(Node *node)
|
||||||
if ((node == 0) || (node->type() != Node::PrimitiveNodeType))
|
if ((node == 0) || (node->type() != Node::PrimitiveNodeType))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
blockSignalsOfProperties(true);
|
||||||
|
|
||||||
// The parameter list
|
// The parameter list
|
||||||
std::list<NLLIGO::CPrimitiveClass::CParameter> parameterList;
|
std::list<NLLIGO::CPrimitiveClass::CParameter> parameterList;
|
||||||
|
|
||||||
|
@ -149,7 +161,6 @@ void PropertyEditorWidget::updateSelection(Node *node)
|
||||||
else if (parameter.Type == NLLIGO::CPrimitiveClass::CParameter::ConstStringArray)
|
else if (parameter.Type == NLLIGO::CPrimitiveClass::CParameter::ConstStringArray)
|
||||||
prop = addConstStringArrayProperty(ligoProperty, parameter, primitive);
|
prop = addConstStringArrayProperty(ligoProperty, parameter, primitive);
|
||||||
else
|
else
|
||||||
// hmn?
|
|
||||||
prop = addBoolProperty(ligoProperty, parameter, primitive);
|
prop = addBoolProperty(ligoProperty, parameter, primitive);
|
||||||
|
|
||||||
// Default value ?
|
// Default value ?
|
||||||
|
@ -166,6 +177,18 @@ void PropertyEditorWidget::updateSelection(Node *node)
|
||||||
|
|
||||||
ite++;
|
ite++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockSignalsOfProperties(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertyEditorWidget::propertyChanged(QtProperty *property)
|
||||||
|
{
|
||||||
|
nlinfo(QString("property %1 changed").arg(property->propertyName()).toStdString().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertyEditorWidget::resetProperty(QtProperty *property)
|
||||||
|
{
|
||||||
|
nlinfo(QString("property %1 reset").arg(property->propertyName()).toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QtProperty *PropertyEditorWidget::addBoolProperty(const NLLIGO::IProperty *property,
|
QtProperty *PropertyEditorWidget::addBoolProperty(const NLLIGO::IProperty *property,
|
||||||
|
@ -175,11 +198,11 @@ QtProperty *PropertyEditorWidget::addBoolProperty(const NLLIGO::IProperty *prope
|
||||||
std::string value;
|
std::string value;
|
||||||
std::string name = parameter.Name.c_str();
|
std::string name = parameter.Name.c_str();
|
||||||
primitive->getPropertyByName(name.c_str(), value);
|
primitive->getPropertyByName(name.c_str(), value);
|
||||||
QtVariantProperty *prop = m_variantManager->addProperty(QVariant::Bool, name.c_str());
|
QtProperty *prop = m_boolManager->addProperty(name.c_str());
|
||||||
// if (Default)
|
// if (Default)
|
||||||
{
|
{
|
||||||
//DialogProperties->setDefaultValue (this, value);
|
//DialogProperties->setDefaultValue (this, value);
|
||||||
prop->setValue(bool((value=="true")?1:0));
|
m_boolManager->setValue(prop, bool((value=="true")?1:0));
|
||||||
}
|
}
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +265,7 @@ QtProperty *PropertyEditorWidget::addConstStringProperty(const NLLIGO::IProperty
|
||||||
|
|
||||||
if (listEnums.isEmpty())
|
if (listEnums.isEmpty())
|
||||||
{
|
{
|
||||||
listEnums << tr("WRN: Check leveldesign!");
|
listEnums << QString(value.c_str()) + tr(" (WRN: Check leveldesign!)");
|
||||||
m_enumManager->setEnumNames(prop, listEnums);
|
m_enumManager->setEnumNames(prop, listEnums);
|
||||||
m_enumManager->setValue(prop, 0);
|
m_enumManager->setValue(prop, 0);
|
||||||
prop->setEnabled(false);
|
prop->setEnabled(false);
|
||||||
|
@ -273,8 +296,8 @@ QtProperty *PropertyEditorWidget::addStringProperty(const NLLIGO::IProperty *pro
|
||||||
std::string value;
|
std::string value;
|
||||||
std::string name = parameter.Name.c_str();
|
std::string name = parameter.Name.c_str();
|
||||||
primitive->getPropertyByName(name.c_str(), value);
|
primitive->getPropertyByName(name.c_str(), value);
|
||||||
QtVariantProperty *prop = m_variantManager->addProperty(QVariant::String, parameter.Name.c_str());
|
QtProperty *prop = m_stringManager->addProperty(parameter.Name.c_str());
|
||||||
prop->setValue(QString(value.c_str()));
|
m_stringManager->setValue(prop, QString(value.c_str()));
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,10 +343,17 @@ QtProperty *PropertyEditorWidget::addConstStringArrayProperty(const NLLIGO::IPro
|
||||||
const NLLIGO::IPrimitive *primitive)
|
const NLLIGO::IPrimitive *primitive)
|
||||||
{
|
{
|
||||||
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());
|
QtProperty *prop = m_stringManager->addProperty(parameter.Name.c_str());
|
||||||
prop->setValue("TODO: ConstStringArray");
|
m_stringManager->setValue(prop, "TODO: ConstStringArray");
|
||||||
prop->setEnabled(false);
|
prop->setEnabled(false);
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertyEditorWidget::blockSignalsOfProperties(bool block)
|
||||||
|
{
|
||||||
|
m_stringManager->blockSignals(block);
|
||||||
|
m_boolManager->blockSignals(block);
|
||||||
|
m_enumManager->blockSignals(block);
|
||||||
|
m_stringArrayManager->blockSignals(block);
|
||||||
|
}
|
||||||
} /* namespace WorldEditor */
|
} /* namespace WorldEditor */
|
||||||
|
|
|
@ -54,6 +54,9 @@ public Q_SLOTS:
|
||||||
/// Update of selections
|
/// Update of selections
|
||||||
void updateSelection(Node *node);
|
void updateSelection(Node *node);
|
||||||
|
|
||||||
|
void propertyChanged(QtProperty *property);
|
||||||
|
void resetProperty(QtProperty *property);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QtProperty *addBoolProperty(const NLLIGO::IProperty *property,
|
QtProperty *addBoolProperty(const NLLIGO::IProperty *property,
|
||||||
const NLLIGO::CPrimitiveClass::CParameter ¶meter,
|
const NLLIGO::CPrimitiveClass::CParameter ¶meter,
|
||||||
|
@ -71,7 +74,10 @@ private:
|
||||||
const NLLIGO::CPrimitiveClass::CParameter ¶meter,
|
const NLLIGO::CPrimitiveClass::CParameter ¶meter,
|
||||||
const NLLIGO::IPrimitive *primitive);
|
const NLLIGO::IPrimitive *primitive);
|
||||||
|
|
||||||
QtVariantPropertyManager *m_variantManager;
|
void blockSignalsOfProperties(bool block);
|
||||||
|
|
||||||
|
QtBoolPropertyManager *m_boolManager;
|
||||||
|
QtStringPropertyManager *m_stringManager;
|
||||||
QtEnumPropertyManager *m_enumManager;
|
QtEnumPropertyManager *m_enumManager;
|
||||||
QtGroupPropertyManager *m_groupManager;
|
QtGroupPropertyManager *m_groupManager;
|
||||||
QtTextPropertyManager *m_stringArrayManager;
|
QtTextPropertyManager *m_stringArrayManager;
|
||||||
|
|
Loading…
Reference in a new issue