]> Shamusworld >> Repos - architektonas/blobdiff - src/drawlineaction.cpp
Added preliminary (i.e., non-functional) trim tool. Also:
[architektonas] / src / drawlineaction.cpp
index e14ba81ca1f440876c5e60dabba0cfe9b95c7962..5490e9829bcc553fc71fbd8213c402a4b66a74b8 100644 (file)
 #include "drawlineaction.h"
 #include "line.h"
 #include "painter.h"
-//#include "vector.h"
 
 
-//#define FIRST_POINT 0
-//#define NEXT_POINT 1
 enum { FIRST_POINT, NEXT_POINT };
 
 
@@ -83,12 +80,22 @@ DrawLineAction::~DrawLineAction()
        {
                p2 = p1;
                state = NEXT_POINT;
+               line = NULL;
        }
        else if (state == NEXT_POINT)
        {
+               Line * oldLine = line;
                // We create the new object here, and then pass it off to the
                // DrawingView which stuffs it into the document.
                line = new Line(p1, p2);
+
+               // Connect Lines by default
+               if (oldLine)
+               {
+                       oldLine->Connect(line, 0);
+                       line->Connect(oldLine, 1.0);
+               }
+
                // We don't need no stinkin' sentinels, when we have signals & slots!
                emit ObjectReady(line);
 
@@ -98,7 +105,7 @@ DrawLineAction::~DrawLineAction()
 }
 
 
-/*virtual*/ bool DrawLineAction::KeyDown(int key)
+/*virtual*/ void DrawLineAction::KeyDown(int key)
 {
        if ((key == Qt::Key_Shift) && (state == NEXT_POINT))
        {
@@ -106,14 +113,12 @@ DrawLineAction::~DrawLineAction()
                p1Save = p1;
                p1 = p2;
                state = FIRST_POINT;
-               return true;
+               emit NeedRefresh();
        }
-
-       return false;
 }
 
 
-/*virtual*/ bool DrawLineAction::KeyReleased(int key)
+/*virtual*/ void DrawLineAction::KeyReleased(int key)
 {
        if ((key == Qt::Key_Shift) && shiftWasPressedOnNextPoint)
        {
@@ -121,9 +126,7 @@ DrawLineAction::~DrawLineAction()
                p2 = p1;
                p1 = p1Save;
                state = NEXT_POINT;
-               return true;
+               emit(NeedRefresh());
        }
-
-       return false;
 }