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