mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-17 22:48:44 +00:00
GEQt Plugin: Starting to add the context menu back.
This commit is contained in:
parent
a419c51a81
commit
bc2ecb6023
3 changed files with 55 additions and 20 deletions
|
@ -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<CForm*>(m_form);
|
||||
NLGEORGES::CFormElm *elm = static_cast<CFormElm*>(&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)
|
||||
|
|
|
@ -67,6 +67,8 @@ namespace GeorgesQt
|
|||
NLGEORGES::UForm *form() { return m_form; }
|
||||
|
||||
bool isEditable(int column);
|
||||
bool isArray();
|
||||
bool isArrayMember();
|
||||
|
||||
QIcon getItemImage(CFormItem *rootItem);
|
||||
|
||||
|
|
|
@ -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<CGeorgesFormProxyModel *>(m_ui.treeView->model());
|
||||
//CGeorgesFormModel *m = dynamic_cast<CGeorgesFormModel *>(mp->sourceModel());
|
||||
//QModelIndex sourceIndex = mp->mapToSource(index);
|
||||
if(!index.isValid())
|
||||
return;
|
||||
|
||||
//if (m)
|
||||
//{
|
||||
//
|
||||
// CFormItem *item = m->getItem(sourceIndex);
|
||||
CGeorgesFormModel *m = dynamic_cast<CGeorgesFormModel *>(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;
|
||||
|
|
Loading…
Reference in a new issue