[Uml-devel] branches/work/soc-umbrello/umbrello
Gopala Krishna A
krishna.ggk at gmail.com
Wed Nov 12 18:17:21 UTC 2008
SVN commit 883340 by gopala:
* Enable hovering for New::AssociationWidget only if it is selected.
* Use relative coloring rather than hard coded color for hightlighting
the hovered line-segment or point in New::AssociationWidget.
M +3 -1 newassociationwidget.cpp
M +29 -13 newlinepath.cpp
M +3 -3 test.cpp
--- branches/work/soc-umbrello/umbrello/newassociationwidget.cpp #883339:883340
@@ -62,7 +62,6 @@
setName('m' + QString::number(collabID));
}
#endif
- setAcceptHoverEvents(true);
setFlags(ItemIsMovable | ItemIsSelectable | ItemIsFocusable);
}
@@ -121,6 +120,9 @@
QVariant AssociationWidget::itemChange(GraphicsItemChange change, const QVariant& value)
{
+ if (change == ItemSelectedHasChanged) {
+ setAcceptHoverEvents(isSelected());
+ }
return WidgetBase::itemChange(change, value);
}
--- branches/work/soc-umbrello/umbrello/newlinepath.cpp #883339:883340
@@ -589,8 +589,14 @@
/// Draws the line path and also takes care of highlighting active point or line.
void AssociationLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt)
{
- painter->setPen(pen());
- painter->setBrush(Qt::NoBrush);
+ QPen _pen = pen();
+ const QColor orig = _pen.color().lighter();
+ QColor invertedColor(orig.green(), orig.blue(), orig.red());
+ if (invertedColor == _pen.color()) {
+ // Ensure different color.
+ invertedColor.setRed((invertedColor.red() + 50) % 256);
+ }
+ invertedColor.setAlpha(150);
int sz = m_points.size();
if (sz == 0) {
@@ -611,30 +617,40 @@
m_points[sz - 1] = newEnd;
}
+ painter->setPen(_pen);
+ painter->setBrush(Qt::NoBrush);
+
painter->drawPolyline(m_points.constData(), m_points.size());
- // Now restore the points array
- m_points[0] = savedStart;
- m_points[sz - 1] = savedEnd;
-
if (opt->state & QStyle::State_Selected) {
QRectF ellipse(0, 0, SelectedPointDiameter, SelectedPointDiameter);
- painter->setBrush(Qt::blue);
+ painter->setBrush(_pen.color());
+ painter->setPen(Qt::NoPen);
for (int i = 1; i < sz - 1; ++i) {
- ellipse.moveCenter(m_points.at(i));
- painter->drawEllipse(ellipse);
+ if (i != m_activePointIndex) {
+ ellipse.moveCenter(m_points.at(i));
+ painter->drawEllipse(ellipse);
+ }
}
if (m_activePointIndex != -1) {
ellipse.moveCenter(m_points.at(m_activePointIndex));
- painter->setBrush(Qt::darkBlue);
+ painter->setBrush(invertedColor);
+ painter->setPen(Qt::NoPen);
painter->drawEllipse(ellipse);
}
else if (m_activeSegmentIndex != -1) {
- painter->setPen(Qt::yellow);
- painter->drawLine(QLineF(m_points[m_activeSegmentIndex], m_points[m_activeSegmentIndex+1]));
+ painter->setPen(QPen(invertedColor, _pen.widthF() + 1));
+ painter->setBrush(Qt::NoBrush);
+
+ QLineF segmentLine(m_points[m_activeSegmentIndex], m_points[m_activeSegmentIndex + 1]);
+ painter->drawLine(segmentLine);
}
}
+
+ // Now restore the points array
+ m_points[0] = savedStart;
+ m_points[sz - 1] = savedEnd;
}
/// Determines the active point or segment, the latter being given more priority.
@@ -771,7 +787,7 @@
}
QPainterPathStroker stroker;
- stroker.setWidth(AssociationLine::Delta); // allow delta region
+ stroker.setWidth(qMax(AssociationLine::Delta, pen().widthF()) + 2); // allow delta region
m_shape = stroker.createStroke(path);
m_boundingRect = m_shape.boundingRect();
--- branches/work/soc-umbrello/umbrello/test.cpp #883339:883340
@@ -93,10 +93,10 @@
path1->insertPoint(0, QPointF(100, 100));
path1->insertPoint(1, QPointF(200, 50));
path1->insertPoint(2, QPointF(700, 300));
- wid->setLineColor(QColor(Qt::blue));
- wid->setLineWidth(2);
+ wid->setLineColor(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
+ wid->setLineWidth(4);
- path1->setStartHeadSymbol(New::HeadSymbol::Diamond);
+ path1->setStartHeadSymbol(New::HeadSymbol::Arrow);
// path1->setEndHeadSymbol(New::HeadSymbol::Circle);
// New::AssociationLine *path2 = new New::AssociationLine(0);
More information about the umbrello-devel
mailing list