mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 01:09:50 +00:00
Implement 'delete array entry' context menu command.
--HG-- branch : dfighter-tools
This commit is contained in:
parent
6fb9c35d84
commit
5bb3e16ca4
4 changed files with 60 additions and 2 deletions
|
@ -483,6 +483,18 @@ namespace GeorgesQt
|
|||
m_browserCtrl->clicked( idx );
|
||||
}
|
||||
|
||||
void CGeorgesTreeViewDialog::onDeleteArrayEntry()
|
||||
{
|
||||
QModelIndex current = m_ui.treeView->currentIndex();
|
||||
QModelIndex parent = current.parent();
|
||||
|
||||
m_model->deleteArrayEntry( current );
|
||||
|
||||
m_ui.treeView->expandAll();
|
||||
m_ui.treeView->setCurrentIndex( parent );
|
||||
m_browserCtrl->clicked( parent );
|
||||
}
|
||||
|
||||
void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
Q_EMIT closing();
|
||||
|
@ -541,8 +553,9 @@ namespace GeorgesQt
|
|||
}
|
||||
else if(item->isArrayMember())
|
||||
{
|
||||
contextMenu.addAction("Delete array entry...");
|
||||
contextMenu.addAction("Insert after array entry...");
|
||||
QAction *deleteAction = contextMenu.addAction("Delete array entry...");
|
||||
connect( deleteAction, SIGNAL( triggered( bool ) ), this, SLOT( onDeleteArrayEntry() ) );
|
||||
//contextMenu.addAction("Insert after array entry...");
|
||||
}
|
||||
// else if(item->getFormElm()->isStruct())
|
||||
// {
|
||||
|
|
|
@ -105,6 +105,7 @@ namespace GeorgesQt
|
|||
|
||||
void onArrayResized( const QString &name, int size );
|
||||
void onAppendArray();
|
||||
void onDeleteArrayEntry();
|
||||
|
||||
private:
|
||||
Ui::CGeorgesTreeViewDialog m_ui;
|
||||
|
|
|
@ -569,7 +569,50 @@ void CGeorgesFormModel::appendArray( QModelIndex idx )
|
|||
item->add( CFormItem::Form, name.c_str(), s, formName.c_str(), 0, item->form(), false );
|
||||
}
|
||||
|
||||
void CGeorgesFormModel::deleteArrayEntry( QModelIndex idx )
|
||||
{
|
||||
CFormItem *item = reinterpret_cast< CFormItem* >( idx.internalPointer() );
|
||||
NLGEORGES::UFormElm &uroot = item->form()->getRootNode();
|
||||
NLGEORGES::CFormElm *root = static_cast< NLGEORGES::CFormElm* >( &item->form()->getRootNode() );
|
||||
NLGEORGES::UFormElm *unode;
|
||||
uroot.getNodeByName( &unode, item->formName().c_str() );
|
||||
NLGEORGES::CFormElm *cnode = static_cast< NLGEORGES::CFormElm* >( unode );
|
||||
NLGEORGES::CFormElmArray *arr = static_cast< NLGEORGES::CFormElmArray* >( cnode->getParent() );
|
||||
|
||||
NLGEORGES::CFormElm *elm = arr->Elements[ idx.row() ].Element;
|
||||
|
||||
Q_EMIT beginResetModel();
|
||||
|
||||
std::vector< NLGEORGES::CFormElmArray::CElement >::iterator itr = arr->Elements.begin() + idx.row();
|
||||
arr->Elements.erase( itr );
|
||||
|
||||
delete elm;
|
||||
|
||||
item = item->parent();
|
||||
item->clearChildren();
|
||||
|
||||
NLGEORGES::CFormElmArray *celm = arr;
|
||||
|
||||
for( int i = 0; i < celm->Elements.size(); i++ )
|
||||
{
|
||||
NLGEORGES::CFormElmArray::CElement &e = celm->Elements[ i ];
|
||||
|
||||
QString formName = item->formName().c_str();
|
||||
formName += '[';
|
||||
formName += QString::number( i );
|
||||
formName += ']';
|
||||
|
||||
QString n;
|
||||
if( e.Name.empty() )
|
||||
n = "#" + QString::number( i );
|
||||
else
|
||||
n = e.Name.c_str();
|
||||
|
||||
item->add( CFormItem::Form, n.toUtf8().constData(), i, formName.toUtf8().constData(), 0, item->form(), false );
|
||||
}
|
||||
|
||||
Q_EMIT endResetModel();
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ namespace GeorgesQt
|
|||
|
||||
void arrayResized( const QString &name, int size );
|
||||
void appendArray( QModelIndex idx );
|
||||
void deleteArrayEntry( QModelIndex idx );
|
||||
|
||||
private:
|
||||
void setupModelData();
|
||||
|
|
Loading…
Reference in a new issue