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