]> Shamusworld >> Repos - architektonas/blob - src/forms/lineoptions.cpp
In the middle of major refactoring...
[architektonas] / src / forms / lineoptions.cpp
1 // lineoptions.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 // (C) 2010 Underground Software
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
11 // ---  ----------  -----------------------------------------------------------
12 // JLH  05/10/2010  Created this file. :-)
13 //
14
15 #include "lineoptions.h"
16
17 #include "rs.h"
18 #include "actiondrawline.h"
19 #include "actioninterface.h"
20
21 LineOptions::LineOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
22         QWidget(parent, flags), action(NULL),
23         bClose(new QToolButton(this)),
24         bUndo(new QToolButton(this))
25 {
26         QHBoxLayout * layout = new QHBoxLayout(this);
27         layout->setContentsMargins(0, 0, 0, 0);
28
29         bClose->setText(tr("Close"));
30         bUndo->setText(tr("Undo"));
31
32         layout->addWidget(bClose);
33         layout->addWidget(bUndo);
34
35         connect(bClose, SIGNAL(clicked()), this, SLOT(close()));
36         connect(bUndo, SIGNAL(clicked()), this, SLOT(undo()));
37
38         // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
39         // nothing will show up on the screen. :-)
40         if (parent)
41                 parent->addWidget(this);
42 }
43
44 LineOptions::~LineOptions()
45 {
46 }
47
48 //void LineOptions::setAction(ActionInterface * a)
49 void LineOptions::setAction(ActionInterface * a)
50 {
51         if (a != NULL && a->rtti() == RS2::ActionDrawLine)
52         {
53                 action = (ActionDrawLine *)a;
54         }
55         else
56         {
57                 RS_DEBUG->print(RS_Debug::D_ERROR, "QG_LineOptions::setAction: wrong action type");
58                 action = NULL;
59         }
60 }
61
62 void LineOptions::close()
63 {
64         if (action)
65                 action->close();
66 }
67
68 void LineOptions::undo()
69 {
70         if (action)
71                 action->undo();
72 }