[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [umbrello/_associationline_refactoring_] umbrello/widgets: m_nMovingPoint removed.
From: Andi Fischer <andi.fischer () hispeed ! ch>
Date: 2013-08-02 10:14:05
Message-ID: E1V5CN3-0001Jh-Al () scm ! kde ! org
[Download RAW message or body]
Git commit aba2b94c957a1ed2a4066646abdbd8be79835f3b by Andi Fischer.
Committed on 02/08/2013 at 10:13.
Pushed by fischer into branch '_associationline_refactoring_'.
m_nMovingPoint removed.
M +0 -24 umbrello/widgets/associationline.cpp
M +0 -1 umbrello/widgets/associationline.h
M +10 -63 umbrello/widgets/associationwidget.cpp
M +0 -2 umbrello/widgets/associationwidget.h
http://commits.kde.org/umbrello/aba2b94c957a1ed2a4066646abdbd8be79835f3b
diff --git a/umbrello/widgets/associationline.cpp \
b/umbrello/widgets/associationline.cpp index 21d5a0d..dacc601 100644
--- a/umbrello/widgets/associationline.cpp
+++ b/umbrello/widgets/associationline.cpp
@@ -1196,30 +1196,6 @@ void \
AssociationLine::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) }
/**
- * Inserts a new point at double click position.
- */
-//void AssociationLine::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
-//{
-// DEBUG(DBG_SRC) << "at " << event->pos();
-// event->accept();
-// int index = closestPointIndex(event->pos());
-// // First check if double click was on a non end point.
-// if (index != -1 && !isEndPointIndex(index)) {
-// if (!m_associationWidget->isSelf() || count() > 4) {
-// removePoint(index);
-// }
-// }
-// else {
-// // Else insert a new point on the line segment
-// index = closestSegmentIndex(event->pos());
-// if (index != -1) {
-// // Insert after the obtained index.
-// insertPoint(index + 1, event->pos());
-// }
-// }
-//}
-
-/**
* Calculates the "to be highlighted" point and segment indicies
* and updates if necessary.
*/
diff --git a/umbrello/widgets/associationline.h b/umbrello/widgets/associationline.h
index 89b83c0..9c6aed5 100644
--- a/umbrello/widgets/associationline.h
+++ b/umbrello/widgets/associationline.h
@@ -160,7 +160,6 @@ public:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
-// void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
diff --git a/umbrello/widgets/associationwidget.cpp \
b/umbrello/widgets/associationwidget.cpp index 6b39988..103ec52 100644
--- a/umbrello/widgets/associationwidget.cpp
+++ b/umbrello/widgets/associationwidget.cpp
@@ -64,7 +64,6 @@ AssociationWidget::AssociationWidget(UMLScene *scene)
m_activated(false),
m_unNameLineSegment(-1),
m_selected(false),
- m_nMovingPoint(-1),
m_nLinePathSegmentIndex(-1),
m_pAssocClassLine(0),
m_pAssocClassLineSel0(0),
@@ -620,7 +619,6 @@ AssociationWidget& AssociationWidget::operator=(const \
AssociationWidget& other) m_pMenu = other.m_pMenu;
setUMLAssociation(other.getAssociation());
m_selected = other.m_selected;
- m_nMovingPoint = other.m_nMovingPoint;
return *this;
}
@@ -1550,8 +1548,7 @@ void \
AssociationWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) void \
AssociationWidget::moveEvent(QGraphicsSceneMouseEvent *me) {
// 2004-04-30: Achim Spangler
- // Simple Approach to block moveEvent during load of
- // XMI
+ // Simple Approach to block moveEvent during load of XMI
/// @todo avoid trigger of this event during load
if (umlDoc()->loading()) {
@@ -1582,28 +1579,29 @@ void AssociationWidget::moveEvent(QGraphicsSceneMouseEvent \
*me) QPointF oldRoleAPoint = calculateTextPosition(TextRole::RoleAName);
QPointF oldRoleBPoint = calculateTextPosition(TextRole::RoleBName);
- m_associationLine->setPoint(m_nMovingPoint, me->scenePos());
+ int movingPoint = m_associationLine->closestPointIndex(me->scenePos());
+ m_associationLine->setPoint(movingPoint, me->scenePos());
int pos = m_associationLine->count() - 1;//set to last point for widget b
- if ( m_nMovingPoint == 1 || (m_nMovingPoint == pos-1) ) {
+ if ( movingPoint == 1 || (movingPoint == pos-1) ) {
calculateEndingPoints();
}
- if (m_role[RoleType::A].changeabilityWidget && (m_nMovingPoint == 1)) {
+ if (m_role[RoleType::A].changeabilityWidget && (movingPoint == 1)) {
setTextPositionRelatively(TextRole::ChangeA, oldChangeAPoint);
}
- if (m_role[RoleType::B].changeabilityWidget && (m_nMovingPoint == 1)) {
+ if (m_role[RoleType::B].changeabilityWidget && (movingPoint == 1)) {
setTextPositionRelatively(TextRole::ChangeB, oldChangeBPoint);
}
- if (m_role[RoleType::A].multiplicityWidget && (m_nMovingPoint == 1)) {
+ if (m_role[RoleType::A].multiplicityWidget && (movingPoint == 1)) {
setTextPositionRelatively(TextRole::MultiA, oldMultiAPoint);
}
- if (m_role[RoleType::B].multiplicityWidget && (m_nMovingPoint == pos-1)) {
+ if (m_role[RoleType::B].multiplicityWidget && (movingPoint == pos-1)) {
setTextPositionRelatively(TextRole::MultiB, oldMultiBPoint);
}
if (m_nameWidget) {
- if (m_nMovingPoint == (int)m_unNameLineSegment ||
- m_nMovingPoint - 1 == (int)m_unNameLineSegment) {
+ if (movingPoint == (int)m_unNameLineSegment ||
+ movingPoint - 1 == (int)m_unNameLineSegment) {
setTextPositionRelatively(TextRole::Name, oldNamePoint);
}
}
@@ -2900,9 +2898,6 @@ void \
AssociationWidget::mousePressEvent(QGraphicsSceneMouseEvent * me) \
selectAssocClassLine(); return;
}
- // see if the user has clicked on a point to start moving the line segment
- // from that point
- checkPoints(mep);
setSelected( !m_selected );
associationLine()->mousePressEvent(me);
}
@@ -2912,27 +2907,6 @@ void \
AssociationWidget::mousePressEvent(QGraphicsSceneMouseEvent * me)
*/
void AssociationWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent * me)
{
-//:TODO:
-// if (me->button() != Qt::RightButton && me->button() != Qt::LeftButton) {
-// setSelected(false);
-// return;
-// }
-
-//:TODO: this should be done in AssociationLine
- // Check whether a point was moved and whether the moved point is
- // located on the straight line between its neighbours.
- // if yes, remove it
- ///@todo: check for non-horizontal / -vertical lines
-// if (m_nMovingPoint > 0 && m_nMovingPoint < m_associationLine->count() - 1)
-// {
-// QPointF m = m_associationLine->point(m_nMovingPoint);
-// QPointF b = m_associationLine->point(m_nMovingPoint - 1);
-// QPointF a = m_associationLine->point(m_nMovingPoint + 1);
-// if ( (b.x() == m.x() && a.x() == m.x()) ||
-// (b.y() == m.y() && a.y() == m.y()) )
-// m_associationLine->removePoint(m_nMovingPoint);
-// }
-// m_nMovingPoint = -1;
associationLine()->mouseReleaseEvent(me);
}
@@ -3165,33 +3139,6 @@ void AssociationWidget::setTextColor(const QColor &color)
m_role[RoleType::B].changeabilityWidget->setTextColor( color );
}
-/**
- * Check all points except the end points to see if we clicked on one of them.
- */
-void AssociationWidget::checkPoints(const QPointF &p)
-{
- m_nMovingPoint = -1;
- //only check if more than the two endpoints
- int size = m_associationLine->count();
- if (size <= 2) {
- return;
- }
- QPointF tempPoint;
- qreal x, y;
- const qreal BOUNDARY = 4.0; // check for pixels around the point
- for (int i = 1; i < size - 1; ++i) {
- tempPoint = m_associationLine->point(i);
- x = tempPoint.x();
- y = tempPoint.y();
- if ( x - BOUNDARY <= p.x() && x + BOUNDARY >= p.x() &&
- y - BOUNDARY <= p.y() && y + BOUNDARY >= p.y() ) {
- m_nMovingPoint = i;
- DEBUG(DBG_SRC) << "we are on point = " << i;
- break; //no need to check the rest
- }
- }
-}
-
bool AssociationWidget::checkAddPoint(const QPointF &scenePos)
{
if (associationType() == AssociationType::Exception ){
diff --git a/umbrello/widgets/associationwidget.h \
b/umbrello/widgets/associationwidget.h index b77292c..0346d4d 100644
--- a/umbrello/widgets/associationwidget.h
+++ b/umbrello/widgets/associationwidget.h
@@ -285,7 +285,6 @@ private:
void setChangeWidget(const QString &strChangeWidget, Uml::RoleType::Enum role);
- void checkPoints(const QPointF &p);
bool checkAddPoint(const QPointF &scenePos);
bool checkRemovePoint(const QPointF &scenePos);
@@ -308,7 +307,6 @@ private:
*/
int m_unNameLineSegment;
bool m_selected;
- int m_nMovingPoint;
QPointF m_oldNamePoint; ///< Position of name floatingtext saved by \
saveIdealTextPositions()
QPointF m_oldMultiAPoint; ///< Position of role A multiplicity floatingtext \
saved by saveIdealTextPositions()
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic