]> Shamusworld >> Repos - architektonas/blob - src/actions/actionblocksattributes.cpp
Bugfixes related to removing Snapper class.
[architektonas] / src / actions / actionblocksattributes.cpp
1 // actionblocksattributes.cpp
2 //
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
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  07/12/2010  Added this text. :-)
15 //
16
17 #include "actionblocksattributes.h"
18
19 #include "drawing.h"
20 #include "dialogfactory.h"
21
22 ActionBlocksAttributes::ActionBlocksAttributes(
23         EntityContainer & container, GraphicView & graphicView):
24         ActionInterface("Edit Block Attributes", container, graphicView)
25 {
26 }
27
28 ActionBlocksAttributes::~ActionBlocksAttributes()
29 {
30 }
31
32 void ActionBlocksAttributes::trigger()
33 {
34         DEBUG->print("editing block attributes");
35
36         if (graphic && DIALOGFACTORY)
37         {
38                 Block * block = graphic->getActiveBlock();
39                 BlockList * blockList = graphic->getBlockList();
40
41                 if (blockList && block)
42                 {
43                         QString oldName = block->getName();
44                         BlockData d = DIALOGFACTORY->requestBlockAttributesDialog(blockList);
45
46                         if (d.isValid())
47                         {
48                                 QString newName = d.name;
49                                 blockList->rename(block, newName);
50
51                                 // update the name of all inserts:
52                                 graphic->renameInserts(oldName, newName);
53                                 graphic->addBlockNotification();
54                         }
55                 }
56         }
57
58         finish();
59 }
60
61 void ActionBlocksAttributes::init(int status)
62 {
63         ActionInterface::init(status);
64         trigger();
65 }