Commit d59a46cd authored by Oliver Kellogg's avatar Oliver Kellogg
Browse files

Merge master@485d601 to work/363582-stable-xmi

parents 3d17c969 485d601d
......@@ -558,7 +558,7 @@ QString uniqObjectName(UMLObject::ObjectType type, UMLPackage *parentPkg, QStrin
case UMLObject::ot_UseCase: currentName = i18n("new_use case"); break;
default:
currentName = i18n("new_object");
uWarning() << "unknown object type";
uWarning() << "model_utils::uniqObjectName unknown object type" << UMLObject::toString(type);
}
}
UMLDoc *doc = UMLApp::app()->document();
......@@ -606,7 +606,7 @@ QString newTitle(UMLObject::ObjectType type)
case UMLObject::ot_UniqueConstraint: return i18n("New unique constraint");
case UMLObject::ot_UseCase: return i18n("New use case");
default:
uWarning() << "unknown object type" << UMLObject::toString(type);
uWarning() << "model_utils::newTitle unknown object type" << UMLObject::toString(type);
return i18n("New UML object");
}
return QString();
......@@ -649,7 +649,7 @@ QString newText(UMLObject::ObjectType type)
case UMLObject::ot_UniqueConstraint: return i18n("Enter the name of the new unique constraint:");
case UMLObject::ot_UseCase: return i18n("Enter the name of the new use case:");
default:
uWarning() << "unknown object type" << UMLObject::toString(type);
uWarning() << "model_utils::newText unknown object type" << UMLObject::toString(type);
return i18n("Enter the name of the new UML object");
}
return QString();
......@@ -692,7 +692,7 @@ QString renameTitle(UMLObject::ObjectType type)
case UMLObject::ot_UniqueConstraint: return i18n("Rename unique constraint");
case UMLObject::ot_UseCase: return i18n("Rename use case");
default:
uWarning() << "unknown object type" << UMLObject::toString(type);
uWarning() << "model_utils::renameTitle unknown object type" << UMLObject::toString(type);
return i18n("Rename UML object");
}
return QString();
......@@ -735,7 +735,7 @@ QString renameText(UMLObject::ObjectType type)
case UMLObject::ot_UniqueConstraint: return i18n("Enter the new name of the unique constraint:");
case UMLObject::ot_UseCase: return i18n("Enter the new name of the use case:");
default:
uWarning() << "unknown object type" << UMLObject::toString(type);
uWarning() << "model_utils::renameText unknown object type" << UMLObject::toString(type);
return i18n("Enter the new name of the UML object");
}
return QString();
......
......@@ -1187,7 +1187,7 @@ QString UMLObject::toI18nString(ObjectType t)
default:
name = QLatin1String("<unknown> &name:");
uWarning() << "unknown object type";
uWarning() << "UMLObject::toI18nString unknown object type " << toString(t);
break;
}
return name;
......@@ -1254,7 +1254,7 @@ Icon_Utils::IconType UMLObject::toIcon(ObjectType t)
default:
icon = Icon_Utils::it_Home;
uWarning() << "unknown object type";
uWarning() << "UMLObject::toIcon unknown object type " << toString(t);
break;
}
return icon;
......
......@@ -1430,8 +1430,15 @@ UMLWidgetList UMLScene::selectedMessageWidgets() const
UMLWidgetList widgets;
foreach(QGraphicsItem *item, items) {
MessageWidget *w = dynamic_cast<MessageWidget*>(item);
if (w)
if (w) {
widgets.append(w);
} else {
WidgetBase *wb = dynamic_cast<WidgetBase*>(item);
QString name;
if (wb)
name = wb->name();
DEBUG(DBG_SRC) << name << " is not a MessageWidget";
}
}
return widgets;
}
......@@ -1441,6 +1448,13 @@ UMLWidgetList UMLScene::selectedMessageWidgets() const
*/
void UMLScene::clearSelected()
{
QList<QGraphicsItem *> items = selectedItems();
foreach(QGraphicsItem *item, items) {
WidgetBase *wb = dynamic_cast<WidgetBase*>(item);
if (wb) {
wb->setSelected(false);
}
}
clearSelection();
//m_doc->enableCutCopy(false);
}
......
......@@ -184,7 +184,7 @@ private:
void createSplinePoints();
AssociationWidget *m_associationWidget; ///< association widget for which this line represents
AssociationWidget *m_associationWidget; ///< association widget which this line represents
QVector<QPointF> m_points; ///< points representing the association line
int m_activePointIndex; ///< index of active point which can be dragged to modify association line
int m_activeSegmentIndex; ///< index of active segment
......
......@@ -188,14 +188,51 @@ void MessageWidget::updateResizability()
/**
* Overridden from UMLWidget.
* Returns the cursor to be shown when resizing the widget.
* The cursor shown is KCursor::sizeVerCursor().
* Checks if the mouse is in resize area and sets the cursor accordingly.
* The resize area is usually at the right bottom corner of the widget
* except in case of a message widget running from right to left.
* In that case the resize area is at the left bottom corner in order
* to avoid overlap with an execution rectangle at the right.
*
* @return The cursor to be shown when resizing the widget.
* @param me The QMouseEVent to check.
* @return true if the mouse is in resize area, false otherwise.
*/
QCursor MessageWidget::resizeCursor() const
bool MessageWidget::isInResizeArea(QGraphicsSceneMouseEvent *me)
{
return Qt::SizeVerCursor;
if (!m_resizable) {
m_scene->activeView()->setCursor(Qt::ArrowCursor);
DEBUG(DBG_SRC) << "!m_resizable";
return false;
}
qreal m = 7.0;
const qreal w = width();
const qreal h = height();
// If the widget itself is very small then make the resize area small, too.
// Reason: Else it becomes impossible to do a move instead of resize.
if (w - m < m || h - m < m) {
m = 2.0;
}
if (me->scenePos().y() < y() + h - m) {
m_scene->activeView()->setCursor(Qt::ArrowCursor);
DEBUG(DBG_SRC) << "Y condition not satisfied";
return false;
}
int x1 = m_pOw[Uml::RoleType::A]->x();
int x2 = m_pOw[Uml::RoleType::B]->x();
if (x1 < x2 && me->scenePos().x() >= x() + w - m ||
x1 > x2 && me->scenePos().x() >= x() - m) {
m_scene->activeView()->setCursor(Qt::SizeVerCursor);
DEBUG(DBG_SRC) << "X condition is satisfied";
return true;
} else {
m_scene->activeView()->setCursor(Qt::ArrowCursor);
DEBUG(DBG_SRC) << "X condition not satisfied";
return false;
}
}
/**
......@@ -232,9 +269,9 @@ void MessageWidget::resizeWidget(qreal newW, qreal newH)
/**
* Constrains the vertical position of the message widget so it doesn't go
* upper than the bottom side of the lower object.
* The height of the floating text widget in the message is taken in account
* if there is any and isn't empty.
* above the bottom side of the lower object.
* The height of the floating text widget in the message is taken into account
* if there is any and it isn't empty.
*
* @param diffY The difference between current Y position and new Y position.
* @return The new Y position, constrained.
......
......@@ -53,7 +53,7 @@ public:
virtual void setY(qreal y);
//---------- LinkWidget Interface methods implemementation from now on.
//---------- LinkWidget Interface methods implementation from here on.
virtual void lwSetFont (QFont font);
virtual UMLClassifier *operationOwner();
......@@ -74,7 +74,7 @@ public:
virtual void constrainTextPos(qreal &textX, qreal &textY, qreal textWidth, qreal textHeight,
Uml::TextRole::Enum tr);
//---------- End LinkWidget Interface methods implemementation.
//---------- End LinkWidget Interface methods implementation.
/// @return Whether the message is synchronous or asynchronous
Uml::SequenceMessage::Enum sequenceMessageType() const {
......@@ -84,7 +84,7 @@ public:
bool hasObjectWidget(ObjectWidget * w);
ObjectWidget* objectWidget(Uml::RoleType::Enum role);
void setObjectWidget(ObjectWidget * ow, Uml::RoleType::Enum role) ;
void setObjectWidget(ObjectWidget * ow, Uml::RoleType::Enum role);
bool isSelf() const;
......@@ -155,7 +155,7 @@ protected:
virtual void moveWidgetBy(qreal diffX, qreal diffY);
virtual void constrainMovementForAllWidgets(qreal &diffX, qreal &diffY);
virtual QCursor resizeCursor() const;
virtual bool isInResizeArea(QGraphicsSceneMouseEvent *me);
void setLinkAndTextPos();
......
......@@ -19,6 +19,13 @@ class ObjectWidget;
class UMLScene;
/**
* A sequence lifeline consists of the object widget at the top and
* a vertical line starting at the bottom edge of the object widget
* at half its width. The line grows downward when sequence messages
* are added such that the line always extends far enough to act as
* the background for all messages.
* This class represents only the line part of the lifeline.
*
* @short Widget class for graphical representation of sequence lines
* @author Paul Hensgen
* Bugs and comments to umbrello-devel@kde.org or https://bugs.kde.org
......
......@@ -368,6 +368,15 @@ void UMLWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
event->ignore();
return;
}
DEBUG(DBG_SRC) << "widget = " << name() << " / type = " << baseTypeStr()
<< " event->scenePos = " << event->scenePos()
<< " pos = " << pos();
/*
if (! onWidget(event->scenePos())) {
DEBUG(DBG_SRC) << name() << " event->scenePos onWidget = false, ignoring event";
event->ignore();
return;
} */
event->accept();
DEBUG(DBG_SRC) << "widget = " << name() << " / type = " << baseTypeStr();
......@@ -397,7 +406,7 @@ void UMLWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
m_shiftPressed = false;
int count = m_scene->selectedCount(true);
int count = m_scene->selectedCount();
if (event->button() == Qt::LeftButton) {
if (isSelected() && count > 1) {
// single selection is made in release event if the widget wasn't moved
......@@ -535,7 +544,7 @@ void UMLWidget::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
void UMLWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (!m_moved && !m_resized) {
if (!m_shiftPressed && (m_scene->selectedCount(true) > 1)) {
if (!m_shiftPressed && (m_scene->selectedCount() > 1)) {
selectSingle(event);
} else if (!isSelected()) {
deselect(event);
......@@ -558,6 +567,7 @@ void UMLWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
UMLApp::app()->executeCommand(new Uml::CmdResizeWidget(this));
m_autoResize = false;
m_resized = false;
deselect(event);
}
if ((m_inMoveArea && wasPositionChanged()) ||
......@@ -1886,11 +1896,24 @@ void UMLWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
// resize anchor would cover up most of the widget.
if (m_resizable && w >= s+8 && h >= s+8) {
brush.setColor(Qt::red);
const int right = 0 + w;
const int bottom = 0 + h;
painter->drawLine(right - s, 0 + h - 1, 0 + w - 1, 0 + h - s);
painter->drawLine(right - (s*2), bottom - 1, right - 1, bottom - (s*2));
painter->drawLine(right - (s*3), bottom - 1, right - 1, bottom - (s*3));
int horSide = w; // horizontal side default: right side
if (baseType() == wt_Message) {
MessageWidget *msg = asMessageWidget();
int x1 = msg->objectWidget(Uml::RoleType::A)->x();
int x2 = msg->objectWidget(Uml::RoleType::B)->x();
if (x1 > x2) {
// On messages running right to left we use the left side for
// placing the resize anchor because the message's execution
// specification as at the left in this case. Furthermore,
// the right side may be covered up by another message's
// execution specification.
horSide = 17; // execution box width
}
}
painter->drawLine(horSide - s, 0 + h - 1, 0 + w - 1, 0 + h - s);
painter->drawLine(horSide - (s*2), bottom - 1, horSide - 1, bottom - (s*2));
painter->drawLine(horSide - (s*3), bottom - 1, horSide - 1, bottom - (s*3));
} else {
painter->fillRect(0 + w - s, 0 + h - s, s, s, brush);
}
......
......@@ -36,10 +36,20 @@
#include <QPointer>
#include <QXmlStreamWriter>
static unsigned eventCnt = 0;
void QGraphicsObjectWrapper::setSelected(bool state)
{
if (!m_calledFromItemChange)
QGraphicsObject::setSelected(state);
QString info;
WidgetBase *wb = dynamic_cast<WidgetBase*>(this);
if (wb)
info = wb->name();
if (info.isEmpty())
DEBUG(DBG_SRC) << ++eventCnt << " new state=" << state << ", fromItemChange=" << m_calledFromItemChange << " " << this;
else
DEBUG(DBG_SRC) << ++eventCnt << " new state=" << state << ", fromItemChange=" << m_calledFromItemChange << " " << info;
m_calledFromItemChange = false;
}
......
......@@ -328,7 +328,7 @@ protected:
Uml::ID::Type m_nId;
/**
* This ID is only used when a widget could be added more then one time to a diagram
* This ID is only used when a widget could be added more than once to a diagram
*/
Uml::ID::Type m_nLocalID;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment