From bc2ecb6023e6eccba190aa401f37b2f0e00724ec Mon Sep 17 00:00:00 2001 From: sfb Date: Thu, 18 Oct 2012 20:56:31 -0500 Subject: [PATCH] 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;