1 // actionblocksremove.cpp
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 06/03/2010 Added this text. :-)
17 #include "actionblocksremove.h"
20 #include "dialogfactory.h"
22 #include "graphicview.h"
25 ActionBlocksRemove::ActionBlocksRemove(EntityContainer & container, GraphicView & graphicView):
26 ActionInterface("Remove Block", container, graphicView)
30 ActionBlocksRemove::~ActionBlocksRemove()
34 void ActionBlocksRemove::trigger()
36 DEBUG->print("ActionBlocksRemove::trigger");
40 Block * block = DIALOGFACTORY->requestBlockRemovalDialog(graphic->getBlockList());
42 // list of containers that might refer to the block via inserts:
43 QList<EntityContainer *> containerList;
44 containerList.append(graphic);
45 BlockList * blkLst = graphic->getBlockList();
47 for(uint bi=0; bi<blkLst->count(); bi++)
48 containerList.append(blkLst->at(bi));
52 for(int i=0; i<containerList.size(); i++)
54 EntityContainer * cont = containerList[i];
55 // remove all inserts from the graphic:
62 for(Entity * e=cont->firstEntity(RS2::ResolveNone); e!=NULL;
63 e=cont->nextEntity(RS2::ResolveNone))
65 if (e->rtti() == RS2::EntityInsert)
67 Insert * ins = (Insert *)e;
69 if (ins->getName() == block->getName())
71 cont->removeEntity(ins);
81 // close all windows that are editing this block:
83 DIALOGFACTORY->closeEditBlockWindow(block);
85 // Now remove the block from the block list:
86 graphic->removeBlock(block);
87 graphic->updateInserts();
88 graphicView->redraw();
93 DIALOGFACTORY->updateSelectionWidget(container->countSelected());
96 void ActionBlocksRemove::init(int status)
98 ActionInterface::init(status);