mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-17 13:01:41 +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)
|
if (column != 0)
|
||||||
return false;
|
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();
|
CFormItem *parent = this->parent();
|
||||||
|
|
||||||
// If it wasn't a root node then lets check the node type.
|
// If it wasn't a root node then lets check the node type.
|
||||||
|
@ -118,7 +148,6 @@ namespace GeorgesQt
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon CFormItem::getItemImage(CFormItem *rootItem)
|
QIcon CFormItem::getItemImage(CFormItem *rootItem)
|
||||||
|
|
|
@ -67,6 +67,8 @@ namespace GeorgesQt
|
||||||
NLGEORGES::UForm *form() { return m_form; }
|
NLGEORGES::UForm *form() { return m_form; }
|
||||||
|
|
||||||
bool isEditable(int column);
|
bool isEditable(int column);
|
||||||
|
bool isArray();
|
||||||
|
bool isArrayMember();
|
||||||
|
|
||||||
QIcon getItemImage(CFormItem *rootItem);
|
QIcon getItemImage(CFormItem *rootItem);
|
||||||
|
|
||||||
|
|
|
@ -460,26 +460,23 @@ namespace GeorgesQt
|
||||||
|
|
||||||
void CGeorgesTreeViewDialog::showContextMenu(const QPoint &pos)
|
void CGeorgesTreeViewDialog::showContextMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
//QMenu contextMenu;
|
QMenu contextMenu;
|
||||||
//QMenu *structContext = NULL;
|
QMenu *structContext = NULL;
|
||||||
//QPoint globalPos = this->mapToGlobal(pos);
|
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())
|
// Fisrt we're going to see if we've right clicked on a new item and select it.
|
||||||
// return;
|
const QModelIndex &index = this->m_ui.treeView->currentIndex();
|
||||||
|
|
||||||
//CGeorgesFormProxyModel * mp = dynamic_cast<CGeorgesFormProxyModel *>(m_ui.treeView->model());
|
if(!index.isValid())
|
||||||
//CGeorgesFormModel *m = dynamic_cast<CGeorgesFormModel *>(mp->sourceModel());
|
return;
|
||||||
//QModelIndex sourceIndex = mp->mapToSource(index);
|
|
||||||
|
|
||||||
//if (m)
|
CGeorgesFormModel *m = dynamic_cast<CGeorgesFormModel *>(m_ui.treeView->model());
|
||||||
//{
|
|
||||||
//
|
|
||||||
// CFormItem *item = m->getItem(sourceIndex);
|
|
||||||
|
|
||||||
// // Right click on the "parents" item
|
if(m)
|
||||||
|
{
|
||||||
|
CFormItem *item = m->getItem(index);
|
||||||
|
|
||||||
|
// Right click on the "parents" item
|
||||||
// if (item->data(0) == "parents")
|
// if (item->data(0) == "parents")
|
||||||
// contextMenu.addAction("Add parent...");
|
// contextMenu.addAction("Add parent...");
|
||||||
// // Right click on a parent item
|
// // Right click on a parent item
|
||||||
|
@ -488,8 +485,15 @@ namespace GeorgesQt
|
||||||
// contextMenu.addAction("Add parent...");
|
// contextMenu.addAction("Add parent...");
|
||||||
// contextMenu.addAction("Remove parent");
|
// contextMenu.addAction("Remove parent");
|
||||||
// }
|
// }
|
||||||
// else if(item->getFormElm()->isArray())
|
if(item->isArray())
|
||||||
// contextMenu.addAction("Add array entry...");
|
{
|
||||||
|
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())
|
// else if(item->getFormElm()->isStruct())
|
||||||
// {
|
// {
|
||||||
// QMenu *structContext = new QMenu("Add struct element...", this);
|
// QMenu *structContext = new QMenu("Add struct element...", this);
|
||||||
|
@ -569,7 +573,7 @@ namespace GeorgesQt
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// } // if selected context menu item is valid.
|
// } // if selected context menu item is valid.
|
||||||
//} // if 'm' model valid.
|
} // if 'm' model valid.
|
||||||
|
|
||||||
//if(structContext)
|
//if(structContext)
|
||||||
// delete structContext;
|
// delete structContext;
|
||||||
|
|
Loading…
Reference in a new issue