toolbarstatearrow.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "toolbarstatearrow.h"
00014
00015
00016 #include "associationwidget.h"
00017 #include "uml.h"
00018 #include "umlview.h"
00019 #include "umlwidget.h"
00020
00021 ToolBarStateArrow::ToolBarStateArrow(UMLView *umlView): ToolBarState(umlView) {
00022 m_selectionRect.setAutoDelete(true);
00023
00024 init();
00025 }
00026
00027 ToolBarStateArrow::~ToolBarStateArrow() {
00028 }
00029
00030 void ToolBarStateArrow::init() {
00031 ToolBarState::init();
00032
00033 m_selectionRect.clear();
00034 }
00035
00036 void ToolBarStateArrow::mousePressAssociation() {
00037 getCurrentAssociation()->mousePressEvent(m_pMouseEvent);
00038 }
00039
00040 void ToolBarStateArrow::mousePressWidget() {
00041 getCurrentWidget()->mousePressEvent(m_pMouseEvent);
00042 }
00043
00044 void ToolBarStateArrow::mousePressEmpty() {
00045 if (m_pMouseEvent->button() != Qt::LeftButton) {
00046
00047
00048 return;
00049 }
00050 ToolBarState::mousePressEmpty();
00051
00052
00053 if (m_selectionRect.count() == 0) {
00054 m_startPosition = m_pMouseEvent->pos();
00055
00056 for (int i = 0; i < 4; i++) {
00057 QCanvasLine* line = new QCanvasLine(m_pUMLView->canvas());
00058 line->setPoints(m_pMouseEvent->x(), m_pMouseEvent->y(),
00059 m_pMouseEvent->x(), m_pMouseEvent->y());
00060 line->setPen(QPen(QColor("grey"), 0, Qt::DotLine));
00061 line->setVisible(true);
00062 line->setZ(100);
00063 m_selectionRect.append(line);
00064 }
00065 }
00066 }
00067
00068 void ToolBarStateArrow::mouseReleaseAssociation() {
00069 getCurrentAssociation()->mouseReleaseEvent(m_pMouseEvent);
00070 }
00071
00072 void ToolBarStateArrow::mouseReleaseWidget() {
00073 getCurrentWidget()->mouseReleaseEvent(m_pMouseEvent);
00074 }
00075
00076 void ToolBarStateArrow::mouseReleaseEmpty() {
00077 if (m_selectionRect.count() == 4) {
00078 m_selectionRect.clear();
00079 } else if (m_pMouseEvent->button() == Qt::RightButton) {
00080 m_pUMLView->setMenu();
00081 }
00082 }
00083
00084 void ToolBarStateArrow::mouseDoubleClickAssociation() {
00085 getCurrentAssociation()->mouseDoubleClickEvent(m_pMouseEvent);
00086 }
00087
00088 void ToolBarStateArrow::mouseDoubleClickWidget() {
00089 getCurrentWidget()->mouseDoubleClickEvent(m_pMouseEvent);
00090 }
00091
00092 void ToolBarStateArrow::mouseMoveAssociation() {
00093 getCurrentAssociation()->mouseMoveEvent(m_pMouseEvent);
00094 }
00095
00096 void ToolBarStateArrow::mouseMoveWidget() {
00097 getCurrentWidget()->mouseMoveEvent(m_pMouseEvent);
00098 }
00099
00100 void ToolBarStateArrow::mouseMoveEmpty() {
00101 if (m_selectionRect.count() == 4) {
00102 QCanvasLine* line = m_selectionRect.at(0);
00103 line->setPoints(m_startPosition.x(), m_startPosition.y(),
00104 m_pMouseEvent->x(), m_startPosition.y());
00105
00106 line = m_selectionRect.at(1);
00107 line->setPoints(m_pMouseEvent->x(), m_startPosition.y(),
00108 m_pMouseEvent->x(), m_pMouseEvent->y());
00109
00110 line = m_selectionRect.at(2);
00111 line->setPoints(m_pMouseEvent->x(), m_pMouseEvent->y(),
00112 m_startPosition.x(), m_pMouseEvent->y());
00113
00114 line = m_selectionRect.at(3);
00115 line->setPoints(m_startPosition.x(), m_pMouseEvent->y(),
00116 m_startPosition.x(), m_startPosition.y());
00117
00118 m_pUMLView->selectWidgets(m_startPosition.x(), m_startPosition.y(),
00119 m_pMouseEvent->x(), m_pMouseEvent->y());
00120 }
00121 }
00122
00123 void ToolBarStateArrow::changeTool() {
00124 }
00125
00126 void ToolBarStateArrow::setCurrentWidget(UMLWidget* currentWidget) {
00127 if (currentWidget != 0 && getCurrentWidget() != 0) {
00128 return;
00129 }
00130
00131 ToolBarState::setCurrentWidget(currentWidget);
00132 }
00133
00134 #include "toolbarstatearrow.moc"
This file is part of the documentation for umbrello Version 3.1.0.