/** * Renames all inserts with name 'oldName' to 'newName'. This is * called after a block was rename to update the inserts. */ void RS_EntityContainer::renameInserts(const RS_String& oldName, const RS_String& newName) { RS_DEBUG->print("RS_EntityContainer::renameInserts()"); //for (RS_Entity* e=firstEntity(RS2::ResolveNone); // e!=NULL; // e=nextEntity(RS2::ResolveNone)) { RS_PtrListIterator<RS_Entity> it = createIterator(); RS_Entity* e; while ( (e = it.current()) != NULL ) { ++it; if (e->rtti()==RS2::EntityInsert) { RS_Insert* i = ((RS_Insert*)e); if (i->getName()==oldName) { i->setName(newName); } } else if (e->isContainer()) { ((RS_EntityContainer*)e)->renameInserts(oldName, newName); } } RS_DEBUG->print("RS_EntityContainer::renameInserts() OK"); }
void RS_ActionBlocksRemove::trigger() { RS_DEBUG->print("RS_ActionBlocksRemove::trigger"); if (graphic!=NULL) { RS_Block* block = RS_DIALOGFACTORY->requestBlockRemovalDialog(graphic->getBlockList()); // list of containers that might refer to the block via inserts: RS_PtrList<RS_EntityContainer> containerList; containerList.append(graphic); RS_BlockList* blkLst = graphic->getBlockList(); for (uint bi=0; bi<blkLst->count(); bi++) { containerList.append(blkLst->at(bi)); } if (block!=NULL) { for (RS_EntityContainer* cont = containerList.first(); cont!=NULL; cont=containerList.next()) { // remove all inserts from the graphic: bool done; do { done = true; for (RS_Entity* e=cont->firstEntity(RS2::ResolveNone); e!=NULL; e=cont->nextEntity(RS2::ResolveNone)) { if (e->rtti()==RS2::EntityInsert) { RS_Insert* ins = (RS_Insert*)e; if (ins->getName()==block->getName()) { cont->removeEntity(ins); done = false; break; } } } } while (!done); } // close all windows that are editing this block: if (RS_DIALOGFACTORY!=NULL) { RS_DIALOGFACTORY->closeEditBlockWindow(block); } // Now remove the block from the block list: graphic->removeBlock(block); graphic->updateInserts(); graphicView->redraw(); } } finish(); RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected()); }
/** * Renames all inserts with name 'oldName' to 'newName'. This is * called after a block was rename to update the inserts. */ void RS_EntityContainer::renameInserts(const QString& oldName, const QString& newName) { RS_DEBUG->print("RS_EntityContainer::renameInserts()"); //for (RS_Entity* e=firstEntity(RS2::ResolveNone); // e; // e=nextEntity(RS2::ResolveNone)) { for (RS_Entity* e: entities){ if (e->rtti()==RS2::EntityInsert) { RS_Insert* i = ((RS_Insert*)e); if (i->getName()==oldName) { i->setName(newName); } } else if (e->isContainer()) { ((RS_EntityContainer*)e)->renameInserts(oldName, newName); } } RS_DEBUG->print("RS_EntityContainer::renameInserts() OK"); }