void __fastcall TMDIChild::actDelCurNodeExecute(TObject *Sender) { if(tvParseTree->Selected == NULL) return; ParseTreeNode * curParseTree = (ParseTreeNode *)tvParseTree->Selected->Data; ClassData * curClass = GetCurParseClass(); if(curClass == NULL) return; if(curParseTree == NULL) { //选择的是结构体 DeleteCurClass(); curClass = NULL; DeleteCurClass(); } else { //选择的是变量 if(curParseTree->GetParent() == NULL) { //只能够删除成员变量 curClass->DeleteMember(curParseTree->GetClassMember()); if(curClass->GetMemberDataCount() == 0) { DeleteCurClass(); } else { m_ParseTree->BindClass(curClass); ExpandFirstNode(); ParseData(); } } } SetModify(); }
void TMDIChild::ChangeNodeName(ParseTreeNode * curParseTree, bool needRefresh, int changeType) { ClassData * curClass = GetCurParseClass(); if(curClass == NULL) return; String showName; if(changeType == 0) { showName = "输入新名称"; } else { showName = "输入新注释"; } String name; int haveResult = 0; if(curParseTree == NULL) { //选择的是结构体 if(changeType==0) { name = curClass->GetName(); } else { name = curClass->GetComment(); } if(InputQuery(showName, showName, name)) { haveResult = 1; if(changeType==0) { curClass->SetName(name); } else { curClass->SetComment(name); } } } else { //选择的是变量 String curName; if(changeType==0) { curName = curParseTree->GetClassMember()->GetName(); } else { curName = curParseTree->GetClassMember()->GetComment(); } if(curName.Pos("[")) { //是数组中的一个 ParseTreeNode * parent = curParseTree->GetParent(); ChangeNodeName(parent, false); parent->SetExNodeName(); haveResult = 1; } else { ClassMember * curModifyMember = NULL; for(int i=0; i<curClass->GetMemberDataCount(); i++) { if((IClassMember *)curClass->GetMemberData(i) == curParseTree->GetClassMember()) { curModifyMember = curClass->GetMemberByIndex(i); } } if(curModifyMember) { if(changeType==0) { name = curModifyMember->GetName(); } else { name = curModifyMember->GetComment(); } if(InputQuery(showName, showName, name)) { haveResult = 1; if(changeType==0) { curModifyMember->SetName(name); } else { curModifyMember->SetComment(name); } curParseTree->SetExNodeName(); } } } } if(haveResult && needRefresh) { RefreshAllClassView(); m_ParseTree->RefreshViewText(); } }