mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-30 04:40:53 +00:00
Implemented rename context menu.
This commit is contained in:
parent
6cc882e95e
commit
127e0b48ef
4 changed files with 52 additions and 0 deletions
|
@ -516,6 +516,25 @@ namespace GeorgesQt
|
||||||
log( key + " = " + value );
|
log( key + " = " + value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGeorgesTreeViewDialog::onRenameArrayEntry()
|
||||||
|
{
|
||||||
|
QModelIndex idx = m_ui.treeView->currentIndex();
|
||||||
|
|
||||||
|
CFormItem *item = static_cast< CFormItem* >( idx.internalPointer() );
|
||||||
|
|
||||||
|
QString newName = QInputDialog::getText( this,
|
||||||
|
tr( "Rename" ),
|
||||||
|
tr( "Enter new name" ),
|
||||||
|
QLineEdit::Normal,
|
||||||
|
item->name().c_str() );
|
||||||
|
|
||||||
|
m_model->renameArrayEntry( idx, newName );
|
||||||
|
|
||||||
|
QString formName = item->formName().c_str();
|
||||||
|
|
||||||
|
log( formName + " renamed = " + newName );
|
||||||
|
}
|
||||||
|
|
||||||
void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event)
|
void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
Q_EMIT closing();
|
Q_EMIT closing();
|
||||||
|
@ -576,6 +595,9 @@ namespace GeorgesQt
|
||||||
{
|
{
|
||||||
QAction *deleteAction = contextMenu.addAction("Delete array entry...");
|
QAction *deleteAction = contextMenu.addAction("Delete array entry...");
|
||||||
connect( deleteAction, SIGNAL( triggered( bool ) ), this, SLOT( onDeleteArrayEntry() ) );
|
connect( deleteAction, SIGNAL( triggered( bool ) ), this, SLOT( onDeleteArrayEntry() ) );
|
||||||
|
|
||||||
|
QAction *renameAction = contextMenu.addAction("Rename");
|
||||||
|
connect( renameAction, SIGNAL( triggered( bool ) ), this, SLOT( onRenameArrayEntry() ) );
|
||||||
//contextMenu.addAction("Insert after array entry...");
|
//contextMenu.addAction("Insert after array entry...");
|
||||||
}
|
}
|
||||||
// else if(item->getFormElm()->isStruct())
|
// else if(item->getFormElm()->isStruct())
|
||||||
|
|
|
@ -107,6 +107,7 @@ namespace GeorgesQt
|
||||||
void onAppendArray();
|
void onAppendArray();
|
||||||
void onDeleteArrayEntry();
|
void onDeleteArrayEntry();
|
||||||
void onValueChanged( const QString &key, const QString &value );
|
void onValueChanged( const QString &key, const QString &value );
|
||||||
|
void onRenameArrayEntry();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void log( const QString &msg );
|
void log( const QString &msg );
|
||||||
|
|
|
@ -614,6 +614,34 @@ void CGeorgesFormModel::deleteArrayEntry( QModelIndex idx )
|
||||||
Q_EMIT endResetModel();
|
Q_EMIT endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGeorgesFormModel::renameArrayEntry( QModelIndex idx, const QString &name )
|
||||||
|
{
|
||||||
|
CFormItem *item = static_cast< CFormItem* >( idx.internalPointer() );
|
||||||
|
|
||||||
|
NLGEORGES::UFormElm *elm;
|
||||||
|
|
||||||
|
item->form()->getRootNode().getNodeByName( &elm, item->formName().c_str() );
|
||||||
|
|
||||||
|
NLGEORGES::CFormElm *celm = dynamic_cast< NLGEORGES::CFormElm* >( elm );
|
||||||
|
if( celm == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
NLGEORGES::UFormElm *uparent = celm->getParent();
|
||||||
|
NLGEORGES::CFormElmArray *cparent = dynamic_cast< NLGEORGES::CFormElmArray* >( uparent );
|
||||||
|
if( cparent == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for( i = 0; i < cparent->Elements.size(); i++ )
|
||||||
|
{
|
||||||
|
if( cparent->Elements[ i ].Element == celm )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cparent->Elements[ i ].Name = name.toUtf8().constData();
|
||||||
|
item->setName( name.toUtf8().constData() );
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
void CGeorgesFormModel::loadFormHeader()
|
void CGeorgesFormModel::loadFormHeader()
|
||||||
|
|
|
@ -78,6 +78,7 @@ namespace GeorgesQt
|
||||||
void arrayResized( const QString &name, int size );
|
void arrayResized( const QString &name, int size );
|
||||||
void appendArray( QModelIndex idx );
|
void appendArray( QModelIndex idx );
|
||||||
void deleteArrayEntry( QModelIndex idx );
|
void deleteArrayEntry( QModelIndex idx );
|
||||||
|
void renameArrayEntry( QModelIndex idx, const QString &name );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupModelData();
|
void setupModelData();
|
||||||
|
|
Loading…
Reference in a new issue