mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-18 06:48:44 +00:00
Implemented 'append array entry' context menu
This commit is contained in:
parent
8653280bbb
commit
8088dabb89
4 changed files with 74 additions and 17 deletions
|
@ -470,6 +470,19 @@ namespace GeorgesQt
|
||||||
m_ui.treeView->setCurrentIndex( idx );
|
m_ui.treeView->setCurrentIndex( idx );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGeorgesTreeViewDialog::onAppendArray()
|
||||||
|
{
|
||||||
|
QModelIndex idx = m_ui.treeView->currentIndex();
|
||||||
|
|
||||||
|
m_model->appendArray( idx );
|
||||||
|
|
||||||
|
m_ui.treeView->reset();
|
||||||
|
m_ui.treeView->expandAll();
|
||||||
|
|
||||||
|
m_ui.treeView->setCurrentIndex( idx );
|
||||||
|
m_browserCtrl->clicked( idx );
|
||||||
|
}
|
||||||
|
|
||||||
void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event)
|
void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
Q_EMIT closing();
|
Q_EMIT closing();
|
||||||
|
@ -523,7 +536,8 @@ namespace GeorgesQt
|
||||||
// }
|
// }
|
||||||
if(item->isArray())
|
if(item->isArray())
|
||||||
{
|
{
|
||||||
contextMenu.addAction("Append array entry...");
|
QAction *appendAction = contextMenu.addAction("Append array entry...");
|
||||||
|
connect( appendAction, SIGNAL( triggered( bool ) ), this, SLOT( onAppendArray() ) );
|
||||||
}
|
}
|
||||||
else if(item->isArrayMember())
|
else if(item->isArrayMember())
|
||||||
{
|
{
|
||||||
|
@ -558,24 +572,10 @@ namespace GeorgesQt
|
||||||
// else if(item->getFormElm()->isAtom() && item->valueFrom() == NLGEORGES::UFormElm::ValueForm)
|
// else if(item->getFormElm()->isAtom() && item->valueFrom() == NLGEORGES::UFormElm::ValueForm)
|
||||||
// contextMenu.addAction("Revert to parent/default...");
|
// contextMenu.addAction("Revert to parent/default...");
|
||||||
|
|
||||||
QAction *selectedItem = contextMenu.exec(QCursor::pos());
|
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...")
|
// if(selectedItem->text() == "Add parent...")
|
||||||
// {
|
// {
|
||||||
// // Get the file extension of the form so we can build a dialog pattern.
|
// // Get the file extension of the form so we can build a dialog pattern.
|
||||||
|
@ -624,6 +624,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)
|
||||||
|
|
|
@ -104,6 +104,7 @@ namespace GeorgesQt
|
||||||
void headerClicked(int);
|
void headerClicked(int);
|
||||||
|
|
||||||
void onArrayResized( const QString &name, int size );
|
void onArrayResized( const QString &name, int size );
|
||||||
|
void onAppendArray();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::CGeorgesTreeViewDialog m_ui;
|
Ui::CGeorgesTreeViewDialog m_ui;
|
||||||
|
|
|
@ -515,6 +515,60 @@ void CGeorgesFormModel::arrayResized( const QString &name, int size )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGeorgesFormModel::appendArray( QModelIndex idx )
|
||||||
|
{
|
||||||
|
if( !idx.isValid() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
CFormItem *item = reinterpret_cast< CFormItem* >( idx.internalPointer() );
|
||||||
|
NLGEORGES::UFormElm *elm = NULL;
|
||||||
|
|
||||||
|
item->form()->getRootNode().getNodeByName( &elm, item->formName().c_str() );
|
||||||
|
|
||||||
|
const NLGEORGES::CFormDfn *parentDfn;
|
||||||
|
const NLGEORGES::CFormDfn *nodeDfn;
|
||||||
|
uint indexDfn;
|
||||||
|
const NLGEORGES::CType *type;
|
||||||
|
NLGEORGES::UFormDfn::TEntryType entryType;
|
||||||
|
NLGEORGES::CFormElm *node;
|
||||||
|
bool created;
|
||||||
|
bool isArray;
|
||||||
|
|
||||||
|
if( elm == NULL )
|
||||||
|
{
|
||||||
|
NLGEORGES::UFormElm *uroot = &item->form()->getRootNode();
|
||||||
|
NLGEORGES::CFormElm *croot = static_cast< NLGEORGES::CFormElm* >( uroot );
|
||||||
|
|
||||||
|
croot->createNodeByName( item->formName().c_str(), &parentDfn, indexDfn, &nodeDfn, &type, &node, entryType, isArray, created );
|
||||||
|
|
||||||
|
if( !created )
|
||||||
|
return;
|
||||||
|
|
||||||
|
elm = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
NLGEORGES::CFormElmArray *celm = dynamic_cast< NLGEORGES::CFormElmArray* >( elm );
|
||||||
|
if( celm == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
unsigned long s = celm->Elements.size();
|
||||||
|
std::string nodeIdx = "[";
|
||||||
|
nodeIdx += QString::number( s ).toUtf8().constData();
|
||||||
|
nodeIdx += "]";
|
||||||
|
|
||||||
|
celm->createNodeByName( nodeIdx.c_str(), &parentDfn, indexDfn, &nodeDfn, &type, &node, entryType, isArray, created );
|
||||||
|
if( !created )
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::string name = "#";
|
||||||
|
name += QString::number( s ).toUtf8().constData();
|
||||||
|
|
||||||
|
std::string formName;
|
||||||
|
node->getFormName( formName );
|
||||||
|
|
||||||
|
item->add( CFormItem::Form, name.c_str(), s, formName.c_str(), 0, item->form(), false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
|
@ -76,6 +76,7 @@ namespace GeorgesQt
|
||||||
}
|
}
|
||||||
|
|
||||||
void arrayResized( const QString &name, int size );
|
void arrayResized( const QString &name, int size );
|
||||||
|
void appendArray( QModelIndex idx );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupModelData();
|
void setupModelData();
|
||||||
|
|
Loading…
Reference in a new issue