Changed: #1302 Added some stuff for weqt property editor.
This commit is contained in:
parent
07fb99c510
commit
f4975287a1
5 changed files with 117 additions and 8 deletions
|
@ -11,7 +11,6 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.
|
||||||
SET(OVQT_CORE_PLUGIN_HDR
|
SET(OVQT_CORE_PLUGIN_HDR
|
||||||
icore.h
|
icore.h
|
||||||
icontext.h
|
icontext.h
|
||||||
imenu_manager.h
|
|
||||||
icore_listener.h
|
icore_listener.h
|
||||||
ioptions_page.h
|
ioptions_page.h
|
||||||
core_plugin.h
|
core_plugin.h
|
||||||
|
|
|
@ -75,9 +75,7 @@ QVariant ListZonesModel::data(const QModelIndex &index, int role) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ListZonesModel::headerData(int section,
|
QVariant ListZonesModel::headerData(int section, Qt::Orientation, int role) const
|
||||||
Qt::Orientation /* orientation */,
|
|
||||||
int role) const
|
|
||||||
{
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,12 +37,16 @@ PropertyEditorWidget::PropertyEditorWidget(QWidget *parent)
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
m_variantManager = new QtVariantPropertyManager(this);
|
m_variantManager = new QtVariantPropertyManager(this);
|
||||||
|
m_enumManager = new QtEnumPropertyManager(this);
|
||||||
connect(m_variantManager, SIGNAL(valueChanged(QtProperty *, const QVariant &)),
|
connect(m_variantManager, SIGNAL(valueChanged(QtProperty *, const QVariant &)),
|
||||||
this, SLOT(valueChanged(QtProperty *, const QVariant &)));
|
this, SLOT(valueChanged(QtProperty *, const QVariant &)));
|
||||||
|
|
||||||
QtVariantEditorFactory *variantFactory = new QtVariantEditorFactory(this);
|
QtVariantEditorFactory *variantFactory = new QtVariantEditorFactory(this);
|
||||||
|
QtEnumEditorFactory *enumFactory = new QtEnumEditorFactory(this);
|
||||||
m_ui.treePropertyBrowser->setFactoryForManager(m_variantManager, variantFactory);
|
m_ui.treePropertyBrowser->setFactoryForManager(m_variantManager, variantFactory);
|
||||||
|
m_ui.treePropertyBrowser->setFactoryForManager(m_enumManager, enumFactory);
|
||||||
|
|
||||||
|
m_groupManager = new QtGroupPropertyManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyEditorWidget::~PropertyEditorWidget()
|
PropertyEditorWidget::~PropertyEditorWidget()
|
||||||
|
@ -51,10 +55,113 @@ PropertyEditorWidget::~PropertyEditorWidget()
|
||||||
|
|
||||||
void PropertyEditorWidget::clearProperties()
|
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<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();
|
||||||
|
|
||||||
|
// 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<NLLIGO::CPrimitiveClass::CParameter>::iterator ite = parameterList.begin ();
|
||||||
|
while (ite != parameterList.end ())
|
||||||
|
{
|
||||||
|
// Next iterator
|
||||||
|
std::set<NLLIGO::CPrimitiveClass::CParameter>::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 */
|
} /* namespace WorldEditor */
|
||||||
|
|
|
@ -50,11 +50,16 @@ public:
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void clearProperties();
|
void clearProperties();
|
||||||
void setCurrentPrimitive(PrimitiveNode *node);
|
|
||||||
|
/// Update of selections
|
||||||
|
void updateSelection(const NodeList &selected, const NodeList &deselected);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QtVariantPropertyManager *m_variantManager;
|
QtVariantPropertyManager *m_variantManager;
|
||||||
|
QtEnumPropertyManager *m_enumManager;
|
||||||
|
QtGroupPropertyManager *m_groupManager;
|
||||||
|
|
||||||
Ui::PropertyEditorWidget m_ui;
|
Ui::PropertyEditorWidget m_ui;
|
||||||
}; /* PropertyEditorWidget */
|
}; /* PropertyEditorWidget */
|
||||||
|
|
||||||
|
|
|
@ -276,7 +276,7 @@ void WorldEditorWindow::updateSelection(const QItemSelection &selected, const QI
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: update property editor
|
// TODO: update property editor
|
||||||
// ...
|
m_ui.propertyEditWidget->updateSelection(nodesSelected, nodesDeselected);
|
||||||
|
|
||||||
QList<QGraphicsItem *> itemSelected;
|
QList<QGraphicsItem *> itemSelected;
|
||||||
Q_FOREACH(Node *node, nodesSelected)
|
Q_FOREACH(Node *node, nodesSelected)
|
||||||
|
|
Loading…
Reference in a new issue