From e527bfdeaa8ef85b7b9319b1e4275f4c97489115 Mon Sep 17 00:00:00 2001 From: sfb Date: Mon, 17 Sep 2012 15:12:01 -0500 Subject: [PATCH 2/9] merging legacy dfn-based method into geqt. Warning: broke the build. --- .../src/plugins/georges_editor/formitem.cpp | 198 ++- .../src/plugins/georges_editor/formitem.h | 17 +- .../georges_treeview_dialog.cpp | 124 +- .../georges_editor/georges_treeview_dialog.h | 12 +- .../georges_editor/georgesform_model.cpp | 1494 ++++++++++------- .../georges_editor/georgesform_model.h | 17 +- .../src/plugins/object_viewer/main_window.cpp | 2 +- 7 files changed, 1140 insertions(+), 724 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp index e6e526631..014338a2d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp @@ -23,11 +23,13 @@ #include #include +using namespace NLGEORGES; + namespace GeorgesQt { CFormItem::CFormItem(NLGEORGES::UFormElm* elm, const QList &data, CFormItem *parent, - NLGEORGES::UFormElm::TWhereIsValue wV, NLGEORGES::UFormElm::TWhereIsNode wN) + NLGEORGES::UFormElm::TWhereIsValue wV, NLGEORGES::UFormElm::TWhereIsNode wN) { parentItem = parent; itemData = data; @@ -159,4 +161,198 @@ namespace GeorgesQt //formElm->setValueByName(); return true; } + +// CFormItem *CFormItem::add (/*TSub type,*/ const char *name, uint structId, const char *formName, uint slot) +// { + // Add at the end +// uint index = _Children.size(); +// _Children.push_back (new CGeorgesEditDocSub); + +// _Children[index]->_Type = type; +// _Children[index]->_Name = name; +// _Children[index]->_Parent = this; +// _Children[index]->_StructId = structId; +// _Children[index]->_FormName = formName; +// _Children[index]->_Slot = slot; +// return _Children[index]; +// CFormItem *newNode = new CFormItem(); +// appendChild(newNode); +// return NULL; +// } + + CFormItem *CFormItem::add(NLGEORGES::UFormElm* root, std::string elmName) + { + CFormItem *newItem = NULL; + UFormElm::TWhereIsNode *whereN = new UFormElm::TWhereIsNode; + UFormElm::TWhereIsValue *whereV = new UFormElm::TWhereIsValue; + // Append a new item to the current parent's list of children. +// std::string elmName; +// if(root->getStructNodeName(num, elmName)) +// { + QList columnData; + //QVariant value; + std::string value; + //NLMISC::CRGBA value_color; + //uint value_uint; + //sint value_sint; + //double value_double; + QString elmtType = ""; + UFormElm *elmt = 0; + if(root->getNodeByName(&elmt, elmName.c_str(), whereN, true)) + { + if (elmt) + { + if (elmt->isArray()) + elmtType = "Array"; + if (elmt->isStruct()) + elmtType = "Struct"; + if (elmt->isAtom()) + { + elmtType = "Atom"; + uint numDefinitions = 0; + const UType *type = elmt->getType(); + if (type) + { + numDefinitions = type->getNumDefinition(); + root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); + switch (type->getType()) + { + case UType::UnsignedInt: + value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toStdString(); + elmtType.append("_uint");break; + case UType::SignedInt: + value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toStdString(); + elmtType.append("_sint");break; + case UType::Double: + value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble(),0,'f',1).toStdString(); + elmtType.append("_double");break; + case UType::String: + elmtType.append("_string");break; + case UType::Color: + elmtType.append("_color");break; + default: + elmtType.append("_unknownType"); + } + } + else + { + elmtType.append("_noType"); + } + + if (numDefinitions) + { + std::string l, v; + QString tmpLabel, tmpValue; + for (uint i = 0; i < numDefinitions; i++) + { + type->getDefinition(i,l,v); + tmpLabel = l.c_str(); + tmpValue = v.c_str(); + if (type->getType() == UType::SignedInt) + { + if (QString("%1").arg(value.c_str()).toDouble() == tmpValue.toDouble()) { + value = l; + break; + } + } + if (type->getType() == UType::String) + { + if (QString(value.c_str()) == tmpValue) + { + value = l; + break; + } + } + } + } + } + if (elmt->isVirtualStruct()) + { + root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); + elmtType = "VirtualStruct"; + } + switch (*whereN) + { + case UFormElm::NodeForm: + elmtType.append("_fromForm"); break; + case UFormElm::NodeParentForm: + elmtType.append("_fromParentForm"); break; + case UFormElm::NodeDfn: + elmtType.append("_isDFN"); break; + case UFormElm::NodeType: + elmtType.append("_isType"); break; + default: + elmtType.append("_noNode"); + } + switch (*whereV) + { + case UFormElm::ValueForm: + elmtType.append("_formValue"); break; + case UFormElm::ValueParentForm: + elmtType.append("_parentValue"); break; + case UFormElm::ValueDefaultDfn: + elmtType.append("_dfnValue"); break; + case UFormElm::ValueDefaultType: + elmtType.append("_typeValue"); break; + default: + elmtType.append("_noValue"); + } + columnData << QString(elmName.c_str()) << QString(value.c_str()) << "";// << elmtType; + + newItem = new CFormItem(elmt, columnData, this, *whereV, *whereN); + this->appendChild(newItem); + + return newItem; + //if (parents.last()->childCount() > 0) { + // parents << parents.last()->child(parents.last()->childCount()-1); + //} + + // The building of the tree should be haoppening in the mode,. + //loadFormData(elmt, parent->child(parent->childCount()-1)); + } + else + { + // add Defaults + // TODO: spams warnings for non ATOM values but i dont get type of non existing nodes + bool success = root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); + switch (*whereN) + { + case UFormElm::NodeForm: + elmtType.append("_fromForm"); break; + case UFormElm::NodeParentForm: + elmtType.append("_fromParentForm"); break; + case UFormElm::NodeDfn: + elmtType.append("_isDFN"); break; + case UFormElm::NodeType: + elmtType.append("_isType"); break; + default: + elmtType.append("_noNode"); + } + switch (*whereV) + { + case UFormElm::ValueForm: + elmtType.append("_formValue"); break; + case UFormElm::ValueParentForm: + elmtType.append("_parentValue"); break; + case UFormElm::ValueDefaultDfn: + elmtType.append("_dfnValue"); break; + case UFormElm::ValueDefaultType: + elmtType.append("_typeValue"); break; + default: + elmtType.append("_noValue"); + } + + columnData << QString(elmName.c_str()) << QString(value.c_str()) << "";// << elmtType; + newItem = new CFormItem(elmt, columnData, this, *whereV, *whereN); + this->appendChild(newItem); + return newItem; + } +// } +// else +// { +// nlinfo("getNodeByName returned false"); +// } + } + } + } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h index f440d1cf4..c56422caf 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h @@ -33,11 +33,13 @@ namespace GeorgesQt public: CFormItem(NLGEORGES::UFormElm *elm, const QList &data, CFormItem *parent = 0, - NLGEORGES::UFormElm::TWhereIsValue = NLGEORGES::UFormElm::ValueForm, - NLGEORGES::UFormElm::TWhereIsNode = NLGEORGES::UFormElm::NodeForm); + NLGEORGES::UFormElm::TWhereIsValue wV = NLGEORGES::UFormElm::ValueForm, + NLGEORGES::UFormElm::TWhereIsNode wN = NLGEORGES::UFormElm::NodeForm); ~CFormItem(); void appendChild(CFormItem *child); + //CFormItem *add (/*TSub type,*/ const char *name, uint structId, const char *formName, uint slot); + CFormItem *add(NLGEORGES::UFormElm* root, std::string elmName); CFormItem *child(int row); int childCount() const; @@ -56,13 +58,18 @@ namespace GeorgesQt return whereN; } - private: + void setValueFrom(NLGEORGES::UFormElm::TWhereIsValue wV) { whereV = wV; } + void setNodeFrom(NLGEORGES::UFormElm::TWhereIsNode wN) { whereN = wN; } + + + private: + //CFormItem() { whereV = NLGEORGES::UFormElm::ValueForm; whereN = NLGEORGES::UFormElm::NodeForm; } QList childItems; QList itemData; CFormItem *parentItem; NLGEORGES::UFormElm* formElm; - NLGEORGES::UFormElm::TWhereIsValue whereV; - NLGEORGES::UFormElm::TWhereIsNode whereN; + NLGEORGES::UFormElm::TWhereIsValue whereV; + NLGEORGES::UFormElm::TWhereIsNode whereN; }; // CFormItem } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp index 3bdc680ff..92da6e8a0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp @@ -61,7 +61,7 @@ namespace GeorgesQt // Set the default sheet dir dir to the level design path. m_lastSheetDir = "."; QSettings *settings = Core::ICore::instance()->settings(); - settings->beginGroup(Core::Constants::DATA_PATH_SECTION); + settings->beginGroup(Core::Constants::DATA_PATH_SECTION); m_lastSheetDir = settings->value(Core::Constants::LEVELDESIGN_PATH, "l:/leveldesign").toString(); settings->endGroup(); @@ -102,12 +102,12 @@ namespace GeorgesQt void CGeorgesTreeViewDialog::headerClicked(int section) { if (section == 0) - { + { if (*(m_header->expanded())) m_ui.treeView->expandAll(); else m_ui.treeView->collapseAll(); - } + } } void CGeorgesTreeViewDialog::setForm(const CForm *form) @@ -119,8 +119,8 @@ namespace GeorgesQt { if(NLMISC::CPath::exists(formName.toStdString())) { - //NLGEORGES::CForm *form = dynamic_cast(m_georges->loadForm(formName.toStdString())); - return (NLGEORGES::CForm *)m_georges->loadForm(formName.toStdString()); + //NLGEORGES::CForm *form = dynamic_cast(m_georges->loadForm(formName.toStdString())); + return (NLGEORGES::CForm *)m_georges->loadForm(formName.toStdString()); } //else //{ @@ -156,56 +156,56 @@ namespace GeorgesQt // } // return form; //} - nlinfo("File '%s' does not exist!", formName.toStdString().c_str()); + nlinfo("File '%s' does not exist!", formName.toStdString().c_str()); return 0; } NLGEORGES::CForm* CGeorgesTreeViewDialog::getFormByDfnName(const QString dfnName) { - if(NLMISC::CPath::exists(dfnName.toStdString())) - { - // Create a new form object. - NLGEORGES::CForm *form = new NLGEORGES::CForm(); - m_form = form; + if(NLMISC::CPath::exists(dfnName.toStdString())) + { + // Create a new form object. + NLGEORGES::CForm *form = new NLGEORGES::CForm(); + m_form = form; - // Retrieve a copy of the root definition. - NLGEORGES::CFormDfn *formDfn = dynamic_cast(m_georges->loadFormDfn(dfnName.toStdString())); + // Retrieve a copy of the root definition. + NLGEORGES::CFormDfn *formDfn = dynamic_cast(m_georges->loadFormDfn(dfnName.toStdString())); - // Next we'll use the root node to build a new form. - NLGEORGES::CFormElmStruct *fes = dynamic_cast(getRootNode(0)); - fes->build(formDfn); + // Next we'll use the root node to build a new form. + NLGEORGES::CFormElmStruct *fes = dynamic_cast(getRootNode(0)); + fes->build(formDfn); - // And then initialize the held elements; - for(uint i = 0; i(getRootNode(i+1)); - fes->build(formDfn); - } + // And then initialize the held elements; + for(uint i = 0; i(getRootNode(i+1)); + fes->build(formDfn); + } - return form; - } - nlinfo("File '%s' does not exist!", dfnName.toStdString().c_str()); - return NULL; + return form; + } + nlinfo("File '%s' does not exist!", dfnName.toStdString().c_str()); + return NULL; } NLGEORGES::CFormElm *CGeorgesTreeViewDialog::getRootNode(uint slot) { - NLGEORGES::CForm *form = getFormPtr(); + NLGEORGES::CForm *form = getFormPtr(); - if(slot == 0) - { - const NLGEORGES::UFormElm &formElm = form->getRootNode(); - return (NLGEORGES::CFormElm *)&formElm; - } + if(slot == 0) + { + const NLGEORGES::UFormElm &formElm = form->getRootNode(); + return (NLGEORGES::CFormElm *)&formElm; + } - // Make sure the slot value is valid and then return the corresponding element. - nlassert(slot < NLGEORGES::CForm::HeldElementCount+1); - return getFormPtr()->HeldElements[slot-1]; + // Make sure the slot value is valid and then return the corresponding element. + nlassert(slot < NLGEORGES::CForm::HeldElementCount+1); + return getFormPtr()->HeldElements[slot-1]; } NLGEORGES::CForm *CGeorgesTreeViewDialog::getFormPtr() { - return dynamic_cast(m_form); + return dynamic_cast(m_form); } void CGeorgesTreeViewDialog::loadFormIntoDialog(CForm *form) @@ -219,14 +219,16 @@ namespace GeorgesQt UFormElm *root = 0; root = &m_form->getRootNode(); + // Extract the parent forms into the list of parents in the dialog. QStringList parents; - uint cnt = form->getParentCount(); - for (uint i = 0; i < cnt /*form->getParentCount()*/; i++) + uint cnt = form->getParentCount(); + for (uint i = 0; i < cnt /*form->getParentCount()*/; i++) { UForm *u = m_form->getParentForm(i); parents << u->getFilename().c_str(); } + // Exact the comment box for the dialog. QString comments; comments = m_form->getComment().c_str(); @@ -255,7 +257,7 @@ namespace GeorgesQt { loadedForm = m_form->getFilename().c_str(); - CGeorgesFormModel *model = new CGeorgesFormModel(root,deps,comments,parents,m_header->expanded()); + CGeorgesFormModel *model = new CGeorgesFormModel(m_form,deps,comments,parents,m_header->expanded()); CGeorgesFormProxyModel *proxyModel = new CGeorgesFormProxyModel(); proxyModel->setSourceModel(model); m_ui.treeView->setModel(proxyModel); @@ -317,12 +319,12 @@ namespace GeorgesQt void CGeorgesTreeViewDialog::write( ) { - NLMISC::COFile file; - std::string s = NLMISC::CPath::lookup(loadedForm.toStdString(), false); - if(file.open (s)) - { - try - { + NLMISC::COFile file; + std::string s = NLMISC::CPath::lookup(loadedForm.toStdString(), false); + if(file.open (s)) + { + try + { // if (loadedForm.contains(".typ")) // { // //nlassert (Type != NULL); @@ -335,7 +337,7 @@ namespace GeorgesQt // // flushValueChange (); // //} // //Type->write (xmlStream.getDocument (), theApp.Georges4CVS); - // //modify (NULL, NULL, false); + // //modify (NULL, NULL, false); // //flushValueChange (); // //UpdateAllViews (NULL); // //return TRUE; @@ -357,17 +359,17 @@ namespace GeorgesQt // } // else // { - nlassert (m_form != NULL); + nlassert (m_form != NULL); - // Write the file + // Write the file // /*if (IsModified ()) // { // ((CForm*)(UForm*)Form)->Header.MinorVersion++; // }*/ // //((CForm*)(UForm*)Form)->write (xmlStream.getDocument (), lpszPathName, theApp.Georges4CVS); - m_form->write(file, false); - setWindowTitle(windowTitle().remove("*")); - m_modified = false; + m_form->write(file, false); + setWindowTitle(windowTitle().remove("*")); + m_modified = false; // //if (strcmp (xmlStream.getErrorString (), "") != 0) // //{ // // char message[512]; @@ -381,16 +383,16 @@ namespace GeorgesQt // // Get the left view // //CView* pView = getLeftView (); // } - } - catch (Exception &e) - { - nlerror("Error while loading file: %s", e.what()); - } - } - else - { - nlerror("Can't open the file %s for writing.", s.c_str()); - } + } + catch (Exception &e) + { + nlerror("Error while loading file: %s", e.what()); + } + } + else + { + nlerror("Can't open the file %s for writing.", s.c_str()); + } } void CGeorgesTreeViewDialog::doubleClicked ( const QModelIndex & index ) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.h index e34ab572b..6f7b57acc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.h @@ -57,14 +57,14 @@ namespace GeorgesQt bool isModified() {return m_modified;} void setModified(bool m) {m_modified = m;} - NLGEORGES::CForm* getFormByName(const QString formName); - NLGEORGES::CForm* getFormByDfnName(const QString dfnName); + NLGEORGES::CForm* getFormByName(const QString formName); + NLGEORGES::CForm* getFormByDfnName(const QString dfnName); - /// Retrieves the root element based on the slot (document or held elements.) - NLGEORGES::CFormElm *getRootNode(uint slot); + /// Retrieves the root element based on the slot (document or held elements.) + NLGEORGES::CFormElm *getRootNode(uint slot); - /// Returns the form as a CForm pointer. - NLGEORGES::CForm *getFormPtr(); + /// Returns the form as a CForm pointer. + NLGEORGES::CForm *getFormPtr(); void addParentForm(QString parentFormNm); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp index 9e3f97c48..b8c9f56ff 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp @@ -16,13 +16,18 @@ #include "georgesform_model.h" +// System Includes +#include + // NeL includes #include #include #include +#include #include #include #include +#include // Qt includes #include @@ -43,653 +48,848 @@ using namespace NLGEORGES; namespace GeorgesQt { - CGeorgesFormModel::CGeorgesFormModel(UFormElm *rootElm, QMap< QString, QStringList> deps, - QString comment, QStringList parents, bool *expanded, QObject *parent) : QAbstractItemModel(parent) - { - - m_rootData << "Value" << "Data" << "Extra";// << "Type"; - m_rootElm = rootElm; - m_rootItem = new CFormItem(m_rootElm, m_rootData); - m_dependencies = deps; - m_comments = comment; - m_parents = parents; - m_parentRows = new QList; - m_expanded = expanded; - - setupModelData(); - } - - CGeorgesFormModel::~CGeorgesFormModel() - { - delete m_rootItem; - } - - /******************************************************************************/ - - QVariant CGeorgesFormModel::data(const QModelIndex &p_index, int p_role) const - { - if (!p_index.isValid()) - return QVariant(); - - switch (p_role) - { - case Qt::DisplayRole: - { - return getItem(p_index)->data(p_index.column()); - } - case Qt::BackgroundRole: - { - QBrush defaultBrush = QBrush(QColor(255,0,0,30)); - QBrush parentBrush = QBrush(QColor(0,255,0,30)); - - // if elm not existing it must be some kind of default or type value - if(!getItem(p_index)->getFormElm()) - { - return defaultBrush; - } - - // else it might be some parent elm - switch (getItem(p_index)->nodeFrom()) - { - case NLGEORGES::UFormElm::NodeParentForm: - { - return parentBrush; - } - case NLGEORGES::UFormElm::NodeForm: - { - switch (getItem(p_index)->valueFrom()) - { - case NLGEORGES::UFormElm::ValueParentForm: - { - return parentBrush; - } - default: - { - // parent status test kindof ugly, testing only 2 steps deep - // only needed for colorization as treeview default hides childs - // when parent is hidden - CFormItem *parent = getItem(p_index)->parent(); - if (parent) - { - if (parent->nodeFrom() == NLGEORGES::UFormElm::NodeParentForm) - { - return parentBrush; - } - - CFormItem *parentParent = parent->parent(); - if (parentParent) - { - if (parentParent->nodeFrom() == NLGEORGES::UFormElm::NodeParentForm) - { - return parentBrush; - } - } // endif parentParent - } // endif parent - } // end default - } // end switch valueFrom - } // end case nodeForm - } // end switch nodeFrom - return QVariant(); - } - case Qt::DecorationRole: - { - if (p_index.column() == 2) - { - //p_index. - QModelIndex in = index(p_index.row(),p_index.column()-1,p_index.parent()); - CFormItem *item = getItem(in); - - QString value = item->data(1).toString(); - //QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); - - /*if (value.contains(".shape")) - { - if (Modules::objViewInt()) - { - QIcon *icon = Modules::objViewInt()->saveOneImage(value.toStdString()); - if (icon) - { - if(icon->isNull()) - return QIcon(":/images/pqrticles.png"); - else - return QIcon(*icon); - } - else - { - return QIcon(); - } - } - }*/ - if(value.contains(".tga") || value.contains(".png")) - { - QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); - if(path.isEmpty()) - { - path = ":/images/pqrticles.png"; - } - return QIcon(path); - } - } - return QVariant(); - break; - } - case Qt::ToolTipRole: - { - if (p_index.column() == 2) - { - QModelIndex in = index(p_index.row(),p_index.column()-1,p_index.parent()); - CFormItem *item = getItem(in); - QString value = item->data(1).toString(); - - /*if (value.contains(".shape")) - { - if (Modules::objViewInt()) - { - QIcon *icon = Modules::objViewInt()->saveOneImage(value.toStdString()); - if (icon) - { - if(icon->isNull()) - return QIcon(":/images/pqrticles.png"); - else - return QIcon(*icon); - } - else - { - return QIcon(); - } - } - }*/ - if(value.contains(".tga") || value.contains(".png")) - { - QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); - if(path.isEmpty()) - { - path = ":/images/pqrticles.png"; - } - - QString imageTooltip = QString("").arg(path); - - return imageTooltip; - } - } - return QVariant(); - break; - } - default: - return QVariant(); - } - } - - /******************************************************************************/ - - CFormItem *CGeorgesFormModel::getItem(const QModelIndex &index) const - { - if (index.isValid()) - { - CFormItem *item = static_cast(index.internalPointer()); - if (item) - return item; - } - return m_rootItem; - } - - /******************************************************************************/ - - bool CGeorgesFormModel::setData(const QModelIndex &index, const QVariant &value, - int role) - { - - if (role != Qt::EditRole) - return false; - - CFormItem *item = getItem(index); - bool result = item->setData(index.column(), value); - - Q_EMIT dataChanged(index, index); - - //setupModelData(); - return result; - } - - /******************************************************************************/ - - Qt::ItemFlags CGeorgesFormModel::flags(const QModelIndex& index) const { - - if (!index.isValid()) - return 0; - - Qt::ItemFlags returnValue = Qt::ItemIsSelectable | Qt::ItemIsEnabled; - - if(index.column() == 1) - returnValue |= Qt::ItemIsEditable; - - return returnValue; - - } - - /******************************************************************************/ - - QVariant CGeorgesFormModel::headerData(int section, - Qt::Orientation orientation, int role) const - { - if (orientation == Qt::Horizontal) - { - if (role == Qt::DisplayRole) - return m_rootItem->data(section); - if (role == Qt::TextAlignmentRole) - return Qt::AlignLeft; - if (section == 0 && role == Qt::DecorationRole) - { - // transparent pixmap as we paint it ourself with tree brach - // if we extend the HeaderView::paintSection for the CE_HeaderLabel - // we could drop this - QPixmap pixmap = QPixmap( - QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize), - QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize)); - // Create new picture for transparent - QPixmap transparent(pixmap.size()); - - // Do transparency - transparent.fill(Qt::transparent); - QPainter p(&transparent); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.drawPixmap(0, 0, pixmap); - p.setCompositionMode(QPainter::CompositionMode_DestinationIn); - // Set transparency level to 150 (possible values are 0-255) - // The alpha channel of a color specifies the transparency effect, - // 0 represents a fully transparent color, while 255 represents - // a fully opaque color. - p.fillRect(transparent.rect(), QColor(0, 0, 0, 0)); - p.end(); - - // Set original picture's reference to new transparent one - pixmap = transparent; - return pixmap; - } - } - return QVariant(); - } - - /******************************************************************************/ - - QModelIndex CGeorgesFormModel::index(int row, int column, const QModelIndex &parent) - const - { - if (!hasIndex(row, column, parent)) - return QModelIndex(); - - CFormItem *parentItem; - - if (!parent.isValid()) - parentItem = m_rootItem; - else - parentItem = static_cast(parent.internalPointer()); - - CFormItem *childItem = parentItem->child(row); - if (childItem) - return createIndex(row, column, childItem); - else - return QModelIndex(); - } - - /******************************************************************************/ - - QModelIndex CGeorgesFormModel::parent(const QModelIndex &index) const - { - if (!index.isValid()) - return QModelIndex(); - - CFormItem *childItem = static_cast(index.internalPointer()); - CFormItem *parentItem = childItem->parent(); - - if (parentItem == m_rootItem) - return QModelIndex(); - - return createIndex(parentItem->row(), 0, parentItem); - } - - /******************************************************************************/ - - int CGeorgesFormModel::rowCount(const QModelIndex &parent) const { - - CFormItem *parentItem; - if (parent.column() > 0) - return 0; - - if (!parent.isValid()) - parentItem = m_rootItem; - else - parentItem = static_cast(parent.internalPointer()); - - return parentItem->childCount(); - - } - - /******************************************************************************/ - - int CGeorgesFormModel::columnCount(const QModelIndex &parent) const { - - if (parent.isValid()) - return static_cast(parent.internalPointer())->columnCount(); - else - return m_rootItem->columnCount(); - - } - - /******************************************************************************/ - - void CGeorgesFormModel::loadFormData(UFormElm *root, CFormItem *parent) { - - if (!root) - return; - - uint num = 0; - - - if (root->isStruct()) - { - //((CFormElm*)root)->getForm()->getComment(); - uint structSize = 0; - root->getStructSize(structSize); - while (num < structSize) - { - UFormElm::TWhereIsNode *whereN = new UFormElm::TWhereIsNode; - UFormElm::TWhereIsValue *whereV = new UFormElm::TWhereIsValue; - // Append a new item to the current parent's list of children. - std::string elmName; - if(root->getStructNodeName(num, elmName)) - { - QList columnData; - //QVariant value; - std::string value; - //NLMISC::CRGBA value_color; - //uint value_uint; - //sint value_sint; - //double value_double; - QString elmtType = ""; - UFormElm *elmt = 0; - if(root->getNodeByName(&elmt, elmName.c_str(), whereN, true)) - { - if (elmt) - { - if (elmt->isArray()) - elmtType = "Array"; - if (elmt->isStruct()) - elmtType = "Struct"; - if (elmt->isAtom()) - { - elmtType = "Atom"; - uint numDefinitions = 0; - const UType *type = elmt->getType(); - if (type) - { - numDefinitions = type->getNumDefinition(); - root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); - switch (type->getType()) - { - case UType::UnsignedInt: - value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toStdString(); - elmtType.append("_uint");break; - case UType::SignedInt: - value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toStdString(); - elmtType.append("_sint");break; - case UType::Double: - value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble(),0,'f',1).toStdString(); - elmtType.append("_double");break; - case UType::String: - elmtType.append("_string");break; - case UType::Color: - elmtType.append("_color");break; - default: - elmtType.append("_unknownType"); - } - } - else - { - elmtType.append("_noType"); - } - - if (numDefinitions) - { - std::string l, v; - QString tmpLabel, tmpValue; - for (uint i = 0; i < numDefinitions; i++) - { - type->getDefinition(i,l,v); - tmpLabel = l.c_str(); - tmpValue = v.c_str(); - if (type->getType() == UType::SignedInt) - { - if (QString("%1").arg(value.c_str()).toDouble() == tmpValue.toDouble()) { - value = l; - break; - } - } - if (type->getType() == UType::String) - { - if (QString(value.c_str()) == tmpValue) - { - value = l; - break; - } - } - } - } - } - if (elmt->isVirtualStruct()) - { - root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); - elmtType = "VirtualStruct"; - } - switch (*whereN) - { - case UFormElm::NodeForm: - elmtType.append("_fromForm"); break; - case UFormElm::NodeParentForm: - elmtType.append("_fromParentForm"); break; - case UFormElm::NodeDfn: - elmtType.append("_isDFN"); break; - case UFormElm::NodeType: - elmtType.append("_isType"); break; - default: - elmtType.append("_noNode"); - } - switch (*whereV) - { - case UFormElm::ValueForm: - elmtType.append("_formValue"); break; - case UFormElm::ValueParentForm: - elmtType.append("_parentValue"); break; - case UFormElm::ValueDefaultDfn: - elmtType.append("_dfnValue"); break; - case UFormElm::ValueDefaultType: - elmtType.append("_typeValue"); break; - default: - elmtType.append("_noValue"); - } - columnData << QString(elmName.c_str()) << QString(value.c_str()) << "";// << elmtType; - parent->appendChild(new CFormItem(elmt, columnData, parent, *whereV, *whereN)); - //if (parents.last()->childCount() > 0) { - // parents << parents.last()->child(parents.last()->childCount()-1); - //} - loadFormData(elmt, parent->child(parent->childCount()-1)); - } - else - { - // add Defaults - // TODO: spams warnings for non ATOM values but i dont get type of non existing nodes - bool success = root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); - switch (*whereN) - { - case UFormElm::NodeForm: - elmtType.append("_fromForm"); break; - case UFormElm::NodeParentForm: - elmtType.append("_fromParentForm"); break; - case UFormElm::NodeDfn: - elmtType.append("_isDFN"); break; - case UFormElm::NodeType: - elmtType.append("_isType"); break; - default: - elmtType.append("_noNode"); - } - switch (*whereV) - { - case UFormElm::ValueForm: - elmtType.append("_formValue"); break; - case UFormElm::ValueParentForm: - elmtType.append("_parentValue"); break; - case UFormElm::ValueDefaultDfn: - elmtType.append("_dfnValue"); break; - case UFormElm::ValueDefaultType: - elmtType.append("_typeValue"); break; - default: - elmtType.append("_noValue"); - } - - columnData << QString(elmName.c_str()) << QString(value.c_str()) << "";// << elmtType; - parent->appendChild(new CFormItem(elmt, columnData, parent, *whereV, *whereN)); - } - } - else - { - nlinfo("getNodeByName returned false"); - } - } - num++; - } - } - if (root->isArray()) - { - uint arraySize = 0; - root->getArraySize(arraySize); - while (num < arraySize) - { - std::string elmName; - if(root->getArrayNodeName(elmName, num)) - { - QList columnData; - std::string value; - QString elmtType = ""; - - UFormElm *elmt = 0; - if(root->getArrayNode(&elmt,0) && elmt) - { - if (elmt->isArray()) - elmtType = "Array"; - if (elmt->isStruct()) { - elmtType = "Struct"; - } - if (elmt->isAtom()) - { - elmt->getValue(value); - elmtType = "Atom"; - } - if (elmt->isVirtualStruct()) - elmtType = "VirtualStruct"; - - elmtType.append("_arrayValue"); - columnData << QString(elmName.c_str()) << QString(value.c_str()) << "";// << elmtType; - parent->appendChild(new CFormItem(elmt, columnData, parent)); - loadFormData(elmt, parent->child(parent->childCount()-1)); - } - } - num++; - } - } - } - - /******************************************************************************/ - - void CGeorgesFormModel::loadFormHeader() - { - - if (m_parents.size()) - { - CFormItem *fi_pars = new CFormItem(m_rootElm, QList() << "parents" << "" << "", m_rootItem); - m_rootItem->appendChild(fi_pars); - - Q_FOREACH(QString str, m_parents) - { - fi_pars->appendChild(new CFormItem(m_rootElm, QList() << str << "" << "", fi_pars)); - } - } - - /*QStringList dfns = _dependencies["dfn"]; - QStringList typs = _dependencies["typ"]; - - _dependencies.remove("dfn"); - _dependencies.remove("typ"); - - CFormItem *fi_dep = new CFormItem(_rootElm, QList() << "dependencies", _rootItem); - _rootItem->appendChild(fi_dep); - - if (!dfns.isEmpty()) { - CFormItem *fi_dfn = new CFormItem(_rootElm, QList() << "dfn", fi_dep); - fi_dep->appendChild(fi_dfn); - foreach(QString str, dfns) { - fi_dfn->appendChild(new CFormItem(_rootElm, QList() << str, fi_dfn)); - } - } - if (!typs.isEmpty()) { - CFormItem *fi_typ = new CFormItem(_rootElm, QList() << "typ", fi_dep); - fi_dep->appendChild(fi_typ); - foreach(QString str, typs) { - fi_typ->appendChild(new CFormItem(_rootElm, QList() << str, fi_typ)); - } - } - if (!_dependencies.isEmpty()) { - CFormItem *fi_other = new CFormItem(_rootElm, QList() << "other", fi_dep); - fi_dep->appendChild(fi_other); - foreach(QStringList list, _dependencies) { - foreach(QString str, list) { - fi_other->appendChild(new CFormItem(_rootElm, QList() << str, fi_other)); - } - } - }*/ - } - - /******************************************************************************/ - - void CGeorgesFormModel::setupModelData() - { - loadFormHeader(); - loadFormData(m_rootElm, m_rootItem); - } - - /******************************************************************************/ - - void CGeorgesFormModel::setShowParents( bool show ) { - m_showParents = show; - Q_EMIT layoutAboutToBeChanged(); - Q_EMIT layoutChanged(); - } - void CGeorgesFormModel::setShowDefaults( bool show ) - { - m_showDefaults = show; - Q_EMIT layoutAboutToBeChanged(); - Q_EMIT layoutChanged(); - } - - void CGeorgesFormModel::addParentForm(QString parentForm) - { - beginResetModel(); - m_parents.push_back(parentForm); - delete m_rootItem; - m_rootItem = new CFormItem(m_rootElm, m_rootData); - setupModelData(); - endResetModel(); - } - - void CGeorgesFormModel::removeParentForm(QString parentForm) - { - beginResetModel(); - m_parents.removeOne(parentForm); - - delete m_rootItem; - m_rootItem = new CFormItem(m_rootElm, m_rootData); - setupModelData(); - endResetModel(); - } + CGeorgesFormModel::CGeorgesFormModel(UForm *form, QMap< QString, QStringList> deps, + QString comment, QStringList parents, bool *expanded, QObject *parent) : QAbstractItemModel(parent) + { + m_form = form; + m_rootData << "Value" << "Data" << "Extra";// << "Type"; + m_rootItem = new CFormItem(m_rootElm, m_rootData); + m_dependencies = deps; + m_comments = comment; + m_parents = parents; + m_parentRows = new QList; + m_expanded = expanded; + + setupModelData(); + } + + CGeorgesFormModel::~CGeorgesFormModel() + { + delete m_rootItem; + } + + /******************************************************************************/ + + QVariant CGeorgesFormModel::data(const QModelIndex &p_index, int p_role) const + { + if (!p_index.isValid()) + return QVariant(); + + switch (p_role) + { + case Qt::DisplayRole: + { + return getItem(p_index)->data(p_index.column()); + } + case Qt::BackgroundRole: + { + QBrush defaultBrush = QBrush(QColor(255,0,0,30)); + QBrush parentBrush = QBrush(QColor(0,255,0,30)); + + // if elm not existing it must be some kind of default or type value + if(!getItem(p_index)->getFormElm()) + { + return defaultBrush; + } + + // else it might be some parent elm + switch (getItem(p_index)->nodeFrom()) + { + case NLGEORGES::UFormElm::NodeParentForm: + { + return parentBrush; + } + case NLGEORGES::UFormElm::NodeForm: + { + switch (getItem(p_index)->valueFrom()) + { + case NLGEORGES::UFormElm::ValueParentForm: + { + return parentBrush; + } + default: + { + // parent status test kindof ugly, testing only 2 steps deep + // only needed for colorization as treeview default hides childs + // when parent is hidden + CFormItem *parent = getItem(p_index)->parent(); + if (parent) + { + if (parent->nodeFrom() == NLGEORGES::UFormElm::NodeParentForm) + { + return parentBrush; + } + + CFormItem *parentParent = parent->parent(); + if (parentParent) + { + if (parentParent->nodeFrom() == NLGEORGES::UFormElm::NodeParentForm) + { + return parentBrush; + } + } // endif parentParent + } // endif parent + } // end default + } // end switch valueFrom + } // end case nodeForm + } // end switch nodeFrom + return QVariant(); + } + case Qt::DecorationRole: + { + if (p_index.column() == 2) + { + //p_index. + QModelIndex in = index(p_index.row(),p_index.column()-1,p_index.parent()); + CFormItem *item = getItem(in); + + QString value = item->data(1).toString(); + //QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); + + /*if (value.contains(".shape")) + { + if (Modules::objViewInt()) + { + QIcon *icon = Modules::objViewInt()->saveOneImage(value.toStdString()); + if (icon) + { + if(icon->isNull()) + return QIcon(":/images/pqrticles.png"); + else + return QIcon(*icon); + } + else + { + return QIcon(); + } + } + }*/ + if(value.contains(".tga") || value.contains(".png")) + { + QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); + if(path.isEmpty()) + { + path = ":/images/pqrticles.png"; + } + return QIcon(path); + } + } + return QVariant(); + break; + } + case Qt::ToolTipRole: + { + if (p_index.column() == 2) + { + QModelIndex in = index(p_index.row(),p_index.column()-1,p_index.parent()); + CFormItem *item = getItem(in); + QString value = item->data(1).toString(); + + /*if (value.contains(".shape")) + { + if (Modules::objViewInt()) + { + QIcon *icon = Modules::objViewInt()->saveOneImage(value.toStdString()); + if (icon) + { + if(icon->isNull()) + return QIcon(":/images/pqrticles.png"); + else + return QIcon(*icon); + } + else + { + return QIcon(); + } + } + }*/ + if(value.contains(".tga") || value.contains(".png")) + { + QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); + if(path.isEmpty()) + { + path = ":/images/pqrticles.png"; + } + + QString imageTooltip = QString("").arg(path); + + return imageTooltip; + } + } + return QVariant(); + break; + } + default: + return QVariant(); + } + } + + /******************************************************************************/ + + CFormItem *CGeorgesFormModel::getItem(const QModelIndex &index) const + { + if (index.isValid()) + { + CFormItem *item = static_cast(index.internalPointer()); + if (item) + return item; + } + return m_rootItem; + } + + /******************************************************************************/ + + bool CGeorgesFormModel::setData(const QModelIndex &index, const QVariant &value, + int role) + { + + if (role != Qt::EditRole) + return false; + + CFormItem *item = getItem(index); + bool result = item->setData(index.column(), value); + + Q_EMIT dataChanged(index, index); + + //setupModelData(); + return result; + } + + /******************************************************************************/ + + Qt::ItemFlags CGeorgesFormModel::flags(const QModelIndex& index) const { + + if (!index.isValid()) + return 0; + + Qt::ItemFlags returnValue = Qt::ItemIsSelectable | Qt::ItemIsEnabled; + + if(index.column() == 1) + returnValue |= Qt::ItemIsEditable; + + return returnValue; + + } + + /******************************************************************************/ + + QVariant CGeorgesFormModel::headerData(int section, + Qt::Orientation orientation, int role) const + { + if (orientation == Qt::Horizontal) + { + if (role == Qt::DisplayRole) + return m_rootItem->data(section); + if (role == Qt::TextAlignmentRole) + return Qt::AlignLeft; + if (section == 0 && role == Qt::DecorationRole) + { + // transparent pixmap as we paint it ourself with tree brach + // if we extend the HeaderView::paintSection for the CE_HeaderLabel + // we could drop this + QPixmap pixmap = QPixmap( + QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize), + QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize)); + // Create new picture for transparent + QPixmap transparent(pixmap.size()); + + // Do transparency + transparent.fill(Qt::transparent); + QPainter p(&transparent); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.drawPixmap(0, 0, pixmap); + p.setCompositionMode(QPainter::CompositionMode_DestinationIn); + // Set transparency level to 150 (possible values are 0-255) + // The alpha channel of a color specifies the transparency effect, + // 0 represents a fully transparent color, while 255 represents + // a fully opaque color. + p.fillRect(transparent.rect(), QColor(0, 0, 0, 0)); + p.end(); + + // Set original picture's reference to new transparent one + pixmap = transparent; + return pixmap; + } + } + return QVariant(); + } + + /******************************************************************************/ + + QModelIndex CGeorgesFormModel::index(int row, int column, const QModelIndex &parent) + const + { + if (!hasIndex(row, column, parent)) + return QModelIndex(); + + CFormItem *parentItem; + + if (!parent.isValid()) + parentItem = m_rootItem; + else + parentItem = static_cast(parent.internalPointer()); + + CFormItem *childItem = parentItem->child(row); + if (childItem) + return createIndex(row, column, childItem); + else + return QModelIndex(); + } + + /******************************************************************************/ + + QModelIndex CGeorgesFormModel::parent(const QModelIndex &index) const + { + if (!index.isValid()) + return QModelIndex(); + + CFormItem *childItem = static_cast(index.internalPointer()); + CFormItem *parentItem = childItem->parent(); + + if (parentItem == m_rootItem) + return QModelIndex(); + + return createIndex(parentItem->row(), 0, parentItem); + } + + /******************************************************************************/ + + int CGeorgesFormModel::rowCount(const QModelIndex &parent) const { + + CFormItem *parentItem; + if (parent.column() > 0) + return 0; + + if (!parent.isValid()) + parentItem = m_rootItem; + else + parentItem = static_cast(parent.internalPointer()); + + return parentItem->childCount(); + + } + + /******************************************************************************/ + + int CGeorgesFormModel::columnCount(const QModelIndex &parent) const { + + if (parent.isValid()) + return static_cast(parent.internalPointer())->columnCount(); + else + return m_rootItem->columnCount(); + + } + + /******************************************************************************/ + + void CGeorgesFormModel::loadFormData(UFormElm *root, CFormItem *parent) { + + if (!root) + return; + + uint num = 0; + + + if (root->isStruct()) + { + //((CFormElm*)root)->getForm()->getComment(); + uint structSize = 0; + root->getStructSize(structSize); + while (num < structSize) + { + UFormElm::TWhereIsNode *whereN = new UFormElm::TWhereIsNode; + UFormElm::TWhereIsValue *whereV = new UFormElm::TWhereIsValue; + // Append a new item to the current parent's list of children. + std::string elmName; + if(root->getStructNodeName(num, elmName)) + { + QList columnData; + //QVariant value; + std::string value; + //NLMISC::CRGBA value_color; + //uint value_uint; + //sint value_sint; + //double value_double; + QString elmtType = ""; + UFormElm *elmt = 0; + if(root->getNodeByName(&elmt, elmName.c_str(), whereN, true)) + { + if (elmt) + { + if (elmt->isArray()) + elmtType = "Array"; + if (elmt->isStruct()) + elmtType = "Struct"; + if (elmt->isAtom()) + { + elmtType = "Atom"; + uint numDefinitions = 0; + const UType *type = elmt->getType(); + if (type) + { + numDefinitions = type->getNumDefinition(); + root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); + switch (type->getType()) + { + case UType::UnsignedInt: + value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toStdString(); + elmtType.append("_uint");break; + case UType::SignedInt: + value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toStdString(); + elmtType.append("_sint");break; + case UType::Double: + value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble(),0,'f',1).toStdString(); + elmtType.append("_double");break; + case UType::String: + elmtType.append("_string");break; + case UType::Color: + elmtType.append("_color");break; + default: + elmtType.append("_unknownType"); + } + } + else + { + elmtType.append("_noType"); + } + + if (numDefinitions) + { + std::string l, v; + QString tmpLabel, tmpValue; + for (uint i = 0; i < numDefinitions; i++) + { + type->getDefinition(i,l,v); + tmpLabel = l.c_str(); + tmpValue = v.c_str(); + if (type->getType() == UType::SignedInt) + { + if (QString("%1").arg(value.c_str()).toDouble() == tmpValue.toDouble()) { + value = l; + break; + } + } + if (type->getType() == UType::String) + { + if (QString(value.c_str()) == tmpValue) + { + value = l; + break; + } + } + } + } + } + if (elmt->isVirtualStruct()) + { + root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); + elmtType = "VirtualStruct"; + } + switch (*whereN) + { + case UFormElm::NodeForm: + elmtType.append("_fromForm"); break; + case UFormElm::NodeParentForm: + elmtType.append("_fromParentForm"); break; + case UFormElm::NodeDfn: + elmtType.append("_isDFN"); break; + case UFormElm::NodeType: + elmtType.append("_isType"); break; + default: + elmtType.append("_noNode"); + } + switch (*whereV) + { + case UFormElm::ValueForm: + elmtType.append("_formValue"); break; + case UFormElm::ValueParentForm: + elmtType.append("_parentValue"); break; + case UFormElm::ValueDefaultDfn: + elmtType.append("_dfnValue"); break; + case UFormElm::ValueDefaultType: + elmtType.append("_typeValue"); break; + default: + elmtType.append("_noValue"); + } + columnData << QString(elmName.c_str()) << QString(value.c_str()) << "";// << elmtType; + parent->appendChild(new CFormItem(elmt, columnData, parent, *whereV, *whereN)); + //if (parents.last()->childCount() > 0) { + // parents << parents.last()->child(parents.last()->childCount()-1); + //} + loadFormData(elmt, parent->child(parent->childCount()-1)); + } + else + { + // add Defaults + // TODO: spams warnings for non ATOM values but i dont get type of non existing nodes + bool success = root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); + switch (*whereN) + { + case UFormElm::NodeForm: + elmtType.append("_fromForm"); break; + case UFormElm::NodeParentForm: + elmtType.append("_fromParentForm"); break; + case UFormElm::NodeDfn: + elmtType.append("_isDFN"); break; + case UFormElm::NodeType: + elmtType.append("_isType"); break; + default: + elmtType.append("_noNode"); + } + switch (*whereV) + { + case UFormElm::ValueForm: + elmtType.append("_formValue"); break; + case UFormElm::ValueParentForm: + elmtType.append("_parentValue"); break; + case UFormElm::ValueDefaultDfn: + elmtType.append("_dfnValue"); break; + case UFormElm::ValueDefaultType: + elmtType.append("_typeValue"); break; + default: + elmtType.append("_noValue"); + } + + columnData << QString(elmName.c_str()) << QString(value.c_str()) << "";// << elmtType; + parent->appendChild(new CFormItem(elmt, columnData, parent, *whereV, *whereN)); + } + } + else + { + nlinfo("getNodeByName returned false"); + } + } + num++; + } + } + if (root->isArray()) + { + uint arraySize = 0; + root->getArraySize(arraySize); + while (num < arraySize) + { + std::string elmName; + if(root->getArrayNodeName(elmName, num)) + { + QList columnData; + std::string value; + QString elmtType = ""; + + UFormElm *elmt = 0; + if(root->getArrayNode(&elmt,0) && elmt) + { + if (elmt->isArray()) + elmtType = "Array"; + if (elmt->isStruct()) { + elmtType = "Struct"; + } + if (elmt->isAtom()) + { + elmt->getValue(value); + elmtType = "Atom"; + } + if (elmt->isVirtualStruct()) + elmtType = "VirtualStruct"; + + elmtType.append("_arrayValue"); + columnData << QString(elmName.c_str()) << QString(value.c_str()) << "";// << elmtType; + parent->appendChild(new CFormItem(elmt, columnData, parent)); + loadFormData(elmt, parent->child(parent->childCount()-1)); + } + } + num++; + } + } + } + + CFormItem *CGeorgesFormModel::addStruct (CFormItem *parent, + NLGEORGES::CFormElmStruct *_struct, + NLGEORGES::CFormDfn *parentDfn, + const char *name, + uint structId, + const char *formName, + uint slot) +{ + // The form pointer + NLGEORGES::CForm *formPtr = static_cast(m_form); + + // Add the new node +// CFormItem *newNode = parent->add(/*CGeorgesEditDocSub::Form,*/ name, structId, formName, slot); + CFormItem *newNode = parent->add(_struct, name); + + // Can be NULL in virtual DFN + if (parentDfn) + { + // Get the parents + std::vector arrayDfn; + arrayDfn.reserve (parentDfn->countParentDfn ()); + parentDfn->getParentDfn (arrayDfn); + + // For each child + uint elm=0; + for (uint dfn=0; dfngetNumEntry (); i++) + { + // Get the entry ref + NLGEORGES::CFormDfn::CEntry &entry = arrayDfn[dfn]->getEntry (i); + + // Form entry name + std::string entryName = (std::string (formName)+"."+entry.getName ()); + + // Is a struct ? + if ( (entry.getType () == NLGEORGES::UFormDfn::EntryDfn) || (entry.getType () == NLGEORGES::UFormDfn::EntryVirtualDfn) ) + { + // Is an array of struct ? + if (entry.getArrayFlag ()) + { + // Get it from the form + CFormElmArray *nextArray = NULL; + if (_struct && _struct->Elements[elm].Element) + nextArray = NLMISC::safe_cast (_struct->Elements[elm].Element); + + // Else, get it from the parent if we are not a virtual DFN (don't inheritate) + + // todo array of virtual struct + if (!nextArray && (entry.getType () != NLGEORGES::UFormDfn::EntryVirtualDfn) ) + { + // For each parent form + for (uint parent=0; parentgetParentCount (); parent++) + { + // Get the node by name + NLGEORGES::UFormElm *uNode; + if (formPtr->getParent (parent)->getRootNode ().getNodeByName (&uNode, entryName.c_str(), NULL, false) && uNode) + { + nextArray = NLMISC::safe_cast (uNode); + } + } + } + + // Add the new struct + addArray (newNode, nextArray, entry.getDfnPtr (), entry.getName().c_str(), elm, entryName.c_str (), slot); + } + else + { + // Add it + NLGEORGES::CFormElmStruct *nextForm = NULL; + + // Get it from the form + if (_struct && _struct->Elements[elm].Element) + nextForm = NLMISC::safe_cast (_struct->Elements[elm].Element); + + // Else, get it from the parent + if (!nextForm) + { + // For each parent form + for (uint parent=0; parentgetParentCount (); parent++) + { + // Get the node by name + NLGEORGES::UFormElm *uNode; + if (formPtr->getParent (parent)->getRootNode ().getNodeByName (&uNode, entryName.c_str(), NULL, false) && uNode) + { + nextForm = NLMISC::safe_cast (uNode); + } + } + } + + // Virtual Dfn pointer + NLGEORGES::CFormElmVirtualStruct *vStruct = ((entry.getType () == NLGEORGES::UFormDfn::EntryVirtualDfn) && nextForm) ? + NLMISC::safe_cast (nextForm) : NULL; + + NLGEORGES::CFormDfn *tmpDfn = vStruct ? + ((NLGEORGES::CFormDfn*)vStruct->FormDfn) : entry.getDfnPtr(); + // Add the new struct + addStruct (newNode, nextForm, tmpDfn, entry.getName().c_str(), elm, entryName.c_str(), slot); + } + } + // Array of type ? + else if ( entry.getArrayFlag () ) + { + NLGEORGES::CFormElmArray *nextArray = NULL; + + // Get it from the form + if (_struct && _struct->Elements[elm].Element) + nextArray = NLMISC::safe_cast (_struct->Elements[elm].Element); + + // Else, get it from the parent + if (!nextArray) + { + // For each parent form + for (uint parent=0; parentgetParentCount (); parent++) + { + // Get the node by name + NLGEORGES::UFormElm *uNode; + if (formPtr->getParent (parent)->getRootNode ().getNodeByName (&uNode, entryName.c_str(), NULL, false) && uNode) + { + nextArray = NLMISC::safe_cast (uNode); + } + } + } + + // Add the new array + addArray ( newNode, nextArray, NULL, entry.getName().c_str(), elm, entryName.c_str(), slot ); + } + + // Next element + elm++; + } + } + } + + return newNode; +} + +// *************************************************************************** + +CFormItem *CGeorgesFormModel::addArray(CFormItem *parent, + NLGEORGES::CFormElmArray *array, + NLGEORGES::CFormDfn *rootDfn, + const char *name, + uint structId, + const char *formName, + uint slot) +{ + // Add the new node + //CFormItem *newNode = parent->add (/*CGeorgesEditDocSub::Form,*/ name, structId, formName, slot); + CFormItem *newNode = parent->add (array, name); + + // The array exist + if (array) + { + // For each array element + for (uint elm=0; elmElements.size(); elm++) + { + // The form name + char formArrayElmName[512]; + NLMISC::smprintf (formArrayElmName, 512, "%s[%d]", formName, elm); + + // The name + char formArrayName[512]; + if (array->Elements[elm].Name.empty ()) + { + NLMISC::smprintf (formArrayName, 512, "#%d", elm); + } + else + { + NLMISC::smprintf (formArrayName, 512, "%s", array->Elements[elm].Name.c_str()); + } + + // Is a struct + if (rootDfn) + { + // Get struct ptr + NLGEORGES::CFormElmStruct *elmPtr = array->Elements[elm].Element ? NLMISC::safe_cast(array->Elements[elm].Element) : NULL; + addStruct (newNode, elmPtr, rootDfn, formArrayName, elm, formArrayElmName, slot); + } + else + { + NLGEORGES::CFormElmArray *elmPtr = array->Elements[elm].Element ? NLMISC::safe_cast(array->Elements[elm].Element) : NULL; + newNode->add (elmPtr, formArrayElmName); + //newNode->add (/*CGeorgesEditDocSub::Form,*/ formArrayName, elm, formArrayElmName, slot); + } + } + } + + return newNode; +} + + + + /******************************************************************************/ + + void CGeorgesFormModel::loadFormHeader() + { + + if (m_parents.size()) + { + CFormItem *fi_pars = new CFormItem(m_rootElm, QList() << "parents" << "" << "", m_rootItem); + m_rootItem->appendChild(fi_pars); + + Q_FOREACH(QString str, m_parents) + { + fi_pars->appendChild(new CFormItem(m_rootElm, QList() << str << "" << "", fi_pars)); + } + } + + /*QStringList dfns = _dependencies["dfn"]; + QStringList typs = _dependencies["typ"]; + + _dependencies.remove("dfn"); + _dependencies.remove("typ"); + + CFormItem *fi_dep = new CFormItem(_rootElm, QList() << "dependencies", _rootItem); + _rootItem->appendChild(fi_dep); + + if (!dfns.isEmpty()) { + CFormItem *fi_dfn = new CFormItem(_rootElm, QList() << "dfn", fi_dep); + fi_dep->appendChild(fi_dfn); + foreach(QString str, dfns) { + fi_dfn->appendChild(new CFormItem(_rootElm, QList() << str, fi_dfn)); + } + } + if (!typs.isEmpty()) { + CFormItem *fi_typ = new CFormItem(_rootElm, QList() << "typ", fi_dep); + fi_dep->appendChild(fi_typ); + foreach(QString str, typs) { + fi_typ->appendChild(new CFormItem(_rootElm, QList() << str, fi_typ)); + } + } + if (!_dependencies.isEmpty()) { + CFormItem *fi_other = new CFormItem(_rootElm, QList() << "other", fi_dep); + fi_dep->appendChild(fi_other); + foreach(QStringList list, _dependencies) { + foreach(QString str, list) { + fi_other->appendChild(new CFormItem(_rootElm, QList() << str, fi_other)); + } + } + }*/ + } + + /******************************************************************************/ + + void CGeorgesFormModel::setupModelData() + { + m_rootElm = &((NLGEORGES::CForm*)m_form)->Elements; + NLGEORGES::CFormElmStruct *rootstruct = &((NLGEORGES::CForm*)m_form)->Elements; + loadFormHeader(); + addStruct(m_rootItem, rootstruct, rootstruct->FormDfn, "Content", 0xffffffff, "", 0); + //loadFormData(m_rootElm, m_rootItem); + } + + /******************************************************************************/ + + void CGeorgesFormModel::setShowParents( bool show ) { + m_showParents = show; + Q_EMIT layoutAboutToBeChanged(); + Q_EMIT layoutChanged(); + } + void CGeorgesFormModel::setShowDefaults( bool show ) + { + m_showDefaults = show; + Q_EMIT layoutAboutToBeChanged(); + Q_EMIT layoutChanged(); + } + + void CGeorgesFormModel::addParentForm(QString parentForm) + { + beginResetModel(); + m_parents.push_back(parentForm); + delete m_rootItem; + m_rootItem = new CFormItem(m_rootElm, m_rootData); + setupModelData(); + endResetModel(); + } + + void CGeorgesFormModel::removeParentForm(QString parentForm) + { + beginResetModel(); + m_parents.removeOne(parentForm); + + delete m_rootItem; + m_rootItem = new CFormItem(m_rootElm, m_rootData); + setupModelData(); + endResetModel(); + } } /* namespace GeorgesQt */ /* end of file */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h index 710598236..493f672dd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h @@ -27,6 +27,10 @@ namespace NLGEORGES { class UFormElm; + class UForm; + class CFormElmStruct; + class CFormDfn; + class CFormElmArray; } namespace GeorgesQt @@ -38,7 +42,7 @@ namespace GeorgesQt { public: - CGeorgesFormModel(NLGEORGES::UFormElm *root, QMap< QString, QStringList> deps, + CGeorgesFormModel(NLGEORGES::UForm *form, QMap< QString, QStringList> deps, QString comment, QStringList parents, bool* expanded, QObject *parent = 0); ~CGeorgesFormModel(); @@ -58,15 +62,22 @@ namespace GeorgesQt void setShowDefaults( bool show ); void addParentForm(QString parentForm); void removeParentForm(QString parentForm); - NLGEORGES::UFormElm *getRootForm() { return m_rootElm; } + NLGEORGES::UFormElm *getRootForm() { return m_rootElm; } + + CFormItem *addStruct (CFormItem *parent, NLGEORGES::CFormElmStruct *_struct, NLGEORGES::CFormDfn *parentDfn, + const char *name, uint structId, const char *formName, uint slot); + + CFormItem *addArray(CFormItem *parent, NLGEORGES::CFormElmArray *array, NLGEORGES::CFormDfn *rootDfn, + const char *name, uint structId, const char *formName, uint slot); private: void setupModelData(); void loadFormData(NLGEORGES::UFormElm *rootElm, CFormItem *parent); void loadFormHeader(); + NLGEORGES::UForm* m_form; CFormItem* m_rootItem; - NLGEORGES::UFormElm* m_rootElm; + NLGEORGES::UFormElm* m_rootElm; QList m_rootData; QMap< QString, QStringList> m_dependencies; QString m_comments; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp index a65f510c4..edbc31275 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp @@ -66,7 +66,7 @@ CMainWindow::CMainWindow(QWidget *parent) _isGraphicsInitialized(false), _isGraphicsEnabled(false), _isSoundInitialized(false), - _isSoundEnabled(true), + _isSoundEnabled(false), // MTR workaround for sheet id nonsense _GraphicsViewport(NULL), _lastDir("."), _mouseMode(NL3D::U3dMouseListener::edit3d) From 51705fd800e1bb804751a4ac3de3c5d4b0cd8d49 Mon Sep 17 00:00:00 2001 From: sfb Date: Thu, 20 Sep 2012 16:39:21 -0500 Subject: [PATCH 3/9] Changed: #1306 Radically changed the plugin in a new branch to match the way classic GE loads forms. - Refactored the tree view to show only structs, arrays, vstructs and eliminated atoms from its view. - Refactored the form view to have a Qt Properties Browser - Refactored the loader to use the classic GE addStruct/addArray. - Moved some functionality into CFormItem. - Added icons from classic GE and configured model/item to return them appropriately. - Getting read for changes via undo commands. - Eliminating/ignoring the hold/slots business from classic GE code. --- .../src/plugins/georges_editor/CMakeLists.txt | 8 +- .../src/plugins/georges_editor/actions.cpp | 17 + .../src/plugins/georges_editor/actions.h | 20 + .../plugins/georges_editor/formdelegate.cpp | 4 + .../src/plugins/georges_editor/formdelegate.h | 4 + .../src/plugins/georges_editor/formitem.cpp | 400 ++++++----------- .../src/plugins/georges_editor/formitem.h | 160 +++---- .../plugins/georges_editor/georges_editor.qrc | 7 + .../georges_treeview_dialog.cpp | 255 +++++------ .../georges_editor/georges_treeview_form.ui | 110 +++-- .../georges_editor/georgesform_model.cpp | 406 ++---------------- .../georgesform_proxy_model.cpp | 3 + .../georges_editor/georgesform_proxy_model.h | 3 +- .../plugins/georges_editor/images/array.ico | Bin 0 -> 1406 bytes .../plugins/georges_editor/images/header.ico | Bin 0 -> 318 bytes .../plugins/georges_editor/images/hold.ico | Bin 0 -> 318 bytes .../plugins/georges_editor/images/root.ico | Bin 0 -> 318 bytes .../plugins/georges_editor/images/struct.ico | Bin 0 -> 318 bytes .../plugins/georges_editor/images/vstruct.ico | Bin 0 -> 318 bytes .../plugins/georges_editor/images/zfee51.ico | Bin 0 -> 2238 bytes 20 files changed, 481 insertions(+), 916 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/array.ico create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/header.ico create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/hold.ico create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/root.ico create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/struct.ico create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/vstruct.ico create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/zfee51.ico diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/CMakeLists.txt index 3661decef..5aba06740 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/CMakeLists.txt @@ -1,12 +1,14 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${LIBXML2_INCLUDE_DIR} - ${QT_INCLUDES}) + ${QT_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/qtpropertybrowser) FILE(GLOB SRC *.cpp *.h) SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h - ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) SET(OVQT_PLUG_GEORGES_EDITOR_HDR georges_editor_plugin.h georges_editor_form.h @@ -36,7 +38,7 @@ SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC}) ADD_LIBRARY(ovqt_plugin_georges_editor MODULE ${SRC} ${OVQT_PLUG_GEORGES_EDITOR_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_PLUG_GEORGES_EDITOR_UI_HDRS} ${OVQT_PLUGIN_GEORGES_EDITOR_RC_SRCS}) -TARGET_LINK_LIBRARIES(ovqt_plugin_georges_editor ovqt_plugin_core nelmisc nelgeorges ${QT_LIBRARIES}) +TARGET_LINK_LIBRARIES(ovqt_plugin_georges_editor ovqt_plugin_core nelmisc nelgeorges qt_property_browser ${QT_LIBRARIES}) NL_DEFAULT_PROPS(ovqt_plugin_georges_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: Georges Editor") NL_ADD_RUNTIME_FLAGS(ovqt_plugin_georges_editor) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp new file mode 100644 index 000000000..dba45fb96 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp @@ -0,0 +1,17 @@ +// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework +// Copyright (C) 2011 Adrian Jaekel +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "actions.h" \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h new file mode 100644 index 000000000..c646adc72 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h @@ -0,0 +1,20 @@ +// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework +// Copyright (C) 2011 Adrian Jaekel +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef ACTIONS_H +#define ACTIONS_H + +#endif // ACTIONS_H \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.cpp index 7f21fa072..ab306bf05 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.cpp @@ -37,6 +37,8 @@ #include "georgesform_proxy_model.h" #include "formitem.h" +#if 0 + namespace GeorgesQt { @@ -276,3 +278,5 @@ namespace GeorgesQt editor->setGeometry(r); } } /* namespace GeorgesQt */ + +#endif // 0 \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.h index b6885833e..42b10ef3d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.h @@ -19,6 +19,8 @@ #include +#if 0 + namespace GeorgesQt { @@ -38,4 +40,6 @@ namespace GeorgesQt }; } +#endif // 0 + #endif // FORMDELEGATE_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp index 014338a2d..98bffa7e2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp @@ -17,9 +17,11 @@ #include "formitem.h" // Qt includes +#include // NeL includes #include +#include #include #include @@ -27,15 +29,8 @@ using namespace NLGEORGES; namespace GeorgesQt { - - CFormItem::CFormItem(NLGEORGES::UFormElm* elm, const QList &data, CFormItem *parent, - NLGEORGES::UFormElm::TWhereIsValue wV, NLGEORGES::UFormElm::TWhereIsNode wN) + CFormItem::CFormItem() { - parentItem = parent; - itemData = data; - formElm = elm; - whereV = wV; - whereN = wN; } CFormItem::~CFormItem() @@ -61,12 +56,14 @@ namespace GeorgesQt int CFormItem::columnCount() const { //nlinfo("columnCount %d",itemData.count()); - return itemData.count(); + //return itemData.count(); + return 1; } QVariant CFormItem::data(int column) const { - return itemData.value(column); + //return itemData.value(column); + return QVariant(_Name.c_str()); } CFormItem *CFormItem::parent() @@ -84,275 +81,146 @@ namespace GeorgesQt bool CFormItem::setData(int column, const QVariant &value) { - if (column < 0 || column >= itemData.size()) + if (column != 0) return false; - // TODO: default values - if (!formElm) - return false; + bool deleteInsert = false; - itemData[column] = value; - if (formElm->isAtom()) - { - const NLGEORGES::UType *type = formElm->getType(); - if (type) - { - switch (type->getType()) - { - case NLGEORGES::UType::UnsignedInt: - case NLGEORGES::UType::SignedInt: - case NLGEORGES::UType::Double: - case NLGEORGES::UType::String: - if (parentItem->formElm->isArray()) - { - //((NLGEORGES::CFormElm*)parentItem->formElm);//->arrayInsertNodeByName( - //if(parentItem->formElm->getArrayNode(elmName, num)) - //{ - //} + - bool ok; - // TODO: the node can be renamed from eg "#0" to "foobar" - int arrayIndex = itemData[0].toString().remove("#").toInt(&ok); - if(ok) - { - NLGEORGES::UFormElm *elmt = 0; - if(parentItem->formElm->getArrayNode(&elmt, arrayIndex) && elmt) - { - if (elmt->isAtom()) - { - ((NLGEORGES::CFormElmAtom*)elmt)->setValue(value.toString().toStdString().c_str()); - nldebug(QString("array element string %1 %2") - .arg(itemData[0].toString()).arg(value.toString()) - .toStdString().c_str()); - } - } - } - } - else - { - if(parentItem->formElm->setValueByName( - value.toString().toStdString().c_str(), - itemData[0].toString().toStdString().c_str())) - { - nldebug(QString("string %1 %2") - .arg(itemData[0].toString()).arg(value.toString()) - .toStdString().c_str()); - } - else - { - nldebug(QString("FAILED string %1 %2") - .arg(itemData[0].toString()).arg(value.toString()) - .toStdString().c_str()); - } - } - break; - case NLGEORGES::UType::Color: - nldebug("Color is TODO"); - break; - default: - break; - } - } - } - else + // Get the parent node + const NLGEORGES::CFormDfn *parentDfn; + uint indexDfn; + const NLGEORGES::CFormDfn *nodeDfn; + const NLGEORGES::CType *nodeType; + NLGEORGES::CFormElm *parentNode; + NLGEORGES::UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + NLGEORGES::CForm *form=static_cast(m_form); + NLGEORGES::CFormElm *elm = static_cast(&form->getRootNode()); + nlverify ( elm->getNodeByName (_FormName.c_str(), &parentDfn, indexDfn, &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + if (parentItem && parentItem->nodeType () == CFormItem::Form) { - nldebug("setting sth other than Atom"); + std::string newName = value.toString().toStdString(); + _Name = newName; + + // Create an action to update the form. } - //formElm->setValueByName(); return true; } -// CFormItem *CFormItem::add (/*TSub type,*/ const char *name, uint structId, const char *formName, uint slot) -// { - // Add at the end -// uint index = _Children.size(); -// _Children.push_back (new CGeorgesEditDocSub); + bool CFormItem::isEditable(int column) + { + // Ensure only valid types can be edited. + if(_Type == Null) + return false; -// _Children[index]->_Type = type; -// _Children[index]->_Name = name; -// _Children[index]->_Parent = this; -// _Children[index]->_StructId = structId; -// _Children[index]->_FormName = formName; -// _Children[index]->_Slot = slot; -// return _Children[index]; -// CFormItem *newNode = new CFormItem(); -// appendChild(newNode); -// return NULL; -// } + // Make sure only the first column (name) can be editted. + if (column != 0) + return false; - CFormItem *CFormItem::add(NLGEORGES::UFormElm* root, std::string elmName) + CFormItem *parent = this->parent(); + + // If it wasn't a root node then lets check the node type. + const NLGEORGES::CFormDfn *parentDfn; + uint indexDfn; + const NLGEORGES::CFormDfn *nodeDfn; + const NLGEORGES::CType *nodeType; + NLGEORGES::CFormElm *parentNode; + NLGEORGES::UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + NLGEORGES::CForm *form = static_cast(m_form); + NLGEORGES::CFormElm *elm = static_cast(&form->getRootNode()); + nlverify ( elm->getNodeByName (parent->formName ().c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + if(array && parentNode) + return true; + + return false; + + } + + QIcon CFormItem::getItemImage(CFormItem *rootItem) + { + if(_Type == CFormItem::Null) + { + return QIcon(":/images/root.ico"); + } + else if(_Type == CFormItem::Form) + { + // If the parent is the root item then this is the content. + if(parentItem == rootItem) + return QIcon(":/images/root.ico"); + + // If it wasn't a root node then lets check the node type. + const NLGEORGES::CFormDfn *parentDfn; + uint indexDfn; + const NLGEORGES::CFormDfn *nodeDfn; + const NLGEORGES::CType *nodeType; + NLGEORGES::CFormElm *node; + NLGEORGES::UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + NLGEORGES::CForm *form = static_cast(m_form); + NLGEORGES::CFormElm *elm = static_cast(&form->getRootNode()); + nlverify ( elm->getNodeByName (_FormName.c_str(), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + if(array) + { + return QIcon(":/images/array.ico"); + } + else + { + if(type == NLGEORGES::UFormDfn::EntryType) + { + if(parentDfn) + { + // Not sure what the hell to do with this. Gets filename from parent dfn? + } + return QIcon(":/images/zfee51.ico"); + } + else if(type == NLGEORGES::UFormDfn::EntryDfn) + { + if(parentDfn) + { + // Not sure what the hell to do with this. Gets filename from parent dfn? + } + return QIcon(":/images/struct.ico"); + } + else if(type == NLGEORGES::UFormDfn::EntryVirtualDfn) + { + if(node) + { + // Not sure what the hell to do with this. Gets filename from parent dfn? + std::string dfnName; + NLMISC::safe_cast(node)->getDfnName(dfnName); + // return dfnName.c_str() ? + } + return QIcon(":/images/vstruct.ico"); + } + } + //return QIcon(":/images/struct.ico"); + } + return QIcon(); + } + + CFormItem *CFormItem::add (TSub type, const char *name, uint structId, const char *formName, uint slot, NLGEORGES::UForm *formPtr) { - CFormItem *newItem = NULL; - UFormElm::TWhereIsNode *whereN = new UFormElm::TWhereIsNode; - UFormElm::TWhereIsValue *whereV = new UFormElm::TWhereIsValue; - // Append a new item to the current parent's list of children. -// std::string elmName; -// if(root->getStructNodeName(num, elmName)) -// { - QList columnData; - //QVariant value; - std::string value; - //NLMISC::CRGBA value_color; - //uint value_uint; - //sint value_sint; - //double value_double; - QString elmtType = ""; - UFormElm *elmt = 0; - if(root->getNodeByName(&elmt, elmName.c_str(), whereN, true)) - { - if (elmt) - { - if (elmt->isArray()) - elmtType = "Array"; - if (elmt->isStruct()) - elmtType = "Struct"; - if (elmt->isAtom()) - { - elmtType = "Atom"; - uint numDefinitions = 0; - const UType *type = elmt->getType(); - if (type) - { - numDefinitions = type->getNumDefinition(); - root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); - switch (type->getType()) - { - case UType::UnsignedInt: - value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toStdString(); - elmtType.append("_uint");break; - case UType::SignedInt: - value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toStdString(); - elmtType.append("_sint");break; - case UType::Double: - value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble(),0,'f',1).toStdString(); - elmtType.append("_double");break; - case UType::String: - elmtType.append("_string");break; - case UType::Color: - elmtType.append("_color");break; - default: - elmtType.append("_unknownType"); - } - } - else - { - elmtType.append("_noType"); - } + CFormItem *newNode = new CFormItem(); + newNode->_Type = type; + newNode->_Name = name; + newNode->parentItem = this; + newNode->_StructId = structId; + newNode->_FormName = formName; + newNode->_Slot = slot; + newNode->m_form = formPtr; - if (numDefinitions) - { - std::string l, v; - QString tmpLabel, tmpValue; - for (uint i = 0; i < numDefinitions; i++) - { - type->getDefinition(i,l,v); - tmpLabel = l.c_str(); - tmpValue = v.c_str(); - if (type->getType() == UType::SignedInt) - { - if (QString("%1").arg(value.c_str()).toDouble() == tmpValue.toDouble()) { - value = l; - break; - } - } - if (type->getType() == UType::String) - { - if (QString(value.c_str()) == tmpValue) - { - value = l; - break; - } - } - } - } - } - if (elmt->isVirtualStruct()) - { - root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); - elmtType = "VirtualStruct"; - } - switch (*whereN) - { - case UFormElm::NodeForm: - elmtType.append("_fromForm"); break; - case UFormElm::NodeParentForm: - elmtType.append("_fromParentForm"); break; - case UFormElm::NodeDfn: - elmtType.append("_isDFN"); break; - case UFormElm::NodeType: - elmtType.append("_isType"); break; - default: - elmtType.append("_noNode"); - } - switch (*whereV) - { - case UFormElm::ValueForm: - elmtType.append("_formValue"); break; - case UFormElm::ValueParentForm: - elmtType.append("_parentValue"); break; - case UFormElm::ValueDefaultDfn: - elmtType.append("_dfnValue"); break; - case UFormElm::ValueDefaultType: - elmtType.append("_typeValue"); break; - default: - elmtType.append("_noValue"); - } - columnData << QString(elmName.c_str()) << QString(value.c_str()) << "";// << elmtType; - - newItem = new CFormItem(elmt, columnData, this, *whereV, *whereN); - this->appendChild(newItem); - - return newItem; - //if (parents.last()->childCount() > 0) { - // parents << parents.last()->child(parents.last()->childCount()-1); - //} - - // The building of the tree should be haoppening in the mode,. - //loadFormData(elmt, parent->child(parent->childCount()-1)); - } - else - { - // add Defaults - // TODO: spams warnings for non ATOM values but i dont get type of non existing nodes - bool success = root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); - switch (*whereN) - { - case UFormElm::NodeForm: - elmtType.append("_fromForm"); break; - case UFormElm::NodeParentForm: - elmtType.append("_fromParentForm"); break; - case UFormElm::NodeDfn: - elmtType.append("_isDFN"); break; - case UFormElm::NodeType: - elmtType.append("_isType"); break; - default: - elmtType.append("_noNode"); - } - switch (*whereV) - { - case UFormElm::ValueForm: - elmtType.append("_formValue"); break; - case UFormElm::ValueParentForm: - elmtType.append("_parentValue"); break; - case UFormElm::ValueDefaultDfn: - elmtType.append("_dfnValue"); break; - case UFormElm::ValueDefaultType: - elmtType.append("_typeValue"); break; - default: - elmtType.append("_noValue"); - } - - columnData << QString(elmName.c_str()) << QString(value.c_str()) << "";// << elmtType; - newItem = new CFormItem(elmt, columnData, this, *whereV, *whereN); - this->appendChild(newItem); - return newItem; - } -// } -// else -// { -// nlinfo("getNodeByName returned false"); -// } - } + appendChild(newNode); + return newNode; } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h index c56422caf..e08a198bd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h @@ -1,76 +1,84 @@ -// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework -// Copyright (C) 2011 Adrian Jaekel -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef FORMITEM_H -#define FORMITEM_H - -// NeL includes -#include - -// Qt includes -#include -#include - -namespace GeorgesQt -{ - - class CFormItem - - { - public: - CFormItem(NLGEORGES::UFormElm *elm, const QList &data, - CFormItem *parent = 0, - NLGEORGES::UFormElm::TWhereIsValue wV = NLGEORGES::UFormElm::ValueForm, - NLGEORGES::UFormElm::TWhereIsNode wN = NLGEORGES::UFormElm::NodeForm); - ~CFormItem(); - - void appendChild(CFormItem *child); - //CFormItem *add (/*TSub type,*/ const char *name, uint structId, const char *formName, uint slot); - CFormItem *add(NLGEORGES::UFormElm* root, std::string elmName); - - CFormItem *child(int row); - int childCount() const; - int columnCount() const; - QVariant data(int column) const; - int row() const; - CFormItem *parent(); - bool setData(int column, const QVariant &value); - NLGEORGES::UFormElm* getFormElm() {return formElm;} - NLGEORGES::UFormElm::TWhereIsValue valueFrom() - { - return whereV; - } - NLGEORGES::UFormElm::TWhereIsNode nodeFrom() - { - return whereN; - } - - void setValueFrom(NLGEORGES::UFormElm::TWhereIsValue wV) { whereV = wV; } - void setNodeFrom(NLGEORGES::UFormElm::TWhereIsNode wN) { whereN = wN; } - - - private: - //CFormItem() { whereV = NLGEORGES::UFormElm::ValueForm; whereN = NLGEORGES::UFormElm::NodeForm; } - QList childItems; - QList itemData; - CFormItem *parentItem; - NLGEORGES::UFormElm* formElm; - NLGEORGES::UFormElm::TWhereIsValue whereV; - NLGEORGES::UFormElm::TWhereIsNode whereN; - }; // CFormItem - -} -#endif // FORMITEM_H +// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework +// Copyright (C) 2011 Adrian Jaekel +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef FORMITEM_H +#define FORMITEM_H + +// NeL includes +#include +#include + +// Qt includes +#include +#include + +namespace GeorgesQt +{ + + class CFormItem + { + public: + // What is the sub object ? + enum TSub + { + Null, // Nothing in this node (root ?) + Header, // Header node + Type, // This node is a type + Dfn, // This node is a dfn + Form, // This node is a form + }; + + CFormItem(); + ~CFormItem(); + + void appendChild(CFormItem *child); + + CFormItem *add (TSub type, const char *name, uint structId, const char *formName, uint slot, NLGEORGES::UForm *formPtr); + + CFormItem *child(int row); + int childCount() const; + int columnCount() const; + QVariant data(int column) const; + int row() const; + CFormItem *parent(); + bool setData(int column, const QVariant &value); + + TSub nodeType() { return _Type; } + std::string formName() { return _FormName; } + std::string name() { return _Name; } + uint structId() { return _StructId; } + + bool isEditable(int column); + + QIcon getItemImage(CFormItem *rootItem); + + private: + QList childItems; + QList itemData; + CFormItem *parentItem; + NLGEORGES::UFormElm* formElm; + NLGEORGES::UForm *m_form; + + uint _StructId; + std::string _Name; + std::string _FormName; + TSub _Type; + uint _Slot; + + }; // CFormItem + +} +#endif // FORMITEM_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor.qrc b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor.qrc index 3d514dbc0..8d71d1438 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor.qrc +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor.qrc @@ -1,5 +1,12 @@ + images/array.ico + images/header.ico + images/hold.ico + images/root.ico + images/struct.ico + images/vstruct.ico + images/zfee51.ico images/ic_nel_georges_editor.png diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp index 92da6e8a0..aa289a4aa 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp @@ -72,23 +72,10 @@ namespace GeorgesQt m_ui.treeView->header()->setStretchLastSection(true); m_ui.treeViewTabWidget->setTabEnabled (2,false); - m_ui.checkBoxParent->setStyleSheet("background-color: rgba(0,255,0,30)"); - m_ui.checkBoxDefaults->setStyleSheet("background-color: rgba(255,0,0,30)"); m_form = 0; - FormDelegate *formdelegate = new FormDelegate(this); - m_ui.treeView->setItemDelegateForColumn(1, formdelegate); - - // Set up custom context menu. - setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint&))); - connect(m_ui.treeView, SIGNAL(doubleClicked (QModelIndex)), this, SLOT(doubleClicked (QModelIndex))); - connect(m_ui.checkBoxParent, SIGNAL(toggled(bool)), - this, SLOT(filterRows())); - connect(m_ui.checkBoxDefaults, SIGNAL(toggled(bool)), - this, SLOT(filterRows())); connect(m_header, SIGNAL(headerClicked(int)), this, SLOT(headerClicked(int))); } @@ -258,16 +245,9 @@ namespace GeorgesQt loadedForm = m_form->getFilename().c_str(); CGeorgesFormModel *model = new CGeorgesFormModel(m_form,deps,comments,parents,m_header->expanded()); - CGeorgesFormProxyModel *proxyModel = new CGeorgesFormProxyModel(); - proxyModel->setSourceModel(model); - m_ui.treeView->setModel(proxyModel); + m_ui.treeView->setModel(model); m_ui.treeView->expandAll(); - // this is a debug output row - m_ui.treeView->hideColumn(3); - filterRows(); - - // //_ui.treeView->setRowHidden(0,QModelIndex(),true); connect(model, SIGNAL(dataChanged(const QModelIndex, const QModelIndex)), this, SLOT(modifiedFile())); @@ -283,8 +263,7 @@ namespace GeorgesQt NLGEORGES::CForm *parentForm = dynamic_cast(uParentForm); NLGEORGES::CForm *mainForm = static_cast(m_form); - CGeorgesFormProxyModel * proxyModel = dynamic_cast(m_ui.treeView->model()); - CGeorgesFormModel *model = dynamic_cast(proxyModel->sourceModel()); + CGeorgesFormModel *model = dynamic_cast(m_ui.treeView->model()); if(parentForm) { @@ -397,19 +376,15 @@ namespace GeorgesQt void CGeorgesTreeViewDialog::doubleClicked ( const QModelIndex & index ) { - // TODO: this is messy :( perhaps this can be done better - CGeorgesFormProxyModel * proxyModel = - dynamic_cast(m_ui.treeView->model()); - CGeorgesFormModel *model = - dynamic_cast(proxyModel->sourceModel()); - QModelIndex sourceIndex = proxyModel->mapToSource(index); + //CGeorgesFormModel *model = + // dynamic_cast((m_ui.treeView->model()); - CFormItem *item = model->getItem(sourceIndex); + //CFormItem *item = model->getItem(index); - if (item->parent() && item->parent()->data(0) == "parents") - { - Q_EMIT changeFile(CPath::lookup(item->data(0).toString().toStdString(),false).c_str()); - } + //if (item->parent() && item->parent()->data(0) == "parents") + //{ + // Q_EMIT changeFile(CPath::lookup(item->data(0).toString().toStdString(),false).c_str()); + //} //// col containing additional stuff like icons //if (index.column() == 2) @@ -475,129 +450,129 @@ namespace GeorgesQt void CGeorgesTreeViewDialog::filterRows() { - CGeorgesFormProxyModel * mp = dynamic_cast(m_ui.treeView->model()); - CGeorgesFormModel *m = dynamic_cast(mp->sourceModel()); - if (m) { - m->setShowParents(m_ui.checkBoxParent->isChecked()); - m->setShowDefaults(m_ui.checkBoxDefaults->isChecked()); - } + //CGeorgesFormProxyModel * mp = dynamic_cast(m_ui.treeView->model()); + //CGeorgesFormModel *m = dynamic_cast(mp->sourceModel()); + //if (m) { + // m->setShowParents(m_ui.checkBoxParent->isChecked()); + // m->setShowDefaults(m_ui.checkBoxDefaults->isChecked()); + //} } void CGeorgesTreeViewDialog::showContextMenu(const QPoint &pos) { - QMenu contextMenu; - QMenu *structContext = NULL; - QPoint globalPos = this->mapToGlobal(pos); - - // Fisrt we're going to see if we've right clicked on a new item and select it. - const QModelIndex &index = this->m_ui.treeView->currentIndex(); + //QMenu contextMenu; + //QMenu *structContext = NULL; + //QPoint globalPos = this->mapToGlobal(pos); + // + //// Fisrt we're going to see if we've right clicked on a new item and select it. + //const QModelIndex &index = this->m_ui.treeView->currentIndex(); - if(!index.isValid()) - return; + //if(!index.isValid()) + // return; - CGeorgesFormProxyModel * mp = dynamic_cast(m_ui.treeView->model()); - CGeorgesFormModel *m = dynamic_cast(mp->sourceModel()); - QModelIndex sourceIndex = mp->mapToSource(index); + //CGeorgesFormProxyModel * mp = dynamic_cast(m_ui.treeView->model()); + //CGeorgesFormModel *m = dynamic_cast(mp->sourceModel()); + //QModelIndex sourceIndex = mp->mapToSource(index); - if (m) - { - - CFormItem *item = m->getItem(sourceIndex); + //if (m) + //{ + // + // CFormItem *item = m->getItem(sourceIndex); - // Right click on the "parents" item - if (item->data(0) == "parents") - contextMenu.addAction("Add parent..."); - // Right click on a parent item - else if(item->parent() && item->parent()->data(0) == "parents") - { - contextMenu.addAction("Add parent..."); - contextMenu.addAction("Remove parent"); - } - else if(item->getFormElm()->isArray()) - contextMenu.addAction("Add array entry..."); - else if(item->getFormElm()->isStruct()) - { - QMenu *structContext = new QMenu("Add struct element...", this); - contextMenu.addMenu(structContext); + // // Right click on the "parents" item + // if (item->data(0) == "parents") + // contextMenu.addAction("Add parent..."); + // // Right click on a parent item + // else if(item->parent() && item->parent()->data(0) == "parents") + // { + // contextMenu.addAction("Add parent..."); + // contextMenu.addAction("Remove parent"); + // } + // else if(item->getFormElm()->isArray()) + // contextMenu.addAction("Add array entry..."); + // else if(item->getFormElm()->isStruct()) + // { + // QMenu *structContext = new QMenu("Add struct element...", this); + // contextMenu.addMenu(structContext); - NLGEORGES::UFormDfn *defn = item->getFormElm()->getStructDfn(); - if(defn) - { - for(uint defnNum=0; defnNum < defn->getNumEntry(); defnNum++) - { - std::string entryName; - std::string dummy; - UFormElm::TWhereIsValue *whereV = new UFormElm::TWhereIsValue; - bool result = defn->getEntryName(defnNum, entryName); - bool result2 = item->getFormElm()->getValueByName(dummy, entryName.c_str(), NLGEORGES::UFormElm::Eval, whereV); + // NLGEORGES::UFormDfn *defn = item->getFormElm()->getStructDfn(); + // if(defn) + // { + // for(uint defnNum=0; defnNum < defn->getNumEntry(); defnNum++) + // { + // std::string entryName; + // std::string dummy; + // UFormElm::TWhereIsValue *whereV = new UFormElm::TWhereIsValue; + // bool result = defn->getEntryName(defnNum, entryName); + // bool result2 = item->getFormElm()->getValueByName(dummy, entryName.c_str(), NLGEORGES::UFormElm::Eval, whereV); - - if(result2 && *whereV != UFormElm::ValueForm) - { - structContext->addAction(entryName.c_str()); - } - delete whereV; - } - } - } - else if(item->getFormElm()->isAtom() && item->valueFrom() == NLGEORGES::UFormElm::ValueForm) - contextMenu.addAction("Revert to parent/default..."); + // + // if(result2 && *whereV != UFormElm::ValueForm) + // { + // structContext->addAction(entryName.c_str()); + // } + // delete whereV; + // } + // } + // } + // else if(item->getFormElm()->isAtom() && item->valueFrom() == NLGEORGES::UFormElm::ValueForm) + // contextMenu.addAction("Revert to parent/default..."); - QAction *selectedItem = contextMenu.exec(globalPos); - if(selectedItem) - { - if(selectedItem->text() == "Add parent...") - { - // Get the file extension of the form so we can build a dialog pattern. - QString file = m_form->getFilename().c_str(); - file = file.remove(0,file.indexOf(".")+1); - QString filePattern = "Parent Sheets (*."+file+")"; - - nlinfo("parent defn name '%s'", file.toStdString().c_str()); - QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select parent sheets..."), m_lastSheetDir, filePattern); - if(!fileNames.isEmpty()) - { - Q_FOREACH(QString fileToParent, fileNames) - { - // Get just the filename. Georges doesn't want the path. - QFileInfo pathInfo( fileToParent ); - QString tmpFileName( pathInfo.fileName() ); + // QAction *selectedItem = contextMenu.exec(globalPos); + // if(selectedItem) + // { + // if(selectedItem->text() == "Add parent...") + // { + // // Get the file extension of the form so we can build a dialog pattern. + // QString file = m_form->getFilename().c_str(); + // file = file.remove(0,file.indexOf(".")+1); + // QString filePattern = "Parent Sheets (*."+file+")"; + // + // nlinfo("parent defn name '%s'", file.toStdString().c_str()); + // QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select parent sheets..."), m_lastSheetDir, filePattern); + // if(!fileNames.isEmpty()) + // { + // Q_FOREACH(QString fileToParent, fileNames) + // { + // // Get just the filename. Georges doesn't want the path. + // QFileInfo pathInfo( fileToParent ); + // QString tmpFileName( pathInfo.fileName() ); - nlinfo("requesting to add parent form '%s'", tmpFileName.toStdString().c_str()); - - // Call to add the form and load it into the Georges form. - addParentForm(tmpFileName); + // nlinfo("requesting to add parent form '%s'", tmpFileName.toStdString().c_str()); + // + // // Call to add the form and load it into the Georges form. + // addParentForm(tmpFileName); - // Save the file lookup path for future dialog boxes. - m_lastSheetDir = pathInfo.absolutePath(); - } - } - m_ui.treeView->expandAll(); - } - else if(selectedItem->text() == "Remove parent") - { - NLGEORGES::CForm *form = static_cast(m_form); - QString parentFileName = item->data(0).toString(); + // // Save the file lookup path for future dialog boxes. + // m_lastSheetDir = pathInfo.absolutePath(); + // } + // } + // m_ui.treeView->expandAll(); + // } + // else if(selectedItem->text() == "Remove parent") + // { + // NLGEORGES::CForm *form = static_cast(m_form); + // QString parentFileName = item->data(0).toString(); - for(uint num = 0; num < form->getParentCount(); num++) - { - QString curParentName = form->getParent(num)->getFilename().c_str(); - if(parentFileName == curParentName) - { - form->removeParent(num); - m->removeParentForm(parentFileName); - break; - } - } + // for(uint num = 0; num < form->getParentCount(); num++) + // { + // QString curParentName = form->getParent(num)->getFilename().c_str(); + // if(parentFileName == curParentName) + // { + // form->removeParent(num); + // m->removeParentForm(parentFileName); + // break; + // } + // } - m_ui.treeView->expandAll(); - } + // m_ui.treeView->expandAll(); + // } - } // if selected context menu item is valid. - } // if 'm' model valid. + // } // if selected context menu item is valid. + //} // if 'm' model valid. - if(structContext) - delete structContext; + //if(structContext) + // delete structContext; } } /* namespace GeorgesQt */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_form.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_form.ui index 8d53bfdd6..0bf52a3ea 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_form.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_form.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 300 + 564 + 525 @@ -18,8 +18,8 @@ - 199 - 165 + 280 + 242 @@ -29,9 +29,21 @@ - + + + 0 + 0 + + + + + + 0 + 0 + + QTabWidget::West @@ -39,60 +51,40 @@ 0 - - Qt::NoFocus - Form - - - 0 - - - - - - 0 - 0 - - - - - 0 - 0 - - - - true - - - - - - - Parent - - - - - + + + Qt::Horizontal - - - 40 - 20 - - - - - - - - Defaults - + + + + 0 + 0 + + + + + 0 + 0 + + + + true + + + + + + 0 + 0 + + + @@ -126,8 +118,14 @@ - - - + + + QtTreePropertyBrowser + QWidget +
qttreepropertybrowser.h
+ 1 +
+
+ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp index b8c9f56ff..9a329f396 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp @@ -53,7 +53,7 @@ namespace GeorgesQt { m_form = form; m_rootData << "Value" << "Data" << "Extra";// << "Type"; - m_rootItem = new CFormItem(m_rootElm, m_rootData); + m_rootItem = new CFormItem(); m_dependencies = deps; m_comments = comment; m_parents = parents; @@ -81,144 +81,12 @@ namespace GeorgesQt { return getItem(p_index)->data(p_index.column()); } - case Qt::BackgroundRole: - { - QBrush defaultBrush = QBrush(QColor(255,0,0,30)); - QBrush parentBrush = QBrush(QColor(0,255,0,30)); - - // if elm not existing it must be some kind of default or type value - if(!getItem(p_index)->getFormElm()) - { - return defaultBrush; - } - - // else it might be some parent elm - switch (getItem(p_index)->nodeFrom()) - { - case NLGEORGES::UFormElm::NodeParentForm: - { - return parentBrush; - } - case NLGEORGES::UFormElm::NodeForm: - { - switch (getItem(p_index)->valueFrom()) - { - case NLGEORGES::UFormElm::ValueParentForm: - { - return parentBrush; - } - default: - { - // parent status test kindof ugly, testing only 2 steps deep - // only needed for colorization as treeview default hides childs - // when parent is hidden - CFormItem *parent = getItem(p_index)->parent(); - if (parent) - { - if (parent->nodeFrom() == NLGEORGES::UFormElm::NodeParentForm) - { - return parentBrush; - } - - CFormItem *parentParent = parent->parent(); - if (parentParent) - { - if (parentParent->nodeFrom() == NLGEORGES::UFormElm::NodeParentForm) - { - return parentBrush; - } - } // endif parentParent - } // endif parent - } // end default - } // end switch valueFrom - } // end case nodeForm - } // end switch nodeFrom - return QVariant(); - } - case Qt::DecorationRole: - { - if (p_index.column() == 2) - { - //p_index. - QModelIndex in = index(p_index.row(),p_index.column()-1,p_index.parent()); - CFormItem *item = getItem(in); - - QString value = item->data(1).toString(); - //QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); - - /*if (value.contains(".shape")) - { - if (Modules::objViewInt()) - { - QIcon *icon = Modules::objViewInt()->saveOneImage(value.toStdString()); - if (icon) - { - if(icon->isNull()) - return QIcon(":/images/pqrticles.png"); - else - return QIcon(*icon); - } - else - { - return QIcon(); - } - } - }*/ - if(value.contains(".tga") || value.contains(".png")) - { - QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); - if(path.isEmpty()) - { - path = ":/images/pqrticles.png"; - } - return QIcon(path); - } - } - return QVariant(); - break; - } - case Qt::ToolTipRole: - { - if (p_index.column() == 2) - { - QModelIndex in = index(p_index.row(),p_index.column()-1,p_index.parent()); - CFormItem *item = getItem(in); - QString value = item->data(1).toString(); - - /*if (value.contains(".shape")) - { - if (Modules::objViewInt()) - { - QIcon *icon = Modules::objViewInt()->saveOneImage(value.toStdString()); - if (icon) - { - if(icon->isNull()) - return QIcon(":/images/pqrticles.png"); - else - return QIcon(*icon); - } - else - { - return QIcon(); - } - } - }*/ - if(value.contains(".tga") || value.contains(".png")) - { - QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); - if(path.isEmpty()) - { - path = ":/images/pqrticles.png"; - } - - QString imageTooltip = QString("").arg(path); - - return imageTooltip; - } - } - return QVariant(); - break; - } + case Qt::DecorationRole: + { + // Based on the _Type return a QIcon from resources. + CFormItem *item = getItem(p_index); + return item->getItemImage(m_rootItem); + } default: return QVariant(); } @@ -239,14 +107,17 @@ namespace GeorgesQt /******************************************************************************/ - bool CGeorgesFormModel::setData(const QModelIndex &index, const QVariant &value, - int role) + bool CGeorgesFormModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (role != Qt::EditRole) return false; + + CFormItem *item = getItem(index); - CFormItem *item = getItem(index); + if(!item->isEditable(index.column())) + return false; + bool result = item->setData(index.column(), value); Q_EMIT dataChanged(index, index); @@ -264,8 +135,12 @@ namespace GeorgesQt Qt::ItemFlags returnValue = Qt::ItemIsSelectable | Qt::ItemIsEnabled; - if(index.column() == 1) - returnValue |= Qt::ItemIsEditable; + CFormItem *item = getItem(index); + + if(item->isEditable(index.column())) + { + returnValue |= Qt::ItemIsEditable; + } return returnValue; @@ -383,223 +258,7 @@ namespace GeorgesQt /******************************************************************************/ void CGeorgesFormModel::loadFormData(UFormElm *root, CFormItem *parent) { - - if (!root) - return; - - uint num = 0; - - - if (root->isStruct()) - { - //((CFormElm*)root)->getForm()->getComment(); - uint structSize = 0; - root->getStructSize(structSize); - while (num < structSize) - { - UFormElm::TWhereIsNode *whereN = new UFormElm::TWhereIsNode; - UFormElm::TWhereIsValue *whereV = new UFormElm::TWhereIsValue; - // Append a new item to the current parent's list of children. - std::string elmName; - if(root->getStructNodeName(num, elmName)) - { - QList columnData; - //QVariant value; - std::string value; - //NLMISC::CRGBA value_color; - //uint value_uint; - //sint value_sint; - //double value_double; - QString elmtType = ""; - UFormElm *elmt = 0; - if(root->getNodeByName(&elmt, elmName.c_str(), whereN, true)) - { - if (elmt) - { - if (elmt->isArray()) - elmtType = "Array"; - if (elmt->isStruct()) - elmtType = "Struct"; - if (elmt->isAtom()) - { - elmtType = "Atom"; - uint numDefinitions = 0; - const UType *type = elmt->getType(); - if (type) - { - numDefinitions = type->getNumDefinition(); - root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); - switch (type->getType()) - { - case UType::UnsignedInt: - value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toStdString(); - elmtType.append("_uint");break; - case UType::SignedInt: - value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toStdString(); - elmtType.append("_sint");break; - case UType::Double: - value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble(),0,'f',1).toStdString(); - elmtType.append("_double");break; - case UType::String: - elmtType.append("_string");break; - case UType::Color: - elmtType.append("_color");break; - default: - elmtType.append("_unknownType"); - } - } - else - { - elmtType.append("_noType"); - } - - if (numDefinitions) - { - std::string l, v; - QString tmpLabel, tmpValue; - for (uint i = 0; i < numDefinitions; i++) - { - type->getDefinition(i,l,v); - tmpLabel = l.c_str(); - tmpValue = v.c_str(); - if (type->getType() == UType::SignedInt) - { - if (QString("%1").arg(value.c_str()).toDouble() == tmpValue.toDouble()) { - value = l; - break; - } - } - if (type->getType() == UType::String) - { - if (QString(value.c_str()) == tmpValue) - { - value = l; - break; - } - } - } - } - } - if (elmt->isVirtualStruct()) - { - root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); - elmtType = "VirtualStruct"; - } - switch (*whereN) - { - case UFormElm::NodeForm: - elmtType.append("_fromForm"); break; - case UFormElm::NodeParentForm: - elmtType.append("_fromParentForm"); break; - case UFormElm::NodeDfn: - elmtType.append("_isDFN"); break; - case UFormElm::NodeType: - elmtType.append("_isType"); break; - default: - elmtType.append("_noNode"); - } - switch (*whereV) - { - case UFormElm::ValueForm: - elmtType.append("_formValue"); break; - case UFormElm::ValueParentForm: - elmtType.append("_parentValue"); break; - case UFormElm::ValueDefaultDfn: - elmtType.append("_dfnValue"); break; - case UFormElm::ValueDefaultType: - elmtType.append("_typeValue"); break; - default: - elmtType.append("_noValue"); - } - columnData << QString(elmName.c_str()) << QString(value.c_str()) << "";// << elmtType; - parent->appendChild(new CFormItem(elmt, columnData, parent, *whereV, *whereN)); - //if (parents.last()->childCount() > 0) { - // parents << parents.last()->child(parents.last()->childCount()-1); - //} - loadFormData(elmt, parent->child(parent->childCount()-1)); - } - else - { - // add Defaults - // TODO: spams warnings for non ATOM values but i dont get type of non existing nodes - bool success = root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); - switch (*whereN) - { - case UFormElm::NodeForm: - elmtType.append("_fromForm"); break; - case UFormElm::NodeParentForm: - elmtType.append("_fromParentForm"); break; - case UFormElm::NodeDfn: - elmtType.append("_isDFN"); break; - case UFormElm::NodeType: - elmtType.append("_isType"); break; - default: - elmtType.append("_noNode"); - } - switch (*whereV) - { - case UFormElm::ValueForm: - elmtType.append("_formValue"); break; - case UFormElm::ValueParentForm: - elmtType.append("_parentValue"); break; - case UFormElm::ValueDefaultDfn: - elmtType.append("_dfnValue"); break; - case UFormElm::ValueDefaultType: - elmtType.append("_typeValue"); break; - default: - elmtType.append("_noValue"); - } - - columnData << QString(elmName.c_str()) << QString(value.c_str()) << "";// << elmtType; - parent->appendChild(new CFormItem(elmt, columnData, parent, *whereV, *whereN)); - } - } - else - { - nlinfo("getNodeByName returned false"); - } - } - num++; - } - } - if (root->isArray()) - { - uint arraySize = 0; - root->getArraySize(arraySize); - while (num < arraySize) - { - std::string elmName; - if(root->getArrayNodeName(elmName, num)) - { - QList columnData; - std::string value; - QString elmtType = ""; - - UFormElm *elmt = 0; - if(root->getArrayNode(&elmt,0) && elmt) - { - if (elmt->isArray()) - elmtType = "Array"; - if (elmt->isStruct()) { - elmtType = "Struct"; - } - if (elmt->isAtom()) - { - elmt->getValue(value); - elmtType = "Atom"; - } - if (elmt->isVirtualStruct()) - elmtType = "VirtualStruct"; - - elmtType.append("_arrayValue"); - columnData << QString(elmName.c_str()) << QString(value.c_str()) << "";// << elmtType; - parent->appendChild(new CFormItem(elmt, columnData, parent)); - loadFormData(elmt, parent->child(parent->childCount()-1)); - } - } - num++; - } - } + return; } CFormItem *CGeorgesFormModel::addStruct (CFormItem *parent, @@ -614,8 +273,9 @@ namespace GeorgesQt NLGEORGES::CForm *formPtr = static_cast(m_form); // Add the new node -// CFormItem *newNode = parent->add(/*CGeorgesEditDocSub::Form,*/ name, structId, formName, slot); - CFormItem *newNode = parent->add(_struct, name); + CFormItem *newNode = parent->add(CFormItem::Form, name, structId, formName, slot, m_form); + + nlinfo("Added form %s : %s", name, formName); // Can be NULL in virtual DFN if (parentDfn) @@ -750,8 +410,7 @@ CFormItem *CGeorgesFormModel::addArray(CFormItem *parent, uint slot) { // Add the new node - //CFormItem *newNode = parent->add (/*CGeorgesEditDocSub::Form,*/ name, structId, formName, slot); - CFormItem *newNode = parent->add (array, name); + CFormItem *newNode = parent->add (CFormItem::Form, name, structId, formName, slot, m_form); // The array exist if (array) @@ -778,14 +437,13 @@ CFormItem *CGeorgesFormModel::addArray(CFormItem *parent, if (rootDfn) { // Get struct ptr - NLGEORGES::CFormElmStruct *elmPtr = array->Elements[elm].Element ? NLMISC::safe_cast(array->Elements[elm].Element) : NULL; + NLGEORGES::CFormElmStruct *elmPtr = array->Elements[elm].Element ? static_cast(array->Elements[elm].Element) : NULL; addStruct (newNode, elmPtr, rootDfn, formArrayName, elm, formArrayElmName, slot); } else { - NLGEORGES::CFormElmArray *elmPtr = array->Elements[elm].Element ? NLMISC::safe_cast(array->Elements[elm].Element) : NULL; - newNode->add (elmPtr, formArrayElmName); - //newNode->add (/*CGeorgesEditDocSub::Form,*/ formArrayName, elm, formArrayElmName, slot); + NLGEORGES::CFormElmArray *elmPtr = array->Elements[elm].Element ? static_cast(array->Elements[elm].Element) : NULL; + newNode->add (CFormItem::Form, formArrayName, elm, formArrayElmName, slot, m_form); } } } @@ -800,7 +458,7 @@ CFormItem *CGeorgesFormModel::addArray(CFormItem *parent, void CGeorgesFormModel::loadFormHeader() { - if (m_parents.size()) + /* if (m_parents.size()) { CFormItem *fi_pars = new CFormItem(m_rootElm, QList() << "parents" << "" << "", m_rootItem); m_rootItem->appendChild(fi_pars); @@ -809,7 +467,7 @@ CFormItem *CGeorgesFormModel::addArray(CFormItem *parent, { fi_pars->appendChild(new CFormItem(m_rootElm, QList() << str << "" << "", fi_pars)); } - } + }*/ /*QStringList dfns = _dependencies["dfn"]; QStringList typs = _dependencies["typ"]; @@ -851,7 +509,7 @@ CFormItem *CGeorgesFormModel::addArray(CFormItem *parent, { m_rootElm = &((NLGEORGES::CForm*)m_form)->Elements; NLGEORGES::CFormElmStruct *rootstruct = &((NLGEORGES::CForm*)m_form)->Elements; - loadFormHeader(); + //loadFormHeader(); addStruct(m_rootItem, rootstruct, rootstruct->FormDfn, "Content", 0xffffffff, "", 0); //loadFormData(m_rootElm, m_rootItem); } @@ -875,7 +533,7 @@ CFormItem *CGeorgesFormModel::addArray(CFormItem *parent, beginResetModel(); m_parents.push_back(parentForm); delete m_rootItem; - m_rootItem = new CFormItem(m_rootElm, m_rootData); + m_rootItem = new CFormItem(); setupModelData(); endResetModel(); } @@ -886,7 +544,7 @@ CFormItem *CGeorgesFormModel::addArray(CFormItem *parent, m_parents.removeOne(parentForm); delete m_rootItem; - m_rootItem = new CFormItem(m_rootElm, m_rootData); + m_rootItem = new CFormItem(); setupModelData(); endResetModel(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.cpp index 8b13ca8ba..81179f61c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.cpp @@ -23,6 +23,8 @@ #include "georgesform_proxy_model.h" #include "georgesform_model.h" +#if 0 + namespace GeorgesQt { @@ -78,4 +80,5 @@ namespace GeorgesQt } } /* namespace GeorgesQt */ +#endif // 0 /* end of file */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.h index cfe7fcca6..f4c968f80 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.h @@ -20,6 +20,7 @@ // Qt includes #include +#if 0 namespace GeorgesQt { @@ -41,5 +42,5 @@ namespace GeorgesQt };/* class CGeorgesFormProxyModel */ } /* namespace GeorgesQt */ - +#endif // 0 #endif // GEORGESFORM_PROXY_MODEL_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/array.ico b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/array.ico new file mode 100644 index 0000000000000000000000000000000000000000..923bec0bd09d868ebfdca30d953af70b87b2b084 GIT binary patch literal 1406 zcmd6mp=(@05XQfwDI6stF{dKhs78-ESKw5?6sr2(o87nH+nw+CX5W(roI5+JM68E~W@v_HUCZ?pM|X5b zcXUVZ%Nlw^ZwwlGL#I=q2YR3fLZBz(WSmjXMr-&RiHt?2RN2!Q3E!?a=0U}|_b9yXFRyc^!N9p#OVf5X4w-?ymY->6N4p~29oL*F*4Qg4q!PusVV z8U%g;Tfhq9NWMMMN z$>EG0j;!2$j_Z{^>GbqelgUJ9XJUsMx_2RDwvmTF)a~~hl{}<06o{r*q8a`~`>vfnu`}g<* Dvj*rN literal 0 HcmV?d00001 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/header.ico b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/header.ico new file mode 100644 index 0000000000000000000000000000000000000000..5ebb3632a07b0c55caa0d98e80995f28fed84db5 GIT binary patch literal 318 zcmZvXAr8YZ3`KvnsTrz@h6i`7qH3rL3tZ67m7^3DMulbBb6Qmcv-AJ6>^M@ShV1)Z z7SBey8UdQuTipC5~d;fm14_1Z`02Q7Kj-(pqL`xIjdy((fz>10+K5Q_gvD zZ{NY}f^UrjbK?vrxHzwF8OID;I1TLA3-C66UPFD(Y~#Nx{M9+6h=&q1&4*U@wu|%y D2y;=Y literal 0 HcmV?d00001 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/hold.ico b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/hold.ico new file mode 100644 index 0000000000000000000000000000000000000000..4b7f115f14d79bc4e7230fe0c3bcb20ef74c1230 GIT binary patch literal 318 zcmbu4p$>vE41~XBBuJ*vNc;?rS3zNa6wLigely1_^{p@@<2sNS!nJqTwQ06NP^6S_ z>;r7wMeppyz)A`>^qW*rQtR8KDls#;5Bf-Y_exZF%jJWZ2Z*H!3vr$_mS4}pALsc5 e8|~l9qpTOmhx;XGzqK`qMLk=8{*}J>Ji-eO5lbil literal 0 HcmV?d00001 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/root.ico b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/root.ico new file mode 100644 index 0000000000000000000000000000000000000000..3fa430766f5ef9080292ee358fc478f056ff4f5f GIT binary patch literal 318 zcmb7dGVc?i*Tas;^FM*`YIpgt6aCa4a z^AHkeF|@(|sDO%6Ld0r?LTgQijl#@3LFp@}-_UZc-ObA6+PQ=-%wt}{?_d8Kehr_= Wbc5Y?Wghd};{_kx-}Nt)({XHRBT$t9 literal 0 HcmV?d00001 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/vstruct.ico b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/vstruct.ico new file mode 100644 index 0000000000000000000000000000000000000000..a184d8a37697585d06f3ed0083f5484f969decd1 GIT binary patch literal 318 zcmbV`F%rTs3RQ=mD#m(4qaKsyoTSu{w4ex ZKC|ftyY9*|=FQ^?AKl;eFO<`9ya8ugQ@sEH literal 0 HcmV?d00001 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/zfee51.ico b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/images/zfee51.ico new file mode 100644 index 0000000000000000000000000000000000000000..ad6bbb7564f9209ac1902598373a757275d144b4 GIT binary patch literal 2238 zcmZ`*3s}?j8h$5(!5GGH?0{o9hYCY(ZeSbAMMY4vU~*9jMNbSx%PVMs!6X5XAeTYJ zxM&?IAW+L;8W>GGqKU_V6wPjG7Uy*6B&VIuuhHS(Z;(8o^zC`~UEcTmewRJ}|1*F^ zKN1N>tkD(_(#VTKLJ>~E0xeS0vPazL7i-krG7aF?Kp(o8E?oJ(hk89)?{=f`UMKWj z4D`bcPTX!qbzd6}_co*US`8|$6r#5&A`KckGqvj~(!M=|l$-JFrd;xc*N}AWAQC$B5Ph)> zQ6H5cwdyL;oARNlszOpnCDf-1k#yn!)>P+1Ue$#s&*fwH`JH&KI|r$Bzp2KxNbKH+ zwHNmw{>m<_>fB1#lVizcPi#8787c2>LB^RF>^Zp<&$lOI+uQMUwg$0{Td=Y{8_Qd_ zV@bh}YnKIezTL<=DwI&r^}}idu&~At3o2v?e$@kkWwQ|aN+3cG`XHpl1FF24m|r*t zf%!AxQ|^tq#Zm-Ui?OhD29)JO1nNWxst_Qc#sLbQ1LQgmLW)FC6p5iIp?sbjX{ZK`0Tyai#zc zbHw1z=FomAL}C&6Vj+Y=S2*$caBks|Ct)=?^01X7kt()6i#x=(X9EX}ZQt2j2GSS^pq6+BzIn|xRHirs6kJM8Nu!={4Trf{o_gXzyF88$TxWaO6^EmE#*vvoy*>ho6WP`BiH7pJfGeDy@jVnC4`W#lb;+3Dma z*Oc+hu7j3?J!U`O?;@(6Ufm}{(!`kZ6AO=ICe@RsZzf%QL`XhY zxqW)P=Z^$LtWp_zLQnM4yLx2sXxeY!e9j3y6~h)x%9EQ0+t40^LC`)qt;xIoZqG@B zVbbZOU*jy)-0bfaU!M{)d4J3@XJPwwBAhZs*#G$c2wTvvSxlEE0yg_`0TIwm_usTM zl9Bk42@}pdA$deNF=ZZDF^rME3be?f;1K$E;SPN_7%8-)U{P;H!7`3=tY2wv(NfG{ tj4Xz^LuZgD80Oa;3hD`mVII(#gyO;Pyw>7rZj|IO2X^EzB^EKm{08(sjoSbK literal 0 HcmV?d00001 From 02a9f4d9206814a23594411707614063708fa47d Mon Sep 17 00:00:00 2001 From: sfb Date: Thu, 27 Sep 2012 08:22:50 -0500 Subject: [PATCH 4/9] Added: #1306 Added undo/redo action for renaming array entry names --- .../src/plugins/georges_editor/actions.cpp | 82 ++++++++++++++++++- .../src/plugins/georges_editor/actions.h | 23 ++++++ .../src/plugins/georges_editor/formitem.cpp | 58 +++++++------ .../src/plugins/georges_editor/formitem.h | 5 ++ .../georges_editor/georges_editor_form.cpp | 7 +- .../georges_editor/georges_editor_form.h | 3 +- 6 files changed, 148 insertions(+), 30 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp index dba45fb96..2a7780eb4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp @@ -14,4 +14,84 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "actions.h" \ No newline at end of file +// Project includes +#include "actions.h" +#include "formitem.h" + +// Qt includes + +// NeL includes +#include +#include +#include +#include +#include +#include +#include + +namespace GeorgesQt +{ + + CUndoFormArrayRenameCommand::CUndoFormArrayRenameCommand(CFormItem *item, QString newValue, uint elementId, QUndoCommand *parent) + : QUndoCommand("Rename Form Array", parent), m_item(item), m_newValue(newValue), m_elementId(elementId) + { } + + void CUndoFormArrayRenameCommand::redo() + { + // Get the parent node + const NLGEORGES::CFormDfn *parentDfn; + uint indexDfn; + const NLGEORGES::CFormDfn *nodeDfn; + const NLGEORGES::CType *nodeType; + NLGEORGES::CFormElm *node; + NLGEORGES::UFormDfn::TEntryType type; + bool isArray; + bool vdfnArray; + NLGEORGES::CForm *form=static_cast(m_item->form()); + NLGEORGES::CFormElm *elm = static_cast(&form->getRootNode()); + nlverify ( elm->getNodeByName (m_item->formName().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, isArray, vdfnArray, true, NLGEORGES_FIRST_ROUND) ); + if (node) + { + nlinfo("doing array rename"); + NLGEORGES::CFormElmArray* array = NLMISC::safe_cast (node->getParent ()); + if(array->Elements[m_elementId].Name.empty()) + { + m_oldValue.append("#"); + m_oldValue.append(QString("%1").arg(m_elementId)); + } + else + { + m_oldValue = array->Elements[m_elementId].Name.c_str(); + } + + array->Elements[m_elementId].Name = m_newValue.toStdString(); + m_item->setName(m_newValue.toStdString()); + } + + } + + void CUndoFormArrayRenameCommand::undo() + { + // Get the parent node + const NLGEORGES::CFormDfn *parentDfn; + uint indexDfn; + const NLGEORGES::CFormDfn *nodeDfn; + const NLGEORGES::CType *nodeType; + NLGEORGES::CFormElm *node; + NLGEORGES::UFormDfn::TEntryType type; + bool isArray; + bool vdfnArray; + NLGEORGES::CForm *form=static_cast(m_item->form()); + NLGEORGES::CFormElm *elm = static_cast(&form->getRootNode()); + nlverify ( elm->getNodeByName (m_item->formName().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, isArray, vdfnArray, true, NLGEORGES_FIRST_ROUND) ); + if (node) + { + NLGEORGES::CFormElmArray* array = NLMISC::safe_cast (node->getParent ()); + //m_oldValue = array->Elements[m_elementId].Name.c_str(); + array->Elements[m_elementId].Name = m_oldValue.toStdString(); + m_item->setName(m_oldValue.toStdString()); + } + + } + +} \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h index c646adc72..c0e0d3b8e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h @@ -17,4 +17,27 @@ #ifndef ACTIONS_H #define ACTIONS_H +#include + +namespace GeorgesQt +{ + class CFormItem; + + class CUndoFormArrayRenameCommand : public QUndoCommand + { + public: + CUndoFormArrayRenameCommand(CFormItem *item, QString newValue, uint elementId, QUndoCommand *parent = 0); + ~CUndoFormArrayRenameCommand() {} + + void redo(); + void undo(); + + protected: + CFormItem *m_item; + QString m_newValue; + QString m_oldValue; + uint m_elementId; + }; +} + #endif // ACTIONS_H \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp index 98bffa7e2..39545afde 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp @@ -14,7 +14,10 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +// Project includes #include "formitem.h" +#include "actions.h" +#include "georges_editor_form.h" // Qt includes #include @@ -81,34 +84,39 @@ namespace GeorgesQt bool CFormItem::setData(int column, const QVariant &value) { - if (column != 0) - return false; - - bool deleteInsert = false; - - - - // Get the parent node - const NLGEORGES::CFormDfn *parentDfn; - uint indexDfn; - const NLGEORGES::CFormDfn *nodeDfn; - const NLGEORGES::CType *nodeType; - NLGEORGES::CFormElm *parentNode; - NLGEORGES::UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - NLGEORGES::CForm *form=static_cast(m_form); - NLGEORGES::CFormElm *elm = static_cast(&form->getRootNode()); - nlverify ( elm->getNodeByName (_FormName.c_str(), &parentDfn, indexDfn, &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - if (parentItem && parentItem->nodeType () == CFormItem::Form) + if(isEditable(column)) { - std::string newName = value.toString().toStdString(); - _Name = newName; + nlinfo("form item is editable."); + // Ensure that it is a child. + if (parentItem && parentItem->nodeType () == CFormItem::Form) + { + nlinfo("retrieving node information for data change."); + // Get the parent node + const NLGEORGES::CFormDfn *parentDfn; + uint indexDfn; + const NLGEORGES::CFormDfn *nodeDfn; + const NLGEORGES::CType *nodeType; + NLGEORGES::CFormElm *parentNode; + NLGEORGES::UFormDfn::TEntryType type; + bool isArray; + bool parentVDfnArray; + NLGEORGES::CForm *form=static_cast(m_form); + NLGEORGES::CFormElm *elm = static_cast(&form->getRootNode()); - // Create an action to update the form. + // Lets check the parent first, for arrays. + nlverify ( elm->getNodeByName (parentItem->formName().c_str(), &parentDfn, indexDfn, &nodeDfn, &nodeType, &parentNode, type, isArray, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + if(isArray && parentNode) + { + nlinfo( "is array and a child, generate rename command"); + CUndoFormArrayRenameCommand *cmd = new CUndoFormArrayRenameCommand(this,value.toString(), _StructId); + GeorgesEditorForm::UndoStack->push(cmd); + return true; + } + } } - return true; + + return false; } bool CFormItem::isEditable(int column) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h index e08a198bd..2acda42bb 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h @@ -58,9 +58,14 @@ namespace GeorgesQt TSub nodeType() { return _Type; } std::string formName() { return _FormName; } + std::string name() { return _Name; } + void setName(std::string name) { _Name = name; } + uint structId() { return _StructId; } + NLGEORGES::UForm *form() { return m_form; } + bool isEditable(int column); QIcon getItemImage(CFormItem *rootItem); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.cpp index a36f411e0..f42d6bc6b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.cpp @@ -35,6 +35,7 @@ namespace GeorgesQt { + QUndoStack *GeorgesEditorForm::UndoStack = NULL; GeorgesEditorForm::GeorgesEditorForm(QWidget *parent) : QMainWindow(parent), @@ -61,7 +62,7 @@ namespace GeorgesQt m_mainDock->setDockNestingEnabled(true); layout->addWidget(m_mainDock); - m_undoStack = new QUndoStack(this); + UndoStack = new QUndoStack(this); Core::MenuManager *menuManager = Core::ICore::instance()->menuManager(); m_openAction = menuManager->action(Core::Constants::OPEN); @@ -114,7 +115,7 @@ namespace GeorgesQt QUndoStack *GeorgesEditorForm::undoStack() const { - return m_undoStack; + return UndoStack; } void GeorgesEditorForm::open() @@ -211,7 +212,7 @@ namespace GeorgesQt } CGeorgesTreeViewDialog *dock = new CGeorgesTreeViewDialog(m_mainDock); - dock->setUndoStack(m_undoStack); + dock->setUndoStack(UndoStack); m_lastActiveDock = dock; m_dockedWidgets.append(dock); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.h index 77fdd1ec8..c9cef964c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.h @@ -38,6 +38,8 @@ public: QUndoStack *undoStack() const; + static QUndoStack *UndoStack; + public Q_SLOTS: void open(); void loadFile(const QString fileName); @@ -54,7 +56,6 @@ private: void readSettings(); void writeSettings(); - QUndoStack *m_undoStack; Ui::GeorgesEditorForm m_ui; CGeorgesDirTreeDialog *m_georgesDirTreeDialog; From e918468ef8c10aa404f5b208cbbd87bf0b5ff354 Mon Sep 17 00:00:00 2001 From: sfb Date: Fri, 28 Sep 2012 07:33:51 -0500 Subject: [PATCH 5/9] Changed: #1306 Moved creation of undo command for form array renames to the model. --- .../src/plugins/georges_editor/actions.cpp | 100 +++++++++++------- .../src/plugins/georges_editor/actions.h | 10 +- .../src/plugins/georges_editor/formitem.cpp | 33 +----- .../georges_editor/georgesform_model.cpp | 7 +- .../georges_editor/georgesform_model.h | 5 +- 5 files changed, 80 insertions(+), 75 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp index 2a7780eb4..a55bc389a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp @@ -17,9 +17,11 @@ // Project includes #include "actions.h" #include "formitem.h" +#include "georgesform_model.h" // Qt includes + // NeL includes #include #include @@ -32,12 +34,30 @@ namespace GeorgesQt { - CUndoFormArrayRenameCommand::CUndoFormArrayRenameCommand(CFormItem *item, QString newValue, uint elementId, QUndoCommand *parent) - : QUndoCommand("Rename Form Array", parent), m_item(item), m_newValue(newValue), m_elementId(elementId) - { } + CUndoFormArrayRenameCommand::CUndoFormArrayRenameCommand(CGeorgesFormModel *model, const QModelIndex &index, const QVariant &value, uint elementId, QUndoCommand *parent) + : QUndoCommand(parent), m_model(model), m_elementId(elementId) + { + m_row = index.row(); + m_col = index.column(); + + m_newValue = value.toString(); + } void CUndoFormArrayRenameCommand::redo() { + update(true); + } + + void CUndoFormArrayRenameCommand::undo() + { + update(false); + } + + void CUndoFormArrayRenameCommand::update(bool redo) + { + QModelIndex index = m_model->index(m_row, m_col); + CFormItem *item = m_model->getItem(index); + // Get the parent node const NLGEORGES::CFormDfn *parentDfn; uint indexDfn; @@ -47,13 +67,33 @@ namespace GeorgesQt NLGEORGES::UFormDfn::TEntryType type; bool isArray; bool vdfnArray; - NLGEORGES::CForm *form=static_cast(m_item->form()); - NLGEORGES::CFormElm *elm = static_cast(&form->getRootNode()); - nlverify ( elm->getNodeByName (m_item->formName().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, isArray, vdfnArray, true, NLGEORGES_FIRST_ROUND) ); + NLGEORGES::CForm *form=static_cast(item->form()); + if(!form) + { + nlinfo("failed to convert form."); + return; + } + + NLGEORGES::CFormElm *elm = static_cast(&form->Elements); + + if(!elm) + nlwarning("Failed to convert elm!"); + + nlverify ( elm->getNodeByName (item->formName().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, isArray, vdfnArray, true, NLGEORGES_FIRST_ROUND) ); if (node) { - nlinfo("doing array rename"); - NLGEORGES::CFormElmArray* array = NLMISC::safe_cast (node->getParent ()); + std::string tmpName; + node->getFormName(tmpName); + nlinfo("doing array rename on '%s'", tmpName.c_str()); + + NLGEORGES::CFormElmArray* array = static_cast (node->getParent ()); + if(!array) + nlwarning("the array is invalid."); + + // In the redo stage save the old value, just in case. + if(redo) + { + // If the name of the element is empty then give it a nice default. if(array->Elements[m_elementId].Name.empty()) { m_oldValue.append("#"); @@ -61,37 +101,21 @@ namespace GeorgesQt } else { - m_oldValue = array->Elements[m_elementId].Name.c_str(); + m_oldValue = QString::fromStdString(array->Elements[m_elementId].Name); } + } - array->Elements[m_elementId].Name = m_newValue.toStdString(); - m_item->setName(m_newValue.toStdString()); - } - + QString value; + if(redo) + value = m_newValue; + else + value = m_oldValue; + + + array->Elements[m_elementId].Name = value.toStdString(); + item->setName(value.toStdString()); + + m_model->emitDataChanged(index); + } } - - void CUndoFormArrayRenameCommand::undo() - { - // Get the parent node - const NLGEORGES::CFormDfn *parentDfn; - uint indexDfn; - const NLGEORGES::CFormDfn *nodeDfn; - const NLGEORGES::CType *nodeType; - NLGEORGES::CFormElm *node; - NLGEORGES::UFormDfn::TEntryType type; - bool isArray; - bool vdfnArray; - NLGEORGES::CForm *form=static_cast(m_item->form()); - NLGEORGES::CFormElm *elm = static_cast(&form->getRootNode()); - nlverify ( elm->getNodeByName (m_item->formName().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, isArray, vdfnArray, true, NLGEORGES_FIRST_ROUND) ); - if (node) - { - NLGEORGES::CFormElmArray* array = NLMISC::safe_cast (node->getParent ()); - //m_oldValue = array->Elements[m_elementId].Name.c_str(); - array->Elements[m_elementId].Name = m_oldValue.toStdString(); - m_item->setName(m_oldValue.toStdString()); - } - - } - } \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h index c0e0d3b8e..43a19257d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h @@ -18,22 +18,28 @@ #define ACTIONS_H #include +#include namespace GeorgesQt { class CFormItem; + class CGeorgesFormModel; class CUndoFormArrayRenameCommand : public QUndoCommand { public: - CUndoFormArrayRenameCommand(CFormItem *item, QString newValue, uint elementId, QUndoCommand *parent = 0); + CUndoFormArrayRenameCommand(CGeorgesFormModel *model, const QModelIndex &index, const QVariant &value, uint elementId, QUndoCommand *parent = 0); ~CUndoFormArrayRenameCommand() {} void redo(); void undo(); + void update(bool redo); + protected: - CFormItem *m_item; + int m_row, m_col; + CGeorgesFormModel *m_model; + QString m_newValue; QString m_oldValue; uint m_elementId; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp index 39545afde..f053719c2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp @@ -84,38 +84,7 @@ namespace GeorgesQt bool CFormItem::setData(int column, const QVariant &value) { - if(isEditable(column)) - { - nlinfo("form item is editable."); - // Ensure that it is a child. - if (parentItem && parentItem->nodeType () == CFormItem::Form) - { - nlinfo("retrieving node information for data change."); - // Get the parent node - const NLGEORGES::CFormDfn *parentDfn; - uint indexDfn; - const NLGEORGES::CFormDfn *nodeDfn; - const NLGEORGES::CType *nodeType; - NLGEORGES::CFormElm *parentNode; - NLGEORGES::UFormDfn::TEntryType type; - bool isArray; - bool parentVDfnArray; - NLGEORGES::CForm *form=static_cast(m_form); - NLGEORGES::CFormElm *elm = static_cast(&form->getRootNode()); - - // Lets check the parent first, for arrays. - nlverify ( elm->getNodeByName (parentItem->formName().c_str(), &parentDfn, indexDfn, &nodeDfn, &nodeType, &parentNode, type, isArray, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - if(isArray && parentNode) - { - nlinfo( "is array and a child, generate rename command"); - CUndoFormArrayRenameCommand *cmd = new CUndoFormArrayRenameCommand(this,value.toString(), _StructId); - GeorgesEditorForm::UndoStack->push(cmd); - return true; - } - } - } - + nlwarning("This should not be called anymore."); return false; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp index 9a329f396..b9511231b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp @@ -42,6 +42,8 @@ // project includes #include "formitem.h" +#include "georges_editor_form.h" +#include "actions.h" using namespace NLGEORGES; @@ -118,12 +120,13 @@ namespace GeorgesQt if(!item->isEditable(index.column())) return false; - bool result = item->setData(index.column(), value); + //bool result = item->setData(index.column(), value); + GeorgesEditorForm::UndoStack->push(new CUndoFormArrayRenameCommand(this,index,value,item->structId())); Q_EMIT dataChanged(index, index); //setupModelData(); - return result; + return true; } /******************************************************************************/ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h index 493f672dd..6c6c2817d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h @@ -40,7 +40,6 @@ namespace GeorgesQt class CGeorgesFormModel : public QAbstractItemModel { - public: CGeorgesFormModel(NLGEORGES::UForm *form, QMap< QString, QStringList> deps, QString comment, QStringList parents, bool* expanded, QObject *parent = 0); @@ -70,6 +69,10 @@ namespace GeorgesQt CFormItem *addArray(CFormItem *parent, NLGEORGES::CFormElmArray *array, NLGEORGES::CFormDfn *rootDfn, const char *name, uint structId, const char *formName, uint slot); + void emitDataChanged(const QModelIndex &index) + { + Q_EMIT dataChanged(index, index); + } private: void setupModelData(); void loadFormData(NLGEORGES::UFormElm *rootElm, CFormItem *parent); From a419c51a81fa8aa2edc36b334c45e5338267dab6 Mon Sep 17 00:00:00 2001 From: sfb Date: Fri, 28 Sep 2012 09:50:44 -0500 Subject: [PATCH 6/9] Changed: #1306 Fixed index bug with form array rename. --- .../src/plugins/georges_editor/actions.cpp | 40 +++++-------------- .../src/plugins/georges_editor/actions.h | 5 +-- .../georges_editor/georgesform_model.cpp | 15 ++++--- .../georges_editor/georgesform_model.h | 1 + 4 files changed, 24 insertions(+), 37 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp index a55bc389a..9fe3b0fa6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.cpp @@ -34,12 +34,9 @@ namespace GeorgesQt { - CUndoFormArrayRenameCommand::CUndoFormArrayRenameCommand(CGeorgesFormModel *model, const QModelIndex &index, const QVariant &value, uint elementId, QUndoCommand *parent) - : QUndoCommand(parent), m_model(model), m_elementId(elementId) + CUndoFormArrayRenameCommand::CUndoFormArrayRenameCommand(CGeorgesFormModel *model, CFormItem *item, const QVariant &value, QUndoCommand *parent) + : QUndoCommand("Rename Form Array Member", parent), m_model(model), m_item(item) { - m_row = index.row(); - m_col = index.column(); - m_newValue = value.toString(); } @@ -54,10 +51,7 @@ namespace GeorgesQt } void CUndoFormArrayRenameCommand::update(bool redo) - { - QModelIndex index = m_model->index(m_row, m_col); - CFormItem *item = m_model->getItem(index); - + { // Get the parent node const NLGEORGES::CFormDfn *parentDfn; uint indexDfn; @@ -67,41 +61,29 @@ namespace GeorgesQt NLGEORGES::UFormDfn::TEntryType type; bool isArray; bool vdfnArray; - NLGEORGES::CForm *form=static_cast(item->form()); - if(!form) - { - nlinfo("failed to convert form."); - return; - } - + NLGEORGES::CForm *form=static_cast(m_item->form()); NLGEORGES::CFormElm *elm = static_cast(&form->Elements); - if(!elm) - nlwarning("Failed to convert elm!"); - - nlverify ( elm->getNodeByName (item->formName().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, isArray, vdfnArray, true, NLGEORGES_FIRST_ROUND) ); + nlverify ( elm->getNodeByName (m_item->formName().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, isArray, vdfnArray, true, NLGEORGES_FIRST_ROUND) ); if (node) { std::string tmpName; node->getFormName(tmpName); - nlinfo("doing array rename on '%s'", tmpName.c_str()); NLGEORGES::CFormElmArray* array = static_cast (node->getParent ()); - if(!array) - nlwarning("the array is invalid."); // In the redo stage save the old value, just in case. if(redo) { // If the name of the element is empty then give it a nice default. - if(array->Elements[m_elementId].Name.empty()) + if(array->Elements[m_item->structId()].Name.empty()) { m_oldValue.append("#"); - m_oldValue.append(QString("%1").arg(m_elementId)); + m_oldValue.append(QString("%1").arg(m_item->structId())); } else { - m_oldValue = QString::fromStdString(array->Elements[m_elementId].Name); + m_oldValue = QString::fromStdString(array->Elements[m_item->structId()].Name); } } @@ -112,10 +94,10 @@ namespace GeorgesQt value = m_oldValue; - array->Elements[m_elementId].Name = value.toStdString(); - item->setName(value.toStdString()); + array->Elements[m_item->structId()].Name = value.toStdString(); + m_item->setName(value.toStdString()); - m_model->emitDataChanged(index); + m_model->emitDataChanged(m_model->index(m_item->row(), 0, m_item)); } } } \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h index 43a19257d..0c57b0577 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/actions.h @@ -28,7 +28,7 @@ namespace GeorgesQt class CUndoFormArrayRenameCommand : public QUndoCommand { public: - CUndoFormArrayRenameCommand(CGeorgesFormModel *model, const QModelIndex &index, const QVariant &value, uint elementId, QUndoCommand *parent = 0); + CUndoFormArrayRenameCommand(CGeorgesFormModel *model, CFormItem *item, const QVariant &value, QUndoCommand *parent = 0); ~CUndoFormArrayRenameCommand() {} void redo(); @@ -37,12 +37,11 @@ namespace GeorgesQt void update(bool redo); protected: - int m_row, m_col; + CFormItem *m_item; CGeorgesFormModel *m_model; QString m_newValue; QString m_oldValue; - uint m_elementId; }; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp index b9511231b..387bc8917 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp @@ -119,9 +119,8 @@ namespace GeorgesQt if(!item->isEditable(index.column())) return false; - - //bool result = item->setData(index.column(), value); - GeorgesEditorForm::UndoStack->push(new CUndoFormArrayRenameCommand(this,index,value,item->structId())); + + GeorgesEditorForm::UndoStack->push(new CUndoFormArrayRenameCommand(this,item,value)); Q_EMIT dataChanged(index, index); @@ -214,6 +213,14 @@ namespace GeorgesQt return QModelIndex(); } + QModelIndex CGeorgesFormModel::index(int row, int column, CFormItem *item) const + { + if(item == m_rootItem) + return QModelIndex(); + + return createIndex(row, 0, item); + } + /******************************************************************************/ QModelIndex CGeorgesFormModel::parent(const QModelIndex &index) const @@ -278,8 +285,6 @@ namespace GeorgesQt // Add the new node CFormItem *newNode = parent->add(CFormItem::Form, name, structId, formName, slot, m_form); - nlinfo("Added form %s : %s", name, formName); - // Can be NULL in virtual DFN if (parentDfn) { diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h index 6c6c2817d..07589b63c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h @@ -50,6 +50,7 @@ namespace GeorgesQt Qt::ItemFlags flags(const QModelIndex &index) const; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + QModelIndex index(int row, int column, CFormItem *item) const; QModelIndex parent(const QModelIndex &index) const; int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; From bc2ecb6023e6eccba190aa401f37b2f0e00724ec Mon Sep 17 00:00:00 2001 From: sfb Date: Thu, 18 Oct 2012 20:56:31 -0500 Subject: [PATCH 7/9] GEQt Plugin: Starting to add the context menu back. --- .../src/plugins/georges_editor/formitem.cpp | 31 +++++++++++++- .../src/plugins/georges_editor/formitem.h | 2 + .../georges_treeview_dialog.cpp | 42 ++++++++++--------- 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp index f053719c2..9281bad2e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp @@ -98,6 +98,36 @@ namespace GeorgesQt if (column != 0) return false; + if(isArrayMember()) + return true; + + return false; + } + + bool CFormItem::isArray() + { + // If it wasn't a root node then lets check the node type. + const NLGEORGES::CFormDfn *parentDfn; + uint indexDfn; + const NLGEORGES::CFormDfn *nodeDfn; + const NLGEORGES::CType *nodeType; + NLGEORGES::CFormElm *node; + NLGEORGES::UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + NLGEORGES::CForm *form = static_cast(m_form); + NLGEORGES::CFormElm *elm = static_cast(&form->getRootNode()); + nlverify ( elm->getNodeByName (_FormName.c_str(), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + if(array && node) + return true; + + return false; + } + + bool CFormItem::isArrayMember() + { CFormItem *parent = this->parent(); // If it wasn't a root node then lets check the node type. @@ -118,7 +148,6 @@ namespace GeorgesQt return true; return false; - } QIcon CFormItem::getItemImage(CFormItem *rootItem) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h index 2acda42bb..258a339db 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h @@ -67,6 +67,8 @@ namespace GeorgesQt NLGEORGES::UForm *form() { return m_form; } bool isEditable(int column); + bool isArray(); + bool isArrayMember(); QIcon getItemImage(CFormItem *rootItem); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp index aa289a4aa..c058e6a20 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp @@ -460,26 +460,23 @@ namespace GeorgesQt void CGeorgesTreeViewDialog::showContextMenu(const QPoint &pos) { - //QMenu contextMenu; - //QMenu *structContext = NULL; - //QPoint globalPos = this->mapToGlobal(pos); - // - //// Fisrt we're going to see if we've right clicked on a new item and select it. - //const QModelIndex &index = this->m_ui.treeView->currentIndex(); + QMenu contextMenu; + QMenu *structContext = NULL; + QPoint globalPos = this->mapToGlobal(pos); - //if(!index.isValid()) - // return; + // Fisrt we're going to see if we've right clicked on a new item and select it. + const QModelIndex &index = this->m_ui.treeView->currentIndex(); - //CGeorgesFormProxyModel * mp = dynamic_cast(m_ui.treeView->model()); - //CGeorgesFormModel *m = dynamic_cast(mp->sourceModel()); - //QModelIndex sourceIndex = mp->mapToSource(index); + if(!index.isValid()) + return; - //if (m) - //{ - // - // CFormItem *item = m->getItem(sourceIndex); + CGeorgesFormModel *m = dynamic_cast(m_ui.treeView->model()); - // // Right click on the "parents" item + if(m) + { + CFormItem *item = m->getItem(index); + + // Right click on the "parents" item // if (item->data(0) == "parents") // contextMenu.addAction("Add parent..."); // // Right click on a parent item @@ -488,8 +485,15 @@ namespace GeorgesQt // contextMenu.addAction("Add parent..."); // contextMenu.addAction("Remove parent"); // } - // else if(item->getFormElm()->isArray()) - // contextMenu.addAction("Add array entry..."); + if(item->isArray()) + { + contextMenu.addAction("Append array entry..."); + } + else if(item->isArrayMember()) + { + contextMenu.addAction("Delete array entry..."); + contextMenu.addAction("Insert after array entry..."); + } // else if(item->getFormElm()->isStruct()) // { // QMenu *structContext = new QMenu("Add struct element...", this); @@ -569,7 +573,7 @@ namespace GeorgesQt // } // } // if selected context menu item is valid. - //} // if 'm' model valid. + } // if 'm' model valid. //if(structContext) // delete structContext; From 098c6b96ebfe0492f4287f6686dcd4d73d43a3f8 Mon Sep 17 00:00:00 2001 From: mattraykowski Date: Sun, 21 Oct 2012 13:48:02 -0700 Subject: [PATCH 8/9] Changed: Enabled custom context menu signal to open a menu at the mouse position. --- .../src/plugins/georges_editor/formitem.h | 182 +++++++++--------- .../georges_treeview_dialog.cpp | 6 +- 2 files changed, 96 insertions(+), 92 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h index 258a339db..cc2dafece 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h @@ -1,91 +1,91 @@ -// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework -// Copyright (C) 2011 Adrian Jaekel -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef FORMITEM_H -#define FORMITEM_H - -// NeL includes -#include -#include - -// Qt includes -#include -#include - -namespace GeorgesQt -{ - - class CFormItem - { - public: - // What is the sub object ? - enum TSub - { - Null, // Nothing in this node (root ?) - Header, // Header node - Type, // This node is a type - Dfn, // This node is a dfn - Form, // This node is a form - }; - - CFormItem(); - ~CFormItem(); - - void appendChild(CFormItem *child); - - CFormItem *add (TSub type, const char *name, uint structId, const char *formName, uint slot, NLGEORGES::UForm *formPtr); - - CFormItem *child(int row); - int childCount() const; - int columnCount() const; - QVariant data(int column) const; - int row() const; - CFormItem *parent(); - bool setData(int column, const QVariant &value); - - TSub nodeType() { return _Type; } - std::string formName() { return _FormName; } - - std::string name() { return _Name; } - void setName(std::string name) { _Name = name; } - - uint structId() { return _StructId; } - - NLGEORGES::UForm *form() { return m_form; } - - bool isEditable(int column); - bool isArray(); - bool isArrayMember(); - - QIcon getItemImage(CFormItem *rootItem); - - private: - QList childItems; - QList itemData; - CFormItem *parentItem; - NLGEORGES::UFormElm* formElm; - NLGEORGES::UForm *m_form; - - uint _StructId; - std::string _Name; - std::string _FormName; - TSub _Type; - uint _Slot; - - }; // CFormItem - -} -#endif // FORMITEM_H +// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework +// Copyright (C) 2011 Adrian Jaekel +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef FORMITEM_H +#define FORMITEM_H + +// NeL includes +#include +#include + +// Qt includes +#include +#include + +namespace GeorgesQt +{ + + class CFormItem + { + public: + // What is the sub object ? + enum TSub + { + Null, // Nothing in this node (root ?) + Header, // Header node + Type, // This node is a type + Dfn, // This node is a dfn + Form, // This node is a form + }; + + CFormItem(); + ~CFormItem(); + + void appendChild(CFormItem *child); + + CFormItem *add (TSub type, const char *name, uint structId, const char *formName, uint slot, NLGEORGES::UForm *formPtr); + + CFormItem *child(int row); + int childCount() const; + int columnCount() const; + QVariant data(int column) const; + int row() const; + CFormItem *parent(); + bool setData(int column, const QVariant &value); + + TSub nodeType() { return _Type; } + std::string formName() { return _FormName; } + + std::string name() { return _Name; } + void setName(std::string name) { _Name = name; } + + uint structId() { return _StructId; } + + NLGEORGES::UForm *form() { return m_form; } + + bool isEditable(int column); + bool isArray(); + bool isArrayMember(); + + QIcon getItemImage(CFormItem *rootItem); + + private: + QList childItems; + QList itemData; + CFormItem *parentItem; + NLGEORGES::UFormElm* formElm; + NLGEORGES::UForm *m_form; + + uint _StructId; + std::string _Name; + std::string _FormName; + TSub _Type; + uint _Slot; + + }; // CFormItem + +} +#endif // FORMITEM_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp index c058e6a20..b2db0edb1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp @@ -74,6 +74,10 @@ namespace GeorgesQt m_form = 0; + m_ui.treeView->setContextMenuPolicy(Qt::CustomContextMenu); + + connect(m_ui.treeView, SIGNAL(customContextMenuRequested(const QPoint&)), + this, SLOT(showContextMenu(const QPoint&))); connect(m_ui.treeView, SIGNAL(doubleClicked (QModelIndex)), this, SLOT(doubleClicked (QModelIndex))); connect(m_header, SIGNAL(headerClicked(int)), @@ -522,7 +526,7 @@ namespace GeorgesQt // else if(item->getFormElm()->isAtom() && item->valueFrom() == NLGEORGES::UFormElm::ValueForm) // contextMenu.addAction("Revert to parent/default..."); - // QAction *selectedItem = contextMenu.exec(globalPos); + QAction *selectedItem = contextMenu.exec(QCursor::pos()); // if(selectedItem) // { // if(selectedItem->text() == "Add parent...") From b78dfebff294822e4833efd22e3a3f4dab3aec10 Mon Sep 17 00:00:00 2001 From: mattraykowski Date: Sun, 21 Oct 2012 13:58:44 -0700 Subject: [PATCH 9/9] Changed: if-statements for context menu selection - no logic --- .../georges_treeview_dialog.cpp | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp index b2db0edb1..690e5106b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp @@ -491,7 +491,7 @@ namespace GeorgesQt // } if(item->isArray()) { - contextMenu.addAction("Append array entry..."); + contextMenu.addAction("Append array entry..."); } else if(item->isArrayMember()) { @@ -527,8 +527,23 @@ namespace GeorgesQt // contextMenu.addAction("Revert to parent/default..."); QAction *selectedItem = contextMenu.exec(QCursor::pos()); - // if(selectedItem) - // { + if(selectedItem) + { + if(selectedItem->text() == "Append array entry...") + { + + + } // Append an array entry... + else if(selectedItem->text() == "Delete array entry...") + { + + } + else if(selectedItem->text() == "Insert after array entry...") + { + + } + + // if(selectedItem->text() == "Add parent...") // { // // Get the file extension of the form so we can build a dialog pattern. @@ -576,7 +591,7 @@ namespace GeorgesQt // m_ui.treeView->expandAll(); // } - // } // if selected context menu item is valid. + } // if selected context menu item is valid. } // if 'm' model valid. //if(structContext)