]> Shamusworld >> Repos - architektonas/blob - src/forms/cadtoolbarpolylines.cpp
Successfully refactored CadToolBarLines to use predefined actions.
[architektonas] / src / forms / cadtoolbarpolylines.cpp
1 // cadtoolbarpolylines.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 "cadtoolbarpolylines.h"
16
17 #include "cadtoolbar.h"
18 #include "qg_actionhandler.h"
19 #include "rs_debug.h"
20
21 CadToolBarPolylines::CadToolBarPolylines(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
22         QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL)
23 {
24         ui.setupUi(this);
25 }
26
27 CadToolBarPolylines::~CadToolBarPolylines()
28 {
29 }
30
31 void CadToolBarPolylines::mousePressEvent(QMouseEvent * e)
32 {
33         if (e->button() == Qt::RightButton && cadToolBar != NULL)
34         {
35                 cadToolBar->back();
36                 e->accept();
37         }
38 }
39
40 void CadToolBarPolylines::contextMenuEvent(QContextMenuEvent * e)
41 {
42         e->accept();
43 }
44
45 void CadToolBarPolylines::setCadToolBar(CadToolBar * tb)
46 {
47         cadToolBar = tb;
48
49         if (tb != NULL)
50                 actionHandler = tb->getActionHandler();
51         else
52                 RS_DEBUG->print(RS_Debug::D_ERROR, "CadToolBarPolylines::setCadToolBar(): No valid toolbar set.");
53 }
54
55 void CadToolBarPolylines::drawPolyline()
56 {
57         if (cadToolBar != NULL && actionHandler != NULL)
58                 actionHandler->slotDrawPolyline();
59 }
60
61 void CadToolBarPolylines::polylineAdd()
62 {
63         if (cadToolBar != NULL && actionHandler != NULL)
64                 actionHandler->slotPolylineAdd();
65 }
66
67 void CadToolBarPolylines::polylineAppend()
68 {
69         if (cadToolBar != NULL && actionHandler != NULL)
70                 actionHandler->slotPolylineAppend();
71 }
72
73 void CadToolBarPolylines::polylineDel()
74 {
75         if (cadToolBar != NULL && actionHandler != NULL)
76                 actionHandler->slotPolylineDel();
77 }
78
79 void CadToolBarPolylines::polylineDelBetween()
80 {
81         if (cadToolBar != NULL && actionHandler != NULL)
82                 actionHandler->slotPolylineDelBetween();
83 }
84
85 void CadToolBarPolylines::polylineTrim()
86 {
87         if (cadToolBar != NULL && actionHandler != NULL)
88                 actionHandler->slotPolylineTrim();
89 }
90
91 void CadToolBarPolylines::back()
92 {
93         if (cadToolBar != NULL)
94                 cadToolBar->back();
95 }